akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 100010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)	for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
 
const ll inf = 1e12 + 7;
const lld EPS = 0.00000001;
const ll modw = 1e9 + 7;

using namespace std;

ll dp[N][3];
ll a[N], b[N], c[N];

int main()
{
	barnarnar
	int n;
	cin >> n;
	forn1(i, n)	cin >> a[i] >> b[i] >> c[i];
	dp[1][0] = a[1];
	dp[1][1] = b[1];
	dp[1][2] = c[1];
	for(int i = 2; i <= n; i++)
	{
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
	return 0;
}



Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int N,K;
    cin>>N>>K;
    int A[N];
    for(int i=0;i<N;++i)cin>>A[i];

    int count[200000]={0};
        
        for(int i=0;i<N;++i){
            count[A[i]-1]++;
        }
        
        // for(int i=0;i<N;++i){
        //     cout<<"count:"<<count[i]<<"\n"s;

        // }
           
        sort(count,count+N,greater<int>());
            
    int  sum=0;

                for(int i=0;i<K;++i){
                    sum+=count[i];
                }
    cout<<N-sum;
    

}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

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


int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time = (h2 - h1) * 60 + m2 - m1;
    cout << time - k << endl;
}

Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <algorithm>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;

/*sortの仕方
 * ■ string s の場合
 * 昇順: sort(s.begin(), s.end())
 * 降順:  sort(s.rbegin(), s.rend())
 *
 * ■ ll a[N] の場合
 * 昇順: sort(a, a+N)
 * 降順: 不明
 */

/*ll alph2ll(char character) {
    ll x = character - 'a';
    return x;
}
*/

// ll my_gcd(ll a, ll b){
// 	return (b==0) ? a : my_gcd(b, a%b);
// }
//
// ll my_lcm(ll a, ll b){
// 	return a*b / my_gcd(a,b);
// }


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

	for(int i=0; i<K; i++){
		if(i%2 == 0){
			B += A/2;
			A = A/2;
		} else {
			A += B/2;
			B = B/2;
		}
	}

	cout << A << endl;
	cout << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    char a;
    cin >> a;
    // cout << a - 'a' << endl;
    if ((a - 'a') >= 0){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl;
    }
   return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007


int a[6],t = 0;;

