akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	if (s[0] != '1' || s[n - 1] != '0') {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < n - 1; i++) {
		if (s[i] != s[n - 2 - i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	int m = 0;
	for (int i = n / 2 - 1; i >= 0; i--) {
		if (s[i] == '1') {
			m = i;
			break;
		}
	}
	vector<P> edge;
	queue<int> que;
	que.push(0);
	for (int i = 1; i <= m; i++) {
		if (s[i] == '0') {
			que.push(i);
		}
		else {
			while (!que.empty()) {
				edge.emplace_back(i, que.front());
				que.pop();
			}
			que.push(i);
		}
	}
	edge.emplace_back(m + 1, que.front());
	for (int i = m + 2; i < n; i++) {
		edge.emplace_back(m + 1, i);
	}
	for (int i = 0; i < n - 1; i++) {
		cout << edge[i].first + 1 << " " << edge[i].second + 1 << endl;
	}
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>

using namespace std;

int A, B, C, D;

void dfs(int depth, vector<bool> &op, vector<bool> &ans){
  if(depth == 3){
    int tmp = 0;
    tmp += A;
    if(op[0]) tmp += B;
    else tmp -= B;
    if(op[1]) tmp += C;
    else tmp -= C;
    if(op[2]) tmp += D;
    else tmp -= D;
    if(tmp == 7){
      for(int i = 0; i < 3; i++){
      ans[i] = op[i];
      }
      return;
    }
    else return;
  }
  op[depth] = true;
  dfs(depth + 1, op, ans);
  op[depth] = false;
  dfs(depth + 1, op, ans);
  return;
}

int main(){
  string s;
  cin >> s;
  
  A = s[0] - '0';
  B = s[1] - '0';
  C = s[2] - '0';
  D = s[3] - '0';
  
  vector<bool> op(3,false);
  vector<bool> ans(3,false);
  
  dfs(0,op,ans);
  cout << char(A+'0') << (ans[0]?'+':'-') << char(B+'0') << (ans[1]?'+':'-') << char(C+'0') << (ans[2]?'+':'-') << char(D+'0') << '=' << '7';

}


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

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

int main(){
    int K;
    cin >> K;
    int sum = 0;

    for(int a = 1; a <= K; a++){
        for(int b = 1; b <= K; b++){
            for(int c = 1; c <= K; c++){
                int d = min({a, b, c});
                int gcd = 1;
                for(int i = d; i >= 1; i--){
                    if(a % i == 0 && b % i == 0 && c % i == 0){
                        gcd = i;
                        break;
                    }
                }
                sum += gcd;
            }
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;

    cin >> n;

    vector<int> a(n + 1, 0);

    for (int i = 0; i < n - 1; i++)
    {
        int x;
        cin >> x;

        a[x]++;
    }

    for (int i = 1; i <= n; i++)
    {
        cout << a[i] << endl;
    }
}


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

using namespace std;

int n;
int h,w,k;
int ans[300][300];

void solve(){
    int i,j;
    string str;
    cin >> h >> w >> k;
    n = 1;
    for(i = 0;i < h;i++){
        cin >> str;
        for(j = 0;j < w;j++){
            if(str[j] == '#'){
                ans[i][j] = n++;
            }
        }
    }
    for(i = 0;i < h;i++) for(j = 1;j < w;j++) if(ans[i][j] == 0 && ans[i][j-1] > 0) ans[i][j] = ans[i][j-1];
    for(i = 0;i < h;i++) for(j = w-2;j >= 0;j--) if(ans[i][j] == 0 && ans[i][j+1] > 0) ans[i][j] = ans[i][j+1];
    for(i = 1;i < h;i++) for(j = 0;j < w;j++) if(ans[i][j] == 0 && ans[i-1][j] > 0) ans[i][j] = ans[i-1][j];
    for(i = h-2;i >= 0;i--) for(j = 0;j < w;j++) if(ans[i][j] == 0 && ans[i+1][j] > 0) ans[i][j] = ans[i+1][j];
    for(i = 0;i < h;i++){
        for(j = 0;j < w;j++){
            cout << ans[i][j] << ' ';
        }
        cout << endl;
    }
}

int main(){
    solve();
}


Measured memory_bytes: 1152
num = gets.to_i
array = []
sum = 0
num.times do |i|
  array.push gets.to_i
end
array.reverse!

array.each_with_index do |a,index|
  sum += a/2
  a -= (a/2)*2
  if array[index + 1] && array[index + 1] < a
    sum += array[index + 1]
    a -= array[index + 1] 
    array[index + 1] = 0
  elsif array[index + 1]
    sum += a
    array[index + 1] -= a
    a = 0
  end 
end
puts sum

Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n][3];
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
    cin>>arr[i][j];
  }
  for(int i=1;i<n;i++)
  {
    arr[i][0]+=max(arr[i-1][1],arr[i-1][2]);
    arr[i][1]+=max(arr[i-1][0],arr[i-1][2]);
    arr[i][2]+=max(arr[i-1][0],arr[i-1][1]);
  }
cout<<max(arr[n-1][0],max(arr[n-1][1],arr[n-1][2]));
}

  

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

int main( )
{
    int n;
    cin >> n;
    if (n % 10 == 7) {
        cout << "Yes\n";
        return 0;
    }
    n /= 10;
    if (n % 10 == 7) {
        cout << "Yes\n";
        return 0;
    }
    n /= 10;
    if (n % 10 == 7) {
        cout << "Yes\n";
        return 0;
    }
    n /= 10;
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int coudp[100001];

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>X(M);
	for (int i = 0;i < M;++i) {
		cin >> X[i];
	}
	SORT(X);
	vector<int>A(M - 1);
	for (int i = 0;i < M - 1;++i) {
		A[i] = abs(X[i] - X[i + 1]);
	}
	sort(A.begin(), A.end(), greater<int>());
	for (int i = 0;i < min(N-1,M-1);++i) {
		A[i] = 0;
	}
	int cnt = 0;
	for (int i = 0;i < A.size();++i) {
		cnt += A[i];
	}
	cout << cnt << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){
    char s[5];
    char a,b;
    int num_a,num_b;
    int i;
    cin >> s;
    a = s[0];
    for(i=1;i<4;i++){
        if( s[i] != a){
            b = s[i];
            break;
        }
    }
    num_a = num_b = 0;
    for(i=0;i<4;i++){
        if( s[i] == a ){
            num_a++;
        }else if(s[i] == b){
            num_b++;
        }
    }
    if( num_a == 2 && num_b == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int h, field[5][10];	//フィールドの高さ、フィールド
		int imos[5][10];
		int max[2][10];
		int fall[5][10];
		int score = 0;			//スコア
		bool flg = true;		//消去可能フラグ

		cin >> h;
		if( h == 0 ) break;

		//データ取得
		for(int i = 0; i < h; i++)
			for(int j = 0; j < 5; j++)
				cin >> field[j][i];


		while( flg ) {
			flg = false;

			for(int i = 0; i < 5; i++) {
				for(int j = 0; j < 10; j++) {
					imos[i][j] = -1;
				}
			}
			for(int i = 0; i < 2; i++) {
				for(int j = 0; j < 10; j++)
					max[i][j] = 0;
			}

			for(int i = 0; i < h; i++ ) {
				int cnt = 1;
				for(int j = 1; j < 5; j++) {
					if( field[j - 1][i] == field[j][i] ) {
						if(field[j - 1][i] > 0 && field[j][i] > 0 ) cnt ++;
					} else {
						cnt = 1;
					}
					imos[j][i] = cnt;
				}
			}


			for(int i = 0; i < h; i++) {
				for(int j = 4; j >= 0; j--) {
					if( imos[j][i] >= 3 ) {
						max[0][i] = j;
						max[1][i] = imos[j][i];
						score += field[j][i] * max[1][i];
						break;
					}
				}
			}
			
			//消去
			for(int i = 0; i < h; i++) {
				for(int j = max[0][i]; j > max[0][i] - max[1][i]; j --) {
					field[j][i] = -1;
					flg = true;
				}
			}

			//落下
			for(int i = 0; i < 5; i++) {
				int cnt = h - 1;
				for(int j = h - 1; j >= 0; j-- ) {
					if( field[i][j] > 0 ) {
						fall[i][cnt] = field[i][j]; 
						cnt --;
					}
				}
				for(int j = cnt; j >= 0; j--) {
					fall[i][j] = -1;
				}
			}

			for(int i = 0; i < 5; i++)
				for(int j = 0; j < h; j++)
					field[i][j] = fall[i][j];

		}
		
		cout << score << endl;
		

	}
	

	

//	while(1){}
    return 0;
}

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

using namespace std;

int main(){
	int N;
	int K;
	int D[50];

	cin>>N>>K;

	for(int i = 0; i < K;i++) cin>>D[i];

	while(1){
		bool flag = true;
		int M = N;

		while(M>0){
			for(int j = 0; j < K; j++){
				int s = M % 10;
				if(s == D[j]) flag = false;
				}
			if(flag) M /=10;
			else break;
		}

		if(flag){
			cout<<N<<"\n";
			return 0;
		}
		else N++;

	}	
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a,b,i,min,d;
  min=1000;
  d=0;
  scanf("%d %d",&a,&b);
  
int c[a],t[a];
  
  for(i=0;i<a;++i)
  {scanf("%d %d",&c[i],&t[i]);
  if(t[i]>b) {d++;}
  else if(min>c[i]) {min=c[i];}
  }
  
  if(d==a) printf("TLE");
  else printf("%d",min);
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>
using namespace std;

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

typedef long long ll;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;

const ll INF = ll(1e18) + 1;

//--------------------------------------------------

ulli gcd(ulli a, ulli b) {
	return (b <= 0) ? a : gcd(b, a % b);
}

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

//---------------------------------------------------

void Main()
{
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	Main();
	
	return 0;
}

Measured memory_bytes: 256
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define vi vector<int>
#define vll vector<ll>
#define fr(i, j, k) for(i = j; i < k; i++)
#define bk(i, j, k) for(i = j; i >= k; i--)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return 
#define time fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock()/CLOCKS_PER_SEC)
#define nl "\n"
#define INF 1LL<<61
#define inf 1<<30
#define dbg(x) (cerr << #x << ": " << x << "\n")
const long long mod = 1e9+7;

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int t = n, ans = n, cnt = 0;
    while(t){
        cnt++;
        t /= 6;
    }
    int mx6 = pow(6, cnt-1);
    t = n;
    cnt = 0;
    while(t){
        cnt++;
        t /= 9;
    }
    int mx9 = pow(9, cnt-1);
    for(int i=0; i<=n; i++){      // checking all possibility for making n using 6 and 9
        t = i;
        cnt = 0;
        int t6 = mx6, t9 = mx9;
        while(t6){     
            cnt += t/t6;
            t %= t6;
            t6 /= 6;
        }
        t = n-i;
        while(t9){
            cnt += t/t9;
            t %= t9;
            t9 /= 9;
        }
        ans = min(ans, cnt);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
//XYetAnotherDieGame.cpp (C)
#include <iostream>
#include <string>
using namespace std;

int main(){
  long long x,Ans;
  cin >> x;
  Ans = 2*(x/11);
  if(x%11!=0){
    if(x%11 <= 6) Ans += 1;
    else Ans += 2;
  }
  printf("%lld\n",Ans);
  return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
int a[22];
int c[22],d[22];
bool dp[20][200010];

bool ok(double x){
  rep(i,n){
    c[i]=(int)ceil((1.0-x)*(double)a[i]);
    d[i]=(int)floor((1.0+x)*(double)a[i]);
  }
  memset(dp,0,sizeof(dp));

  repl(i,c[0],d[0]+1)dp[0][i]=true;

  rep(i,n-1){
    repl(j,c[i],d[i]+1){
      if(!dp[i][j])continue;
      for(int k=1;j*k<=d[i+1];k++)dp[i+1][j*k]=true;
    }
  }

  bool ok=false;
  repl(i,c[n-1],d[n-1]+1){
    if(dp[n-1][i])ok=true;
  }
  return ok;
}

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n)cin>>a[i];
  double lb=0.0,ub=1.0;
  rep(hoge,30){
    double mid=(lb+ub)/2.0;
    if(ok(mid))ub=mid;
    else lb=mid;
  }
  printf("%.12f\n", (lb+ub)/2.0);
	return 0;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)

li n, q;
string s;

li sum[100100];

int main() {
	cin >> n >> q;
	cin >> s;
	sum[0] = 0;
	repp(i, 1, n) {
		if (s.substr(i - 1, 2) == "AC") {
			sum[i] = sum[i - 1] + 1;
		} else {
			sum[i] = sum[i - 1];
		}
	}
	rep(i, q) {
		li l, r;
		cin >> l >> r;
		l--;
		r--;
		cout << sum[r] - sum[l] << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int N;
	string S;
	cin >> N >> S;

	auto result = 0;
	set<char> left;
	for (auto i = 0; i < N - 1; ++i)
	{
		left.insert(S[i]);

		auto sum = 0;
		set<char> right;
		for (auto j = i + 1; j < N; ++j)
		{
			right.insert(S[j]);
		}

		for (auto s : right)
		{
			if (left.find(s) != left.end())
			{
				++sum;
			}
		}

		result = max(result, sum);
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
#define F first
#define S second
const int N=3e3+10;
int max(int a,int b){return a>b?a:b;}
string a,b;
int val[N][N];
pair<int,int> to[N][N];
int dp(int l,int r){
  if(l<0||r<0)return 0;
  if(val[l][r]>=0)return val[l][r];
  if(a[l]==b[r]){

	  to[l][r]={-1,-1};
 	return val[l][r]=dp(l-1,r-1)+1;
 }
  else{
    int x=dp(l-1,r),y=dp(l,r-1);
    if(x>y){
      val[l][r]=x;
      to[l][r]={-1,0};
    }
    else{
      val[l][r]=y;
      to[l][r]={0,-1};
    }
    return val[l][r];
  }
}
int main(){
  cin>>a>>b;
  string s;
  int l=(int)a.size()-1,r=(int)b.size()-1,tl,tr;
  for(int i=0;i<=l;i++)for(int j=0;j<=r;j++)val[i][j]=-1;
  dp(l,r);
  while(l>=0&&r>=0){
    if(to[l][r].F*to[l][r].S==1)s+=a[l];
    tl=l+to[l][r].F;
    tr=r+to[l][r].S;
    l=tl;
    r=tr;
  }
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}


Measured memory_bytes: 106624
IDENTIFICATION DIVISION.
PROGRAM-ID. ABC074A.

DATA DIVISION.
WORKING-STORAGE SECTION.
77 N PIC 9(3).
77 A PIC 9(5).
77 S PIC ZZZZ9.

PROCEDURE DIVISION.
ACCEPT N.
ACCEPT A.
COMPUTE S = N * N - A.
DISPLAY S.
STOP RUN.


Measured memory_bytes: 764
#include <iostream>
using namespace std;
const int maxx=110;
const int infinity=(1<<30);
 
int A[maxx][maxx];
bool flag[maxx];	//用flag来标记这个节点是不是在MST中，true是在T里，false是在V-T里；
 
int main (){
		int n;
		cin>>n;
		for(int i =1;i<=n;i++){
			for(int j=1;j<=n;j++){
				int e;cin>>e;
				A[i][j]=(e==-1)?infinity:e;
			}
		}
 
		for(int i=0;i<maxx;i++) flag[i]=false;
		int sum=0,minv,minj;
		flag[1]=true;
		while(1){
			minv=infinity;
			minj=-1;
			for(int i=1;i<=n;i++){
				if(flag[i]==true){//找到一个在T中的顶点
					for(int j=1;j<=n;j++){
						if(A[i][j]!=-1 && A[i][j]<minv && flag[j]==false) {//找到一个在V-T中的顶点
							minv=A[i][j];//找到权值的最小值minv
							minj=j;//找到权值的最小值对应的顶点，就是下一步要加入到MST中的顶点minj
						} 
					}
				}
			}
//			cout<<minj<<endl;
			if(minv==infinity || minj==-1) break;
			flag[minj]=true;
			sum+=minv;
		}
		
		cout<<sum<<endl;
		return 0;
		
}



Measured memory_bytes: 3124
#include <iostream>
#define MAX_N 100000
using namespace std;

int a[MAX_N];
int b[MAX_N]; // 出席順
int n;

void solve()
{
    for (int i = 0; i < n; i++)
    {
        b[a[i] - 1] = i + 1;
    }

    for (int i = 0; i < n; i++)
    {
        cout << b[i] << " ";
    }
}

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

    solve();
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct Edge{
    int to;
    int weight;

    Edge(int t, int w): to(t), weight(w){}
};

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

    int n, m, s;
    cin >> n >> m >> s;
    
    vector<vector<Edge>> g(n);
    for(int i = 0; i < m; ++i){
        int from, to, cost;
        cin >> from >> to >> cost;

        g[from].push_back(Edge(to, cost));
    }

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.push(make_pair(0, s));
    const int INF = 1001001001;
    vector<int> dist(n, INF);
    dist[s] = 0;
    
    while(!pq.empty()){
        pair<int, int> p = pq.top();
        pq.pop();
        int v = p.second;

        for(auto edge: g[v]){
            if(dist[edge.to] > dist[v] + edge.weight){
                dist[edge.to] = dist[v] + edge.weight;
                pq.push(make_pair(dist[edge.to], edge.to));
            }
        }
    }

//    for(int res: dist){
//        if(res == INF) cout << "INF" << endl;
//        else cout << res << endl;
//    }
    for(int i = 0; i < n; ++i){
        if(dist[i] == INF) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }

}


Measured memory_bytes: 12920
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N,M,C;cin>>N>>M>>C;
    int B[M];
    REP(i,M)cin>>B[i];
    int ans=0;
    REP(i,N){
        int A[M];
        int sum=C;
        REP(j,M){
            cin>>A[j];
            sum+=A[j]*B[j];
        }
        if(sum>0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int s = 0; //各桁の和

    for (int n_ = n; n_ > 0; n_ /= 10)
        s += n_ % 10;

    if (n % s == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void output(int array[],int n, int count){
  int i;
  
   for(i = 0;i<n;i++){
    if(i>0){
      printf(" ");
    }
      printf("%d",array[i]);
    
  }
    printf("\n");
    printf("%d\n",count);

    
  }



  


int selectionSort(int array[], int n){
  int i,j,miji;
  int tmp;
  int count = 0;
  for(i=0;i<n-1;i++){
    miji = i;
    for(j = i;j<n;j++){
      if(array[j] < array[miji]){
	miji = j;
      }
    }
    tmp = array[i];
    array[i] = array[miji];
    array[miji] = tmp;
    if(i != miji){
      count++;
      
    }
        }
  return count;
}


int main(){
  int array[101];
  int i,n;
  int count;
 

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&array[i]);
  }
  count = selectionSort(array,n);
  output(array ,n,count);

  /* for(i = 0;i<n;i++){
    if(i>0){
      printf(" ");
    }
      printf("%d",array[i]);
    
  }
    printf("\n");
    printf("%d\n",count);*/

    return 0;
  }
    
  



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

long long mod_inv_buf[1001];
bool mod_inv_flag[1001];
long long mod_inv(long long value, long long m){
	long long r0 = m, r1 = value;
	if(mod_inv_flag[value])
		return mod_inv_buf[value];
	mod_inv_flag[value] = true;

	long long m0[2][2] = {{0, 1}, {1, -r0 / r1}}, m1[2][2];
	r0 = r0 % r1;
	std::swap(r0, r1);
	if(r1 == 0)
		return mod_inv_buf[value] = m0[0][1] >= 0 ? m0[0][1] : m0[0][1] + m;

	while(1){
		long long k = -r0 / r1;
		m1[0][0] = m0[1][0];
		m1[0][1] = m0[1][1];
		m1[1][0] = m0[0][0] + k * m0[1][0];
		m1[1][1] = m0[0][1] + k * m0[1][1];
		r0 = r0 % r1;
		std::swap(r0, r1);
		if(r1 == 0)
			return mod_inv_buf[value] = m1[0][1] >= 0 ? m1[0][1] : m1[0][1] + m;
		k = -r0 / r1;
		m0[0][0] = m1[1][0];
		m0[0][1] = m1[1][1];
		m0[1][0] = m1[0][0] + k * m1[1][0];
		m0[1][1] = m1[0][1] + k * m1[1][1];
		r0 = r0 % r1;
		std::swap(r0, r1);
		if(r1 == 0)
			return mod_inv_buf[value] = m0[0][1] >= 0 ? m0[0][1] : m0[0][1] + m;
	}
}

#define M 1000000007

long long fact[1001];
long long afact[1001];

long long buf[1001][1001];
bool mark[1001][1001];
long long n, a, b, c, d;

long long calc(int x, int y){
	if(mark[x][y])
		return buf[x][y];
	if(x < a){
		return y == 0 ? 1 : 0;
	}
	long long sum = calc(x - 1, y);
	for(int i = c; i <= d && x * i <= y; i++){
		long long t = calc(x - 1, y - x * i);
		long long tt = (fact[n - y + x * i] * afact[n - y]) % M;
		t = (t * tt) % M;
		tt = afact[x];
		for(long long j = 0; j < i; j++){
			t = (t * tt) % M;
		}
		t = (t * afact[i]) % M;
		sum = (sum + t) % M;
	}
	mark[x][y] = true;
	buf[x][y] = sum;
	return sum;
}

int main(int argc, char *argv[]){
	afact[0] = fact[0] = 1;
	for(int i = 1;i <= 1000; i++){
		fact[i] = (fact[i - 1] * i) % M;
		afact[i] = (afact[i - 1] * mod_inv(i,M)) % M;
	}
	std::cin >> n >> a >> b >> c >> d;
	std::cout << calc(b, n) << std::endl;
	return 0;
}


Measured memory_bytes: 8192
#include <iostream>

#include <deque>

#include <stdio.h>

#include <cstdio>

#include <algorithm>

#include<bits/stdc++.h>

#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define sp <<" "
#define nw <<"\n"
#define ca "Case "<<tc++<<": "
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define ull unsigned LL
#define check cout<<"* ";
#define show_vector(i) for(int q=0;q<i.size();q++){cout<<i[q]<<" ";}
#define REP(i,n) for (int i=0;i<(n);++i)
#define N_MAX 26
#define rep(i, a, b) for(int i = a; i < b; i++)

const int inf=1<<30;
const long long int INF=1e10;
const int MOD=1e9+7;
const int maxn = 1e5+10;
int a[200005],b[1000005];

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
/*
int ck_prime(int n)
{
    int coun;
     coun=0;
     if(n>1){
      for(int i=2;i*i<=n;i++){
        if( n%i==0 ){
            coun++;
            break;
          }
        }
      }
     if(n==1){
       coun=coun;
         }
    if(coun==0){
           return 1; // n is prime
        }
    return 0;
}
*/
int main()
{
    int n;
    cin>>n;
    vector<int> a(n+1), b(n);
    rep(i, 0, n+1 ) cin >> a[i];
    rep(i, 0, n) cin >> b[i];

    long long int sum=0;
    rep(i, 0, n){
        int x=min(a[i],b[i]);
        sum+=x;
        a[i]=a[i]-x;
        b[i]=b[i]-x;
        x=min(a[i+1],b[i]);
        sum+=x;
        a[i+1]=a[i+1]-x;
        b[i]=b[i]-x;
    }
    cout<<sum nw;
}



Measured memory_bytes: 3928
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

macro_rules! eprint(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = write!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! eprintln(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! dbg {
    ($val:expr) => {
        // Use of `match` here is intentional because it affects the lifetimes
        // of temporaries - https://stackoverflow.com/a/48732525/1063961
        match $val {
            tmp => {
                eprintln!(
                    "[{}:{}] {} = {:#?}",
                    file!(),
                    line!(),
                    stringify!($val),
                    &tmp
                );
                tmp
            }
        }
    };
}

fn main() {
    input! {
        x: u64,
        y: u64,
    }

    let mut x = x;
    let mut answer = 0u64;

    while x <= y {
        answer += 1;
        x *= 2;
    }

    println!("{}", answer);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],x;
	for(int i=0;i<n;++i){
		cin>>x;
		a[x-1]=i;
	}
	for(int i=0;i<n;++i)
		cout<<a[i]+1<<' ';
	return 0;
}

Measured memory_bytes: 1152
TakaHP,TakaATK,AoHP,AoATK=list(map(int,input().split()))
Tcount=0
Acount=0
while TakaHP>0:
    Tcount+=1
    TakaHP-=AoATK
while AoHP>0:
    Acount+=1
    AoHP-=TakaATK
if Tcount>=Acount:
    print('Yes')
else:
    print('No')

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    VSORT(a); VSORT(b); VSORT(c);
    vi cnt(n);
    rep(i, n) cnt[i] += distance(upper_bound(all(c), b[i]), c.end());
    vll sum(n+1);
    rep(i, n) sum[i+1] = sum[i] + cnt[i];
    ll ans = 0;
    rep(i, n) {
        int posb = distance(b.begin(), upper_bound(all(b), a[i]));
        ans += sum[n] - sum[posb];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int cnt=0;
    string str1,str2;
    cin>>str1>>str2;
    for(int i=0;i<str1.size();i++)
    {
        if(str1[i]!=str2[i])
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3900
#include <stdio.h>
int main() {
  int input;
  scanf("%d", &input);
  int even, odd;
  int count = 0;

  for (even = 2; even <= input; even += 2) {
     for (odd = 1; odd <= input; odd += 2) {
       ++count;
     }
  }
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>

#define MAX 1024

using namespace std;

vector<string> EnumerateTerms(string &s, unsigned int min_len, unsigned int max_len){
	string term;
	vector<string> terms;
	for(unsigned int i = 0; i < s.length(); i++){
		if( s[i] == '.' || s[i] == ' ' || s[i] == ',' ){
			if( min_len <= term.length() && term.length() <= max_len ) terms.push_back(term);
			term.clear();
		}else term+=s[i];
	}
	return terms;
}

int main(void){
	char buf[MAX];
	string s;
	vector<string> terms;

	cin.getline(buf,sizeof(buf)/sizeof(*buf));
	s = buf;

	terms = EnumerateTerms(s, 3, 6);

	if( terms.size() > 0 ){
		cout << terms[0];
		for(unsigned int i = 1; i < terms.size(); i++){
			cout << ' ' << terms[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    int n,x;cin>>n>>x;
    while(n||x){
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int z=j+1;z<=n;z++){
                    if(i+j+z==x)ans++;
                }
            }
        }
        cout<<ans<<endl;
        cin>>n>>x;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


































Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}

int32_t main()
{
	c_p_c();
	char ch; cin>>ch;
	ch++;
	cout<<ch<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (c<=a&&a<=d&&c<=b&&b<=d){
        cout<<b-a<<endl;
    } else if (a<=c&&c<=b&&a<=d&&d<=b){
        cout<<d-c<<endl;
    } else if (a<=c&&c<=b){
        cout<<b-c<<endl;
    } else if (a<=d&&d<=b){
        cout<<d-a<<endl;
    } else {
        cout<<0<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include "stdio.h"

int n;
char S[51][60] = {};
int num[123] = {};
int num2[123] = {};

int main() {
	scanf("%d", &n);
	for (int i = 97; i <= 122; i++) {
		num[i] = 3000;
	}
	for (int i = 1; i <= n; i++) {
		scanf("%s", S[i]);
		for (int i = 97; i <= 122; i++) {
			num2[i] = 0;
		}
		for (int j = 0; j <= 50; j++) {
			if (S[i][j] == NULL)break;
			num2[S[i][j]]++;
		}
		for (int j = 97; j <= 122; j++) {
			if (num2[j]<num[j])num[j] = num2[j];
		}
	}
	for (int i = 97; i <= 122; i++) {
		if (num[i]<=2500) {
			for (int j = 1; j <= num[i]; j++) {
				printf("%c", i);
			}
		}
	}
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x =sc.nextInt();
        int y =sc.nextInt();
        if(y>4*x){
            System.out.println("No");
            return;
        }
        else if(y<2*x){
            System.out.println("No");
        }
        else if(y%2==0){
            System.out.println("Yes");
        }
        else System.out.println("No");
    }
}

Measured memory_bytes: 35748
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 2005
#define _x1 x1
#define _x2 x2
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int n,m;
ll v;
int fa[maxn],id[maxn],x[maxn],y[maxn];
ll w[maxn];
int getfa(int now)
{
	return fa[now]==now ? now : fa[now]=getfa(fa[now]);
}
int cmp(int i,int j)
{
	return w[i]<w[j];
}
ll kruskal(int now)
{
	for(int i=1;i<=n;i++) fa[i]=i;
	ll ans=0;
	if(now)
		fa[x[now]]=y[now],ans+=w[now];
	for(int i=1;i<=m;i++)
	{
		int pos=id[i];
		int x1=getfa(x[pos]),y1=getfa(y[pos]);
		if(x1!=y1)
		{
			ans+=w[pos];
			fa[x1]=y1;
		}
	}
	return ans;
}
ll quickpow(ll p,ll k)
{
	ll ans=1;
	while(k)
	{
		if(k&1)
			ans=(ans*p)%mod;
		p=(p*p)%mod;
		k>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d%d%lld",&n,&m,&v);
	for(int i=1;i<=m;i++)
		scanf("%d%d%lld",&x[i],&y[i],&w[i]),id[i]=i;
	sort(id+1,id+1+m,cmp);
 
	ll temp=kruskal(0);
 
	if(temp>v)
	return printf("0\n"),0;
 
	if(temp==v)
	{
		int cnt1=0,cnt2=0;
		for(int i=1;i<=m;i++)
		{
			if(kruskal(i)==temp)
				cnt1++;
			else
				cnt2++;
		}
		ll res1=(quickpow(2,cnt1)-2+mod)%mod;
		ll res2=quickpow(2,cnt2)%mod;
		return printf("%lld\n",res1*res2%mod),0;
	}
	else
	{
		int cnt1=0,cnt2=0;
		for(int i=1;i<=m;i++)
		{
			ll res1=kruskal(i);
			if(res1==v)
				cnt1++;
			else if(res1>v)
				cnt2++;
		}
		ll res1=2ll*((quickpow(2,cnt1)-1+mod)%mod)%mod;
		ll res2=quickpow(2,cnt2);
		printf("%lld\n",res1*res2%mod);
	}
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main()
{
  int n, k;
  cin >> n >> k;
  vi x(n);
  for (int &i : x)
  {
    cin >> i;
  }
  vi dist(n - 1);
  rep(i, n - 1)
  {
    dist.at(i) = x.at(i + 1) - x.at(i);
  }
  vi sum(n);
  rep(i, n - 1)
  {
    sum.at(i + 1) = sum.at(i) + dist.at(i);
  }
  int l = 0,
      r = l + k - 1;
  int ans = INT_MAX;
  int tmp = 0;

  for (l = 0; r < n; l++)
  {
    //左から
    tmp = sum.at(r) - sum.at(l);
    tmp += abs(x.at(l));
    ans = min(ans, tmp);
    //右から
    tmp = sum.at(r) - sum.at(l);
    tmp += abs(x.at(r));
    ans = min(ans, tmp);

    r = l + k ;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;


int main(){
	int x, y;
	cin >> x >> y;
	if (x < 10 && y < 10){
		cout << x*y << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int n; cin >> n;
    ll c = 0;
    ll a[n]; rep(i, n) cin >> a[i], c = c ^ a[i];
    vector<ll> b(n);
    rep(i, n) {
        b[i] = a[i] ^ c;
    }
    rep(i, n) {
        cout << b[i] << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 6352
#include<stdio.h>
int main(void)
{
	int i,j,H,W;
	
	for(;;){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  string s1="";
  string s2="";
  string s3="";
  for(int i=0;i<5;i++)
    s1+=s.at(i);
  for(int i=6;i<13;i++)
    s2+=s.at(i);
  for(int i=14;i<19;i++)
    s3+=s.at(i);
  cout<<s1<<" "<<s2<<" "<<s3<<endl;
  
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int i, j=0;
    if(s=="RRR"){
        cout << 3 << endl;
    }else if((s=="RRS")||(s=="SRR")){
        cout << 2 << endl;
    }else if((s=="RSR")||(s=="RSS")||(s=="SRS")||(s=="SSR")){
        cout << 1 << endl;
    }else if(s=="SSS"){
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>

using namespace std;

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin); freopen("input2.in", "w", stdout);
	int n; scanf("%d", &n);
	if(n == 3)
		printf("2 5 63\n");
	else if(n == 4)
		printf("2 5 20 63\n");
	else if(n <= 15002)
	{
		printf("3 9");
		n -= 2;
		int last = 0;
		for(int i = 1;  i+2 <= n; i+=3)
		{
			printf(" %d %d %d", i*2, i*2+2, i*2+4);
			last = i+2;
		}
		n %= 3;
		if(n == 2)
			printf(" %d %d", last*2+2, last*2+4);
		else if(n == 1)
			printf(" %d", last*2+6);
		printf("\n");
	}
	else
	{
		printf("2");
		for(int i = 2; i <= 15000-(n&1); i++)
			printf(" %d", i*2);
		n -= 15000-(n&1);
		for(int i = 1; i <= n; i++)
			printf(" %d", i*6-3);
		printf("\n");
	}

}





Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int x ,y , z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 50 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int M,N,A,B,C,T;
int s[MAXN];

struct Matrix{
    LL a[MAXN][MAXN];
}st,mp;

Matrix Matrix_Multiply(const Matrix& a,const Matrix& b,int MOD){
    Matrix c;
    memset(c.a,0,sizeof(c.a));
    for(int k=1;k<=N;k++){
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                c.a[i][k]+=a.a[i][j]*b.a[j][k];
            }
        }
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++) c.a[i][j]%=MOD;
    }
    return c;
}

void Power(int X,int MOD){
    while(X){
        if(X&1) st=Matrix_Multiply(st,mp,MOD);
        mp=Matrix_Multiply(mp,mp,MOD);
        X>>=1;
    }
}

void work(){
    while(~scanf("%d%d%d%d%d%d",&N,&M,&A,&B,&C,&T)){
        for(int i=1;i<=N;i++) scanf("%d",&s[i]);
        memset(mp.a,0,sizeof(mp.a));
        for(int i=1;i<=N;i++){
            mp.a[i][i-1]=A;
            mp.a[i][i]=B;
            mp.a[i][i+1]=C;
        }
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++) st.a[i][j]=(i==j);
        }
        Power(T,M);
        for(int i=1;i<=N;i++){
            LL ans=0;
            for(int j=1;j<=N;j++){
                ans=(ans+st.a[i][j]*s[j])%M;
            }
            printf("%lld%s",ans,i==N ? "\n" : " ");
        }
    }
}

int main(){
#ifdef NNever
    freopen("data.in","r",stdin);
//    freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}










Measured memory_bytes: 3244
import java.util.Scanner;

public class Main {

    private static int n;
    private static int[] a;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) a[i] = sc.nextInt();

        int q = sc.nextInt();
        int[] m = new int[q];
        for (int i = 0; i < q; i++) m[i] = sc.nextInt();

        StringBuilder answer = new StringBuilder();
        for (int i = 0; i < q; i++) {
            if (solve(0, m[i]))
                answer.append("yes\n");
            else
                answer.append("no\n");
        }

        System.out.print(answer.toString());

    }

    private static boolean solve(int i, int m) {
        if (m == 0) return true;
        if (i >= n) return false;
        return solve(i + 1, m) || solve(i + 1, m - a[i]);
    }
}



Measured memory_bytes: 26580
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int n; cin >> n;
    int p[n]; for(int i=0; i<n; i++) cin >> p[i];
    int maxp=0;
    int sum=0;
    for(int i=0; i<n; i++){
        if(maxp<p[i]) maxp=p[i];
        sum+=p[i];
    }
    sum-=maxp/2;
    cout << sum << endl;
}


Measured memory_bytes: 384
import collections
n = int(input())
a = list(map(int, input().split()))
C = collections.Counter(a)
ans = sum(a)
q = int(input())
for _ in range(q):
  b,c = map(int, input().split())
  ans -= C[b]*b 
  ans += C[b]*c
  print(ans)
  C[c] += C[b]
  C[b] = 0

Measured memory_bytes: 23996
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        String s = bf.readLine();
        int n = s.length();
        int mod = 1000000007;
        long[][] dp = new long[n+1][13];
        dp[0][0] = 1;
        for(int i=1; i<=n; i++) {

            if(s.charAt(i-1) == '?') {
              for(int val=0; val<10; val++) {
                for(int k=0; k<13; k++) {
                  dp[i][(10*k+val)%13] += dp[i-1][k];
                  dp[i][(10*k+val)%13] %= mod;
                }
              }
            }
            else {
              int val = s.charAt(i-1)-'0';
              for(int k=0; k<13; k++) {
                dp[i][(10*k+val)%13] += dp[i-1][k];
                dp[i][(10*k+val)%13] %= mod;
              }
            }

        }
        out.println(dp[n][5]);
        // int n = Integer.parseInt(bf.readLine());
        // StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        // int n = Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }
}


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

#define INF 2e9+1;

typedef long long int ll;

using namespace std;

int main(void){

    int L, R, min = INF;

    cin >> L >> R;

    if(R-L > 2020){
        min = 0;
    }else{
        for(ll i = L;i < R;i++){
            for(ll j = i+1;j <= R;j++){
                if(min > (i*j)%2019) min = (i*j)%2019;
                if(min == 0) break;
            }
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
	int h,w;
	int i,j;
	while(1){
		cin>>h>>w;
		if(h==w && w==0) break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				cout << '#';
			}
			cout << endl;
		}
		cout <<endl;
	}
	return 0;
}

Measured memory_bytes: 1152