akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef pair<int,int> ii;

vector<int> adj[200005];
int ans[200005];
int M[200005];
int P[200005];

ii edges[200005];
int twoK[20][400005];
int maxEdge[400005];
ii child[400005];
int sz[400005];

struct UFDS{
	int p[400005];
	
	void create(int n) {
		for(int i = 0;i <= 2*n;i++) p[i] = i;
	}
	
	int findSet(int u){
		if(u == p[u]) return u;
		else{
			p[u] = findSet(p[u]);
			return p[u];
		}
	}
	
	void unionSet(int u, int v){
		if(u > v) swap(u,v);
		p[u] = v;
	}
} uf;

int dfs(int u){
	if(child[u].first == 0) sz[u] = 1;
	else sz[u] = dfs(child[u].first) + dfs(child[u].second);
	return sz[u];
}

int Q(int u, int limit, bool tolerate){
	if(u >= limit){
		if(!tolerate) return 0;
		
		int ans = 1;
		for(int v : adj[u]){
			if(v == P[u]) continue;
			if(v >= limit) continue;
			ans += Q(v, limit, false);
		}
		return ans;
	}
	
	for(int j = 19;j >= 0;j--){
		int newU = twoK[j][u];
		if(newU == 0) continue;
		if(maxEdge[newU] >= limit) continue;
		u = newU;
	}
	return sz[u];
}

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin >> n;
	for(int i = 0;i < n - 1;i++){
		int u, v; cin >> u >> v;
		if(u < v) swap(u,v); ///edge weight = larger node = u
		
		edges[i] = ii(u,v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	
	uf.create(2*n);
	
	sort(edges,edges+(n-1));
	int newNode = n + 1;
	for(int i = 0;i < n-1;i++){
		int u = uf.findSet(edges[i].first);
		int v = uf.findSet(edges[i].second);
		int w = edges[i].first; ///edge weight = larger node = u
		
		uf.unionSet(u, newNode);
		uf.unionSet(v, newNode);
		twoK[0][u] = newNode;
		twoK[0][v] = newNode;
		maxEdge[newNode] = w;
		child[newNode] = ii(u,v);
		newNode++;
	}
	
	for(int j = 1;j < 20;j++){
		for(int i = 1;i < newNode;i++){
			twoK[j][i] = twoK[j-1][twoK[j-1][i]];
		}
	}
	dfs(newNode-1);
		
	queue<int> bfs;
	bfs.push(1);
	fill(ans, ans+(n+1),-1);
	ans[1] = 0;
		
	while(!bfs.empty()){
		int u = bfs.front();
		bfs.pop();
		
		for(int v : adj[u]){
			if(ans[v] != -1) continue;
			bfs.push(v);
			P[v] = u;
			M[v] = max(u, M[u]);
		}
		
		if(u == 1) continue;
		
		int m = M[P[u]];
		int p = P[u];
				
		if(u > m){
			ans[u] = ans[p] + Q(u, max(m,p), true);
			//cout << u << " " << p << "M\n";
		}
		else{
			if(m > p) ans[u] = ans[p];
			else ans[u] = ans[p] + Q(u,p,true) - Q(u,m,true);
			//cout << u << " " << p << "P\n";
		}
	}
	
	
	for(int i = 2;i <= n;i++) cout << ans[i] << " ";
}


Measured memory_bytes: 62452
#include <bits/stdc++.h>
using namespace std;

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string a, b;
    cin >> a >> b;

    if (a.size() > b.size()) {
        puts("GREATER");
        return 0;
    } else if (a.size() < b.size()) {
        puts("LESS");
        return 0;
    } else {
        if (a > b) {
            puts("GREATER");
            return 0;
        } else if (a < b) {
            puts("LESS");
            return 0;
        }
    }

    puts("EQUAL");

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-5;
const int inf=1e8;
int main(){
	int a,b,c;
	while(cin>>a>>b>>c,a||b||c){
		for(int sa=1;sa*sa<=a;sa++)if(a%sa==0){
			int la=a/sa;
			for(int sb=-10000;sb<=10000;sb++){
				if(sb&&c%sb)continue;
				int lb=(sb?c/sb:0);
				rep(i,2){
					rep(j,2){
						if(sa*lb+la*sb==b){
							if(la==sa&&lb<sb)swap(lb,sb);
							cout<<la<<" "<<lb<<" "<<sa<<" "<<sb<<endl;
							goto end;
						}
						sb*=-1;
						lb*=-1;
					}
					swap(sb,lb);
				}
			}
		}
		cout<<"Impossible"<<endl;
		end:;
	}
}

Measured memory_bytes: 3076
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int point = str.length()-1;
        while(point > 0) {
            String s = str.substring(0,point);
            point--;
            if(s.length()%2!=0) continue;
            if(s.substring(0,s.length()/2).equals(s.substring(s.length()/2))) {
                System.out.println(s.length());
                return;
            }
        }
        System.out.println(0);
    }
}

