akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s;cin>>s;
  int ans=0;
  int r=0;
  for(int i=0;i<3;i++){
    if(s[i]=='R'){
      r++;
    }else{
      ans=max(ans,r);
      r=0;
    }
  }
  ans=max(ans,r);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3592
import bisect
import math

n, h = map(int, input().split())
A, B = [], []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
atk = max(A)
B.sort(reverse=True)
L = [0]
for i in range(n):
    if B[i] >= atk:
        L.append(L[-1] + B[i])
    else:
        break
if L[-1] >= h:
        ans = bisect.bisect_left(L, h)
else:
    h -= L[-1]
    ans = len(L) - 1 + math.ceil(h / atk)
print(ans)


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

ll mulm(ll x, ll y){
	return ((x%MOD)*(y%MOD))%MOD;
}

ll powm(ll x, ll y){
  	if(y==0) return 1;
  	else if(y==1) return x;
	else if(y%2==0) return mulm(powm(x, y/2),powm(x, y/2));
  	else return mulm(mulm(powm(x, y/2),powm(x, y/2)), x);
}

void Main()
{
	int n;
  	cin >> n;
	vi a(n), b(n);
  	rep(i,n) cin >> a[i];
	sort(all(a));
  	if(n%2==1){
      	b[0] = 0;
      	rep(i,n/2) b[2*i+1] = b[2*i+2] = b[2*i] + 2;
      	if(a==b) cout << powm(2,n/2) << endl;
      	else cout << 0 << endl;
      	return;
    }
  	else{
      	b[0] = b[1] = 1;
      	rep(i,n/2) b[2*i+2] = b[2*i+3] = b[2*i] + 2;
      	if(a==b) cout << powm(2,n/2) << endl;
      	else cout << 0 << endl;
      	return;
    }
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug_x(x) cout<< #x <<"---> : "<<x<<endl;
#define debug_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
std::mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll _;
/***********************/

int main(){
    ssd;
    ll n ;cin>>n;
    string s;
    cin>>s;
    if( s.size() > n) 
    cout<<s.substr(0,n)<<"..."<<endl;
    else cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3616
// https://atcoder.jp/contests/abc085/tasks/abc085_b
#include <iostream>
#include <set>
using namespace std;

int N;
set<int> bag;

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        bag.insert(x);
    }
    cout << bag.size() << endl;
}

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

ll minCost(ll arr[], ll n, ll dp[]){

    if(dp[n] != -1)
        return dp[n];

    if(n == 1)
        return 0;

    ll ans1 = INT_MAX, ans2 = INT_MAX;

    if(n-1 > 0)
        ans1 = abs(arr[n] - arr[n-1]) + minCost(arr, n-1, dp);
    if(n-2 > 0)
        ans2 = abs(arr[n] - arr[n-2]) + minCost(arr, n-2, dp);
    
    dp[n] = min(ans1, ans2);

    return dp[n];

}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;
    
    ll arr[n+1] = {0}, dp[n+1] = {0};
    dp[0] = -1;
    
    for(ll i=1; i<=n; i++){
        cin >> arr[i];
        dp[i] = -1;
    }
    
    cout << minCost(arr, n, dp) << endl;

    return 0;
}

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

#define SIZE 40

