akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#pragma warning(disable:4996)
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include<cstring>
#include <stack>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include <string>
#define itn int
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
const int maxn = 2000 + 6;
const int maxa = 1000 * 1000 * 1000 + 7;
typedef long long ll;
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int t, n, m, T;
int res[maxn];
int main()
{
#ifdef _DEBUG
	freopen("D:\\input.txt", "r", stdin);
	//	freopen("E:\\output.txt", "w", stdout);
#endif
	int i, j;
	std::ios::sync_with_stdio(false); cin.tie(0);	cout.tie(0);
	int n, x, y;
	cin >> n >> x >> y;
	int a = n - (y - x);
	int b = y - x;
	for (int i = 1; i <= n - 1; i++) {
		for (int j = i + 1; j <= n; j++) {
			int dis = j - i;
			dis = min(dis, 1+abs(i - x) + abs(j - y));
			dis = min(dis, 1+abs(j - x) + abs(i - y));
			res[dis]++;
		}
	}

	for (int i = 1; i <= n - 1; i++) {
		cout<<res[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long n,ans=1,sum=0;
    cin>>n;
    long long a[n+1];
    vector <long long> s(n+1,0);
    f(i,1,n+1){
        cin>>a[i];
    }
    while(ans!=2&&s[ans]==0){
        sum+=1;
        s[ans]++;
        ans=a[ans];
        
    }
    if(ans==2){
        cout<<sum<<endl;
    }
    else{
        cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 4756
V,E = map(int,input().split())
INF = 2*10**10
C = [[INF]*V for _ in range(V)]
for i in range(E):
    tmp = list(map(int,input().split()))
    C[tmp[0]][tmp[1]] = tmp[2]

for i in range(V):
    C[i][i] = 0

for k in range(V):
    for i in range(V):
        if C[i][k] == INF:
            continue
        for j in range(V):
            if C[k][j] == INF:
                continue
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])

negative_cycle_f = False
for i in range(V):
    if C[i][i] < 0:
        negative_cycle_f = True

if negative_cycle_f:
    print("NEGATIVE CYCLE")
else:
    for i in range(V):
        for j in range(V):
            if C[i][j] == INF:
                print("INF",end="")
            else:
                print("{}".format(C[i][j]),end="")
            if j != V-1:
                print(" ",end="")
        print("")









Measured memory_bytes: 6800
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=2e5+50;
const int mod=1e9+7;
using namespace std;
int n,i,a[nmax],j;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	j=1;
	for(i=1;i<=n;i++)
	{
		if(a[i]==j)j++;
	}
	if(j==1)rc(-1);
	cout<<n-j+1<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


signed main(){

	int N;
	cin >> N;
	if (N % 2 == 0) cout << N << endl;
	else
		cout << 2 * N << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,i,d1,d2,a,b,c,name;
	while(1)
	{
		scanf("%d",&n);
		if(n == 0)break;

		c = -1;
		for(i = 0;i < n;i++)
		{
			scanf("%d %d %d",&a,&d1,&d2);
			b = d1 + d2;
			if(b > c)
			{
				c = b;
				name = a;
			}
		}
		printf("%d %d\n",name,c);
	}
	return 0;
}

Measured memory_bytes: 600
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int N,L;
	cin>>N>>L;
	vint a;
	for(int i=0;i<N;i++){
		int c;
		cin>>c;
		a.pb(c);
	}
	int sz=a.size();
	for(int i=1;i<sz;i++){
		if(a[i-1]+a[i]>=L){
			cout<<"Possible"<<endl;
			for(int j=1;j<i;j++)
				cout<<j<<endl;
			for(int j=N-1;j>i;j--)
				cout<<j<<endl;
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   { 
       ll l,r,d,i,ans=0;
       cin>>l>>r>>d;
       for(i=l;i<=r;i++)
        if(i%d==0)
         ans++;
       cout<<ans;  
   }
}

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

typedef long long int ll;

int main(){

  int n,d1,d2,cou=0,ans=0;

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> d1 >> d2;
    if(d1==d2){
      cou++;
      if(cou==3)ans=1;
    }
    else cou=0;
  }

  if(ans==1)cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}


Measured memory_bytes: 3620
//Volume5-0515
import java.util.Arrays;
import java.util.Scanner;

class Main {

	private static int    [][] dp;
	private static boolean[][] flg;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int a,b,n,x,y;
		while(true){
			a = sc.nextInt();
			b = sc.nextInt();
			if(a==0&&b==0){break;}
			a++; b++;
			dp  = new int    [b][a];
			flg = new boolean[b][a];
			dp[1][0]=1;
			for(int i=0;i<b;i++){Arrays.fill(flg[i], true);}
			n   = sc.nextInt();
			while(n-- > 0){
				x = sc.nextInt();
				y = sc.nextInt();
				flg[y][x]=false;
			}
			for(int i=1;i<b;i++){
				for(int j=1;j<a;j++){
					if(flg[i][j]){
						dp[i][j]=dp[i-1][j]+dp[i][j-1];
					}
				}
			}
			System.out.println(dp[b-1][a-1]);
		}
	}
}

Measured memory_bytes: 20316
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
	ll n,k;cin>>n>>k;
	vector<ll>a(n);
	rep(i,0,n)cin>>a[i];
	rep(i,0,n-k){
		ans1(a[i]<a[i+k]);
	}
  return 0;
}

