akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {

    double a, b, x, theta;
    cin >> a >> b >> x;

    if (x > a * a * b / 2) { 
        theta = atan(2 * (a * a * b - x) / (a * a * a));
    }
    else {
        theta = atan((a * b * b) / (2 * x));
    }
    double PI = 3.14159265358979;
    theta = theta * 180 / PI;
    cout << fixed << setprecision(10) << theta << '\n';
}


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

int main() {
    int A, B;
    cin>>A>>B;

    int K;
    K=(A+B)/2;

    int R;
    R=(A+B)%2;

    if(R==0){cout<<K<<endl;}
    else{cout<<"IMPOSSIBLE"<<endl;}
}


Measured memory_bytes: 3600
n = input()
a_str = input().split()
a = list(map(int, a_str))
count = 0
should_continue = True
while should_continue:
    # print("i")
    for i, num in enumerate(a):
        # print(num)
        if num%2 == 0:
            num //= 2
            a[i] = num
            # print(num)
        else:
            should_continue = False
    if should_continue:
        count+=1
print(count)

Measured memory_bytes: 3060
public class Main {

  private static void solve() {
    int n = ni();
    int[] a = na(n);
    
    long ret = a[0] - 1;
    a[0] = 1;
    int p = 2;
    for (int i = 1; i < n; i ++) {
      if (a[i] == p) {
        p ++;
      } else if (a[i] > p) {
        ret += (a[i] - 1) / p;
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 36456
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int A[5], sp;
  vector<pair<int,int>> diff(5);
  for (int i =0;i < 5;i++)
  {
    cin >> A[i];
  }
  for(int i = 0;i<5;i++)
  {
    sp = A[i] - (A[i]/10)*10;
    diff[i].first = sp;
    if(sp == 0)
    {
      diff[i].second = A[i]/10;
    }
    else
    {
      diff[i].second = A[i]/10 + 1;
    }

  }

  sort(diff.begin(),diff.end());

  int total = 0;


  bool flag = true;

  for (int i = 0;i < 5;i++)
  {
    if(diff[i].first == 0)
    {
      total += diff[i].second * 10;
    }
    else
    {
      if(flag == true)
      {
        total += (diff[i].second-1)*10 + diff[i].first;
        flag = false;
      }
      else{
        total += diff[i].second * 10;
      }
    }

  }


  cout << total;
  return 0;

}


Measured memory_bytes: 256
a,b,k = input().split()

a = int(a)
b = int(b)
k = int(k)

#公約数
small = min(a,b)

list = []

for i in range(small):
  if (a % (i+1) == 0) and (b% (i+1) ==0):
    list.append(i+1)

order = len(list)-k

print(list[order])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
#define MAX 200003

vector<ll> sum;

ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1){       //nのbitと...00001を比較  nが2で割り切れるならtrue
      res=(res*a);
    }
    a=(a*a);
    n>>=1;
  }
  return res;
}

void dfs(ll N,ll num){
  if(num==0){
    cout<<endl;
    return;
  }
  ll i=1;
  while(N>i*modpow(26,num-1)){
    i++;
  }
  char c=(char)(i-1+'a');
  cout<<c;
  dfs(N-(i-1)*modpow(26,num-1),num-1);
}


int main(){
  ll N;
  cin>>N;
  string S="";
  ll num=0;
  sum.push_back(0);
  while(N>sum.at(num)){
    num++;
    sum.push_back(sum.at(num-1)+modpow(26,num));
  }
  N-=sum.at(num-1);

  dfs(N,num);
}


Measured memory_bytes: 3624
N,M=map(int,input().split())
T=[]
for i in range(M):
    u,v=map(int,input().split())
    u,v=u,v-1
    T.append([u,v])
T.sort(key=lambda x:x[1])
tmp=0
ans=0
for i in range(M):
    if tmp<T[i][0]:
        tmp=T[i][1]
        ans+=1
print(ans)


Measured memory_bytes: 62552
costs = [2, 5, 5, 4, 5, 6, 3, 7, 6]


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [-1 for _ in range(N + 1)]
    dp[0] = 0
    for i in range(1, N + 1):
        for a in A:
            if i < costs[a - 1]:
                continue
            dp[i] = max(dp[i], dp[i - costs[a - 1]] * 10 + a)
    print(dp[N])


main()