Measured memory_bytes: 23124
n,t=map(int,input().split())
a=list(map(int,input().split()))
x=[0]*n
x[0]=a[0]
for i in range(1,n):
    x[i]=min(x[i-1],a[i])
d=dict()
for i in range(1,n):
    y=a[i]-x[i-1]
    if y>0:
        if y in d:
            d[y]+=1
        else:
            d[y]=1
d=list(d.items())
d.sort(reverse=True)
print(d[0][1])

Measured memory_bytes: 25164
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2])
    {
        cout << "Yes";
    }
    else if (s[1] == s[2] && s[2] == s[3])
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    set<char> s;
    rep(i,n) {
        char c;
        cin >> c;
        s.insert(c);
    }
    if(s.size() == 3) cout << "Three" << endl;
    else cout << "Four" << endl;
}

Measured memory_bytes: 256
using System;

class Sample30
{
    public static void Main()
    {
        while (true)
        {
            var data = Console.ReadLine().Trim();
            
            //終了処理
            if (data == "0") 
            {
                break;
            }
            
            var result = 0;
            var limit = data.Length;
            int sumNumber = 0;
            
            //計算して出力
            for (int  i = 0; i < limit; i++)
            {
                //Parse
                try
                {
                    sumNumber = int.Parse(data[i].ToString());
                }
                catch(FormatException e)
                {
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine("入力された値を数字に変換できませんでした。");
                    Environment.Exit(0);
                }
                
                //out of range
                try
                {
                    if(9999 < sumNumber || sumNumber < -9999)
                    {
                        throw new ArgumentOutOfRangeException();
                    }
                }
                catch(ArgumentOutOfRangeException e)
                {
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine("データの要素が範囲外です。");
                    Environment.Exit(0);
                }
                
                result += sumNumber ;
            }
            Console.WriteLine(result);
            result = 0;
       }
    }
}


Measured memory_bytes: 17740
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int N;
  cin >> N;
  int c[N], flg=0;
  for (int i = 0; i < N; i++){
    c[i] = 0;
  }
  
  for (int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    if (i==0 && tmp==0){
      flg = 1;
    }
    
    c[tmp] += 1;
  }

  if (c[0]==1 && flg == 1) {
    unsigned long long ans = 1, tmp = 1;
    unsigned long long t = 998244353;
    for (int i = 2; i < N; i++){
      if (c[i-1] == 0 && c[i] > 0){
        ans = 0;
        break;
      }else if(c[i] == 0){
        continue;
      }
      
      tmp = c[i-1];
      for (int j = 2; j <= c[i]; j++){
        tmp = tmp % t;
        tmp = tmp * (c[i-1] % t);

      }
      ans = ans % t;
      tmp = tmp % t;
      ans *= tmp;
      ans %= t;
    }
    printf("%llu\n", ans);
  }else{
    printf("0\n");
  }
}