Measured memory_bytes: 4780
#include<stdio.h>

int main(){
  int n,i,num[5],k,flag,j,d[9];
  scanf("%d %d",&n,&k);
  for(i=0;i<k;i++)
    scanf("%d",&d[i]);
  for(i=n;i<=10*n;i++){
    flag=1;
    if(i>=10000){
      num[4]=i/10000%10;
      for(j=0;j<k;j++)
        if(num[4]==d[j])
          flag=0;
    }
    if(i>=1000){
      num[3]=i/1000%10;
      for(j=0;j<k;j++)
          if(num[3]==d[j])
            flag=0;
    }
    if(i>=100){
      num[2]=i/100%10;
      for(j=0;j<k;j++)
        if(num[2]==d[j])
          flag=0;
    }
    if(i>=10){
      num[1]=i/10%10;
      for(j=0;j<k;j++)
        if(num[1]==d[j])
          flag=0;
    }
    num[0]=i%10;
    for(j=0;j<k;j++)
      if(num[0]==d[j])
        flag=0;
    if(flag){
      printf("%d\n",i);
      break;
    }
  }
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc146/tasks/abc146_e>
 問題文============================================================
 E - Rem of Sum is Num
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    for(auto& in:A){ cin >> in; in%=K; }
    vector<ll> X(N+1);
    for(int i = 0; i < N;i++){
        X[i+1] = (X[i] + A[i])%K;
    }
    
    /*
     0 <= l < r <= N
     (X_r - X_l)%K = r - l
     
     if r-l < K
        (X_r - X_l)%K   = (r - l)%K
        (X_r - r)%K     = (X_l - l)%K
    */

    map<ll,ll> mp;
    for(int i = 0; i <= N;i++){
        X[i] = (X[i] - i%K + K)%K;
    }
    for(int i = 0; i <= N;i++){
        if(i-K>=0){
            mp[X[i-K]]--;
        }
        res += mp[X[i]];
        mp[X[i]]++;
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

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

    int n;
    cin >> n;

    vector<int> a(n + 1);
    REP(i, n + 1) cin >> a[i];

    vector<int> b(n);
    REP(i, n) cin >> b[i];

    ll ans = 0;
    REP(i, n) {
        ans += min(a[i], b[i]);
        if (b[i] - a[i] > 0) {
            int tmp = min(b[i] - a[i], a[i + 1]);
            ans += tmp;
            a[i + 1] = max(a[i + 1] - tmp, 0);
        }
    }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
#define sz(x) (int)x.size() 
int const N=5e5+10;

int aa[N],an[N];
int main() {
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>aa[i];
	int m=0;
	for(int i=n;i>0;i--){
		int sum=0;
		for(int j=2*i;j<=n;j+=i)sum+=an[j];
		sum%=2;
		if(aa[i]){
			if(sum)an[i]=0;
			else an[i]=1;
		}else{
			if(sum)an[i]=1;
			else an[i]=0;
		}
		m+=an[i];
	}
	cout<<m<<'\n';
	for(int i=1;i<=n;i++)if(an[i])cout<<i<<' ';
    return 0;
}



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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */
int main(){
    int A,B;
    cin >> A >> B;
    int ans;
    if (A >= 13) ans = B;
    else if (A >= 6) ans = B/2;
    else ans = 0;
    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();

    sc.close();

    String answer = "";

    if (N == 0) {
      answer = "0";
    } else {
      while (N != 0) {
        if (N % 2 != 0) {
          N--;
          answer = "1" + answer;
        } else {
          answer = "0" + answer;
        }
        N = N / -2;
      }
    }

    System.out.println(answer);

  }

}

Measured memory_bytes: 22736
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; i++)
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
#define MOD (int)(1e9+7)
using namespace std;
typedef pair<int, int> P;
struct edge {
    int to, cost;
};

class dijkstra {
private:
    int V;
    int d[100002];
    priority_queue<P, vector<P>, greater<>> que;

public:
    dijkstra(int v, int s, vector<edge> G[]) {
        V = v;
        update(s, G);
    }

    void update(int s, vector<edge> G[]) {
        fill(d, d + V + 1, 100000000000ll);
        d[s] = 0;
        que.push(make_pair(0, s));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first)
                continue;
            rep(i, G[v].size()) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }
    }

    int find(int e) {
        return d[e];
    }
};

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

bool prime(int a) {
    if (a == 1)
        return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0)
            return false;
    }
    return true;
}