Measured memory_bytes: 14388
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

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

  int n;

  cin >> n;

  vector<pair<int, int>> h(n);
  rep(i, n) {
    int x;
    cin >> x;
    h[i] = make_pair(x, i+1);
  }
  sortv(h);

  rep(i, n) {
      cout << h[i].second << endl;
  }
}


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

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<int> A;
    rep(i, N) {
        int a;
        cin >> a;
        A.push(a);
    }
    int odd = 0;
    rep(i, M) {
        int m = A.top();
        if(m%2==1) {
            ++odd;
        }
        m /= 2;
        A.pop();
        A.push(m);
    }
    ll ans = 0;
    rep(i, N) {
        ans += A.top();
        A.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

int main() {
	ll argN;
	cin >> argN;

	vector<ll> argA(5);
	for (auto itr = argA.begin(); itr != argA.end(); ++itr) {
		cin >> *itr;
	}

	auto itr = min_element(argA.begin(), argA.end());
	ll maxNum = argN % *itr == 0 ? argN / *itr : argN / *itr + 1;

	cout << maxNum + argA.size() - 1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();	//都市
		int M = sc.nextInt();	//本数
		
		int a[] = new int[M*2];
		
//		System.out.println(a.length);
		
		for (int i=0; i<M*2; i=i+2){
			a[i] = sc.nextInt();
			a[i+1] = sc.nextInt();
		}
		
		int ans[] = new int[N];
		for (int i=1; i<N+1; i++){
			
			for(int j=0; j<M*2; j++){
				
				if(i==a[j]){
					ans[i-1]++;
				}
				
				
			}
			
		}

		for (int i=0; i<N; i++){
			System.out.println(ans[i]);
		}
		
		

	}

}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