int main() {
    string s;
    cin >> s;
    for(int i = 1; i < s.length(); i++) {
        if(s[i] == 'C' && s[i-1] == 'A') {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }

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

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

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL N;
	cin >> N;
	LL ans = INF;

	FOR(i, 1, N + 1) {
		LL j = N - i;
		if (i > 0 && j > 0 && i + j == N) {
			string a = to_string(i);
			string b = to_string(j);
			LL now = 0;
			FOR(k, 0, a.length())now += a[k] - '0';
			FOR(k, 0, b.length())now += b[k] - '0';
			ans = min(ans, now);
		}
	}

	/*FOR(i, 1, N / 2 + 1) {
		FOR(j, i + 1, N / 2 + 1) {
			if (i + j == N) {
				string a = to_string(i);
				string b = to_string(j);
				LL now = 0;
				FOR(k, 0, a.length())now += a[k] - '0';
				FOR(k, 0, b.length())now += b[k] - '0';
				ans = min(ans, now);
			}
		}
	}*/
	O(ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vi vector<int>
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

#define intmax 101000
int isprime[intmax];
void makeprime(){
	REP(i,intmax) if(i%2!=0) isprime[i] = true;
	isprime[1] = false;
	isprime[2] = true;
	for(ll int i=3;i<sqrt(intmax);i+=2){
		for(ll int j=i+2;j<intmax;j+=2){
			if(j%i==0) isprime[j] = false;
		}
	}
}

ll int a,b,m,p,q;

int main(){
	makeprime();
	while(1){
		ll int c = -1;
		ll int ansp,ansq;
		cin >> m >> a >> b;
		if(m==0) break;
		for(ll int p = m; p > 0; p--){
			if(!isprime[p]) continue;
			for(ll int q = p; q <= m/p; q++){
				if(!isprime[q]) continue;
				if(p*b<a*q) continue;
				if(c<p*q){
					c = p * q;
					ansp = p; ansq = q;
				}
			}
		}
		cout << ansp << " " << ansq << endl;
	}
}

Measured memory_bytes: 1548
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define MOD 1000000007
using namespace std;

int main() {
    long long n, sn = 0;
    cin >> n;
    long long t = n;
    while (t >= 1) {
        sn += t % 10;
        t /= 10;
    }
    if (n%sn == 0)Yes;
    else No;
    return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
c = [list(map(int,input().split())) for i in range(10)]
A = [list(map(int,input().split())) for i in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j],c[i][k]+c[k][j])
ans = 0
for i in range(h):
    for j in A[i]:
        if j != -1:
            ans += c[j][1]
print(ans)


Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner fs = new FastScanner(System.in);
        int n = fs.nextInt();
        int[] l = fs.nextArrInt(n);
        int ans = 0;
        Arrays.sort(l);
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                for (int k = j+1; k < n; k++) {
                    if (l[i] != l[j] && l[j] != l[k] && l[i] + l[j] > l[k]) {
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);
    }
    
    static class FastScanner {
        StringTokenizer st;
        BufferedReader br;

        public FastScanner(InputStream system) {
            br  = new BufferedReader(new InputStreamReader(system));
        }

        public FastScanner(File file) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException { return br.readLine(); }
        public int nextInt() throws IOException { return Integer.parseInt(next()); }
        public long nextLong() throws IOException { return Long.parseLong(next()); }
        public double nextDouble() throws IOException { return Double.parseDouble(next()); }
        public char nextChar() throws IOException { return next().charAt(0); }
        public int[] nextArrInt(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }
        public long[] nextArrLong(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
        public double[] nextArrDouble(int n) throws IOException {
            double[] a = new double[n];
            for (int i = 0; i < n; i++) a[i] = nextDouble();
            return a;
        }
        public boolean ready() throws IOException { return br.ready(); }
        public void waitForInput() throws InterruptedException  { Thread.sleep(3000); }
    }
}

Measured memory_bytes: 32992
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
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> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
void myrev(string &a){reverse(a.begin(),a.end()) ;}

int main(){
	string s ; cin >> s ;
	int n = s.size() ;
	if(n!=26){
		for(char c='a';c<='z';c++){
			bool ok = true ;
			for(int i=0;i<n;i++){
				if(s.at(i)==c) ok = false ;
			}
			if(ok){
				cout << s << c << endl ;
				return 0 ;
			}
		}
	}else{
		string az = "abcdefghijklmnopqrstuvwxyz" ;
		myrev(az) ;
		if(s==az) cout << -1 << endl ;
		else{
			for(int i=n-2;i>=0;i--){
				for(int j=n-1;j>i;j--){
					if(s.at(i)<s.at(j)){
						for(int k=0;k<i;k++) cout << s.at(k) ;
						cout << s.at(j) << endl ;
						return 0 ;
					}
				}
			}
		}
	}
}


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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int ans = a * x + b * y;
  int z = max(x, y);
  for (int i = z; i > 0; i--) {
    int t = a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i;
    ans = min(ans, t);
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#define H 250

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

int main(){
  int i,n;
  int A[H];

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2>=1)
      printf("parent key = %d, ",A[parent(i)]);      
    if(2*i<=n)
      printf("left key = %d, ",A[left(i)]);
    if(2*i+1<=n)
      printf("right key = %d, ",A[right(i)]);
  printf("\n");    
  }



  return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
int main(void){
	int a,b=100000,c,d,e=1000;
	cin>>a;
	for (int A=0;A<a;A++){
		c=b*1.05;
		d=c%1000;
		if (d!=0){
			e-=d;
			c+=e;
			b=c;
			e=1000;
		}
		b=c;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3052
while True:
    n=int(input())
    if n==0:
        break
    k=0
    while True:
        if n==1:
            break
        elif n%2==0:
            n=int(n/2)
            k+=1
        else:
            n=n*3+1
            k+=1
        
    print(k)


Measured memory_bytes: 5584
n = int(input())
s_old = input()
s = str(s_old).lower()

# 以下に、記述してください。
answer = ""

for char in list(s):
    ASCII = ord(char)
    num = ASCII - 97
    num = (num + n) % 26
    ASCII = num + 97
    answer += chr(ASCII)

print(answer.upper())

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

using namespace std;

int main(){
  int N,k;
  cin >> N >> k;
  
  vector<long long int> vec(N);
  
  for (int i=0;i<N;i++){
    cin >> vec[i];}
  
  sort(vec.begin(),vec.end());
  
  long long int min= vec[k-1] - vec[0];
  
  for(int i=1;i<N-k+1;i++){
    if(min > vec[i+k-1] - vec[i]) min = vec[i+k-1] - vec[i];}
  
  cout << min ;
  
}
    

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K,x,ans;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    cin >> x;
    ans+=(x<abs(K-x)?x:abs(K-x))*2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int L, R, d, C = 0;

  std::cin >> L >> R >> d;

  for (int i = L; i <= R; i ++)
    if (i % d == 0)
      C ++;

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int r, c, k;
void print(vector<vector<vector<ll>>> a){
    rep(i, r){
        rep(j, c)cout << a[i][j][0] << " ";
        cout << endl;
    }
    cout << endl;
    rep(i, r){
        rep(j, c)cout << a[i][j][1] << " ";
        cout << endl;
    }
    cout << endl;
    rep(i, r){
        rep(j, c)cout << a[i][j][2] << " ";
        cout << endl;
    }
    cout << endl;
    rep(i, r){
        rep(j, c)cout << a[i][j][3] << " ";
        cout << endl;
    }
    cout << endl;
}
int main(){
    cin >> r >> c >> k;
    vector<vector<ll>> v(r, vector<ll>(c, 0LL));
    rep(i, k){
        ll a, b, value;
        cin >> a >> b >> value;
        a--; b--;
        v[a][b] = value;
    }
    vector<vector<vector<ll>>> dp(r, vector<vector<ll>>(c, vector<ll>(4, 0LL)));
    dp[0][0][0] = 0;
    dp[0][0][1] = v[0][0];
    REP(i, r-1){
        chmax(dp[i][0][0], dp[i-1][0][3]);
        chmax(dp[i][0][0], dp[i-1][0][2]);
        chmax(dp[i][0][0], dp[i-1][0][1]);
        chmax(dp[i][0][0], dp[i-1][0][0]);

        chmax(dp[i][0][1], dp[i][0][0] + v[i][0]);
    }
    REP(i, c-1){
        chmax(dp[0][i][0], dp[0][i-1][0]);
        chmax(dp[0][i][1], dp[0][i-1][1]);
        chmax(dp[0][i][2], dp[0][i-1][2]);
        chmax(dp[0][i][3], dp[0][i-1][3]);

        chmax(dp[0][i][1], dp[0][i-1][0] + v[0][i]);
        chmax(dp[0][i][2], dp[0][i-1][1] + v[0][i]);
        chmax(dp[0][i][3], dp[0][i-1][2] + v[0][i]);
    }
    REP(i, r-1){
        REP(j, c-1){
            chmax(dp[i][j][0], dp[i-1][j][3]);
            chmax(dp[i][j][0], dp[i-1][j][2]);
            chmax(dp[i][j][0], dp[i-1][j][1]);
            chmax(dp[i][j][0], dp[i-1][j][0]);

            chmax(dp[i][j][1], dp[i][j][0] + v[i][j]);
            
            chmax(dp[i][j][0], dp[i][j-1][0]);
            chmax(dp[i][j][1], dp[i][j-1][1]);
            chmax(dp[i][j][2], dp[i][j-1][2]);
            chmax(dp[i][j][3], dp[i][j-1][3]);

            chmax(dp[i][j][1], dp[i][j-1][0] + v[i][j]);
            chmax(dp[i][j][2], dp[i][j-1][1] + v[i][j]);
            chmax(dp[i][j][3], dp[i][j-1][2] + v[i][j]);

        }
    }
    cout << max({dp[r-1][c-1][0], dp[r-1][c-1][1], dp[r-1][c-1][2], dp[r-1][c-1][3]}) << endl;
}

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

int main(){
  int N,count;
  cin >> N;
  int a[N];
  rep(i,N){
    cin >> a[i];
  }
  
  count = 0;
  
  rep(i,N){
    if(((i+1)%2 == 1) && (a[i]%2 == 1)) count++;
  }
  
  cout << count;
  return 0;
}


Measured memory_bytes: 3548
#include <cstdio>
#include <algorithm>
using namespace std;
short ita[5005][5005]={};
int n;
int m;
int main()
{
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++)
    {
      int a,b,c;
      scanf("%d %d %d",&a,&b,&c);
      ita[a][b]=max((int)ita[a][b],c+1);
    }
  int ans=0;
  for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=n;j++)
	{
	  ita[i][j]=max(ita[i][j],(short)max(ita[i-1][j-1]-1,ita[i-1][j]-1));
	  if(ita[i][j]) ans++;
	}
    }
  printf("%d\n",ans);
  return 0;
}

  

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;

    int nume = 0;
    int numw = 0;
    vector<int> a(n);
    rep(i, n) {
        a[i] = numw;
        if(s[i] == 'E') {
            nume++;
        }
        if(s[i] == 'W') {
            numw++;
        }
    }

    int ans = 1e9;
    nume = 0;
    numw = 0;
    for(int i = n-1; i>= 0; --i) {
        ans = min(ans, a[i] + nume);

        if(s[i] == 'E') {
            nume++;
        }
        if(s[i] == 'W') {
            numw++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int N, M;
void solve() {
    if (N % 2 == 1) {
        for (int i = 0; i < M; ++i) {
            cout << i+1 << " " << N-i << endl;
        }
    }
    else {
        for (int i = 0; i < (M+1)/2; ++i) {
            cout << i+1 << " " << N-i << endl;
        }
        for (int i = (M+1)/2; i < M; ++i) {
            cout << i+1 << " " << N-i-1 << endl;
        }
    }
}

int main() {
    while (cin >> N >> M) solve();
}

















Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n,k;
  cin >>n >>k;
  string s;
  cin >> s;
  long long int a[100010],b[100010],ans[100010],re[100010];
  for(int i=0;i<k;i++){
    cin >> a[i] >> b[i];
  }
  
  for(int i=0;i<n;i++){
    ans[i]=0;
    re[i]=0;
  }
  re[n]=0;
  for(int i=0;i<n-1;i++){
    if(s[i]=='A' && s[i+1]=='C') ans[i+1]=1;
  }
  for(int i=0;i<n;i++){
    re[i+1]=re[i]+ans[i];
  }
  
  for(int i=0;i<k;i++){   
      cout << re[b[i]]-re[a[i]] <<endl;
}
}

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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

int main() {
    ll k, n, x;
    cin >> n >> k;
    vector<ll>v, u;
    for (ll i = 0; i < n; i++) {
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    ll ans = INT_MAX;
    for (ll i = 0; i < n - k + 1; i++) {
    ans = min(ans, (v[i + k - 1] - v[i]));
   }
   cout << ans << endl;
   return 0;

}



Measured memory_bytes: 4304
n, k = gets.split.map(&:to_i)
try = Array.new(n+1, 0)
trymax = 0
for i in 1..n
  cnt = 0
  divs = k / i
  if k % i > 0
    divs += 1
  end
  while 1
    if (divs / (2 ** cnt) == 1 && divs % (2 ** cnt) == 0) || divs / (2 ** cnt) < 1
      break
    else
      cnt += 1
    end
  end
  try[i] = cnt
  trymax = cnt if trymax < cnt
end
gm = 2.0 ** trymax
gc = 0.0
for i in 1..n
  gc += gm / (2.0 ** try[i])
end
gm *= n
puts gc / gm

Measured memory_bytes: 2556
// finish date: 2018/01/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    X-=Z;
    cout << X / (Y + Z) << endl;


    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc105/tasks/abc105_d
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define isvisiblechar(c) (0x21 <= (c) && (c) <= 0x7E)
#define cin scanner
#define cout printer
namespace {
class MaiScanner {
  public:
    template <typename T> void input_integer(T &var) {
        var = 0;
        T sign = 1;
        int cc = getchar_unlocked();
        for (; cc < '0' || '9' < cc; cc = getchar_unlocked())
            if (cc == '-')
                sign = -1;
        for (; '0' <= cc && cc <= '9'; cc = getchar_unlocked())
            var = (var << 3) + (var << 1) + cc - '0';
        var = var * sign;
    }
    inline int c() { return getchar_unlocked(); }
    inline MaiScanner &operator>>(int &var) {
        input_integer<int>(var);
        return *this;
    }
    inline MaiScanner &operator>>(long long &var) {
        input_integer<long long>(var);
        return *this;
    }
    inline MaiScanner &operator>>(string &var) {
        int cc = getchar_unlocked();
        for (; !isvisiblechar(cc); cc = getchar_unlocked())
            ;
        for (; isvisiblechar(cc); cc = getchar_unlocked())
            var.push_back(cc);
        return *this;
    }
    template <typename IT> void in(IT begin, IT end) {
        for (auto it = begin; it != end; ++it)
            *this >> *it;
    }
};
class MaiPrinter {
  public:
    template <typename T> void output_integer(T var) {
        if (var == 0) {
            putchar_unlocked('0');
            return;
        }
        if (var < 0)
            putchar_unlocked('-'), var = -var;
        char stack[32];
        int stack_p = 0;
        while (var)
            stack[stack_p++] = '0' + (var % 10), var /= 10;
        while (stack_p)
            putchar_unlocked(stack[--stack_p]);
    }
    inline MaiPrinter &operator<<(char c) {
        putchar_unlocked(c);
        return *this;
    }
    inline MaiPrinter &operator<<(int var) {
        output_integer<int>(var);
        return *this;
    }
    inline MaiPrinter &operator<<(long long var) {
        output_integer<long long>(var);
        return *this;
    }
    inline MaiPrinter &operator<<(char *str_p) {
        while (*str_p)
            putchar_unlocked(*(str_p++));
        return *this;
    }
    inline MaiPrinter &operator<<(const string &str) {
        const char *p = str.c_str();
        const char *l = p + str.size();
        while (p < l)
            putchar_unlocked(*p++);
        return *this;
    }
    template <typename IT> void join(IT begin, IT end, char sep = ' ') {
        for (bool b = 0; begin != end; ++begin, b = 1)
            b ? *this << sep << *begin : *this << *begin;
    }
};
} // namespace
MaiScanner scanner;
MaiPrinter printer;

int main(void) {
    int N, M, t;
    cin >> N >> M;
    // A[left, right) が M の倍数
    unordered_map<int, int> cnt;
    cnt[0]++;
    ll sum = 0, ans = 0;
    REP(i, N) {
        cin >> t;
        sum += t;
        ans += (cnt[sum % M]++);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3596
n,x,y=map(int,input().split())
l=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        l[(min(abs(i-j),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i)))-1]+=1
for i in l:
    print(i)


Measured memory_bytes: 3444
import java.util.Scanner;

class Main{




	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int[] b = new int[m];
		int[] c = new int[m];

		for(int i = 0;i < m;i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();

		}
		
		
		
		int[][] map = new int[n+1][n+1];
		int inf = 1000000;

		

		for(int i = 1;i < n+1;i++){
			for(int j = 1;j < n+1;j++){
				map[i][j] = inf;
			}
		}

		for(int i = 0;i < m;i++){
			map[a[i]][b[i]] = c[i];
			map[b[i]][a[i]] = c[i];
		}
		for(int k = 1;k <= n;k++ ){
			for(int i = 1;i <= n;i++){
				for(int j = 1;j <= n;j++){
					map[i][j] = Math.min(map[i][j], map[i][k]+map[k][j]);
				}
			}
		}
//		for(int i = 0;i < m;i++){
//			System.out.println("a[i] "+a[i] +" b[i] "+b[i] +" " +map[a[i]][b[i]]);
//		}
		
		
		
		int ans = 0;
		for(int i = 0;i < m;i++){
			if(map[a[i]][b[i]] != c[i]){
				ans++;
			}
		}
		System.out.println(ans);
		
		



	}
}

class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 27664
import sys
sys.setrecursionlimit(1000001)

def main():
    n, m = map(int, input().rstrip().split())
    dist = [[500000 for i in range(n)]for j in range(n)]

    for i in range(n):
        for j in range(n):
            if (i==j):
                dist[i][j]=0

    a = [None] * m
    b = [None] * m
    c = [None] * m

    for i in range(m):
        x, y, z = map(int, input().rstrip().split())
        dist[x-1][y-1] =  min(dist[x-1][y-1], z)
        dist[y-1][x-1] =  min(dist[x-1][y-1], z)
        a[i] = x - 1
        b[i] = y - 1
        c[i] = z
        
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])
    #print(dist)
    result = m

    for i in range(m):
        for j in range(n):
            if dist[j][a[i]] + c[i] == dist[j][b[i]]:
                result -= 1
                break

    print(result)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 40944
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll N;
    cin >> N;
    FOR(i,1,N+1){
        ll cnt=0;
        FOR(j,1,100){
            FOR(k,1,100){
                FOR(l,1,100){
                    if(j*j+k*k+l*l+j*k+k*l+l*j==i){
                        cnt++;
                    }else if(j*j+k*k+l*l+j*k+k*l+l*j > i){
                        break;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;  
}


Measured memory_bytes: 3632
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
MOD = 10**9+7
d = [[0, 0] for i in range(n)]
for i in range(n):
  cur1 = 0
  cur2 = 0
  for j in range(i):
    if a[i]>a[j]:
      cur2 += 1
  for j in range(i+1, n):
    if a[i]>a[j]:
      cur1 += 1
      cur2 += 1
  d[i] = [cur1, cur2]
ans = 0
for i in range(n):
  ans = (ans+d[i][0]*k)%MOD
  t = ((k*(k-1))//2)%MOD
  ans = (ans+d[i][1]*t)%MOD
print(ans)

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    string line;
    int ans;
    cin >> line;
    cin >> ans;
    vi ns;
    vb ops;
    for (int i = 0; i < line.length()-1; i += 2) {
        ns.push_back(line[i] - '0');
        ops.push_back(line[i+1] == '+');
    }
    ns.push_back(line[line.length()-1] - '0');

    int L = ns[0];
    FOR(i, 1, ns.size()) {
        if (ops[i-1]) {
            L += ns[i];
        } else {
            L *= ns[i];
        }
    }

    FOR(i, 1, ns.size()) {
        if (!ops[i-1]) {
            ns[i] = ns[i-1] * ns[i];
            ns[i-1] = 0;
        }
    }
    int M = accumulate(ALL(ns), 0);

    if (ans == M && ans == L) {
        cout << "U" << endl;
    } else if (ans == M) {
        cout << "M" << endl;
    } else if (ans == L) {
        cout << "L" << endl;
    } else {
        cout << "I" << endl;
    }
}

Measured memory_bytes: 3184
N = gets.chomp.to_i

BA = []
N.times do
  a, b = gets.chomp.split().map(&:to_i)
  BA << [b, a]
end

sorted_BA = BA.sort_by {|x| [x[0], -x[1]]}
work_sum = 0

sorted_BA.each do |ba|
  work_sum += ba[1]
  if work_sum > ba[0]
    print('No')
    exit(0)
  end
end

print('Yes')


Measured memory_bytes: 39352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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(){
    string w; cin>>w;
    map<char,ll> m;
    for(char c: w) m[c]++;
    for(char c='a'; c<='z'; c++){
        if(m[c]%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a, b;
  int ans = 0;

  scanf("%d %d", &a, &b);

  if(b >= a){
    ans = a;
  }
  else{
    ans = a - 1;
  }

  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fr(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    ll n,k,size,sum = 0;
    cin >> n >> k;
    ll a[n];
    vector<ll> b;
    fr(i,n){
        cin >> a[i];
        b.pb(a[i]); 
    }
    sort(b.begin(),b.end());
    size = b.size();
    fr(i,k){
        size--;
    }
    fr(i,size){
        sum += b[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3444
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
xy =[]
ans = 0

for i in range(n):
  xyi = v[i] - c[i]
  xy.append(xyi)

for i in xy:
  if i > 0:
    ans += i

print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String n = sc.next();
        String nn[] = n.split("");
        int i,j;
        long mozi = Integer.parseInt(nn[0]);
        long ans = 0;
        long check = 0;
        String nisin;
        String count[] = new String[n.length()];
        Arrays.fill(count,"0");
        int loop = (int) Math.pow(2, n.length() - 1);
		
        for(i = 0; i < loop;i++){
          nisin = Integer.toBinaryString(i);
          for(j = nisin.length();j < n.length() - 1; j++){
            nisin = "0" + nisin;
          }
          count = nisin.split("");
          check = 0;
          mozi = Integer.parseInt(nn[0]);
          for(j = 1;j <n.length(); j++){
            if(count[j - 1].equals("0")){
              mozi = mozi * 10;
              mozi += Integer.parseInt(nn[j]);
            }else{
              check += mozi;
              mozi = Integer.parseInt(nn[j]);
            }
          }
          ans += mozi + check;
        }
      	  
          System.out.println(ans);
      
    }
}

Measured memory_bytes: 39576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, y = 0;
  cin >> N;
  
 
  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    y += r - l + 1;       
  }
  cout << y << endl;

}

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

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

    int r, d, x;

    cin >> r >> d >> x;

    for(int i = 0; i < 10; i++)
    {
        x = x * r - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
 
int main(){
int n,m;
long long a[51],b[51],c[51],d[51];
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>a[i]>>b[i];
}
for(int i=0;i<m;i++){
cin>>c[i]>>d[i];
}
for(int i=0;i<n;i++){
long long ans=10000000000;
int an=0;
for(int j=0;j<m;j++){
if(abs(a[i]-c[j])+abs(b[i]-d[j])<ans)an=j;
ans=min(abs(a[i]-c[j])+abs(b[i]-d[j]),ans);
}
cout<<an+1<<endl;
}

}

Measured memory_bytes: 256
#include<stdio.h>
typedef long long ll;
int a[10010],b[10010];
int main(){
	int n,i;
	ll s;
	scanf("%d",&n);
	s=0;
	for(i=1;i<=n;i++){
		scanf("%d",a+i);
		s-=a[i];
	}
	for(i=1;i<=n;i++){
		scanf("%d",b+i);
		s+=b[i];
	}
	for(i=1;i<=n;i++){
		if(a[i]<b[i])s-=(b[i]-a[i]+1)/2;
	}
	puts(s<0?"No":"Yes");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

template<typename T>
using v = vector<T>;

int main() {
	string s;
	cin >> s;
	vi num(26, 0);
	int N = s.length();

	int ans = INF;
	rep(c, 26) {
		int m = -1, l = -1;
		rep(i, N) {
			if (s[i] == 'a' + c) {
				m = max(m, i - l - 1);
				l = i;
			}
		}
		m = max(m, N - 1 - l);
		//cout << (char)('a' + c) << " " << m << endl;
		if (m == -1)continue;
		ans = min(ans, m);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;

#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

void work() {
    int n;
    cin >> n;
    LL ansx = 1, ansy = 1;
    for (int i = 1; i <= n; ++i) {
        LL a, b;
        cin >> a >> b;
        LL k1 = 1;
        if (a < ansx) {
//            k1 = max(k1, (LL)ceil(1.0 * ansx / a)); ceil有毒？
            k1 = ansx / a;
            if (ansx % a != 0) k1++;
        }
        if (b < ansy) {
//            k1 = max(k1, (LL)ceil(1.0 * ansy / b));
            LL t = ansy / b;
            if (ansy % b != 0) t++;
            k1 = max(k1, t);
        }
        ansx = a * k1;
        ansy = b * k1;
    }
    cout << ansx + ansy << endl;
}

int main() {
#ifdef local
    freopen("data.txt","r",stdin);
#endif
    work();
    return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            final int n = Integer.parseInt(br.readLine());
            if (n == 0) { break; }
            
            Map<String, Long> data = new HashMap<>();
            List<String> out = new ArrayList<>();
            for (int i=1; i <= n; i++) {
                StringTokenizer st = new StringTokenizer(br.readLine());
                String e = st.nextToken();
                Long p = Long.parseLong(st.nextToken());
                Long q = Long.parseLong(st.nextToken());
                Long total = data.getOrDefault(e, 0L) + p * q;
                data.put(e, total);
                if (total >= 1_000_000L) {
                    if (out.contains(e) == false) {
                        System.out.println(e);
                        out.add(e);
                    }
                }
            }
            if (out.isEmpty()) {
                System.out.println("NA");
            }
        }
    }
}

Measured memory_bytes: 26964
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=5000+10,inf=0x3f3f3f3f;
char s1[maxn],s2[maxn];
int p1[maxn],p2[maxn],t1,t2;
int main(){
	int n=read(),ans=0;
	scanf("%s%s",s1+1,s2+1);
  	if(n<=2){
    	REP(i,1,n) if(s1[i]!=s2[i]) ++ans;
     	return printf("%d\n",ans),0;
    }
	REP(i,1,n-1) if(s1[i]!=s1[i+1]) p1[++t1]=i;
	REP(i,1,n-1) if(s2[i]!=s2[i+1]) p2[++t2]=i;
	
	int res=0,res1=0,res2=0;
	REP(i,1,t1){
		res1+=p1[i];
		res2+=n-p1[i];
	}
	ans+=min(res1,res2);
	res1=res2=0;
	REP(i,1,t2){
		res1+=p2[i];
		res2+=n-p2[i];
	}
	ans+=min(res1,res2);
	REP(i,1,t1) if(s1[p1[i]]==s2[p2[1]]){
		res=0;
		REP(j,1,t2){
			if(i+j-1<=t1) res+=abs(p1[i+j-1]-p2[j]);
			else res+=abs(n-p2[j]);
		}
		REP(j,i+t2,t1) res+=abs(n-p1[j]);
		REP(j,1,i-1) res+=p1[j];
		chkmin(ans,res);
	}
	swap(p1,p2),swap(t1,t2),swap(s1,s2);
	REP(i,1,t1) if(s1[p1[i]]==s2[p2[1]]){
		res=0;
		REP(j,1,t2){
			if(i+j-1<=t1) res+=abs(p1[i+j-1]-p2[j]);
			else res+=abs(n-p2[j]);
		}
		REP(j,i+t2,t1) res+=abs(n-p1[j]);
		REP(j,1,i-1) res+=p1[j];
		chkmin(ans,res);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

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

ll b[300005][61]={};
ll c[300005][61]={};

int main(){
    fast_io
    
    int n;
    cin>>n;
    vector<string> s(n);
    set<string> st;
    rep(i,n) {
        cin>>s[i];
        st.insert(s[i]);
    }
    cout<<st.size()<<endl;

    return 0;
}

Measured memory_bytes: 25072
#include<cstdio>

int main(){
  int a, b;
  while( true ){
    scanf("%d %d", &a, &b);
    if(a == 0 && b == 0) break;
    for(int i = 0; i < a; i++){
      for(int j = 0; j < b; j++){
	printf("#");
      }
      printf("\n");
    }
  printf("\n");
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const 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 true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n,k,s;
    cin>>n>>k>>s;
    Vec a(n);

    rep(i,n){
        if(i<k){
            a[i] = s;
        }else{
            if(s<=2){
                a[i] = s+1;
            }else{
                a[i] = s-1;
            }
        }
    }
    rep(i,n){
        cout<<a[i]<<" ";
    }
    return  0;
}


Measured memory_bytes: 2176