class Union_Find {
private:
    vector<int> t, s;

public:
    Union_Find(int max_length) {
        rep(i, max_length + 1) {
            t.push_back(i);
            s.push_back(1);
        }
    }

    void Union(int x, int y) {
        if (same(x, y))
            return;
        int tx = Find(x), ty = Find(y);
        if (s[tx] < s[ty]) {
            s[ty] += s[tx];
            t[tx] = ty;
        } else if (s[tx] > s[ty]) {
            s[tx] += s[ty];
            t[ty] = tx;
        } else if (tx > ty) {
            t[tx] = ty;
            s[ty] += s[tx];
        } else {
            t[ty] = tx;
            s[tx] += s[ty];
        }
    }

    int Find(int n) {
        if (t[n] == n)
            return n;
        else
            return t[n] = Find(t[n]);
    }

    bool same(int x, int y) {
        return Find(x) == Find(y);
    }

    int get_Size(int a) {
        return s[a];
    }
};

vector<int> primeFactorization(int n) {
    vector<int> re;
    int cnt = 2;
    while (n != 1) {
        if (n % cnt != 0) {
            cnt++;
            continue;
        }
        n /= cnt;
        re.push_back(cnt);
    }
    return re;
}
signed main() {
    int n,d;
    cin>>n>>d;
    cout<<(n+d+d)/(d+d+1)<<endl;
}


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

int main() {
	int n, m;
	string s[1000], t[1000];
	cin >> n;
	for (int i = 0;i < n;i++)cin >> s[i];
	cin >> m;
	for (int i = 0;i < m;i++)cin >> t[i];
	int ans = 0;
	for (int i = 0;i < n;i++) {
		int p = 0;
		for (int j = 0;j < n;j++) {
			if (s[i] == s[j])p++;
		}
		for (int j = 0;j < m;j++) {
			if (t[j] == s[i])p--;
		}
		ans = max(ans, p);
	}
	cout << ans << endl;
}

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

int main()
{
    int m, r, f;
    while (cin >> m >> f >> r)
    {
        if (m == -1 && f == -1 && r == -1)
        {
            break;
        }
        else if (m == -1 || f == -1)
        {
            cout << "F\n";
        }
        else if (m + f >= 80)
        {
            cout << "A\n";
        }
        else if (m + f >= 65 && (m + f < 80))
        {
            cout << "B\n";
        }
        else if (m + f >= 50 && (m + f < 65))
        {
            cout << "C\n";
        }
        else if (m + f >= 30 && (m + f < 50))
        {
            if (r >= 50)
            {
                cout << "C\n";
            }
            else
            {
                cout << "D\n";
            }
        }
        else if (m+f<30){
            cout << "F\n";
        }
    }
}


Measured memory_bytes: 3052
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] x = new int[M];
		int[] y = new int[M];
		for (int i = 0; i < M; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}

		// 隣接リスト
		List<List<Integer>> g = new ArrayList<>();
		List<List<Integer>> rev = new ArrayList<>();
		for (int i = 0; i <= N; i++) {
			g.add(new ArrayList<>());
			rev.add(new ArrayList<>());
		}

		for (int i = 0; i < M; i++) {
			g.get(x[i]).add(y[i]);
			rev.get(y[i]).add(x[i]);
		}

		sc.close();

		// トポロジカルソートする

		// 入次元
		int[] indegree = new int[N + 1];
		for (int i = 0; i < M; i++) {
			indegree[y[i]]++;
		}

		Deque<Integer> que = new ArrayDeque<>();

		for (int i = 0; i <= N; i++) {
			if (indegree[i] == 0) {
				que.add(i);
			}
		}

		List<Integer> sorted = new ArrayList<>();
		while (!que.isEmpty()) {
			int a = que.poll();
			sorted.add(a);

			for (int n : g.get(a)) {
				indegree[n]--;
				if (indegree[n] == 0) {
					que.add(n);
				}
			}
		}

		int[] d = new int[N + 1];

		for (int i : sorted) {
			for (int j : rev.get(i)) {
				d[i] = Math.max(d[j] + 1, d[i]);
			}
		}

		int ans = 0;
		for (int i = 0; i <= N; i++) {
			ans = Math.max(ans, d[i]);
		}

		out.println(ans);

	}

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


Measured memory_bytes: 86204
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
signed main(void){
    int n; 
    cin>>n;
    vector <double> a(n);
    rep(i,n) cin>>a[i];
    vector <vector<double>> dp(3005,vector <double>(3005)); //何番目か/何回買ったか
    dp[0][1] = a[0];
    dp[0][0] = 1.0 - a[0];
    rep(i,n){
        if(i == 0) continue;
        rep(j,3005){
            dp[i][j+1] += dp[i-1][j] * a[i];
            dp[i][j] += dp[i-1][j]*(1 - a[i]); 
        }
    }
    double ans = 0;
    rep(i,n+1){
        if(i >= (n+1)/2) ans += dp[n-1][i];
    }
  
    printf("%.10f\n", ans);
}


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