int main(){
  for(int i = 0; i < 5; i++){
    cin >> a[i];
  }
  int ans,ret = 1e9;
  for(int i = 0;i < 5; i++){
    ans = 0;
    for(int j = 0; j < 5; j++){
        if( i == j) continue;
      for(int k = 0; k < 5; k++){
          if( i == k) continue;
          if( j == k) continue;
        for(int l = 0; l < 5; l++){
          if( i == l) continue;
          if( j == l) continue;
          if( k == l) continue;
          for(int m = 0; m < 5; m++){
            if( i == m) continue;
            if( j == m) continue;
            if( k == m) continue;
            if( l == m) continue;
            ans = 0;
            ans += a[i];
            if(ans%10>0){
              t = 10-ans%10;
            }
            ans += a[j] + t;
            t = 0;
            if(ans%10>0){
              t = 10-ans%10;
            }
            ans += a[k] + t;
            t = 0;
            if(ans%10>0){
              t = 10-ans%10;
            }
            ans += a[l] + t;
            t = 0;
            if(ans%10>0){
              t = 10-ans%10;
            }
            ans += a[m] + t;
            ret = min(ans,ret);
          }
        }
      }
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        try(Scanner sc = new Scanner (System.in)){
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for(int i = 0; i< length; i ++){
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch)){
                    answer += Character.toUpperCase(ch);
                    
                }else{
                    answer += Character.toLowerCase(ch);
                }
            }
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 31232
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
#include <bits/stdc++.h>

using namespace std;

int main(){
    int a,b,c;
    int k;
    int d[1000] = {};

    cin >> a >> b >> k;

    if(a > b) swap(a,b);

    c = __gcd(a,b);

    int j = 0;
    for(int i = 1;i <= c;i++){
        if(c % i == 0){
            d[j] = i;
            j++;
        }
    }

    //for(int i = 0;i < j;i++) cout << d[i] << endl;

    cout << d[j-k] << endl;

    return 0;
}

Measured memory_bytes: 256
#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 N,M;
int ok[404][404];
int A[101010],B[101010];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(y,N) FOR(x,N) ok[y][x]=(y!=x);
	
	while(M--) {
		cin>>x>>y;
		x--;y--;
		if(ok[x][y]) {
			ok[x][y]=ok[y][x]=0;
			FOR(i,N) if(ok[x][i]==0) ok[y][i]=ok[i][y]=0;
			FOR(i,N) if(ok[y][i]==0) ok[x][i]=ok[i][x]=0;
		}
		else {
			FOR(j,N) ok[x][j]=ok[j][x]=ok[y][j]=ok[j][y]=0;
		}
	}
	
	int ret=0;
	FOR(y,N) FOR(x,y) ret+=ok[y][x];
	cout<<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: 896
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  vector< vector<int> > pos(26);
  int n = (int)s.size();  
  for (int i = 0; i < n; ++i) {
    pos[s[i] - 'a'].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    pos[s[i] - 'a'].push_back(i + n);
  }  

  int m = (int)t.size();
  int p = 0;
  long long ans = 0;
  for (int i = 0; i < m; ++i) {
    int c = t[i] - 'a';
    if (pos[c].size() == 0) {
      puts("-1");
      return 0;
    }

    p = *lower_bound(pos[c].begin(), pos[c].end(), p) + 1;
    if (p >= n) {
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1724
#include <bits/stdc++.h> 
#include <queue>
using namespace std;
char maze[20][20];
int H,W;
typedef pair<int,int> P;
int getMoves( int sx, int sy )
{
	int dirx[] = { 0, 0, 1, -1 };
	int diry[] = { 1, -1,0, 0};
	queue<P> poss; 
	poss.push(P(sx,sy));
	map<P,int> steps;
	steps[P(sx,sy)] = 0;
	int step = 0;
	while( !poss.empty() )
	{
		P pos = poss.front();
		poss.pop();
		for( int i=0; i<4; i++ )
		{
			int gx = pos.first + dirx[i];
			int gy = pos.second + diry[i];
			if( gx>=0 && gx<H && gy>=0 && gy<W && maze[gx][gy]=='.' )
			{				
				if( !steps.count(P(gx,gy) ) )
				{
					steps[P(gx,gy)] = steps[P(pos.first,pos.second)]+1;
					poss.push(P(gx,gy));
					if( step < steps[P(gx,gy)] )
						step = steps[P(gx,gy)];
				}
			}
		}
	}
	return step;
}
int main()
{
	//while(true)
	{
		cin>>H>>W;
		for( int i=0; i<H; i++ )
		{
			for( int j=0; j<W; j++ )
			{
				cin>>maze[i][j];
			}
		} 
		
		int maxMoves = 0;
		for( int i=0; i<H; i++ ) 
		{
			for( int j=0; j<W; j++ )
			{
				if( maze[i][j] == '.')
				{
					int moves = getMoves(i,j);
					if( maxMoves < moves )
						maxMoves = moves;	
				}
			}
		}
		cout <<maxMoves<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N, K;
    cin >> N >> K;
    int H[N];
    rep(i,N) cin >> H[i];

    int dp[N];
    rep(i,N) dp[i] = INT_MAX;
    dp[0] = 0;

    // dp[i] = カエルが足場H[i]に辿り着くまでに支払うコストの総和の最小値
    rep(i,N)rep1(j,K) {
        if (i+j < N) dp[i+j] = min(dp[i+j], dp[i] + abs(H[i+j] - H[i]));
    }

    cout << dp[N-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
//
// C - Lining Up
//

#include <iostream>

using namespace std;
using ULL = unsigned long long;

const int MOD = 1000000007;

long long power(long long x, long long n, long long mod) {
    if (n == 0) return 1;
    long ret = power(x * x % mod, n / 2, mod);
    if ((n & 1) == 1) ret = ret * x % mod;
    return ret;
}

int main() {

    int N;
    cin >> N;

    int A[N];
    fill(A, A + N, 0);

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

    bool check = true;
    int i = 1;

    if (N % 2) {
        i = 2;
        if (A[0] != 1) {
            check = false;
        }
    }

    if (check) {
        for (; i < N; i += 2) {
            if (A[i] != 2) {
                check = false;
                break;
            }
        }
    }

    if (check) {
        ULL ans = power(2, N / 2, MOD);
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

ll a, b, c;
ll aa, bb, cc;
ll r;

int main() {

cin >> a >> b >> c;

if(a == b && b == c) {
    if(a % 2) cout << 0 << '\n';
    else cout << -1 << '\n';
} else {
    while(true) {
        if((a % 2) + (b % 2) + (c % 2)) {
            cout << r << '\n';
            break;
        } else {
            aa = a;
            bb = b;
            a += (b + c) / 2;
            b += (aa + c) / 2;
            c += (aa + bb) / 2;
            r++;
        }
    }
}

return 0;

}


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

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

    int h, w, d;
    cin >> h >> w >> d;
    vector<pair<int, int>> a(h * w + 1);
    vector<ll> s(h * w + 1);
    rep(i, h) rep(j, w)
    {
        int b;
        cin >> b;
        a[b] = make_pair(i, j);
    }
    forx(i, 1 + d, h * w + 1)
    {
        s[i] += s[i - d] + abs(a[i].first - a[i - d].first) + abs(a[i].second - a[i - d].second);
    }

    int q;
    cin >> q;
    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        cout << s[r] - s[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    // ２で何回割れるか数える:O(N*log(1e9))
    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        int ai; cin >> ai;
        while (ai % 2 == 0)
        {
            ++ans;
            ai /= 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int MAX_N=100000;

int main(){
    ios::sync_with_stdio(false);
    int n;
    int p[MAX_N+5];
    cin >> n;
    rep(i,n){
        cin >> p[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        if(p[i]==i+1){
            int a=i;
            while(p[a]==i+1){
                a++;
                ans++;
            }
            swap(p[i],p[a]);
        } else continue;
    }
    cout << ans<< endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int h,w;
vs a;

void f(){
	vs c;
	for(int i=0;i<h;i++) if(a[i]!=string(w,'.')) c.push_back(a[i]);
	a=c;
	h=a.size();
	vs b(w,string(h,'a'));
	for(int i=0;i<w;i++) for(int j=0;j<h;j++) b[i][j]=a[j][i];
	a=b;
	swap(h,w);
}

int main(){
	cin>>h>>w;
	a=vs(h);
	for(int i=0;i<h;i++) cin>>a[i];
	f();f();
	for(int i=0;i<h;i++) cout<<a[i]<<endl;
}

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

using ll = long long;

signed main(){
	string s;
	cin >> s;

	ll sum = 0;
	for(int i=0;i < s.size();i++){
		sum = sum + (s[i]-'0');
	}

	if(sum % 9 == 0){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll a ; cin >> a ; 
	cout << a+a*a+a*a*a << endl ;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <map>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){

int n;
cin >> n;

int r[201];
int b[201];

for(int i=0; i < 201; i++){
r[i] = -1;
b[i] = -1;
}

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

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



int ans = 0;
for(int i=0; i < n*2; i++){
if(b[i] != -1){
 int m = 200;   // a[200] = -1である 
 for(int j = 0; j < i; j++){
 if(r[m] < r[j] && r[j] < b[i]) m = j;
  }
 if(m != 200) { ans++; r[m] = -1;}
 }
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
s=input()
if 0<int(s[:2])<=12 and 0<int(s[2:])<=12:
    print("AMBIGUOUS")
elif 0<int(s[:2])<=12:
    print("MMYY")
elif 0<int(s[2:])<=12:
    print("YYMM")
else:
    print("NA")

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll h,w,k;
  cin >> h >> w >> k;
  vector<vl> area(h,vl(w,0));
  vector<string> s(h);
  REP(i,h){
    cin >> s[i];
  }

  ll firstLine = -1;
  REP(i,h){
    bool existSt = false;
    REP(j,w){
      if(s[i][j]=='#'){
        existSt = true;
        break;
      }
    }
    if(existSt){
      firstLine = i;
      break;
    }
  }

  ll count = 0;
  FOR(i,firstLine,h){
    bool existSt = false;
    REP(j,w){
      if(s[i][j]=='#'){
        existSt = true;
        break;
      }
    }
    if(!existSt){
      REP(j,w){
        area[i][j] = area[i-1][j];
      }
      continue;
    }
    REP(j,w){
      area[i][j] = count+1;
      if(s[i][j]=='#'){
        count++;
      }
    }
    RREP(j,w){
      if(s[i][j]=='.') area[i][j] --;
      else break;
    }
  }
  REP(i,firstLine){
    REP(j,w){
      area[i][j] = area[firstLine][j];
    }
  }

  REP(i,h){
    REP(j,w){
      cout << area[i][j] << " ";
    }
    cout << endl;
  }
  
  //cout << fixed << setprecision(10);
  return 0;
}


Measured memory_bytes: 1664
S = input()
N = len(S)
ans = 0
for k in range(2**(N-1)):
    t = []
    p = 0
    for d in range(N+1):
        if (k>>d)&1:
            t.append(int(S[p:d+1]))
            p = d+1
    t.append(int(S[p:d]))
    ans += sum(t)
print(ans)


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

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

int main() {
    int n;
    cin>>n;
    vector<int> a(n), b(n);
    rep(i, n){
        cin>>a[i];
        b[i]=a[i];
    }

    sort(b.begin(), b.end(), greater<int>());
    
    rep(i, n){
        if(a[i]==b[0]){
            cout<<b[1]<<endl;
        }else{
            cout<<b[0]<<endl;
        }
    }
}

Measured memory_bytes: 3200
package main

import (
	"fmt"
	"math/big"
)

func main() {
	var x, k, d int
	fmt.Scan(&x, &k, &d)

	if abs(x)/d >= k {
		bd := big.NewInt(int64(d))
		bk := big.NewInt(int64(k))
		bx := big.NewInt(int64(abs(x)))
		fmt.Println(bx.Sub(bx, bd.Mul(bd, bk)))
	} else {
		if (abs(x)/d)%2 == k%2 {
			fmt.Println(abs(x) % d)
		} else {
			fmt.Println(d - abs(x)%d)
		}
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 1916
#include"bits/stdc++.h"
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(b>c || c-b>a){
		cout<<0;
		return 0;
	}
	cout<<(a-1)*c+b-(c+(a-1)*b)+1;
}

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

typedef signed long long ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) x.begin(),x.end()

#define DEBUG

int main()
{
	bool c = true;
	string s;

	cin >> s;

	rep(i,3)
	{
		if(s[i] == s[i+1])
		{
			c = false;
		}
	}

	if(c == false) cout << "Bad" << endl;
	else cout << "Good" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int sin[] = new int[5];
		int good = 0;
		
	
		for(int i = 0; i < 5; i++) {
			sin[i] = scan.nextInt();
			if(sin[i] == 0) {
				good = i;
				break;
				
			}
			
		}
		
		System.out.println(good + 1);
		
	}
		
	
}



Measured memory_bytes: 35616
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <map>
#include <complex>
#include <vector>
#include <algorithm>

#define INF (1<<30)
#define re(i, n) for(int i=0;i<(n);i++)
#define rep(i, s, n) for(int i=(s);i<(n);i++)
#define pe(x) return cout<<(x)<<endl,0
#define PI 3.1415926535897932
using namespace std;
typedef long long ll;

typedef complex<double> point;

int n;

void pt(point a) {
    printf("%.6lf %.6lf\n", a.real(), a.imag());
}

void koch(point p1, point p2, int d) {
    if (d == n)return;
    point s = (p2 - p1) / 3.0+p1;
    point t = (p2 - p1) / 3.0 * 2.0+p1;
    point u = (t - s) * polar(1.0, PI / 3.0) + s;
    koch(p1, s, d + 1);
    pt(s);
    koch(s, u, d + 1);
    pt(u);
    koch(u, t, d + 1);
    pt(t);
    koch(t, p2, d + 1);

}

int main(void) {
    cin >> n;
    pt(point(0, 0));
    koch(point(0, 0), point(100, 0), 0);
    pt(point(100, 0));
    return 0;
}



Measured memory_bytes: 3208
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    int n, m;
    string s;
    string p;
    while(cin >> n && n)
    {
        cin >> m >> s;
        p = "I";
        REP(n) p = p + "OI";

        int ans = 0;
        int pos = 0;
        while(1)
        {
            pos = s.find(p, pos);
            if(pos == string::npos) break;
            ans++;
            pos++;
        }
        cout << ans << endl;


    }

    return 0;
}

Measured memory_bytes: 2124
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>

using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    
    ll n;
    cin >> n;

    vll a(n);
    rep(i,n) {
        cin >> a[i];
        a[i]--;
    }
    ll count = 0;
    rep(i,n){
        if(a[i] < i){
            if(a[a[i]] == i) count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

int main() {
    int n; cin >> n;
    
    vector<vector<int>> seat(n,vector<int>(2));
    rep(i,n) cin >> seat[i][0] >> seat[i][1];
    
    int sum = 0;
    rep(i,n){
        sum += seat[i][1] - seat[i][0] + 1;
    }
    
    cout << sum;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int a,b,c,d;
ll comb[1024][1024],memo[1024][1024];
bool done[1024][1024];

ll rwpw(ll a, ll p = MOD-2){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

ll solve(int n, int g){
	int i;
	ll k=1ll;
	if(!n){
		return 1ll;
	}else if(g>b){
		return 0ll;
	}
	if(done[n][g]){
		return memo[n][g];
	}
	done[n][g] = true;
	memo[n][g] = solve(n,g+1);
	for(i=1; i<=d; ++i){
		if(i*g>n){
			break;
		}
		mul_mod(k,comb[n-(i-1)*g][g]);
		mul_mod(k,rwpw(i));
		if(i>=c){
			add_mod(memo[n][g],(solve(n-i*g,g+1)*k)%MOD);
		}
	}
	// cout << n << " " << g << " " << memo[n][g] << endl; 
	return memo[n][g];
}

int main(void){
	int n,i,j;
	cin >> n >> a >> b >> c >> d;
	for(i=0; i<=n; ++i){
		comb[i][0] = 1ll;
		comb[i][i] = 1ll;
		for(j=1; j<i; ++j){
			comb[i][j] = (comb[i-1][j-1] + comb[i-1][j])%MOD;
		}	
	}
	cout << solve(n,a) << endl;
	return 0;
}


Measured memory_bytes: 17536
#include <stdio.h>

int left(int i) { return i*2; }
int right(int i) { return i*2+1; }

int H;

void maxHeapify(int *A, int i) {
    int l = left(i);
    int r = right(i);
    int largest;
    
    if(l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    if(r <= H && A[r] > A[largest]) largest = r;
    
    if(largest != i) {
        int tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(int *A) {
    for (int i=H/2; i>0; i--) {
        maxHeapify(A, i);
    }
}

int main() {
    scanf("%d", &H);
    int A[H*2+1];
    for (int i=0; i<=2*H; i++) A[i] = 0;
    for (int i=1; i<=H; i++) scanf("%d", &A[i]);
    
    buildMaxHeap(A);
    for (int i=1; i<=H; i++) printf(" %d", A[i]);
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 6604
#include <iomanip>
#include <string>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std;
int main() {
	long long int n, a, b;
	cin >> n;
	for (int i = 1; i >= 0; i++) {
		a = i*(i + 1) / 2;
		if (n <= a) {
			b = i;
			break;
		}
	}
	a -= n;
	for (int i = 1; i <= b; i++) {
		if (i != a) {
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){

  int A,B,C;
  //string S,T,U;
  
  //cin>>S>>T;
  cin>>A>>B>>C;
  //cin>>U;

  if(A==B and B!=C){
    cout<<"Yes"<<endl;
      }
  else if(A==C and A!=B){
    cout<<"Yes"<<endl;
  }
  else if(B==C and A!=B){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>


using namespace std;

typedef long long ll;

const ll INF = 1ll << 60;

int main(void){
	long double n;
	cin >> n;

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

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

	long double c1 = floor((n - 1) / 2);
	long double c2 = ceil((n - 1) / 2);

	if (d[c1] == d[c2]){
		cout << 0 << endl;
		return 0;
	}

	cout << d[c2] - d[c1] << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

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

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

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


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int D, G;
    cin >> D >> G;
    vector<int> p(D);
    vector<int> c(D);

    for(int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }

    int ans = 1e9;
    for(int mask = 0; mask < (1 << D); ++mask){
        int s = 0, num = 0, rest_max = -1;
        for(int i = 0; i < D; ++i){
            if(mask >> i & 1){
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }else{
                rest_max = i;
            }
        }
        if( s < G){
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if(need >= p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1000000007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    ind(n); 
    
    out(n*6.283185);
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int prod;
    cin>>prod;
    
    int a,temp=prod,flag = 0;
    
    for(int i=1;i<=9;++i)
    {
        a = temp/i;
        
        if(a<=9 && a*i == prod)
        {
            flag = 1;
            break;
        }
    }
    if(flag==1)
    {
        cout<<"Yes"<<"\n";
    }
    else 
    {
        cout<<"No"<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    long long input;
    scanf("%lld",&input);
    int i = 0;
    char ans[100];
    while(input > 0){
        int temp = input % 26;
        if(temp == 0){
            ans[i++] = 'z';
            input = (input/26) - 1;
        }
        else{
            ans[i++] = (temp - 1) + 'a';
            input = input/26;
        }
    }
    ans[i] = '\0';
    for(int j = i - 1; j >= 0; j--){
        printf("%c",ans[j]);
    }
    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N; cin >> N;
    bool ans = true;
    int t=0,x=0,y=0;
    for (int i=0;i<N;i++){
        int T,X,Y; cin >> T >> X >> Y;
        int dis_abs = abs(X-x)+abs(Y-y);
        int time_ela = T - t;
        if (time_ela<dis_abs) ans = false;
        if (time_ela%2!=dis_abs%2) ans = false;
    }
    cout << ((ans)? "Yes":"No") << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			int[] c = {
			        in.nextInt(), in.nextInt(), in.nextInt()
			};
			if (c[0] != 0 || c[1] != 0 || c[2] != 0) {
				Arrays.sort(c);
				double d = Math.hypot(c[0], c[1]) / 2;
				int n = in.nextInt();
				for (int i = 0; i < n; i++) {
					if (in.nextInt() > d) {
						System.out.println("OK");
					} else {
						System.out.println("NA");
					}
				}
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=3e5+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;

int n;
string a;
int main()
{


    	cin>>a;

    	if(a[0]=='S')cout<<"Cloudy\n";
    	else if(a[0]=='C')cout<<"Rainy\n";
    	else cout<<"Sunny\n";
 	


}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define EQ(x, y) (abs(x - y) < EPS)
typedef long long ll;
using namespace std;

const int N = 1e5 + 1;
int dp[N];
int n, m;
vector<vector<int>> g; // directed

int dfs(int node){
	dp[node] = 0;
	for (auto &x : g[node]){
		if (dp[x] != -1){
			dp[node] = max(dp[node], 1 + dp[x]);
		}
		else {
			dp[node] = max(dp[node], 1 + dfs(x));
		}
	}
	return dp[node];
}

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

	cin >> n >> m;
	g.resize(n + 1);
	for (int i = 0; i < m; ++i){ // from x to y
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
	}
	memset(dp, -1, sizeof(dp));
	
	for (int i = 1; i <= n; ++i)
		g[0].push_back(i);
	cout << dfs(0) - 1 << '\n';
	return 0;
}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back

#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto item : (x))
#define output_s(a) printf("%s\n",(a).c_str())

//library----------------------------------------------


int main(){
    int a,b;cin>>a>>b;
    printf("%d\n",6-(a+b));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int x1,x2,y1,y2;
  cin>>x1>>y1>>x2>>y2;
  int X=x2-x1,Y=y2-y1;
    printf("%d %d %d %d\n",x2-Y,y2+X,x1-Y,y1+X);
  }




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

int isin(int x, vector<int>& V) {
  for (int v : V) {
    if (v == x) return 1;
  }
  return 0;
}

void f(int N, vector<int> V) {
  int now = 1;
  for (int i = 0; i < 2*N-1; i++) {
    if (N-3 <= i && i <= N) {
      cout << V[i-(N-3)] << endl;
    } else {
      while (isin(now, V)) now++;
      cout << now++ << endl;
    }
  }
}

int main() {
  int N, x;
  cin >> N >> x;
  if (x == 1 || x == 2*N-1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  if (N == 2) {
    cout << 1 << endl;
    cout << 2 << endl;
    cout << 3 << endl;
    return 0;
  }
  if (x == 2) f(N, {3, 2, 1, 4});
  else f(N, {x-1, x, x+1, x-2});
}

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

int solve(vector<int> &arr, int k){
    int n = arr.size();
    vector<int> dp(n, INT_MAX);
    
    // Base Cases
    dp[n-1] = 0;
    dp[n-2] = abs(arr[n-1]-arr[n-2]);
    
    // Filling the dp table
    for(int i = n-3 ; i >= 0 ; i--){
        int j = i+1;
        for(j = 1 ; j <= k && i+j < n ; j++){
            dp[i] = min(dp[i], abs(arr[i+j]-arr[i])+dp[i+j]);
        }
    }
    
    return dp[0];
}

int main(){
    // INPUT
    int n, k;
    cin >> n;
    cin >> k;
    vector<int> arr(n);
    for(auto &ele : arr)
        cin >> ele;
    
    // OUTPUT
    cout << solve(arr, k);
}

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

int main() {
  int n, m, sum = 0;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) {
    cin >> a[i];
    sum += a[i];
  }
  int c = 0;
  rep(i,n) {
    if (a[i] * 4 * m >= sum) {
      c++;
    }
  }
  if (c >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int m = sc.nextInt();
		int d = sc.nextInt();
		int cnt = 0;
		for (int i = 1; i <= m; i++) {
			for (int j = 22; j <= d; j++) {
				if (j / 10 >= 2 && j % 10 >= 2 && i == (j / 10) * (j % 10)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s(D, vector<int>(26));
    for (int i = 0; i < 26; ++i)
        cin >> c[i];
    for (int i = 0; i < D; ++i)
        for (int j = 0; j < 26; ++j)
            cin >> s[i][j];
    vector<int> t(D);
    for (int i = 0; i < D; ++i) {
        cin >> t[i];
        t[i]--;
    }

    vector<int> last(26), ans(D + 1);
    for (int i = 0; i < D; ++i) {
        ans[i + 1] = ans[i] + s[i][t[i]];
        last[t[i]] = i + 1;
        for (int j = 0; j < 26; ++j)
            ans[i + 1] -= c[j] * (i + 1 - last[j]);
        cout << ans[i + 1] << '\n';
    }

    return 0;
}


Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        try (Scanner scan = new Scanner(System.in)) {
            long count = Long.parseLong(scan.nextLine());
            String[] line = scan.nextLine().split(" ");

            long min = Long.parseLong(line[0]);
            long max = Long.parseLong(line[0]);
            long sum = 0;
            long num = 0;

            for (int i = 0; i < count; i++) {
                num = Integer.parseInt(line[i]);
                sum += num;

                if (num < min) min = num;
                if (num > max) max = num;

            }

            System.out.println(min + " " + max + " " + sum);
        }

    }

}



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

long long N;
//vector<int> A[51];
long long P[51];
vector<int> D[51];

void solve() {
	
	for (int n = 0; n < N; n ++) {
		int F;
		cin >> F;
		for (int f = 0; f < F; f ++) {
			int a;
			cin >> a;
			D[a].push_back(n);
		}
	}
	for (long long n = 0; n < N; n++) {
		P[n] = static_cast<long long>(1) <<  n;
	}
	for (int d = 0; d < 31; d++) {
		for (auto n2 : D[d]) {
			for (auto n : D[d]) {
				P[n2] = (P[n2] | P[n]);
			}
			if (P[n2] == (static_cast<long long>(1) <<  N) - 1) {
				cout << d << endl;
				return;
			}
		}
	}
	cout << "-1" << endl;
}
	
int main() {
	cin >> N;
	while (N){
		for (int i = 0; i < 51; i ++) {
			D[i] = {};
		}
		solve();
		cin >> N;
	}
}



Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int x[3];
    for(int i ;i<3;i++){
        cin>>x[i];
    }
    sort(x,x+3);
    cout<<x[0]<<" "<<x[1]<< " "<<x[2]<<endl;
    
}


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

using namespace std;

typedef long long ll;

const int N = 300010;

int n;
set <ll> s;
map <ll, int> cnt;
ll a[N], lt[N], rt[N];

int main (int argc, char const *argv[]) {
  scanf("%d", &n);
  for (int i = 1; i <= 3 * n; ++i) {
    scanf("%lld", a + i);
  }
  for (int i = 1; i <= n; ++i) {
    lt[n] += a[i];
    s.insert(a[i]);
    cnt[a[i]]++;
  }
  for (int i = n + 1; i <= n + n; ++i) {
    ll cur = a[i];
    lt[i] = lt[i - 1];
    ll mn = *s.begin();
    if (cur > mn) {
      cnt[mn]--;
      if (cnt[mn] == 0) {
        s.erase(mn);
      }
      s.insert(cur);
      cnt[cur]++;
      lt[i] -= mn, lt[i] += cur;
    }
  }
  s.clear(), cnt.clear();
  for (int i = 3 * n; i > n + n; --i) {
    rt[n + n] += a[i];
    s.insert(a[i]);
    cnt[a[i]]++;
  }
  for (int i = n + n - 1; i >= n; --i) {
    ll cur = a[i + 1];
    rt[i] = rt[i + 1];
    ll mx = *(--s.end());
    if (cur < mx) {
      cnt[mx]--;
      if (cnt[mx] == 0) {
        s.erase(mx);
      }
      s.insert(cur);
      cnt[cur]++;
      rt[i] -= mx, rt[i] += cur;
    }
  }
  ll ans = -1e18 - 5;
  for (int i = n; i <= n + n; ++i) {
    ans = max(ans, lt[i] - rt[i]);
  }
  printf("%lld\n", ans);
  return 0;
}



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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
const int INF = INT_MAX/3;
const double EPS = 1e-14;

template<typename U, typename T>
void chmin(U &x, T y) { x = min(x, y); }

template<typename U, typename T>
void chmax(U &x, T y) { x = max(x, y); }

typedef long long int lli;
typedef long double ld;

int phi(int n) {
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    if (n % i == 0) sum++;
  }
  return sum;
}

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

  int i = 1;
  while (phi(i) != n) { i++; }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 1160
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 998244353
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a,b,c,d;
int dp[3030][3030];

int nc2(int x){
	return (x*(x-1))/2;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> a >> b >> c >> d;
  dp[a][b]=1;
  for(int i=1;i<=c;i++){
  	for(int j=1;j<=d;j++){
  		dp[i+1][j] = (dp[i+1][j]+dp[i][j]*j)%mod;
  		dp[i][j+1] = (dp[i][j+1]+dp[i][j]*i)%mod;
  		dp[i+1][j+1] = (dp[i+1][j+1] - (dp[i][j]*(i*j)%mod) + mod)%mod;
  	}
  }
  cout << dp[c][d] << endl;


return 0;
}
///....


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9+7;



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

    ll n; cin >> n;
    vll a(n), b(n,0);
    REP(i,n) cin>>a[i];


    REPR(i,n){
        ll c = i;
        ll ans = 0;
        while(c<n){
            ans += b[c];
            c += i+1;
        }
        ans %= 2;
        if(a[i]!=ans) b[i]=1;
        else b[i]=0; 

    }

    cout<<accumulate(ALL(b), 0LL)<<endl;
    REP(i,n){
        if(b[i]==1){
            cout<< i+1 <<endl;
        }
    }

    return 0;
}

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

int main(){
    int x, y, i;
    cin >> x >> y;
    for(i=0; i<=x; i++){
        if( (i*2 + (x-i)*4) == y ) break; 
    }
    if(i<=x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>

using namespace std;

long long int a, b, c;
char s;
string str1,str2;
int main() {
	cin >> str1;
	for (int k = 0; k < 3; k++) {
		printf("%c", str1[k] == '1' ? '9' : '1');
	}
	return 0;
}

Measured memory_bytes: 256
member = []
count = 0
name_count = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
N = int(input())
for i in range(N):
    name = input()
    member.append(name)
for i in range(N):
    if member[i][0] in name_count:
        name_count[member[i][0]] += 1
count += name_count['M'] * name_count['A'] * name_count['R']
count += name_count['M'] * name_count['A'] * name_count['C']
count += name_count['M'] * name_count['A'] * name_count['H']
count += name_count['M'] * name_count['R'] * name_count['C']
count += name_count['M'] * name_count['R'] * name_count['H']
count += name_count['M'] * name_count['C'] * name_count['H']
count += name_count['A'] * name_count['C'] * name_count['R']
count += name_count['A'] * name_count['H'] * name_count['R']
count += name_count['A'] * name_count['H'] * name_count['C']
count += name_count['H'] * name_count['C'] * name_count['R']
print(count)


Measured memory_bytes: 16244
n = int(input())
c = input().split()
b = [int(n) for n in c]
if n == 2:
    N = b[0] * 2
else:
    a = [n]
    a[0] = b[0]
    for i in range(1,n-1):
        x = min(b[i-1],b[i])
        a.append(x)
    a.append(str(b[n-2]))
    N = 0
    for i in range(n):
        N = N + int(a[i])
print(N)

Measured memory_bytes: 3064