Measured memory_bytes: 4096
import java.util.*;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    while(sc.hasNext()) {
      int d = sc.nextInt();

      int sum = 0;
      for(int i = 0; i < 600; i += d) {
        sum += d * i * i;
      }

      System.out.println(sum);
    }
  }

  private final Scanner sc = new Scanner(System.in);
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N, K;
    cin >> N >> K;
    vector<pair<int, int>> C((N * N - 1)/2);
    int j = 0;
    int cn_num;
    REP(i, 2, N + 1) {
        C[j] = make_pair(1, i);
        j++;
    }
    cn_num = j;
    int L = ((N - 1) * (N - 2) / 2) - K ;
    if (L < 0) {
        cout << -1 << endl;
        return 0;
    }
    j = 2;
    int k = 3;
    rep(i, L) {
        if (k > N) {
            j++;
            k = j + 1;
        }
        C[cn_num] = make_pair(j, k);
        cn_num++;
        k++;

    }
    if (cn_num  <= 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << cn_num << endl;
    rep(i, cn_num) {
        cout << C[i].first << " " << C[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
  return (a*b)/gcd(b%a, a);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  int a, p;
  cin >> a >> p;
  cout << (3 * a + p)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int a,b,c,d,e[100],i,j,tmp,max=0,sum=0,doll=0;
  for(i=0;i<100;i++)e[i]=0;//初期化
  scanf("%d %d %d %d",&a,&b,&c,&d);
  for(i=0;i<a;i++)scanf("%d",&e[i]);

  //1.素のみ(無条件)
  doll=b;
  sum=d;
  max=sum/doll;

  //(昇順バブルソート)
  for(i=0;i<a-1;i++){
    for(j=a-1;j>i;j--){
      if(e[j]>e[j-1]){
	tmp=e[j];
	e[j]=e[j-1];
	e[j-1]=tmp;
      }
    }
  }

  //2.素+数種類のトッピング(max<cal/1$)
  for(i=0;i<a;i++){
    sum+=e[i];
    doll+=c;
    if(max<sum/doll)max=sum/doll;
  }

  //出力
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N;
    cin >> N;
    map<ll, ll> mp;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        mp[A[i]]++;
    }
    ll ans = 0;
    for (auto ite = mp.begin(); ite != mp.end(); ++ite) {
        ans += ite->second * (ite->second - 1) / 2;
    }
    for (int i = 0; i < N; i++) {
        ll x = mp[A[i]];
        cout << ans - x * (x - 1) / 2 + (x - 1) * (x - 2) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 11904
a,b,c  = map(int,input().split())
list_sort = sorted([a,b,c])
i = 0
while ((list_sort[0]!=list_sort[2]) and (list_sort[1]!=list_sort[2])):
    i += 1
    list_sort[0] = list_sort[0]+1
    list_sort[1] = list_sort[1]+1
import math
if (list_sort[1] - list_sort[0]) % 2 == 0:
    i += int((list_sort[1] - list_sort[0]) / 2)
else:
    i += math.floor((list_sort[1] - list_sort[0]) / 2)
    i += 2
print(i)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
//#define endl "\n" //インタラクティブでは消す
//ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
ut N, M, K, L, Q, D, H, W,R;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL maps[SIZE2][SIZE2];
LL A, B,X,Y;
string s[3];
LL solve() {
	cin >> N;
	REP(i, 3) cin >> s[i];
	LL ans = 0;
	REP(i, N) {
		if (s[0][i] == s[1][i] and s[1][i] == s[2][i]);
		else if (s[0][i] == s[1][i] or s[1][i] == s[2][i] or s[0][i] == s[2][i]) ans += 1;
		else ans += 2;
	}
	cout << ans << endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	string s;
	solve();
		
	
	//cin >> N;
	return 0;

}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

string S;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> S;
    cout << S.substr(0, 3) << endl;
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N;
  cin>>N;
  if(N%2==1)
    N*=2;
  cout<<N;
  }


Measured memory_bytes: 256
import java.util.Scanner;
     
     
    public class Main {
        

        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String s =sc.next();
            int n =s.length();
            for (int i=0;i<n;i++){
                 System.out.print("x");

            }

           
            
           } 
        }
    


Measured memory_bytes: 35644
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back

const int maxn = 2e5 + 20;

map<ll , int> mp;

int a[maxn];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	for(int i = 0; i < n; i++)
		cin >> a[i];

	mp[0]++;

	ll res = 0 , s = 0;

	for(int i = 0; i < n; i++)
	{
		s += a[i];
		res += mp[s];
		mp[s]++;
	}

	cout << res << endl;


}









































Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[100003],a[100003];
int main()
{
  ll n,i;
  cin>>n;
  for(i=0;i<n;i++)
    cin>>a[i];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(i=2;i<n;i++)
  {
    dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;

const int DIRECTSIZE = 4;
struct _direct {
    int drow;
    int dcol;
} direct[DIRECTSIZE] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};

const int N = 1000;
const int N2 = 10;
char grid[N][N], visited[N][N];
int h, w, n;
struct _factory {
    int row;
	int col;
} factory[N2];

struct _node {
    int row;
	int col;
	int level;
};

int bfs(int n, char goal) {
    memset(visited, 0, sizeof(visited));
    _node start={factory[n-1].row, factory[n-1].col, 0}, temp;
    visited[start.row][start.col] = 1;
    queue<_node> q;
    q.push(start);
    while(!q.empty()) {
        _node front = q.front();
        q.pop();
        for(int i=0; i<DIRECTSIZE; i++) {
            int nextrow = front.row + direct[i].drow;
            int nextcol = front.col + direct[i].dcol;
            if( 0 <= nextrow && nextrow < h && 0 <= nextcol && nextcol < w) {
                if(grid[nextrow][nextcol] == goal) {
                    return front.level + 1;
                }
				else if(visited[nextrow][nextcol] == 0 && grid[nextrow][nextcol] != 'X') {
                    visited[nextrow][nextcol] = 1;
                    temp.row = nextrow;
                    temp.col = nextcol;
                    temp.level = front.level + 1;
                    q.push(temp);
                }
            }
        }
    }
    return 0;
}

int main() {
    while (~scanf("%d %d %d", &h, &w, &n)){
        for(int i = 0; i < h; i++) {
			scanf("%s", grid[i]);
            for(int j = 0; j < w; j++) {
                if(grid[i][j] == 'S') {
                    factory[0].row = i;
                    factory[0].col = j;
				}
				else if(isdigit(grid[i][j])) {
                    factory[grid[i][j] - '0'].row = i;
                    factory[grid[i][j] - '0'].col = j;
                }
            }
		}
        int minstep = 0;
        char goal = '1';
        for(int i=1; i<=n; i++) {
            minstep += bfs(i, goal);
            goal++;
        }
        printf("%d\n", minstep);
    }
    return 0;
}

Measured memory_bytes: 5056
PROGRAM ATCODER

implicit none
double precision :: sum, b
double precision,allocatable :: x(:)
character(len=3),allocatable :: u(:)
integer :: n, i

b = 380000.d0

read(*,*) n
allocate(x(n), u(n))

do i = 1, n
	read(*,*) x(i), u(i)
end do

sum = 0.d0

do i = 1, n
	if(u(i) == 'BTC') then
    	x(i) = x(i)*b
    end if
    sum = sum + x(i)
end do

if (sum == 0.d0) then
	write(*,'(a)') '0.00000'
	stop
end if

write(*,'(f0.5)') sum

END PROGRAM ATCODER


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  long int lucas[N+1];
  lucas[0] = 2;
  lucas[1] = 1;
  for(int i=2;i<N+1;i++){
    lucas[i] = lucas[i-1]+lucas[i-2];
  }
  cout << lucas[N] << endl;
}