double dp[3000][3000];

int main()
{
  int n;
  double i,ans=0;

  scanf("%d",&n);
  dp[0][0]=1;
  for(int c=1;c<=n;c++)
  {
    scanf("%lf",&i);
    for(int c2=0;c2<=c;c2++)
    dp[c][c2]=(c2==0?0:(i*dp[c-1][c2-1]))+((1-i)*dp[c-1][c2]);
  }
  for(int c=(n+1)/2;c<=n;c++)ans+=dp[n][c];
  printf("%.10lf\n",ans);
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      //数字の数を入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
      //短針が進む角度
      double tanshin = 0.5 *m + 30*h;
      //長針
      double tyoshin = 6 * m;
      //なす角度
      double kakudo = tanshin - tyoshin;

        if(kakudo > 180){
        	kakudo = 360 - kakudo;
      	}
        if(kakudo < 0){
        	kakudo *= -1;
        }
        
      	double result2 = a*a + b*b - 2*a*b* Math.cos(Math.toRadians(kakudo));
      	double result = Math.sqrt(result2);
      	System.out.println(result);
      
      }             
      
	}



Measured memory_bytes: 35980
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  long long int n, x[200009];
  vector<long long> v;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x[i];
    v.push_back(x[i]);
  }
  sort(v.begin(), v.end());
  long long md = v[(n-1)/2];
  for(int i=0;i<n;i++){
    if(x[i]<=md){
      cout << v[(n+1)/2] << endl;
    }
    else{
      cout << v[(n-1)/2] << endl;
    }
  }
}

Measured memory_bytes: 5488
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

int W, H;
int D[10][10];
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

void check(int x, int y, int &cx, int &cy,
	   int &num, int canVisit[10][10][10][10]) {
  for(int i = 0; i < 4; ++i) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx < 0 || nx >= W) continue;
    if(ny < 0 || ny >= H) continue;
    if(nx == cx && ny == cy) continue;
    if(D[ny][nx] == 1) continue;
    if(canVisit[cy][cx][ny][nx] != 0) continue;
    canVisit[cy][cx][ny][nx] = num;
    check(nx, ny, cx, cy, num, canVisit);
  }
}

class State {
public:
  int cx, cy, sx, sy, cost;
  State(int cx, int cy, int sx, int sy, int cost)
  : cx(cx), cy(cy), sx(sx), sy(sy), cost(cost) {}
};

void solve(int cx, int cy, int sx, int sy) {
  int canVisit[10][10][10][10];
  fill(&canVisit[0][0][0][0], &canVisit[9][9][9][9]+1, 0);
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      if(D[i][j] == 1) continue;
      int num = 1;
      for(int k = 0; k < H; ++k) {
	for(int l = 0; l < W; ++l) {
	  if(i == k && j == l) continue;
	  if(D[k][l] == 1) continue;
	  if(canVisit[i][j][k][l] != 0) continue;
	  canVisit[i][j][k][l] = num;
	  check(l, k, j, i, num, canVisit);
	  ++num;
	}
      }
    }
  }

  queue<State> que;
  State s(cx, cy, sx, sy, 0);
  bool visited[10][10][10][10];
  fill(visited[0][0][0], visited[10][0][0], false);
  que.push(s);
  while(!que.empty()) {
    s = que.front();
    que.pop();

    if(D[s.cy][s.cx] == 3) {
      cout << s.cost << endl;
      return;
    }
    //cout << s.cx << ", " << s.cy << "¨";
    for(int i = 0; i < 4; ++i) {
      int rx = s.cx - dx[i];
      int ry = s.cy - dy[i];
      if(rx < 0 || rx >= W) continue;
      if(ry < 0 || ry >= H) continue;
      //cout << canVisit[s.cy][s.cx][s.sy][s.sx] << ":"
      //   << canVisit[s.cy][s.cx][ry][rx] << endl;
      if(canVisit[s.cy][s.cx][s.sy][s.sx]
       != canVisit[s.cy][s.cx][ry][rx]) continue;

      int nx = s.cx + dx[i];
      int ny = s.cy + dy[i];
      if(nx < 0 || nx >= W) continue;
      if(ny < 0 || ny >= H) continue;
      if(D[ny][nx] == 1) continue;

      if(visited[s.cy][s.cx][ry][rx]) continue;
      visited[s.cy][s.cx][ry][rx] = true;
      que.push(State(nx, ny, s.cx, s.cy, s.cost+1));
    }
  }
  cout << -1 << endl;
}

main() {
  while((cin >> W >> H) && (W || H)) {
    int cx, cy, sx, sy;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
	cin >> D[i][j];
	if(D[i][j] == 2) {
	  D[i][j] = 0;
	  cx = j;
	  cy = i;
	} else if(D[i][j] == 4) {
	  D[i][j] = 0;
	  sx = j;
	  sy = i;
	}
      }
    }
    solve(cx, cy, sx, sy);
  }
}

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