void trace(int a[], int n){
    REP(i, n) {
        if (i>0) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

void insertionSort(int a[], int n){
    int key;
    REP(i, n) {
        key = a[i];
        int j = i-1;
        while ((j>=0) && (a[j]>key)) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = key;
        trace(a, n);
    }
}

int main () {
    int n;
    cin >> n;

    int a[100];
    REP(i, n) {
        cin >> a[i];
    }

    insertionSort(a, n);

    return 0;
}

Measured memory_bytes: 3068
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li  	int64_t
#define ld  	double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl      	cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

void solve(){
  li a,b,c,d;
  cin>>a>>b>>c>>d;
  li ans=0;
  li cnt1=0,cnt2=0,i;
  rep(i,0,max(b,d)+1){
    if(i==a) cnt1=1;
    if(i==c) cnt2=1;
    if(i==b) cnt1=0;
    if(i==d) cnt2=0;
    if(cnt1 and cnt2) ans++;
  }
  cout<<ans;
}

int main(){
  opt
  #ifndef ONLINE_JUDGE
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  #endif
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    map<int, int> mp;
    rep(i, N) {
        int a;
        cin >> a;
        mp[a]++;
    }

    int k = mp.size();
    if (k % 2) {
        cout << k << endl;
    } else {
        cout << k - 1 << endl;
    }
}

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

int main()
{
	int a, b, c;
	int k;
	int cnt = 0;
	cin >> a >> b >> c >> k;
	if (a >= b) {
		int i = 0;
		while (a >= b)
		{
			b *= 2;
			i++;
		}
		cnt += i;
	}
	if (b >= c) {
		int i = 0;
		while (b >= c)
		{
			c *= 2;
			i++;
		}
		cnt += i;
	}
	if (cnt <= k)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3616
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 3005;
const int mod = 1000000007;

struct P {
  int x,y,z;
  P(int x, int y, int z):x(x),y(y),z(z){}
  bool operator<(const P&a)const {
    if(x==a.x)return y<a.y;
    return x<a.x;
  }
};

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m,T;
  cin>>n>>m>>T;
  vector<P>a;
  for(int i=0;i<T;i++){
    int x,y,z;
    cin>>x>>y>>z;
    a.push_back(P(x,y,z));
  }
  sort(a.begin(),a.end());
  ll ret = 0;
  vector<ll>f = vector<ll>(m+1, 0);
  for(int i=0;i<T;i++){
    int j = i;
    while(j+1<T&&a[j+1].x==a[i].x)j++;
    vector<vector<ll>>g = vector<vector<ll>>(j-i+1, vector<ll>(4, 0));
    for(int k=i;k<=j;k++){
      g[k-i][1] = a[k].z + f[a[k].y];
      g[k-i][0] = f[a[k].y];
      if(k>i){
        for(int t=0;t<=3;t++){
          g[k-i][t] = max(g[k-i][t],g[k-i-1][t]);
          if(t)g[k-i][t] = max(g[k-i][t], g[k-i-1][t-1]+a[k].z);
        }
      }
    }
    for(int k=i;k<=j;k++)
      for(int t=0;t<=3;t++)f[a[k].y]=max(f[a[k].y],g[k-i][t]);
    for(int k=1;k<=m;k++)f[k]=max(f[k],f[k-1]);
    i=j;
  }
  for(int i=0;i<=m;i++)ret = max(ret, f[i]);
  cout<<ret<<endl;
  return 0;
}

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

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

using namespace std;

typedef long long   ll;
typedef long double ld;

typedef pair<ll, ll>    pll;
typedef pair<ll, int>   pli;
typedef pair<int, int>  pii;

typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll>  vll;

const int Inf = (int) 1e9;
const ll  InfL = (ll)  1e18;

char grid[15][15];
int n, m, row[15], col[15];

bool dfs2(int x) {

    if (x > m)
        return true;

    if (col[x])
        return dfs2(x + 1);
    else {

        int t = 0;
        bool rev = false;

        for (int i = x; i <= m; i++)
            if (!col[i])
                ++t;

        for (int i = x; i <= m; i++) {
            if (!col[i]) {

                rev = true;
                col[x] = i, col[i] = x;
                for (int j = 1; j <= n; j++) {

                    if ( (grid[j][x] != grid[row[j]][i]) || (grid[row[j]][x] != grid[j][i]) ) {

                        rev = false;
                        break;
                    }
                }

                if ( (rev) && ( (t & 1) || (x != i) ) && (dfs2(x + 1)) )
                    return true;

                col[x] = 0, col[i] = 0;
            }
        }
    }
    return false;
}

bool dfs1(int x) {

    if (x > n)
        return dfs2(1);

    if (row[x])
        return dfs1(x + 1);
    else {

        int t = 0;
        for (int i = x; i <= n; i++)
            if (!row[i])
                ++t;

        for (int i = x; i <= n; i++) {
            if (!row[i]) {

                row[x] = i, row[i] = x;

                if ( ((t & 1) || (i != x)) && dfs1(x + 1) )
                    return true;

                row[x] = 0, row[i] = 0;
            }
        }
    }
    return false;
}

int main() {

    ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> (grid[i] + 1);

    if (dfs1(1)) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

typedef long long ll;
typedef int ii;
//typedef vector<ll> vi;

#define INF 1000000007

#define pi 3.141592654

#define T while(t--)
#define for2(i,a,b) for(i=a;i>=b;i--)
#define for3(i,a,b) for(i=a;i<=b;i=i+2)
#define for1(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define mp make_pair

#include<sstream>

#define si set<ll>
#define se multiset<ll>

typedef long double ld;

typedef vector<ll> vi;

#define bb(arr,nn,xx) upper_bound(arr,arr+nn,xx)-arr
#define aa(arra,nna,xxa) lower_bound(arra,arra+nna,xxa)-arra

#define all(v) sort(v.begin(),v.end())
 
#define all1(v) sort(v.rbegin(),v.rend())

ll factors(ll n)
{
 
    ll i; set<ll> s1; map<ll,ll> m;
    
    for1(i,2,sqrt(n))
    {
    
        while(n%i==0)
        {
            
            s1.insert(i);
            
            m[i]+=1;
            
            n/=i;
            
        }
    
    }
    
    if(n>1) {s1.insert(n); m[n]+=1;}
    
    
    ll fact=1;
    
    for(auto u : s1)
    {
    
        fact*=(m[u]+1);
        
    }
 
 
    return fact;
    
}


ii main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    ll n,i; cin>>n; ll sum=0;
    
    for1(i,1,n-1)
    {
    
        sum+=factors(i);
        
    }
    
    cout<<sum<<"\n";
    
}


Measured memory_bytes: 3664
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);


ll N , M;

struct Matrix{
  static const int maxn = 105;
  ll A[maxn][maxn];
  int n;

  Matrix(int n_): n(n_) {
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
        A[i][j] = 0;
  }

  Matrix operator * (const Matrix& o) const {
    Matrix ret(n);
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
        for(int k = 0; k < n; ++k){
          ll c = A[i][k] * o.A[k][j] % MOD;
          ret.A[i][j] = (ret.A[i][j] + c) % MOD;
        }
    return ret;
  }

  static Matrix identity(int n){
    Matrix ret(n);
    for(int i = 0; i < n; ++i)
      ret.A[i][i] = 1;
    return ret;
  }

  Matrix operator ^ (long long k) const {
    Matrix ret = identity(n);
    Matrix a = *this;
    while(k){
      if(k & 1)ret = ret * a;
      a = a * a;
      k /= 2;
    }
    return ret;
  }

};

int main(){
  ll n,k;
  cin>>n>>k;
  M=n;
  N=k;
  Matrix a(M);
  for(int i = 0; i < M; ++i){
    for(ll j=0;j<M;j++){
      cin>>a.A[i][j];
    }
  }
  a = a ^ (N);
  ll ret = 0;
  for(int i = 0; i < M; ++i){
    for(ll j=0;j<M;j++){
      ret=(ret+a.A[i][j])%MOD;
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	ll n;cin>>n;
	ll a[n];rep(i,0,n)cin>>a[i];
	ll i=0,j=0,mp=-1;
	while(i<=j&&j<n){
		if(a[j+1]<=a[j])j++;
		else {mp=max(mp,j-i+1);j++;i=j;}
	}
	cout<<mp-1;
	return 0;
}



Measured memory_bytes: 1024
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm( int m, int n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}
int main(){
    int n; cin>>n;
    vi v(n,0);rep(i,n)cin>>v[i];
    sort(all(v));
    for(int i=1;i<=v[0];i++){
        bool flag=true;
        rep(j,n){if(v[j]%i)flag=false;}
            if(flag)cout<<i<<endl;
    }
}

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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  map<int, int> odds, evens;
  for (int i = 0; i < n; ++i) {
    if (i % 2) {
      odds[v[i]]++;
    } else {
      evens[v[i]]++;
    }
  }
  vector<pair<int, int>> oddv, evenv;
  for (auto &it : odds) {
    oddv.push_back(make_pair(it.second, it.first));
  }
  for (auto &it : evens) {
    evenv.push_back(make_pair(it.second, it.first));
  }
  sort(oddv.rbegin(), oddv.rend());
  sort(evenv.rbegin(), evenv.rend());
  if (oddv[0].second == evenv[0].second) {
    int ans1 = 0, ans2 = 0;
    for (size_t i = 0; i < oddv.size(); ++i) {
      if (i == 1)
        continue;
      ans1 += oddv[i].first;
    }
    for (size_t i = 1; i < evenv.size(); ++i) {
      ans1 += evenv[i].first;
    }
    for (size_t i = 1; i < oddv.size(); ++i) {
      ans2 += oddv[i].first;
    }
    for (size_t i = 0; i < evenv.size(); ++i) {
      if (i == 1)
        continue;
      ans2 += evenv[i].first;
    }
    cout << min(ans1, ans2) << "\n";
  } else {
    int ans = 0;
    for (size_t i = 1; i < oddv.size(); ++i) {
      ans += oddv[i].first;
    }
    for (size_t i = 1; i < evenv.size(); ++i) {
      ans += evenv[i].first;
    }
    cout << ans << "\n";
  }
}


Measured memory_bytes: 6524
#include <stdio.h>
int main(void){
    // Your code here!
    char s[4], tmp = 0, ans = 0;
    int i;
    scanf("%s" ,s);
    while (s[i])
    {
        if (s[i] == 'R')
            tmp++;
        else if (ans < tmp)
        {
            ans = tmp;
            tmp = 0;
        }
        else
            tmp = 0;
        i++;
    }
    printf("%d", ans > tmp ? ans : tmp);
    
}


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

using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> vec(m), dp(n+1,INT_MAX);
  for(int i = 0; i < m; i++) cin >> vec[i];
  dp[0] = 0;
  for(int i = 0; i <= n; i++){
    if(dp[i] == INT_MAX) continue;
    for(int j = 0; j < (int)vec.size(); j++){
      if(i+vec[j] <= n)
        dp[i+vec[j]] = min(dp[i+vec[j]], dp[i]+1);
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1288
X,N = map(int, input().split())
P = list(map(int, input().split()))

table = [0] * 102
ans = X
dist = 102

for p in P:
  table[p] = 1

for i in range(102):
  if table[i] != 0:
    continue
  if abs(i - X) < dist:
    ans = i
    dist = abs(i - X)
  elif abs(i - X) == dist:
    ans = min(i, ans)

print(str(ans))

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

int main()
{
	long long n, d, x, y;
	cin>>n>>d;
	d *= d;
	int counter = 0;
	while(n--)
	{
		cin>>x>>y;
		if (d >= x*x+y*y)
			counter++;
	}
	cout<<counter;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)


using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;


int main(){
	fast_io; cout_precision;
	string s,t;	cin >> s >> t;
  	int count=0;
  for(int i=0; i<s.size();i++)	if(s[i]==t[i])	count++;
  	cout<<count<<endl;
	
	return 0;
}

Measured memory_bytes: 256
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
     int a,b;
     cin>>a>>b;
     for(int i=1;i<=1000;i++)
     {
         if((i*8)/100 == a && (i*10)/100 == b)
         {
             cout<<i<<endl;
             return;
         }
     }
     cout<<"-1"<<endl;
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 384
// AOJ 0572: Card Game is Fun
// 2017.10.29 bal4u@uu

#include <stdio.h>

int a[5003], b[5003];

char buf[25105], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int la, lb, i, j, ans;

	fgets(p=buf, 16, stdin), la = getint(), p++, lb = getint();
	fgets(p=buf, 25100, stdin);
	for (i = 0; i < la; i++) a[i] = getint(), p++;
	fgets(p=buf, 25100, stdin);
	for (i = 0; i < lb; i++) b[i] = getint(), p++;

	for (ans = 0, i = 0; i < lb; i++) {
		int t = i, k = 0;
		if (lb - i < ans) break;
		for (j = 0; j < la && t < lb; j++) if (a[j] == b[t]) t++, k++;
		if (k > ans) ans = k;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1832
#include<bits/stdc++.h>
using namespace std;
int main(void){
  long long n,k,ans=0;
  cin>>n>>k;
  long long h[n];
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h,h+n);
  reverse(h,h+n);
  for(int i=k;i<n;i++){
    ans+=h[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
//#define local
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    long long ans=0;
    int n,x,i,a[100010];
    cin>>n>>x;
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    if(a[0]>x)
    {
        ans+=a[0]-x;
        a[0]=x;
    }
    for(i=1; i<n; i++)
    {
        if(a[i]+a[i-1]>x)
        {
            ans+=a[i]+a[i-1]-x;
            a[i]=x-a[i-1];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int n = in();
    vector<int> score(n + 1, 0);
    rep(i, n * (n - 1) / 2){
        int a, b;
        int a_p, b_p;
        a = in();
        b = in();
        a_p = in();
        b_p = in();
        if (a_p == b_p){
            score[a] += 1;
            score[b] += 1;
        }
        else if (a_p > b_p){
            score[a] += 3;
        }
        else {
            score[b] += 3;
        }
    }
    lep(i, n){
        int rank = 1;
        lep(j, n){
            if (score[i] < score[j]) rank++;
        }
        printf("%d\n", rank);
    }

    return (0);
}

Measured memory_bytes: 1192
N,K = gets.split.map(&:to_i)
x = gets.strip.split.map(&:to_i)
x.sort!
answer = []

for i in 0..N-K

    if x[i] <= 0 && x[K-1+i] <= 0

        answer[i] = x[i].abs

    elsif x[i] <= 0 && x[K-1+i] >= 0

        if x[i].abs <= x[K-1+i]
            
            answer[i] = 2*x[i].abs + x[K-1+i]

        else

            answer[i] = 2*x[K-1+i] + x[i].abs

        end

    else

        answer[i] = x[K-1+i]

    end

end

puts answer.min 


Measured memory_bytes: 10240
def gcd(x,y):
    _x = min(x,y)
    _y = max(x,y)
    _z = _y % _x
    if _z == 0:
        return _x
    else:
        return gcd(_x,_z)

def run():
    x, y = [int(i) for i in input().split()]
    print(gcd(x,y))

if __name__ == '__main__':
    run()


Measured memory_bytes: 5604
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

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

	int H, W;
	cin >> H >> W;
	vector<string> A(H);

	REP(i, H) {
		cin >> A[i];
	}

	if(A[0][0] != '#') {
		cout << "Impossible" << endl;
		return 0;
	}

	pair<int, int> p(0, 0);
	pair<int, int> goal(H-1, W-1);
	vector<pair<int, int> > visited;
	visited.push_back(p);

	int dx[] = {1,0,-1,0};
	int dy[] = {0,1,0,-1};

	while(true) {
		int cnt = 0;
		pair<int, int> next;
		REP(k, 2) {
			int rx = p.first + dx[k];
			int ry = p.second + dy[k];
			if(0 <= rx && rx < H && 0 <= ry && ry < W &&
				A[rx][ry] == '#' && find(visited.begin(), visited.end(), pair<int, int>(rx, ry)) == visited.end()) {
				cnt++;
				next = pair<int, int>(rx, ry);
				visited.push_back(next);
			}
		}

		if(cnt != 1) {
			cout << "Impossible" << endl;
			return 0;
		}
		cnt = 0;
		p = next;
		FOR(k, 2, 4) {
			int rx = p.first + dx[k];
			int ry = p.second + dy[k];
			if(0 <= rx && rx < H && 0 <= ry && ry < W &&
				A[rx][ry] == '#' && find(visited.begin(), visited.end(), pair<int, int>(rx, ry)) == visited.end()) {
				cout << "Impossible" << endl;
				return 0;
			}
		}
		if(p == goal) {
			cout << "Possible" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define lint long long

int main() {

	vector<int> A(5);
	for (int i = 0; i < 5; i++)
	{
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	int k;
	cin >> k;
	if (A[4] - A[0] > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int j=0;

  for(int i=0 ; i<N ; i++) {
    string H;
    cin >> H;
    if (H=="Y"){
      j++;
      break;
    }
    else;{
    }
  }
  if (j==0){
    cout<<"Three"<<endl;
  }
  else{
    cout<<"Four"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define ll long long
#define all(v) v.begin(),v.end()
using namespace std;
map<ll,ll>u;
inline void solve(){
	u.clear();
	ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;
	priority_queue<pair<ll,ll> >pq;
	pq.push({0,n});u[n]=0;
	for(;pq.size();){
		pair<ll,ll>p=pq.top();pq.pop();
		ll xx=p.second,f=-p.first;
		if(u[xx]!=f)continue;
//		cerr<<xx<<' '<<f<<'\n';
		if(xx==0){
			cout<<f<<'\n';
			return;
		}
		for(ll x=xx-5;x<=xx+5;++x){
			if(x<0)continue;
			if(x==0){
				if(!u[0] or u[0]>(f+d*xx)){
					u[0]=(f+d*xx);
					pq.push({-(f+d*xx),0});
				}
				continue;					
			}
			if(x%2==0 and (!u[x/2] or u[x/2]>a+f+d*abs(x-xx))){
				if(x/2<=a/d){
					if(!u[0] or u[0]>xx*d+f){
						u[0]=xx*d+f;
						pq.push({-(xx*d+f),0});
					}
				}
				u[x/2]=a+f+d*abs(x-xx);
				pq.push({-(a+f+d*abs(x-xx)),x/2});
			}
			if(x%3==0 and (!u[x/3] or u[x/3]>b+f+d*abs(x-xx))){
				if(x/3<=b/d){
					if(!u[0] or u[0]>xx*d+f){
						u[0]=xx*d+f;
						pq.push({-(xx*d+f),0});
					}
				}
				u[x/3]=b+f+d*abs(x-xx);
				pq.push({-(b+f+d*abs(x-xx)),x/3});
			}
			if(x%5==0 and (!u[x/5] or u[x/5]>c+f+d*abs(x-xx))){
				if(x/5<=c/d){
					if(!u[0] or u[0]>xx*d+f){
						u[0]=xx*d+f;
						pq.push({-(xx*d+f),0});
					}
				}
				u[x/5]=c+f+d*abs(x-xx);
				pq.push({-(c+f+d*abs(x-xx)),x/5});
			}			
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int T;cin>>T;
	for(;T--;)solve();
}

Measured memory_bytes: 6576
n = int(input())
arr = [[int(i) for i in list(input().split())] for j in range(n)]
for i in range(1,n):
	arr[i][0] += max(arr[i-1][1], arr[i-1][2])
	arr[i][2] += max(arr[i-1][1], arr[i-1][0])
	arr[i][1] += max(arr[i-1][0], arr[i-1][2])
print(max(arr[n-1]))


Measured memory_bytes: 28648
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
// 最小包含球を計算
// 以下はn<=30,0<=x,y,z<=100の制約の下での計算
const double EPS=1e-8;
const int MAX_N=101;
double xs[MAX_N],ys[MAX_N],zs[MAX_N];
double solve(double xs[MAX_N],double ys[MAX_N],double zs[MAX_N],int n){
  // 球の中心座標
  double cx=0,cy=0,cz=0;
  // 初期中心座標を決定
  for(int i=0;i<n;i++)cx+=xs[i],cy+=ys[i],cz+=zs[i];
  cx/=n,cy/=n,cz/=n;
  // iterate回数
  const int ITE_MAX=50;
  double co=0.5;
  // このloopで移動係数を変更
  for(int o=0;o<50;o++){
    // この回数最も距離が遠い点のベクトルを使って移動
    for(int iter=0;iter<ITE_MAX;iter++){
      int idx=-1;
      double max_dist=-1;
      double d;
      // 最大距離とその点のindexを求める
      for(int j=0;j<n;j++){
	d=sqrt(pow(xs[j]-cx,2)+pow(ys[j]-cy,2)+pow(zs[j]-cz,2));
	if(max_dist<d)max_dist=d,idx=j;
      }
      // 現在地点から移動
      double dx=xs[idx]-cx,dy=ys[idx]-cy,dz=zs[idx]-cz;
      cx+=dx*co;
      cy+=dy*co;
      cz+=dz*co;
    }
    co/=2;
  }
  // 最大距離を計算
  double max_dist=-1;
  for(int j=0;j<n;j++){
    double d=sqrt(pow(xs[j]-cx,2)+pow(ys[j]-cy,2)+pow(zs[j]-cz,2));
    max_dist=max(max_dist,d);
  }
  return max_dist;
}

int main(){
  int n;
  while(cin>>n&&n){
    for(int i=0;i<n;i++)cin>>xs[i]>>ys[i]>>zs[i];
    double r=solve(xs,ys,zs,n);
    printf("%.5f\n",r);
  }
  
  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
string s;
LL ans,len;
LL count(LL a,LL i)
{
    LL s=0;
    LL cnt=i;
    i=pow(2,i);
    s+=i;
    for(int j=1;j<=len-cnt-1;j++)
    {
        s=s*10+i;
        i*=2;
    }
    return a*s;
}
int main()
{
    cin>>s;
    len=s.length();
    for(LL i=0;i<s.length();i++)
    {
        ans+=count(s[i]-'0',i);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
// 2011/09/29 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int N, L;
	cin >> N >> L;

	int I[100002];
	I[0] = 0;
	for(int i=1; i<=N; i++)
		cin >> I[i];
	I[N+1] = 0;

	int T[100002];
	T[0] = 0;
	T[N+1] = 0;
	int max = 0;

	while(true){
		bool flg = false;
		for(int i=1; i<=N; i++)
			if(I[i]>I[i-1]&&I[i]>I[i+1]){
				if(T[i-1]>T[i+1])
					T[i] = T[i-1];
				else
					T[i] = T[i+1];
				T[i] += (L-I[i]);
				if(T[i]>max)
					max = T[i];
				I[i] = 0;
				flg = true;
				i++;
			}

		if(!flg)
			break;
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 1556
open String
let () =
  Scanf.scanf " %s %s" @@ fun s t ->
  let s_len = length s in
  let t_len = length t in
  let dpl = Array.init (s_len+1) (fun _ -> Array.make (t_len+1) 0) in
  let dpp = Array.init (s_len+1) (fun _ -> Array.init (t_len+1) (fun _ -> [])) in
  for si = 0 to s_len-1 do
    for ti = 0 to t_len-1 do
      if s.[si] = t.[ti] then begin
        dpl.(si+1).(ti+1) <- dpl.(si).(ti) + 1;
        dpp.(si+1).(ti+1) <- s.[si] :: dpp.(si).(ti);
      end else
      if dpl.(si+1).(ti) > dpl.(si).(ti+1) then begin
        dpl.(si+1).(ti+1) <- dpl.(si+1).(ti);
        dpp.(si+1).(ti+1) <- dpp.(si+1).(ti);
      end else begin
        dpl.(si+1).(ti+1) <- dpl.(si).(ti+1);
        dpp.(si+1).(ti+1) <- dpp.(si).(ti+1);
      end
    done;
  done;
  dpp.(s_len).(t_len)
  |> List.rev |> List.iter print_char;
  print_newline ()



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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll r, g, b, n, c=0, t;
  cin >> r >> g >> b >> n;
  for(int i=0; i*r<=n; i++){
	for(int j=0; j*g<=n; j++){
	  t = n - i * r - j * g;
	  if(t % b == 0 && t >= 0)
		c++;
	}
  }
  cout << c << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<string>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
int main() {
  int t[3];
  for (int i=0; i<3; i++) cin >> t[i];
  sort(t,t+3);
  cout << t[0] + t[1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define MOD 1000000007
using namespace std; 
int main() {
  long n, k; 
  cin >> n >> k; 
  long long compteur = 0;;  
  long long gauche = ((k-1)*(k))/2; 
  long long droite = (k*n) - ((k-1)*(k))/2; 
  for (long l = k; l <= n+1; l++) {
    compteur += (droite-gauche + 1); 
    gauche += l; 
    droite += n - l; 
  }
  cout << compteur % MOD << endl; 
  return 0; 
}

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

typedef unsigned long long  ULL;
typedef long long LL;

#define pb push_back
#define mp make_pair
#define reset(a, b) memset(a, b, sizeof(a))
#define rep(i,b) for(int i=0; i<b; i++)
#define F first 
#define S second

 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int T;
//    cin>>T;
    T=1;
    while(T--){
       
       int n;
       cin>>n;
       
       map<int,int> m;
       
       rep(i,n-1){
           int x;
           cin>>x;
           m[x]++;
           
           
       }
       
       rep(i,n){
           cout<<m[i+1]<<"\n";
       }
    }
    
    return 0;
}

Measured memory_bytes: 13040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  ll max_pxpy, min_pxpy, max_mxpy, min_mxpy;
  max_pxpy = max_mxpy = INT_MIN;
  min_pxpy = min_mxpy = INT_MAX;
  for (int i = 0; i < N; i++) {
    ll x, y;
    cin >> x >> y;
    max_pxpy = max(max_pxpy, x + y);
    min_pxpy = min(min_pxpy, x + y);
    max_mxpy = max(max_mxpy, -x + y);
    min_mxpy = min(min_mxpy, -x + y);
  }
  cout << max(max_pxpy - min_pxpy, max_mxpy - min_mxpy) << "\n";
}


Measured memory_bytes: 3616
n = int(input())
l = list(map(int, input().split()))
maxi = max(l)
# max_ind = l.index(maxi)
# print(max_ind)
sum_l = sum(l)
sum_without_max = sum_l - maxi
if maxi<sum_without_max:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <cstdio>
#include <set>
using namespace std;

int main(void)
{
    int N,x;
    scanf("%d",&N);
    set<int> s;
    while(N--)
    {
        scanf("%d",&x);
        if(s.count(x)==0)
            s.insert(x);
        else
            s.erase(x);
    }
    printf("%d\n",s.size());
    return 0;
}
    

Measured memory_bytes: 4864
str = gets.chomp

flag = false
if str == 'hi' ||
  str == 'hihi' ||
  str == 'hihihi' ||
  str == 'hihihihi' ||
  str == 'hihihihihi'
  flag = true
end

if flag
  print('Yes')
else
  print('No')
end

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    vector<lli> v(m);
    cin >> v;

    if (m <= n) {
      cout << 0 << endl;
      continue;
    }
    sort(v.begin(), v.end());
    
    vector<lli> x;
    for (int i = 0; i + 1 < v.size(); ++i) {
      x.push_back(abs(v[i] - v[i + 1]));
    }
    sort(x.begin(), x.end());
    lli sum = accumulate(x.begin(), x.begin() + (m - n), 0LL);
    cout << sum << endl;
  }
  
  return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

const int MAX = 100'000 + 5;
bool isPrime[MAX];

void init() {
  rep(i, MAX) isPrime[i] = true;
  isPrime[0] = isPrime[1] = false;
  for (int i = 2; i*i <= MAX; i++) {
    if (!isPrime[i]) continue;
    for (int j = i*i; j < MAX; j+=i) {
      isPrime[j] = false;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  init();
  vi cnt(MAX);
  for (int i = 1; i < MAX; i+=2) {
    cnt[i] += cnt[max(0, i-2)] + (isPrime[i] && isPrime[(i+1)/2]);
  }
  int q; std::cin >> q;
  rep(i, q) {
    int l, r; std::cin >> l >> r;
    int ans = cnt[r];
    if (l - 2 >= 0) ans -= cnt[l-2];
    std::cout << ans << "\n";
  }
}


Measured memory_bytes: 1152