Measured memory_bytes: 256
MAX_PRIME = 10**5
is_prime = [1] * MAX_PRIME
primes = []
is_prime[0] = 0
is_prime[1] = 0
for i in range(MAX_PRIME):
    if is_prime[i]:
        primes.append(i)
        for j in range(2, ((MAX_PRIME-1)//i) + 1):
            is_prime[i*j] = 0

m = int(input())
mod = 10 ** 9 + 7
factor = [0] * (m+1)
for n in range(1, m+1):
    for p in primes:
        if p ** 2 > n:
            break
        while n % p == 0:
            n //= p
            factor[p] += 1
    if n > 1:
        factor[n] += 1

ans = 1
for x in factor:
    if x:
        ans *= x+1
        ans %= mod
print(ans)

Measured memory_bytes: 4188
local n = io.read("*n", "*l")
local str = io.read()
local cnt = {}
local t_cnt = 0
for i = 1, n do
  if(str:sub(i, i) == "E") then
    t_cnt = t_cnt + 1
  end
  cnt[i] = t_cnt
end
local minret = n
for i = 1, n do
  local ret = 0
  if(1 < i) then
    ret = ret + ((i - 1) - cnt[i - 1])
  end
  if(i < n) then
    ret = ret + cnt[n] - cnt[i]
  end
  minret = math.min(minret, ret)
end
print(minret)



Measured memory_bytes: 9316
n = int(input())
s = input()

cnt = 0
m = 0

for i in range(len(s)):
    if s[i] == 'I':
        cnt += 1
        m = max(m, cnt)
    if s[i] == 'D':
        cnt -= 1
        m = max(m, cnt)
print(m)



Measured memory_bytes: 9180
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	S := sc.Next()
	T := sc.Next()

	for i := 0; i < len(S); i++ {
		hit := true
		for j := 0; j < len(T); j++ {
			if S[(i+j)%len(T)] != T[j] {
				hit = false
				break
			}
		}
		if hit {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
///HELLO THERE~!
///CREATED BY MD SADMAN MEHEDI SIVAN [IUT CSE(SWE)-19]

#include<bits/stdc++.h>
using namespace std;

#define fastio          ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define read            freopen("blue.txt","r",stdin);
#define write           freopen("red.txt","w",stdout);

using ll=long long;
using ull=unsigned long long;
const double pi = 2*acos(0.0);

int  main()
{

    fastio;

    int x,n;
    cin>>x>>n;

    int a[n+1];

    map<int,int>mp;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }

    int min=99999999;
    int p,q;
    int i=-1;
    while(1)
    {
        i++;
        if(i>x)
            break;

        if(mp[i]>0)
            continue;
        int r=abs(x-i);
        if(r<=min)
        {
            p=i;
            min=r;
        }
    }

    min=9999999;
     i=102;
    while(1)
    {
        i--;
        if(i<=x)
            break;

        if(mp[i]>0)
            continue;

        int r=abs(x-i);

        if(r<=min)
        {
            q=i;
            min=r;
        }
    }

    if(abs(p-x)<=abs(q-x))
        cout<<p<<endl;
    else
        cout<<q<<endl;


    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    s="R"+s+"L";
    int ans=n;
    for(int i=1;i<=n;i++){
        if(s[i]=='L'&&s[i-1]=='R')ans--;
        else if(s[i]=='R'&&s[i+1]=='L')ans--;
    }
    ans=min(n-1,ans+2*k);
    cout<<ans<<endl;
}


Measured memory_bytes: 512
//  Copyright 2020 Nikita Golikov

#include <bits/stdc++.h>

using namespace std;

using i64 = int64_t;
using ui64 = uint64_t;

template <class A, class B>
bool smin(A &x, B &&y) {
  if (y < x) {
    x = y;
    return true;
  }
  return false;
}

template <class A, class B>
bool smax(A &x, B &&y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int main() {
#ifdef GOLIKOV
  assert(freopen("in", "rt", stdin));
  auto _clock_start = chrono::high_resolution_clock::now();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<int>> val(n, vector<int>(m));
  for (int i = 0; i < k; ++i) {
    int r, c, x;
    cin >> r >> c >> x;
    val[r - 1][c - 1] = x;
  }
  vector<vector<vector<i64>>> dp(n, vector<vector<i64>>(m,
      vector<i64>(4)));
  for (int r = 0; r < n; ++r) {
    for (int c = 0; c < m; ++c) {
      for (int pr = 0; pr < 4; ++pr) {
        for (int up : {0, 1}) {
          int dr = up;
          int dc = 1 - up;
          auto rr = r + dr;
          auto cc = c + dc;
          if (rr >= n || cc >= m) continue;
          auto can_pick = pr != 3;
          if (up) {
            smax(dp[rr][cc][0], dp[r][c][pr]);
            if (can_pick) {
              smax(dp[rr][cc][0], dp[r][c][pr] + val[r][c]);
            }
          } else {
            smax(dp[rr][cc][pr], dp[r][c][pr]);
            if (can_pick) {
              smax(dp[rr][cc][pr + 1], dp[r][c][pr] + val[r][c]);
            }
          }
        }
      }
    }
  }
  i64 ans = 0;
  for (int pr = 0; pr < 4; ++pr) {
    auto res = dp[n - 1][m - 1][pr];
    if (pr != 3) {
      res += val[n - 1][m - 1];
    }
    smax(ans, res);
  }
  cout << ans << '\n';

#ifdef GOLIKOV
  cerr << "Executed in " << chrono::duration_cast<chrono::milliseconds>(
      chrono::high_resolution_clock::now()
          - _clock_start).count() << "ms." << endl;
#endif
  return 0;
}


Measured memory_bytes: 670872
n,x=map(int,input().split())
ans=n
M=max(n-x,x)
m=min(n-x,x)
while(True):
  r=M%m
  q=int((M-r)/m)
  if(r==0):
    ans+=(2*q-1)*m
    break
  else:
    ans+=2*q*m
    M=m
    m=r
print(ans)
    

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;
typedef vector<char> vchar;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<string>> vvstring;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	string S;
	cin >> S;

	if (S[2] == S[3] && S[4] == S[5])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}




}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
    while ( b != 0 ) {
        ll t = b;
        b = a % b;
        a = t;
    }
    return a;
}

ll solve() {
    ll N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;
    ll g = gcd(N, M);
    ll l = N*M/g;
    ll f = N/g*M/g;
    for ( ll i = 0; i < g; i++ ) {
        if ( S[N/g*i] != T[M/g*i] ) return -1;
    }
    return l;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x;
        int y;
        ArrayList<Integer> A = new ArrayList<Integer>();
        for (;;) {
            x = sc.nextInt();
            y = sc.nextInt();
            if (x == 0 && y == 0) {
                for (int i=0; i<A.size(); i=i+2) {
                    System.out.print(A.get(i));
                    System.out.print(" ");
                    System.out.println(A.get(i+1));
                }
                break;
            }
            else {
                if (x > y) {
                    A.add(y);
                    A.add(x);
                }
                else {
                    A.add(x);
                    A.add(y);
                }
            }

        }
    }
}