int main(){
  string S;
  getline(cin, S);

  for(int i=0; i<S.length(); i++){
    if(S[i] != ' ' && S[i] != '.'){
      S[i] = (S[i]-'a') + 'A';
    }
  }

  cout << S << endl;

}
  
  


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

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  int x_min=0, y_min=0, x_max=W, y_max=H;

  for (int i=0; i<N; i++) {
    int x, y, z;
    cin >> x >> y >> z;

    if (z==1) {
      x_min = max(x_min, x);
    }
    if (z==2) {
      x_max = min(x_max, x);
    }
    if (z==3) {
      y_min = max(y_min, y);
    }
    if (z==4) {
      y_max = min(y_max, y);
    }
  }

  int ans = (y_max - y_min) * (x_max - x_min);
  if ((y_max-y_min)<0 || (x_max-x_min)<0) ans=0;
  
  cout << ans << endl;
}

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

int main(){
    int n;
    scanf("%d", &n);
    vector<int> adjlist[n+1];
    bool visited[n+1];
    visited[n] = false;
    for(int i = 1; i < n; i++){
        visited[i] = false;
        int a, b;
        scanf("%d %d", &a, &b);
        adjlist[a].push_back(b);
        adjlist[b].push_back(a);
    }
    queue<int> tovisit;
    int lvisited;
    tovisit.push(1);
    while(!tovisit.empty()){
        lvisited = tovisit.front();
        visited[lvisited] = true;
        tovisit.pop();
        for(int i = 0; i < adjlist[lvisited].size(); i++){
            if(!visited[adjlist[lvisited][i]]){
                tovisit.push(adjlist[lvisited][i]);
            }
        }
    }
    tovisit.push(lvisited);
    tovisit.push(0);
    int diameter = 1;
    while(tovisit.size() > 1){
        lvisited = tovisit.front();
        visited[lvisited] = false;
        tovisit.pop();
        if(lvisited == 0){
            diameter++;
            tovisit.push(0);
            continue;
        }
        for(int i = 0; i < adjlist[lvisited].size(); i++){
            if(visited[adjlist[lvisited][i]]){
                tovisit.push(adjlist[lvisited][i]);
            }
        }
    }
    if(diameter == 1){
        printf("First");
        return 0;
    }
    if(diameter % 3 == 2){
        printf("Second");
        return 0;
    }
    printf("First");
}


Measured memory_bytes: 13044
import scala.io.StdIn._
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val s = sc.next
  var ans =700
  for(i <- 0 to 2){
    if(s.charAt(i)=='o'){
     ans+=100 
    }  
  }
  println(ans)
}

Measured memory_bytes: 25636
#include <cstdio>
#include <algorithm>

using namespace std;
#define LL long long


int main(){
	int n,t;
	scanf("%d%d",&n,&t);
	int ans = 1001;
	for(int i = 1;i <= n;++i){
		int ci,ti;
		scanf("%d%d",&ci,&ti);
		if(ti <= t)ans = min(ans,ci);
	}
	if(ans == 1001)return puts("TLE"),0;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            long ans = N / 11;
            ans *= 2;
            if ( N % 11 > 6)
            {
                ans += 2;
            }
            else if ( N % 11 > 0) {
                ans++;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), X = sc.nextInt();
		int sum = 0;
		int Count = 1;
		for(int i = 0; i < N; i++) {
			sum += sc.nextInt();
			if(sum > X) {
				break;
			}else {
				Count++;
			}
		}
		System.out.println(Count);
	}
}


Measured memory_bytes: 23124
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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






int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    vector<ll> dp(n + 5, INF);
    vector<vector<ll>> v(n);
    for(ll i = 0; i < n; i++){
        ll itr = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
        dp[itr] = a[i];
        v[itr].push_back(a[i]);
    }
    ll itr = 0;
    while(dp[itr] != INF){
        itr++;
    }
    itr--;
    ll ans = 0, mx = INF;
    for(ll i = itr; i >= 0; i--){
        ll t = -1;
        REP(j, v[i].size()){
            if(v[i][j] < mx){
                t = max(t, v[i][j]);
            }
        }
        ans += t;
        mx = min(mx, t);
    }
    cout << ans << endl;
}



Measured memory_bytes: 9828
/*************************************************************************
    > File Name: B.cpp
    > Author: Roundgod
    > Mail: wcysai@foxmail.com 
    > Created Time: 2018-11-29 13:26:41
 ************************************************************************/

