akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define  f(i,a,b) for( i=a;i<b;i++) 
#define ll long long int
using namespace std;

int main()
{	
	int n,k,m=0,i; cin>>n>>k;

	int t = min(2,2+k),p,q;
	for(int i=1;i<n;i++)
		{
			p = 2*t;
			q = t+k;
		  if(p>q) t=q;
		  else t=p; }
	

	cout<<t;
}



Measured memory_bytes: 256
from fractions import gcd
from functools import reduce
def lcm(a, b):return a//gcd(a,b)*b

def f(x):
    c = 0
    while x%2==0:
        x //= 2
        c += 1
    return c

n,m = map(int, input().split())
a = list(map(lambda x:int(x)//2, input().split()))
t = f(a[0])
m >>= t
l = 1
for x in a:
    if f(x) != t:
        print(0)
        quit()
    x >>= t
    l = l // gcd(l,x) * x
    if l > m:
        print(0)
        quit()

print((m//l+2-1)//2) # round up


Measured memory_bytes: 16344
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j,rev;
    long double ans=1;
    cin>>n;
    for(i=0;i<n;++i){
    	cin>>rev;
    	if(ans!=-1){
    		ans*=rev;
		}
		if(rev==0){
			ans=0;
		}
		if(ans<0 || ans>1000000000000000000){
			ans=-1;
		}
	}
	cout<<(ll)ans;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, wt, val=0;
  cin>>n>>wt;
  int w[n+1], v[n+1];
  for(int i=1;i<=n;i++) 
  {
    cin>>w[i]>>v[i];
    val+=v[i];
  }
  long long int dp[val+1];
  dp[0]=0;
  for(int i=1;i<=val;i++) dp[i]=INT_MAX;
  for(int j=1;j<=n;j++) for(int i=val;i>=0;i--) if(v[j]<=i) dp[i]=min(dp[i],dp[i-v[j]]+w[j]);
  for(int i=val;i>=0;i--) if(dp[i]<=wt)
  {
    cout<<i;
    break;
  }
}

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

const long long MOD = 1000000007;
const int MAX = 10000000;
long long fac[MAX], finv[MAX], inv[MAX];

void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long mod_comb(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    long long x, y;
    cin >> x >> y;
    comb_init();

    long long ans = 0;
    for (int i = 0; i <= max(x, y); i++) {
        int j = y - 2 * i;
        if (j < 0) continue;
        
        if ((i + 2 * j == x) && (2 * i + j == y)) {
            ans += mod_comb(i + j, i);
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 234624
#C問題
N,M = map(int,input().split())
K = []
S = []
for i in range(M):
    ks =list(map(int,input().split()))
    ss = []
    kk = ks[0]
    K.append(kk)
    for j in range(kk):
        ss.append(ks[j+1])
    
    S.append(ss)
P = list(map(int,input().split()))
Bit = 2**N
ans = 0
for i in range(Bit):
    b = bin(i)
    b = b.lstrip("0b")
    lenb = len(b)
    j = 0
    for j in range(N-lenb):
        b = "0"+b
        
    sw = []
    j = 0

    for j in range(N):
        if b[j] == "1":
            sw.append(1)
        else:
            sw.append(0)
    
    j = 0
    flag = 0
    for j in range(M):
        cond = P[j]
        now = 0
        for k in range(K[j]):
            now+=sw[S[j][k]-1]
            
        if now%2 == cond:
            pass
        else:
            flag = 1
            break
            
    if flag == 0:
        ans+=1
    
print(ans)

Measured memory_bytes: 3064
import java.util.*;  
class  Main{
   public static void main(String[] args){
   	
   	Scanner input = new Scanner(System.in);
   	int n = input.nextInt();//入力文字数決定
   
        // 文字列を List へ追加
        List<String> list = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
        	String s = input.next();
            list.add(s);
        }
   		list.toString();

        // 昇順にソート
        Collections.reverse(list);
			String separator = " ";
        // List の文字列を StringBuilder に追加
        StringBuilder sb = new StringBuilder();
        for (String str : list) {
        	if(sb.length() > 0){
        		sb.append(separator);
        	}
            sb.append(str);
        }
   	System.out.println(sb.toString());
   }
}

Measured memory_bytes: 17180
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;

void add(ll& x, ll y) {x+=y; x%=M;}

ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}

int main() {
  int n; cin>>n;
  string _; cin>>_; int m = _.size();

  ll dp[2][n+1]; fill(dp[0],dp[2],0);
  dp[0][0]=1;
  for(int i=0;i<n;i++) {
    int nw = i%2, nx = (i+1)%2;
    fill(dp[nx],dp[nx]+n+1,0);
    for(int j=0;j<n;j++) {
      add(dp[nx][max(0,j-1)],dp[nw][j]);
      add(dp[nx][j+1],dp[nw][j]*2);
    }
  }
  ll an = mod_pow(mod_pow(2, m), M-2);
  an = an * dp[n%2][m] % M;
  cout<<an<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)


ll S;

int main() {
    cin >> S;
    ll up = S/100;
    ll down = S%100;
    if ((up <= 12 && up > 0) && (down <= 12 && down > 0)) cout <<"AMBIGUOUS" << endl;
    else if(up <= 12 && up > 0) cout << "MMYY" << endl;
    else if (down <= 12 && down > 0) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    
    return 0;
}

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

int n;
ll a[100010];
vector<int> e[100010];

ll f(int x, int p){
	ll s = 0, mx = 0; int flag = 0;
    for(auto &i : e[x]){
		if(i == p) continue;
		flag = 1;
        ll t = f(i, x);
        if(t == -1) return -1;
        s += t;
        mx = max(mx, t);
    }
    if(!flag) return a[x];
    ll d = (mx <= s - mx) ? (s % 2) : (mx - (s - mx));
	//printf("%d : %lld %lld -> %lld / %lld\n", x, s, mx, d, a[x]);
	if(s + d <= 2 * a[x] && 2 * a[x] <= 2 * s) return 2 * a[x] - s;
	else return -1;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", a + i);
	for(int i = 0; i < n - 1; i++){
		int x, y; scanf("%d%d", &x, &y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	for(int i = 1; i <= n; i++){
		if(e[i].size() == 1) continue;
		if(f(i, 0)) puts("NO");
		else puts("YES");
		return 0;
	}
	if(a[1] == a[2]) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
#define int long long
int memo[2222][10];
vector<int> v[10];
int dfs(int b,int c){
  //cout<<b<<" "<<c<<endl;
  if(c==10) return 0;
  if(~memo[b][c]) return memo[b][c];
  int res=dfs(b,c+1),tmp=0;
  for(int i=0;i<(int)v[c].size();i++){
    if(b-(i+1)<0) break;
    tmp+=v[c][i];
    res=max(res,(tmp+i*(i+1))+dfs(b-(i+1),c+1));
  }
  //cout<<b<<" "<<c<<" "<<res<<endl;
  return memo[b][c]=res;
}
signed main(){
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int c,g;
    cin>>c>>g;
    v[g-1].push_back(c);
  }
  for(int i=0;i<10;i++) sort(v[i].rbegin(),v[i].rend());
  /*
  for(int i=0;i<10;i++){
    cout<<i<<":";
    for(int j=0;j<(int)v[i].size();j++) cout<<v[i][j]<<" ";
    cout<<endl;
  }
  */
  memset(memo,-1,sizeof(memo));
  cout<<dfs(k,0)<<endl;
  return 0;
}

Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define eb emplace_back

int in(){int x;cin>>x;return x;}

using Real = double;
using Point = complex<Real>;
const Real EPS = 1e-8,PI = acos(-1);
inline bool eq(Real a,Real b){ return fabs(b-a) < EPS;}
Point rotate(Real _theta,const Point &p){
    Real theta = (_theta*PI/180);
    return Point(cos(theta)*p.real()-sin(theta)*p.imag(),sin(theta)*p.real()+cos(theta)*p.imag());
}
struct Segment {
    Point a,b;
    Segment()=default;
    Segment(Point a,Point b):a(a),b(b){}
};
Real dot(const Point &a,const Point &b){
    return real(a)*real(b)+imag(a)*imag(b);
}

Point projection(const Segment &l,const Point &p){
    double t = dot(p-l.a,l.a-l.b)/norm(l.a-l.b);
    return l.a+(l.a-l.b)*t;
}
Real cross(const Point &a, const Point &b) {
    return real(a) * imag(b) - imag(a) * real(b);
}
int ccw(const Point &a, Point b, Point c) {
    b = b - a, c = c - a;
    if(cross(b, c) > EPS) return +1;  
    if(cross(b, c) < -EPS) return -1;
    if(dot(b, c) < 0) return +2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}
bool intersect(const Segment &s,const Point &p){
    return ccw(s.a,s.b,p) == 0;
}
bool intersect(const Segment &s, const Segment &t) {
    return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
Real distance(const Segment &s,const Point &p){
    Point r = projection(s,p);
    if(intersect(s,r)) return abs(r-p);
    return min(abs(s.a-p),abs(s.b-p));
}
Real distance(const Segment &a, const Segment &b) {
    if(intersect(a, b)) return 0;
    return min({distance(a, b.a), distance(a, b.b), distance(b, a.a), distance(b, a.b)});
}
struct Star{
    Point center;
    Real r;
    Real theta;
    Point p[5];
    Segment s[5];
    Star(int x,int y,int a,int r):r(r),theta(a){
        center=Point(x,y);
        rep(i,5){
            Point P(0,r);
            P = rotate(a+72*i,P);
            p[i] = Point(center+P);
        }
        rep(i,5){
            s[i] = Segment(p[i],p[(i+2)%5]);
        }
    }
};
Real distance(Star &x,Star &y){
    Real d = 1e10;
    rep(i,5){
        rep(j,5){
            d = min(d,distance(x.s[i],y.s[j]));
        }
    }
    return d;
}
    

main(){
    while(1){
        int n=in(),m=in(),l=in();
        if(!n)exit(0);
        vector<Star> v;
        rep(i,n){
            int x=in(),y=in(),a=in(),r=in();
            v.emplace_back(x,y,a,r);
        }
        Real mat[n][n];
        rep(i,n){
            rep(j,n){
                if(i==j)mat[i][j]=0;
                else mat[i][j] = distance(v[i],v[j]);
            }
        }
        rep(k,n){
            rep(i,n){
                rep(j,n){
                    mat[i][j] = min(mat[i][j],mat[i][k]+mat[k][j]);
                }
            }
        }
        cout << setprecision(15) << fixed << mat[m-1][l-1] << endl;
    }
}



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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m;
int a[N];

int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i=0; i<n; i++) {
		cin >> a[i];
		a[i] /= 2;
	}
	int lcm = 1;
	for(int i=0; i<n; i++){
		lcm = lcm * a[i] / __gcd(lcm, a[i]);
		if (lcm > m) {
			return 0*puts("0");
		}	
	}
	for(int i=0; i<n; i++){
		if (lcm / a[i] % 2 == 0) return 0*puts("0");
	}
	
	cout << 1 + (m-lcm)/(2*lcm) << endl;
	
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  
  int a[11];
  for(int i=0;i<n;i++)cin>>a[i];
  
  sort(a,a+n,greater<int>());
  
  int sum=0;
  for(int i=1;i<n;i++){
    sum= sum+a[i];
  }
  if(a[0]<sum){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main(){

  int A, B, C, D;
  cin >> A >> B >> C;

  if(!A%B){
    cout << "NO" << endl;
    return 0;
  }

  D = A%B;
  for(int i=0; i<1000; i++){
    if(D==C){
      cout << "YES" << endl;
      return 0;
    }
    D += A%B;
    D %= B;
  }
  cout << "NO" << endl;
  return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n,color;
  cin>>n>>color;
  auto d = vec<int>(color,color);
  auto c = vec<int>(n,n);
  cin>>d>>c;

  for(auto& y:c)for(auto& x:y)x--;

  vector<vector<int>> b(3);
  rep(i,n)rep(j,n){
    b[(i+j+2)%3].emplace_back(c[i][j]);
  }

  vector<vector<pair<int,int>>> uku(3);
  rep(i,3)rep(e,color){
    int tmp = 0;
    for(auto v:b[i]){
      tmp += d[v][e];
    }
    uku[i].emplace_back(tmp,e);
  }
  for(auto& vec:uku)sort(begin(vec),end(vec));

  int ans = 1<<28;
  rep(i,3)rep(j,3)rep(k,3){
    if(uku[0][i].second==uku[1][j].second)continue;
    if(uku[1][j].second==uku[2][k].second)continue;
    if(uku[0][i].second==uku[2][k].second)continue;
    ans = min(ans,uku[0][i].first+uku[1][j].first+uku[2][k].first);
  }
  cout<< ans <<endl;

/*
  vector<int> c(3);
  int ans = 1<<28;
  for(c[0]=0;c[0]<color;++c[0]){
    for(c[1]=0;c[1]<color;++c[1]){
      if(c[0]==c[1])continue;
      for(c[2]=0;c[2]<color;++c[2]){
        if(c[0]==c[2]||c[1]==c[2])continue;
        int tmp = 0;
        rep(i,n)rep(j,n){
          int x = a[i][j];
          int y = c[(i+j+2)%3];
          tmp += uku[x][y];
        }
        chmin(ans,tmp);
      }
    }
  }
  cout<<(ans)<<endl;
*/

}

Measured memory_bytes: 2428
#include <stdio.h>
int main(void) {
    int n;
    int h[1000];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }

    int max = h[0];
    ;
    int cnt = 1;

    for (int i = 1; i < n; i++) {
        if (h[i] >= max) {
            max = h[i];
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;

#define Nmax 100

int main(){
    int k,s;
    int x,y,z;
    int cnt = 0;

    cin >> k >> s;

    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            if(0 <= s - i - j && s - i - j <= k) {
                //cout << i << j << endl;
                cnt++;
            }
            //else break;
        }
    }

    cout << cnt;
    //cout << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int a,b,c,n;
    cin >> a >> b >> c >> n;
    vector<int> ab(3001,0),ac(3001,0),bc(3001,0);
    for(int o=0;o<=3000;o++)
    {
        for(int i=0;i<=3000;i++)
        {
            if(a*o+b*i<=3000) ab[a*o+b*i]++;
            if(a*o+c*i<=3000) ac[a*o+c*i]++;
            if(b*o+c*i<=3000) bc[b*o+c*i]++;
        }
    }
    int res=0;
    for(int i=0;i<=3000;i++) if(a*i<=n) res+=bc[n-a*i];
    for(int i=0;i<=3000;i++) if(b*i<=n) res+=ac[n-b*i];
    for(int i=0;i<=3000;i++) if(c*i<=n) res+=ab[n-c*i];
    cout << res/3 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner (System.in);
		String s = sc.next();
		String year = "2018";
		String month = s.substring(4);
		System.out.println(year + month);
		// your code goes here
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

ll a[4100000];

int main(){
    ll N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    ll posNum[64];
    fill(posNum, posNum+64, 0);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 62; j++){
            posNum[j] += (a[i] >> j) % 2;
        }
    }

    ll res = 0;
    for(int j = 0; j < 62; j++){
        ll addedNum = (1LL << j) % mod;
        res = add(res, mul(addedNum, mul(posNum[j], N - posNum[j])));
    }

    cout << res << endl;


    return 0;
}




Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int n,q;
int x;
char s[200050];
char t[200050];
char d[200050];
void input(){
  cin>>n>>q;
  rep1(i,n)cin>>s[i];
  rep(i,q)cin>>t[i]>>d[i];
  s[0]='0';
  s[q+1]='0';
}
void go(char d){
  if(d=='L')x--;
  if(d=='R')x++;
}
bool left(int p){
  x=p;
  rep(i,q){
    if(s[x]==t[i]){
      go(d[i]);
  }
  }
  return x==0;
}
bool right(int p){
  x=p;
  rep(i,q){
    if(s[x]==t[i]){
      go(d[i]);
  }
  }
  return x==n+1;
}
int main(){
  input();
  int l=0;
  int r=n+1;
  int mid;
  while(r-l>1){
    mid=(l+r)/2;
    if(left(mid))l=mid;
    else r=mid;
  }
  int limit_l=l;
  l=0;
  r=n+1;
  while(r-l>1){
    mid=(l+r)/2;
    if(right(mid))r=mid;
    else l=mid;
  }
  int limit_r=r;
  int ans=q-(q+1-limit_r)-limit_l;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
const int MAX = 1e5*2 + 10;
int64_t MINF = -1e18;
int64_t dp[MAX][3];

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      dp[i][j] = MINF;
    }
  }
  
  if(N == 2){
    cout << max(vec[0],vec[1]);
  }
  else{
    dp[0][0] = vec[0];
    dp[1][1] = vec[1];
    dp[2][2] = vec[2];
    for(int i=0; i<N; i++){
      for(int j=0; j<3; j++){
        if(dp[i][j] == MINF){
          continue;
        }
        else{
          for(int k=0; k<3; k++){
            if(i + k + 2 < N && j + k < 3){
              dp[i+k+2][j+k] = max(dp[i+k+2][j+k], dp[i][j] + vec[i+k+2]);
            }
          }
        }
      }
    }
    int64_t ans = MINF;
    for(int i=0; i<N; i++){
      for(int j=0; j<3; j++){
        if((i+2-j)/2 == N/2){
          ans = max(ans,dp[i][j]);
        }
      }
    }
    cout << ans << endl;
  }
}

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

int main() {
int N, W, X;
int prise = 0;
cin >> N >> W >> X;
vector<vector<int>> A(N, vector<int>(W + 1));
vector<int> sum(W + 1);
for(int i = 0; i < N; i++){
for(int j = 0; j < (W + 1); j++){
cin >> A.at(i).at(j);}}
for(int bit = 0; bit < (1 << N); bit++){
bitset<12> s(bit);
 for(int i = 0; i < N; i++){
  if(s.test(i)){
   for(int j = 0; j < W + 1; j++){
   sum.at(j) += A.at(i).at(j);}}} //sumにAのi列加算
int count = 0;
 for(int k = 1; k < W + 1; k++){
  if(sum.at(k) >= X){
  count++;}}
 if(count == W){
  if(prise == 0){
  prise = sum.at(0);}
  if(prise != 0 && prise > sum.at(0)){
  prise = sum.at(0);}}
for(int l = 0; l < W + 1; l++){ //sum初期化
sum.at(l) = 0;}}
if(prise != 0){
cout << prise << endl;}
else cout << "-1" << endl;}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
long a[101][101],b[101][101],ans[101][101];
int main(){
int n,m,l;
cin>>n>>m>>l;
for(int i=0;i<n;i++)
	{for(int i2=0;i2<m;i2++)
		{cin>>a[i][i2];
		}
	}
for(int i=0;i<m;i++)
	{for(int i2=0;i2<l;i2++)
		{cin>>b[i][i2];
		}
	}
for(int i=0;i<n;i++)
	{for(int i2=0;i2<l;i2++)
		{for(int i3=0;i3<m;i3++)
			{
			ans[i][i2]+=a[i][i3]*b[i3][i2];
			}
		if(i2!=0) cout<<" ";
		cout<<ans[i][i2];
		}
	cout<<endl;
	}
return 0;
}


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

using namespace std;

#define INF 1 << 25

int main()
{
  int N;
  int t[16][17];
  while(cin >> N, N){
    for(int i = 0; i < N; i++){
      for(int j = 0; j <= N; j++) cin >> t[i][j];
    }
    int dp[1 << 16];
    for(int i = 0; i < 1 << 16; i++) dp[i] = INF;
    dp[0] = 0;
    for(int i = 0; i < 1 << N; i++){
      for(int j = 0; j < N; j++){
	if((i >> j) & 1) continue;
	for(int k = 0; k < N; k++){
	  if((i >> k) & 1) dp[i | (1 << j)] = min(dp[i | (1 << j)], dp[i] + t[j][k+1]);
	}
	dp[i | (1 << j)] = min(dp[i | (1 << j)], dp[i] + t[j][0]);
      }
    }
    cout << dp[(1 << N) - 1] << endl;
  }  
  return 0;
}

Measured memory_bytes: 1416
#include <stdio.h>

int main(void) {
  long long int x, y, rem;
  long long int temp;

  scanf("%lld %lld", &x, &y);

  if (x < y) {
    temp = x;
    x = y;
    y = temp;
  }

  while (y) {
    rem = x % y;
    x = y;
    y = rem;
  }

  printf("%lld\n", x);

  return 0;
}



Measured memory_bytes: 2080
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int stack[100];
int i= 1;

int push(int);
int pop(void);

int main(){
  int buf1,buf2,ans;
  int x;
  char s[100];
  
  while( scanf("%s", s) != EOF){
    if ( s[0] == '+' ){
      buf1 = pop();
      buf2 = pop();
      ans = buf1 + buf2;
      push(ans);
    } 
    else if ( s[0] == '-' ){
      buf1 = pop();
      buf2 = pop();
      ans = buf2 - buf1;
      push(ans);
    } 
    else if ( s[0] == '*' ){
      buf1 = pop();
      buf2 = pop();
      ans = buf1 * buf2;
      push(ans);
    } 
    else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",stack[i]);
  return 0;
}

int push(int x){
  i++;
  stack[i] = x;
}
int pop(void){
  i--;
  return stack[i+1];
}

Measured memory_bytes: 548
import java.util.Scanner;


public class Main {

	static Scanner sc = new Scanner(System.in);
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		while(sc.hasNextLine()){
			char sentence[] = sc.nextLine().toCharArray();
			
			for(int i=0; i < 26; i++){
				for(int j=0; j < sentence.length; j++){
					if(sentence[j] != ' ' && sentence[j] != '.'){
						sentence[j] = (char)((int)(sentence[j] - 'a' + 1) % 26 + 'a');
					}
				}
				
				String str = String.valueOf(sentence);
				if(str.indexOf("this") != -1 || str.indexOf("the") != -1 || str.indexOf("that") != -1){
					System.out.println(str);
					break;
				}
			}
			
		}

	}

}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n;
	cin>>n;
	vector<int> p(n),q(n),num(n);
	rep(i,n){
		cin>>p[i];
		p[i]--;
	}
	rep(i,n){
		cin>>q[i];
		q[i]--;
	}
	rep(i,n)num[i]=i;

	int cnt=0;
	int a=-1,b=-1;
	do{
		cnt++;
		if(num==p)a=cnt;
		if(num==q)b=cnt;
	}while(next_permutation(all(num)));
	cout<<abs(a-b)<<endl;

	return 0;
}

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

int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(D,vector<int>(26,0));
  rep(i,D)rep(j,26) cin >> s[i][j];
  vector<int> t(D);
  vector<int> v(D,0);
  vector<int> last(26,0);
  
  rep(d,D) {
    int maxElementIndex = std::max_element(s[d].begin(), s[d].end()) - s[d].begin();
    t[d] = maxElementIndex + 1;
    int m = 0;
    last[t[d]-1]=d+1;
    rep(j,26) m += c[j]*(d+1-last[j]);
    if(d==0) v[d] = s[d][t[d]-1] - m;
    else v[d] = v[d-1] + s[d][t[d]-1] - m;
  }
  rep(i,D) cout << t[i] << endl;
  
  return 0;
}

Measured memory_bytes: 3684
#include <iostream>
using namespace std;
int main()
{
int a,b,c,d,p,q,x,y;
cin>>a>>b>>c>>d>>p;
x=p*a;
if(p<=c){ y=b;}else{ y=b+(p-c)*d; }
cout << (x<y?x:y) << endl;
return 0;
}

Measured memory_bytes: 1160
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
    return 0;
}


Measured memory_bytes: 3216
#include <stdio.h>
#include <math.h>

struct POINT {
    double x;
    double y;
};

double Dist(const POINT &a, const POINT &b){
    return sqrt( (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) );  
}

double Square(const POINT &a, const POINT &b, const POINT &c){    //3点を頂点に持つ"平行四辺形の"面積
    return fabs( (a.x - b.x) * (a.y - c.y) - (a.y - b.y) * (a.x - c.x) );
}


int main(){
    POINT zP[3];
    for (int i = 0; i < 3; i++){
        scanf("%lf %lf", &zP[i].x, &zP[i].y);
    }
    double xAns,yAns,rAns;
    xAns = ( Dist(zP[1], zP[2]) * zP[0].x + Dist(zP[2], zP[0]) * zP[1].x + Dist(zP[0], zP[1]) * zP[2].x )
           / ( Dist(zP[1], zP[2]) + Dist(zP[2], zP[0]) + Dist(zP[0], zP[1]) );
    yAns = ( Dist(zP[1], zP[2]) * zP[0].y + Dist(zP[2], zP[0]) * zP[1].y + Dist(zP[0], zP[1]) * zP[2].y )
           / ( Dist(zP[1], zP[2]) + Dist(zP[2], zP[0]) + Dist(zP[0], zP[1]) );
    rAns = Square(zP[1], zP[2], zP[0]) / ( Dist(zP[1], zP[2]) + Dist(zP[2], zP[0]) + Dist(zP[0], zP[1]) );
    printf("%lf %lf %lf", xAns, yAns, rAns);
    
    return 0;
}


Measured memory_bytes: 2736
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

#define MAX 17
ll cnt[MAX];

ll ipow(int n, int r) { return r==0?1:n*ipow(n, r-1); }

ll fir(ll n, ll d)
{
	for (ll i = n;; i++) if (i%d==0) return i;
}

ll las(ll n, ll d)
{
	for (ll i = n;; i--) if (i%d==0) return i;
}

ll divs(ll b, ll e, ll divisor)
{
	return (las(e, divisor)-fir(b, divisor))/divisor + 1;
}

ll range(ll b, ll e, ll offset, ll len)
{
	ll three = divs(b, e, 3);
	ll five = divs(b, e, 5);
	ll fifteen = divs(b, e, 15);
	ll all = e-b+1;
	ll nums = all - three - five + fifteen;
	three -= fifteen;
	five -= fifteen;
	return offset+nums*len+(three+five)*4+fifteen*8;
}

void calc(void)
{
	cnt[0] = 0;
	for (int e = 0; e < MAX; e++) {
		ll s = ipow(10, e);
		ll g = s*10-1;
		ll ans = range(s, g, 0, e+1);
		cnt[e+1] = cnt[e] + ans;
		//printf("%d:%lld, %e\n", e+1, cnt[e+1], (double)cnt[e+1]);
		//printf("%lld\n", s);
	}
}

string to_number(ll n)
{
	string r = "";
	while (n > 0) {
		r = (char)(n%10 + '0') + r;
		n /= 10;
	}
	return r;
}

void solve(ll i, ll s)
{
	ll bb = ipow(10, i);
	ll ee = ipow(10, i+1)-1;

	ll b = bb, e = ee;
	while (e-b > 1) {
		ll m = (b+e)/2;
		ll idx = range(bb, m - 1, cnt[i], i+1);

		//dump3(s, idx, m);
		
		if (s <= idx) {
			e = m;
		} else {
			b = m;
		}
	}

	string str = "";
	ll idx = range(bb, b - 1, cnt[i], i+1) + 1;
	for (ll n = b; idx+str.size() < s+40; n++) {
		if (n%15==0) {
			str += "FizzBuzz";
		} else if (n%3==0) {
			str += "Fizz";
		} else if (n%5==0) {
			str += "Buzz";
		} else {
			str += to_number(n);
		}
	}
	cout << str.substr(s-idx, 20) << endl;
}

int main(void)
{
	calc();

	ll s;
	cin >> s;
	for (int i = 0; i < MAX; i++) {
		if (cnt[i] < s && s <= cnt[i+1]) {
			solve(i, s);
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1208
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

get_i_to_x_rbtree0(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 0, T2, T).

get_i_to_x_rbtree1(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 1, T2, T).

get_i_to_x_rbtree(0, _, T, T).
get_i_to_x_rbtree(N, I, T2, T) :-
    get_number(X),
    rb_insert(T2, I, X, T3),    
    N2 is N - 1,
    I2 is I + 1,
    get_i_to_x_rbtree(N2, I2, T3, T).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)
*/

main :-
    get_number(N, D),
    X is (N + 2 * D) div (2 * D + 1),
    writeln(X).

    % statistics(inferences, IC), writeln(IC).


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

const long long INF = (long long) 1e18;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, x;
  cin >> n >> m >> x;
  vector<long long> c(n);
  vector< vector<long long> > a(n, vector<long long>(m));
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  long long ans = INF;
  for (int mask = 0; mask < (1 << n); mask++) {
    long long cost = 0;
    vector<long long> understanding(m, 0);
    for (int i = 0; i < n; i++) {
      if (mask & (1 << i)) {
        cost += c[i];
        for (int j = 0; j < m; j++) {
          understanding[j] += a[i][j];
        }
      }
    }
    bool pos = true;
    for (int i = 0; i < m; i++) {
      if (understanding[i] < x) {
        pos = false;
        break;
      }
    }
    if (pos) {
      ans = min(ans, cost);
    }
  }
  if (ans == INF) {
    cout << -1 << '\n';
  } else {
    cout << ans << '\n';
  }
  return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  cin >> n;
  
  int64_t a[n] = {0};
  map<int64_t, int64_t> count;

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

  int64_t sumOrg = 0;
  for(const auto& [key, value]:count){
    if(value>=2){
      sumOrg += (value)*(value-1)/2;
    }
  }

  for(int i=0;i<n;i++){
    int64_t sum = sumOrg;
    int64_t countA = count[a[i]];
    if(countA>=2){
      sum -= countA*(countA-1)/2;
    }
    if(countA>=3){
      sum += (countA-1)*(countA-2)/2;
    }
    cout << sum << endl;
  }
 
  return 0;
}




Measured memory_bytes: 13156
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])
ans = 0
for i in range(N):
    if M > AB[i][1]:
        ans += AB[i][0] * AB[i][1]
        M -= AB[i][1]
    else:
        ans += AB[i][0] * M
        break