Measured memory_bytes: 36508
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//string型文字列をint型整数にして返す
int str_to_num(string s) {return atoi(s.c_str());}
//約数の総数を返す
int count_divisor(int n){int c[n/2] = {1}; int n_half = n/2; for(int i=2;i<n_half;i++){if(n%i==0){n /= i;c[i]+=1;i--;if(n>1) continue;else break;}  }int r = 1;for(int i=2;i<n_half;i++){r *= c[i];}return r;}
//各桁の数の和を返す
int dig_num(int n){return (n<10) ? n: dig_num(n/10) + n%10;}

int dig_ord(int n){return (n<10) ? 1: dig_ord(n/10) + 1;}

int main(){
  int k,x; cin >> k >> x;
  int s = x-(k-1);
  int e = x+(k-1);
  for(int i=s;i<e+1;i++){
    cout << i << " ";
  }
  cout << "\n";
}

Measured memory_bytes: 256
N, K = map(int, input().split())

ans = 0
for b in range(1, N+1):
    d, m = divmod(N+1, b)
    k = max(b-K, 0)
    ans += max(k*d, 0)
    if K == 0:
        ans -= 1
    ans += max(m-K, 0)

print(ans)

Measured memory_bytes: 3064
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# modulo 2019 で同じもの、右からApple Pen
MOD = 2019
S = sr()
remain = [0] * 2019
remain[0] = 1
answer = 0
power = 1
cur = 0
for s in S[::-1]:
    num = int(s)
    cur += num * power
    cur %= MOD
    answer += remain[cur]
    remain[cur] += 1
    power *= 10; power %= MOD