#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 1005
#define MAXM 520000
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll b[MAXN],a[MAXM],n,K,tot;
bool valid[MAXM];
int main()
{
    scanf("%lld%lld",&n,&K);
    for(ll i=1;i<=n;i++) scanf("%lld",&b[i]);
    for(ll i=1;i<=n;i++)
    {
        ll s=0;
        for(ll j=i;j<=n;j++) {s+=b[j]; a[++tot]=s;}
    }
    memset(valid,true,sizeof(valid));
    ll ans=0;
    for(ll j=40;j>=0;j--)
    {
        ll cnt=0;
        for(ll i=1;i<=tot;i++)
        {
            if(!valid[i]) continue;
            if(a[i]&(1LL<<j)) cnt++;
        }
        if(cnt>=K) 
        {
            for(ll i=1;i<=tot;i++) if(!(a[i]&(1LL<<j))) valid[i]=false;
            ans+=(1LL<<j);
        }
    }
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 4736
#include<stdio.h>
#include<stdbool.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<utility>
#include<list>
#define N (1000000000+7)
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

int main() {
	ll n;
	cin >> n;
	vector<ll>t(n);
	for (ll i = 0;i < n;i++)cin >> t[i];
	if (n == 1) {
		cout << t[0] << endl;
		return 0;
	}
	ll ans = t[0] * (t[1] / gcd(t[0], t[1]));
	for (ll i = 2;i < n;i++) {
		ans = ans*(t[i] / gcd(ans, t[i]));
	}
	cout << ans << endl;
	return 0;
}

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

int abs(int, int);

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

  if (abs(A-B) < 2) {
    cout << A+B << endl;
  } else {
    if (A>B) {
      cout << A+(A-1)<< endl;        
    } else {
      cout << B+(B-1) << endl;        
    }
  }
}

int abs(int a, int b) {
  if (a>b) {
    return a;
  } else {
    return b;
  }
}

Measured memory_bytes: 256
<?php 
fscanf(STDIN,"%d",$n);
for($i=0;$i<$n;$i++){
    $d=array();
    fscanf(STDIN,"%d %d %d",$d[0],$d[1],$d[2]);
    sort($d);
    list($a,$b,$c)=$d;
    echo $a*$a+$b*$b==$c*$c ? "YES" : "NO","\n";
}
?>

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここからコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////
// 2進数体の行列のランク //
/////////////////////////

// M×N型行列
template<int M, int N>
class GaussianElimination{
private:
	using Matrix = std::array<std::bitset<N>, M>;

	bool keyExist(const int key_r, const int key_c)
	{
		for (int r_i{key_r}; r_i < M; r_i++)
			if ((*this)[r_i][key_c])
			{
				std::swap(accessIndex_[key_r], accessIndex_[r_i]);
				return true;
			}
		return false;
	}
	Matrix matrix_;
	std::array<int, M> accessIndex_;
	int rank_;

public:
	const int& rank;

	GaussianElimination(const Matrix& matrix)
		: matrix_(matrix), rank(rank_)
	{
		for (int i{}; i < M; i++) accessIndex_[i] = i;
		int key_r{};
		for (int key_c{}; key_r < M && key_c < N; key_r++, key_c++)
		{
			while (key_c < N && !keyExist(key_r, key_c))
				key_c++;
			if (key_c == N) break;
			for (int r_i{}; r_i < M; r_i++)
				if (r_i != key_r && (*this)[r_i][key_c])
					(*this)[r_i] ^= (*this)[key_r];
		}
		rank_ = key_r;
	}