print(ans)


Measured memory_bytes: 29020
#include <iostream>
using namespace std;
int main()
{
	int x[3];
	bool yes = true;
	cin >> x[0];
	for (int i = 1; i < 3; i++)
	{
		cin >> x[i];
		if (x[i - 1] >= x[i])
		{
			yes = false;
		}
	}
	cout << (yes ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a;

    cin >> a;

    if (a < 1000) {
        cout << "ABC" << endl;
    }
    else {
        cout << "ABD" << endl;
    }
}


Measured memory_bytes: 256
from math import sqrt

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

result = 0
for i in range(N):
  for j in range(N):
    if i != j:
      result += sqrt((xy[i][0] - xy[j][0]) * (xy[i][0] - xy[j][0]) + (xy[i][1] - xy[j][1]) * (xy[i][1] - xy[j][1]))
print(result / N)


Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {


    var sc = Scanner(System.`in`)

    val n = sc.nextInt()
    
    val dp = IntArray(n+1)
    
    dp[0] = 1
    dp[1] = 1
    
    for(i in 2..n){
        dp[i] = dp[i-1] + dp[i-2]
    }
    
    println(dp[n])

}




Measured memory_bytes: 25624
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 100001
#define ll long long
using namespace std;

int main(){
    int n;
    cin>>n;
    int f[n+1][11];
    int p[n+1][11];
    
    for (int i=1; i<=n; i++){
        for (int j=1; j<=10; j++){
            cin>>f[i][j];
        }
    }
    
    for (int i=1; i<=n; i++){
        for (int j=0; j<=10; j++){
            cin>>p[i][j];
        }
    }
    
    ll ans=-100000000000;
    for (int bit = 1; bit < (1<<10); ++bit){
        vector<int> S;
        for (int i = 0; i < 10; ++i) {
            if (bit & (1<<i))  S.push_back(1);
            else S.push_back(0);
        }
        
        int day[n+1];
        for (int i=1; i<=n; i++) day[i]=0;
        
        for (int i=1; i<=n; i++){
            for (int j=0; j<10; j++){
                if (S[j]==1 && f[i][j+1]) day[i]++;
            }
        }
        
        
        
        ll sum=0;
        for (int i=1; i<=n; i++){
            sum+=p[i][day[i]];
        }
  
        ans=max(sum,ans);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue<LL>
#define PQS priority_queue<LL, vector<LL>, greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
//#define MOD 1000000007
#define MOD 998244353
#define ERR 0.00000000000001
#define NUM 200010

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}

struct UF{
private:
  VL par;
public:
  UF(LL n){par.resize(n,-1);}
  LL root(LL x){if(par[x]<0)return x;else return par[x]=root(par[x]);}
  LL size(LL x){return -par[root(x)];}
  bool same(LL x,LL y){return root(x)==root(y);}
  void unite(LL x,LL y){x=root(x);y=root(y);if(x!=y){if(size(x)<size(y))swap(x,y);par[x]+=par[y];par[y]=x;}}
};

int main(){
  LL i,N,M;
  cin>>N>>M;
  VL A(M),B(M),dp(M);
  rep(i,M)cin>>A[i]>>B[i];
  UF u(N+1);
  dp[M-1]=N*(N-1)/2;
  for(i=M-2;i>=0;i--){
    dp[i]=dp[i+1];
    if(!u.same(A[i+1],B[i+1])){
      dp[i]-=u.size(A[i+1])*u.size(B[i+1]);
      u.unite(A[i+1],B[i+1]);
    }
  }
  rep(i,M)cout<<dp[i]<<endl;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define maxN 200005
#define mod 1000000007
#define pi 3.14159265358979323846264338327950

void solve()
{
    ll n;
    cin >> n;
    string s;
    while (n != 0)
    {
        int temp = n % 26;
        if (temp == 0)
        {
            s += 'z';
            n -= 26;
        }
        else
        {
            s += ('a' + (temp - 1));
        }
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 3656
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

int main(){
    int N;
   cin>>N;
   vector<int>A(N);
   vector<int>B(N);
   vector<int>C(N-1);
    int64_t sum=0;
   rep(i,N){
       cin>>A.at(i);
   }
   rep(i,N){
       cin>>B.at(i);
       sum+=B.at(i);
   }
   rep(i,N-1){
       cin>>C.at(i);
       
   }
   rep(i,N-1)
if(A.at(i+1)-A.at(i)==1){
           sum+=C.at(A.at(i)-1);
       }
   cout<<sum<<endl;
    return 0; 
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N;
  int cnt[128] {};
  i64 a[5];

  cin >> N;
  for (int i = 0; i < N; ++i) {
    char s[12]; cin >> s;
    cnt[s[0]] += 1;
  }

  a[0] = cnt['M'];
  a[1] = cnt['A'];
  a[2] = cnt['R'];
  a[3] = cnt['C'];
  a[4] = cnt['H'];

  i64 ans = 0;
  for (int i = 0; i < 5; ++i) {
    for (int j = i+1; j < 5; ++j) {
      for (int k = j+1; k < 5; ++k) {
        ans += a[i] * a[j] * a[k];
      }
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
K = int(input())
D = int(input())
MOD = 10**9 + 7

dp = [[[0]*D for _ in range(2)] for _ in range(int(len(str(K)))+1)]
dp[0][0][0] = 1

for digit in range(int(len(str(K)))):
    for smaller_flg in [0,1]:
        lim = 9 if smaller_flg else int(str(K)[digit])
        for digit_num in range(lim+1):
            new_smaller_flg = smaller_flg or digit_num < lim
            for mod_d in range(D):
                new_mod_d = (mod_d + digit_num)%D
                dp[digit+1][new_smaller_flg][new_mod_d] += dp[digit][smaller_flg][mod_d]
                dp[digit+1][new_smaller_flg][new_mod_d] %= MOD

print((dp[int(len(str(K)))][1][0] + dp[int(len(str(K)))][0][0] - 1) % MOD)

Measured memory_bytes: 61788
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int N=1e5+7;
vector<int> adj[N];
bool vis[N];
int dp[N];
int deg[N];
void dfs(int u){
	vis[u]=1;
	for(int v:adj[u]) {
		dp[v]=max(dp[v],dp[u]+1);
		deg[v]--;
		if(!deg[v]) {
			dfs(v);
		}
	}
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1; i<=m; i++) {
		int u,v; cin>>u>>v;
		adj[u].push_back(v);
		deg[v]++;
	}
	for(int i=1; i<=n; i++) {
		if(!vis[i] and deg[i]==0) {
			dfs(i);
		}
	}

	int mx=-1;
	for(int i=1; i<=n; i++) {
		mx=max(dp[i],mx);
	}
	cout<<mx<<endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int N, cnt = 0;
    long long D, x, y;
    cin >> N >> D;
    D = D * D;
    
    rep(i, N) {
        cin >> x >> y;
        if ((x*x + y*y) <= D){
            ++cnt;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	char a, b;
	cin >> a >> b;
	puts(a == b ? "H" : "D");
	return 0;
}

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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  cout << max({A, B, C})-min({A, B, C}) << endl;
} 

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  string A, B, C;
  cin >> A >> B >> C;
  
  int ans = 0;
  for(int i = 0; i < N; i++){
    map<char, int> mp;
    mp[A[i]]++;
    mp[B[i]]++;
    mp[C[i]]++;
    ans += mp.size()-1;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#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)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  string S; cin>>S;
  sort(ALL(S));
  string ans="Yes";
  if(S[0]==S[2]) ans="No";
  cout<<ans<<endl;
  }


Measured memory_bytes: 256