print(answer)


Measured memory_bytes: 79928
S = input()

i = 0
j = len(S) - 1
res = 0
while i < j:
    if S[i] == S[j]:
        i += 1
        j -= 1
    elif S[i] == 'x':
        res += 1
        i += 1
    elif S[j] == 'x':
        res += 1
        j -= 1
    else:
        print(-1)
        exit()

print(res)


Measured memory_bytes: 9272
{-
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1195&lang=jp
?????????: Encryption System
?????°:
18:50 Haskell?????????????????¨????????§Haskell????????????
19:11 ????\???¢?????±???????¨???\?????????????????????
19:24 ????\???¢?????±?????????????????????????????????????????£????????????????????§??????????????????
19:32 ?????°??£????????§?????´?????????????????????
-}
import Control.Monad
import Control.Applicative
import Data.List

main = do
 info <- getLine
 unless (info == "#") $ do
 let arr = sort $ analyze info
 print (length arr)
 mapM_ putStrLn $ if length arr <= 10 then arr else take 5 arr ++ (reverse . take 5 . reverse)arr 
 main

analyze :: String -> [String]
analyze str = return str
 >>= decipher 'z' 'y'
 >>= decipher 'y' 'x'
 >>= decipher 'x' 'w'
 >>= decipher 'w' 'v'
 >>= decipher 'v' 'u'
 >>= decipher 'u' 't'
 >>= decipher 't' 's'
 >>= decipher 's' 'r'
 >>= decipher 'r' 'q'
 >>= decipher 'q' 'p'
 >>= decipher 'p' 'o'
 >>= decipher 'o' 'n'
 >>= decipher 'n' 'm'
 >>= decipher 'm' 'l'
 >>= decipher 'l' 'k'
 >>= decipher 'k' 'j'
 >>= decipher 'j' 'i'
 >>= decipher 'i' 'h'
 >>= decipher 'h' 'g'
 >>= decipher 'g' 'f'
 >>= decipher 'f' 'e'
 >>= decipher 'e' 'd'
 >>= decipher 'd' 'c'
 >>= decipher 'c' 'b'
 >>= decipher 'b' 'a'