	typename decltype(matrix_)::reference operator[](const int r) { return matrix_[accessIndex_[r]]; }
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここまでコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);
	std::array<std::bitset<11>, 10> matrix;
	for (int i{}; i < M; i++)
	{
		int k;
		scanf("%d", &k);
		for (int j{}; j < k; j++)
		{
			int s;
			scanf("%d", &s);
			s--;
			matrix[i][s] = true;
		}
	}
	for (int i{}; i < M; i++)
	{
		int p;
		scanf("%d", &p);
		matrix[i][N] = p == 1;
	}
	GaussianElimination<10, 11> gauss(matrix);
	bool incons{gauss.rank > 0 && gauss[gauss.rank - 1][N]};
	if (incons)
	{
		for (int i{}; i < N; i++)
			if (gauss[gauss.rank - 1][i])
				incons = false;
	}
	if (incons)
		puts("0");
	else
	{
		int ans{1};
		for (int i{}; i < N - gauss.rank; i++) ans *= 2;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <iostream>
#define MODD 1000000007
#define ll long long
using namespace std;


int A[3333];

ll modpow(ll x, ll y) {
    x%=MODD;
    ll xs = x;
    ll answer = 1;
    while(y) {
        if (y&1) {
            answer = (answer * xs) % MODD;
        }
        y >>= 1;
        xs = (xs * xs) % MODD;
    }
    return answer;
}


ll X[3333][3333];
ll Y[3333][3333];



int main() {
    int N,Q;
    cin>>N>>Q;
    for(int i=1;i<=N;i++)
        cin>>A[i];
    
    
    for(int i=1;i<=N;i++)
        for(int j=1;j<=N;j++) {
            X[i][j] = (A[i] < A[j] ? 1 : 0);
            Y[i][j] = (A[i] > A[j] ? 1 : 0);
        }
    
    ll twoinv = modpow(2,MODD-2);
    
    for(int q=1;q<=Q;q++) {
        
        int x,y;
        cin>>x>>y;
        
        
        // X[x][y] and X[y][x]
        
        // X[x][i] -> X[y][i]
        // X[y][i] -> X[x][i]
        
        
        
        
        // P(A[x] < A[y]) and P(A[y] < A[x])
        
        ll newx = (X[x][y]+X[y][x])*twoinv%MODD;
        ll newy = (Y[x][y]+Y[y][x])*twoinv%MODD;
        
        
        for(int j=1;j<=N;j++) {
            if (j != x && j != y) {
                X[x][j]=X[y][j]=(X[x][j]+X[y][j])*twoinv%MODD;
                Y[x][j]=Y[y][j]=(Y[x][j]+Y[y][j])*twoinv%MODD;
            }
        }
        for(int i=1;i<=N;i++) {
            if (i != x && i != y) {
                X[i][x]=X[i][y]=(X[i][x]+X[i][y])*twoinv%MODD;
                Y[i][x]=Y[i][y]=(Y[i][x]+Y[i][y])*twoinv%MODD;
            }
        }
        
        X[x][y]=X[y][x]=newx;
        Y[x][y]=Y[y][x]=newy;
        X[x][x]=X[y][y]=Y[x][x]=Y[y][y]=0;
        
    }
    
    ll ans = 0;
    
    for(int i=1;i<=N;i++)
        for(int j=1;j<=N;j++) {
            if (i < j) {
                ans = (ans + Y[i][j])%MODD;
            } else {
                ans = (ans + X[i][j])%MODD;
            }
        }
    
    ans = (ans * modpow(2, Q))%MODD;
    ans = (ans * twoinv)%MODD;
    
    cout << ans << endl;
    
    
    // M[i][j] = P(X[i] < X[j])
    
    
    
    
    
    
}

Measured memory_bytes: 160000
N = int(input())
xu = [[i for i in input().split()] for i in range(N)]
a = []
for i in range(len(xu)):
    if xu[i][1] == 'JPY':
        a.append(int(xu[i][0]))
    else:
        a.append(float(xu[i][0]) * 380000)
print(sum(a))

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0521

int main() {
	int in;
	while(cin >> in) {
		if (in == 0) break;
		int p = 1000 - in;
		int ans = 0;
		int units[] = { 500, 100, 50, 10, 5, 1 };
		for (int i = 0; i < 6; i++) {
			ans += p /  units[i];
			p %= units[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from functools import reduce
import fractions
n = int(input())
a = list(map(int, input().split()))
L = [0] * (n + 1)
R = [0] * (n + 1)
for i in range(n-1):
    L[i + 1] = fractions.gcd(L[i], a[i])
    R[n - i - 1] = fractions.gcd(R[n - i], a[n - i - 1])

rl = [0] * n
for i in range(n):
    rl[i] = fractions.gcd(L[i], R[i + 1])
print(max(rl))


Measured memory_bytes: 16136
#include <iostream>
#include<string>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <cstdlib>
//#include <vector.h>
//#include <malloc.h>
#include <math.h>
using namespace std;
#include<stdlib.h>
#include<stdio.h>

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

}

int main(){
    
    int n;
    cin>>n;
    
    long long sum=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                sum+= gcd(i, gcd(j, k));
            }
        }
    }
    cout<<sum<<"\n";
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int T;
int N,D;

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>T;
	while(T--) {
		cin>>N>>D;
		
		int ret=0;
		FOR(i,N-1) {
			ret += 127;
			D^=127;
		}
		cout<<D+ret<<endl;
		
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    
    char op;
    
    while(1){
    cin  >> a >> op >> b;
    
    if(op=='+'){
        cout<<a+b<<endl;
    }else if(op=='-'){
        cout<<a-b<<endl;
    }else if(op=='*'){
        cout<<a*b<<endl;
    }else if(op=='/'){
        cout<<a/b<<endl;
    }else {
        break;
    }
    }
    return 0;
}



Measured memory_bytes: 3096
#include<stdio.h>
int main(){

	int max, min, mid, i, j, k, x, y, z, sum;
	
	scanf("%d %d %d", &x, &y, &z);
	
	if(x>=y && x>=z){
		max = x;
	}
	
	else if(y>=x && y>=z){
		max = y;
	}
	else if(z>=x && z>= y){
		max = z;
	}
	
	if(max==x){
		if(y>=z){
			mid = y;
			min =z;
		}
		
		else{
			mid = z;
			min = y;
		}
	}
	
	if(max == y){
		if(x>=z){
			mid = x;
			min = z;
		}
		else{
			mid = z;
			min = x;
		}
	}
	
	if(max==z){
		if(x>=y){
			mid = x;
			min = y;
		}
		else{
			mid = y;
			min = x;
		}	
	}
	 
	 sum = (max-mid) + (mid-min);
	 
	 printf("%d\n", sum);
	 
	 return 0;

}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

long long int Array[100010];
long long int sum;
int n;
int q;
int b, c;

int main(){
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        sum += a;
        Array[a]++;
    }
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> b >> c;
        Array[c] += Array[b];
        sum += Array[b] * (c - b);
        Array[b] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define X first
#define Y second
#define sz(v) (int)v.size()
using ord = tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update>;
 
void solve();
 
main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ONPC
	freopen("in.txt", "r", stdin);
#endif
	int t = 1;
	//cin >> t;
	while (t--) solve();
	return 0;
}



void solve() {
	ll a, b;
	cin >> a >> b;
	ll ans = a / __gcd(a, b) * b;
	cout << ans;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[100005][4];
ll a[4][100005];
ll n,k;
ll f(int ind,int last){
	if(ind==n+1) return 0;
	if(dp[ind][last]>=0) return dp[ind][last];
	ll res = -1;
	for(int i=1;i<=3;i++){
		if(i!=last){
			res = max(res,f(ind+1,i)+a[i][ind]);
		}
	}
	return dp[ind][last]=res;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		fill(dp[i],dp[i]+4,-1);
	}
	for(int i=1;i<=n;i++){
		cin>>a[1][i]>>a[2][i]>>a[3][i];
	}
	//for(int i=1;i<=3;i++) dp[1][i]=a[i][1];
	cout<<max({f(1,1),f(1,2),f(1,3)});
}


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

void swap(int &x, int &y)
{
	int t;
	t = x;
	x = y;
	y = t;
}
int main()
{
	int N; //????´???°
	int num = 0; //?????????????????°
	cin >> N;
	int* x = new int[N + 1];
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}

	int mini;
	for (int i = 0; i < N; i++) {
		mini = i;
		for (int j = i+1; j < N;j++) {
			if (x[j] < x[mini]) {
				mini = j;
				
			}
			
		}
		if (i != mini) {
			swap(x[i], x[mini]);
			num++;
		}
	}
	for (int i = 0; i < N - 1; i++) {
		cout << x[i] << " ";
	}
	cout << x[N - 1] << "\n";

	cout << num << "\n";
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
//Function to find modulo inverse of a
ll gcdExtended(ll a, ll b, ll *x, ll *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    ll x1, y1; // To store results of recursive call
    ll gcd = gcdExtended(b%a, a, &x1, &y1);


    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}
ll modInverse(ll a, ll m)
{
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);

    ll res = (x%m + m) % m;
    return res;
}
int main(){
    fastread;
    ll n,i,j,k,l,m;
    cin>>n>>k;
    /*ll kola1=1;
    ll ini=n+1;
    while(ini>=(n+1-k+1)){
        kola1=(kola1*ini)%MOD;
        ini--;
    }
    ll kola2=1;
    ini=k;
    while(ini>=1){
        kola2=(kola2*ini)%MOD;
        ini--;
    }
    ll sum=(kola1*modInverse(kola2,MOD))%MOD;
    for(i=k+1;i<=n+1;i++){
        kola1=(kola1*(n-i+2))%MOD;
        kola2=(kola2*(i))%MOD;
        ll res=(kola1*modInverse(kola2,MOD))%MOD;
        sum=(sum+res)%MOD;
    }
    cout<<sum;*/
    ll ini=0;
    ll fina=0;
    for(i=0;i<k;i++)
        ini+=i;
    for(i=1;i<=k;i++){
        fina+=(n-i+1);
    }
    ll inpos=k-1;
    ll finpos=n-k+1;
    ll sum=0;
    for(i=k;i<=n+1;i++){
        sum=(sum+max(1LL,fina-ini+1))%MOD;
        ini+=(inpos+1);
        fina+=(finpos-1);
        finpos--;
        inpos++;
    }
    cout<<sum;
}

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

int main(){
	int n,k,count=0,tmp;
  	cin >> n >> k;
  	for(int i = 0; i<n;i++) {
		cin >> tmp;
      	if(tmp < k-tmp)	{
         	count += 2* tmp;
        } else {
        	count += 2*(k-tmp);
        }
    }  	
	cout << count << endl;
	
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int min_at = -1;
  for (int i = 0; i < n; ++i) {
    int value;
    scanf("%d", &value), --value;
    if (value == 0)
      min_at = i;
  }
  assert(min_at != -1);

  int result = INT_MAX;
  for (int i = 0; i + k <= n; ++i) {
    if (i <= min_at && min_at < i + k) {
      int cand = 1 +
        (i + (k - 2)) / (k - 1) +
        (n - (i + k) + (k - 2)) / (k - 1);
      result = min(result, cand);
    }
  }
  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 256