-- decipher 'b' 'a' "want a aeer" = ["wbnt a aeer","want b aeer","want a beer","want a aeer"]
decipher :: Char -> Char -> String -> [String]
decipher b a str
 | b `elem` str = let (front,back) = break (==b) str in map (++back) (replaceOne a b front) -- b??\???????????????????????????????????¨back?????¨??????????????£???
 | otherwise = replaceOne' a b str



-- replaceOne 'a' 'b' "an algebra" = ["bn algebra", "an blgebra", "an algebrb"]
replaceOne :: (Eq a) => a -> a -> [a] -> [[a]]
replaceOne a b = init . replaceOne' a b -- ????????????????????????

replaceOne' :: (Eq a) => a -> a -> [a] -> [[a]]
replaceOne' _ _ [] = [[]]
replaceOne' a b (c:xs)
 | a == c = (b:xs) : map (c:) (replaceOne' a b xs) -- ???????????????????????????????????¨???????????????????????¨
 | otherwise = map (c:) (replaceOne' a b xs) -- ???????????£????????????????????????????????????

Measured memory_bytes: 34756
S=input()
final=(''.join([ chr(97+i) for i in range(26)]))[::-1]
if S==final:
	print('-1')
else:
	if len(S)<26:
		for i in range(26):
			if chr(97+i) in S:
				continue
			else:
				print(S+chr(97+i))
				break
	else:
		S_cut = S
		continuate = True
		while continuate:
			S_cut = S_cut[:-1]
			tail = ord(S_cut[-1]) - ord('a')
			for i in range(tail+1, 26):
				if chr(97+i) in S_cut[:-1]:
					continue
				else:
					print(S_cut[:-1]+chr(97+i))
					continuate = False
					break

Measured memory_bytes: 3064
#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 55;
const int base = 311;

// dung inverse module de tinh nCk
// beginer 82
// mbeginer
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];
//vector<ll>adj[e];

/*ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}*/

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/

ll n, m, k, q;
ll x[e];
ll a, b;

int main()
{
   cin >> a >> b >> n;
   cout << (a*min(b-1, n))/b - a*(min(b-1, n)/b);
}
/*

*/


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  int a[n],b[n],c[n-1];
  for(int i=0;i<n;i++)
  {
  cin>>a[i];
  }
 for(int i=0;i<n;i++)
  {
  cin>>b[i];
  } 
  for(int i=0;i<n-1;i++)
    {
  cin>>c[i];}
  int sum=0;
  for(int i=0;i<n;i++)
  {sum=sum+b[a[i]-1];
  if(i<n-1){if(a[i+1]==a[i]+1)
    sum=sum+c[a[i]-1];}
  }cout<<sum;}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const ll N=800005;
ll dp[100002][101];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,s;
  cin>>n>>s;
  ll w[n],v[n];
  forn(i,n)
  {
    cin>>w[i]>>v[i];
  }
  for(ll i=0;i<=s;i++)
  {
    forn(j,n+1)
    {
      if(j==0){
        dp[i][j]=0;
        continue;
      }
      dp[i][j]=dp[i][j-1];
      if(i-w[j-1]>=0)
      {
        dp[i][j]=max(dp[i][j],dp[i-w[j-1]][j-1]+v[j-1]);
      }
    }
  }
  cout<<dp[s][n];
}
//nothing is impossible

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int a;
    cin >> a;
    string s;
    cin >> s;
    cout << (a < 3200 ? "red" : s) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) { return *this *= p.inverse(); }
  ModInt operator-() const { return ModInt() - *this; }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
    return ModInt(u);
  }
  ModInt pow(int64_t e) const {
    ModInt ret(1);
    for (ModInt b = *this; e; e >>= 1, b *= b)
      if (e & 1) ret *= b;
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int modulo() { return mod; }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  using Mint = ModInt<int(1e9 + 7)>;
  long long N, K;
  cin >> N >> K;
  Mint f[K + 1];
  f[K] = 1;
  for (int i = K - 1; i >= 1; i--) {
    f[i] = Mint(K / i).pow(N);
    for (int j = 2 * i; j <= K; j += i) f[i] -= f[j];
  }
  Mint ans = 0;
  for (int i = 1; i <= K; i++) {
    ans += f[i] * i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4012
S = input()

f_ = S[0:2]
s_ = S[2:4]

if 0 < int(f_) < 13 and 0 < int(s_) < 13:
    print('AMBIGUOUS')
elif 0 < int(f_) < 13:
    print('MMYY')
elif 0 < int(s_) < 13:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int a[200000];

int main(void){
    int n=in(),i,r,l;
    long long tmp=0,ans=0;
    rep(i,n)a[i]=in();
    for(l=0,r=0;l<n;l++){
        while(r<n&&tmp+a[r]==(tmp^a[r])){
            tmp+=a[r];
            r++;
        }
        ans+=r-l;
        tmp^=a[l];
    }
    llprint(ans);
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;cin>>n>>m;pair<int,int> st[n],ch[m];
    for(int i=0;i<n;i++){cin>>st[i].first>>st[i].second;}
    for(int i=0;i<m;i++){cin>>ch[i].first>>ch[i].second;}
    ///-----------------------------------------------///
    for(int i=0;i<n;i++)
    {
        long long pos,mn=1e12;
        for(int j=0;j<m;j++)
        {
            if(abs(st[i].first-ch[j].first)+abs(st[i].second-ch[j].second)<mn)
            {
                pos=j+1;
                mn=abs(st[i].first-ch[j].first)+abs(st[i].second-ch[j].second);
            }
        }
        cout<<pos<<endl;
    }
}


Measured memory_bytes: 3640
/*
 * SKP🔥🔥🔥
*/
#include <bits/stdc++.h>
using namespace std;

//TYPEDEF
typedef long long ll;

// DEFINE SECTION
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr);

//IMPORTANT_FUNCTIONS
void io_file()
{
}
// OTHER_FUNCTIONS
//MAIN
int main()
{
    io_file();
    fio;
    ll t, count = 0;
    cin >> t;
    int a[t], b[t];
    int z[t];
    for (int i = 0; i < t; i++)
    {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < t; i++)
    {
        if (a[i] - b[i] == 0)
            z[i] = 1;
        else
            z[i] = 0;
    }
    for (int i = 0; i <= t - 3; i++)
    {
        if (z[i] + z[i + 1] + z[i + 2] == 3)
        {
            count = 1;
            break;
        }
    }
    if (count == 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;

    if((a==1&&b==2)||(b==1&&a==2))cout<<3;
    else if((a==1&&b==3)||(b==1&&a==3))cout<<2;
    else if((a==2&&b==3)||(a==3&&b==2))cout<<1;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<int> cnt1(n + 1, 0), cnt2(n + 1, 0);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    cnt1[i + 1] = a + cnt1[i];
  }

  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    cnt2[i + 1] = a + cnt2[i];
  }

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int sum = cnt1[i + 1] + cnt2.back() - cnt2[i];
    ans = max(sum, ans);
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long f[100005][25];
long long arr[100005];
int main(){
	long long n,l,a,b,q;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	cin>>l;
	for(int i=1;i<=n;i++){
		long long k=upper_bound(arr+1,arr+n+1,arr[i]+l)-arr;
		k=k-1;
		if(arr[i]+l>=arr[n]){
			f[i][0]=n;
		}
		else {
			f[i][0]=k;
		}
	}
	for(int j=1;j<=20;j++){
		for(int i=1;i<=n;i++){
			f[i][j]=f[f[i][j-1]][j-1];
		}
	}
	cin>>q;
	while(q--){
		cin>>a>>b;
		if(a>b)
			swap(a,b);
			long long ans=0;
			for(int i=20;i>=0;i--){
				if(f[a][i]<b){
					ans+=(1<<i);
					a=f[a][i];
				}
			}
			cout<<ans+1<<endl;
	}
}

Measured memory_bytes: 21120
#include<bits/stdc++.h>
using namespace std;

int main(void){

    int N; cin>>N;
    int ans=0;
    int tmp; cin>>tmp;
    ans += tmp;
    for (int i = 1; i < N; ++i) {
        int a; cin>>a;
        if(a-tmp > 0) ans+=a-tmp;
        tmp = a;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <set>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int s;
    cin >> s;
    set<int> st;
    int result = 1;
    do { 
        st.insert(s);
        if(s&1){
            s = s * 3 + 1;
        }else{
            s /= 2;
        }
        result++;
    } while (!st.count(s));
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256