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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	string s, t;
	cin >> s >> t;
	REP(i, N){
		bool flag = true;
		REP(j, N){
			if(i+j>=N) continue;
			if(s[i+j]!=t[j]) flag = false;
		}
		if(flag){
			cout << i + N << endl;
			return 0;
		}
	}
	cout << 2*N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<ll, ll>
#define pll pair<ll , ll>
#define mpi make_pair
#define F first
#define S second
#define pb push_back
#define N 200005
#define INF 1000000000000000

int arr[200005];
int main()
{   
    fastio
    int n;
    cin>>n;
    int k;
    cin>>k;
    for(int i = 0 ; i<n;i++)
    {
        cin>>arr[i];
    }

    int dp[n];
    for(int i = 0 ; i<n;i++)dp[i] = INT_MAX;

    dp[0] = 0;

    for(int i = 1 ; i<n;i++)
    {   
        // cout<<dp[i]<<" ";
        for(int j = i-1 ; j>= i-k && j>=0 ;j--)
        {
            dp[i] = min(dp[i] , abs(arr[i]-arr[j]) + dp[j]);
        }
        // cout<<dp[i]<<" ";
    }

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

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

signed main(void) {
  ll N;
  cin >> N;
  bool find = false;
  ll A = sqrt(N);
  ll B = sqrt(N);
  while(!find) {
    B = N/A;
    if (N == A*B) {
      find = true;
    } else {
      A--;
    }
  }
  cout << A+B-2 << endl;
}


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

int main(){
	int n;
	cin >> n;
	
	set<int> paper;
	int a;
	
	for(int i = 0; i < n; i++){
		cin >> a;
		set<int>::iterator it = paper.find(a);
		if(it == paper.end()){
			paper.insert(a);
		}else{
			paper.erase(it);
		}
	}
	
	cout << paper.size() << endl;
	
	return 0;
}

Measured memory_bytes: 4864
n = int(input())
a = [int(i) for i in input().split()]

max_a = max(a)
flag = [True for i in range(max_a+1)]

dup = set()
for i in range(n):
    if a[i] in dup:
        flag[a[i]] = False
    else:
        dup.add(a[i])
    for j in range(2*a[i], max_a+1, a[i]):
        flag[j] = False

ans = 0
for i in a:
    ans += flag[i]
print(ans)

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

int main(){
    int k;
    string s;
    cin >> k >> s;
    if((int)s.length() <= k){
        cout << s;
    }else{
        rep(i, k){
            cout << s.at(i);
        }
        cout << "...";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	int h,w;
	cin>>h>>w;
	
	int a,b;
	cin>>a>>b;
	
	cout<<(h-a)*(w-b)<<endl;
}

Measured memory_bytes: 256
use std::collections::BinaryHeap;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let (_, m) = (input[0], input[1]);
    let mut bh = BinaryHeap::new();

    let ax = read_vec::<usize>();
    for a in ax {
        bh.push(a);
    }

    for _ in 0..m {
        if let Some(x) = bh.pop() {
            bh.push(x/2);
        }
    }

    let ans: usize = bh.into_iter().sum();

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

Measured memory_bytes: 9464
#include<bits/stdc++.h>
//typedef long long int ll;
using namespace std;
using ll = long long;
using ld = long double;
using Vc = vector <char>;
using Vs = vector <string>;
using Vll = vector <ll>;
using Vi = vector <int>;
using Sll = set <ll>;
using Ss = set <string>;
using Sc = set <char>;
using Si = set <int>;
using MiVi = map<int,Vi>;
using MllVll = map<ll,Vll>;
using Mllll = map<ll,ll>;
using Mii = map<int,int>;
using MllSll = map<ll,Sll>;
using Mlls = map<ll,string>;
using Pllll = pair<ll,ll>;
using Pii = pair<int,int>;
 
 
#define nl cout<<endl
#define ns cout<<" "
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define forAuto(i,x) for(auto i: x)
#define forRange(i,l,h) for(int i=l;i<h;i++)
#define all(x) x.begin(),x.end()
#define append push_back
 
 
template<class T>
T gcd(T a,T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll bigmod(ll a, ll b, ll c)
{
    if(b==0) return 1;
    
    if(b%2==0)
    {
        ll x=bigmod(a,b/2,c);
        return (x*x)%c;
    }
    else return (a%c * bigmod(a,b-1,c))%c;
}
 
void vsInput()
{
    #ifndef ONLINE_JUDGE
         freopen("input.txt","r",stdin);
         freopen("output.txt","w",stdout);
    #endif // ONLINE_JUDGE
}
template<class T1,class T2>
T2 sum(T1 a,T2 ans){ans=0;forAuto(i,a)ans+=i;return ans;}
 
template<class T>
void printC(T a){forAuto(i,a)cout<<i<<" ";cout<<endl;}
 
template<class T1,class T2>
void printP(pair<T1,T2> i){cout<<"{"<<i.first<<",";cout<<i.second<<"} ";}
 
template<class T1,class T2>
void printG(map<T1,T2> a){forAuto(i,a){cout<<i.first<<" -> ";printC(i.second);}}
 
template<class T1,class T2>
void printWG(map<T1,T2> a){forAuto(i,a){cout<<i.first<<" -> ";forAuto(j,i.second)printP(j);nl;}}
 
void value() {}
template <class T1, class... T2>
void value(T1& var1, T2&... var2) { cin>>var1; value(var2...); }
 
void print() {}
template <class T1, class... T2>
constexpr void print(const T1& var1, const T2& ... var2) { cout<<var1;ns; print(var2...); }
 
 
template<class T1,class T2>
void printM(map<T1,T2> a){forAuto(i,a){cout<<i.first<<" -> ";cout<<i.second; nl;}}
 
Vll Vinput(ll n){Vll a;forRange(i,0,n){ll x;cin>>x;a.append(x);}return a;}
 
bool cmp(const ll &a, const ll &b)
{ return a<b; }
 
 
#define CPN 700007
#define M 1000000007
const int inf=1e18+5;
 
 
//----------------------------CODE----------------------------//
 
 
 
void code()
{
    ll n;cin>>n;
    Vll height(n);
    
    forRange(i,0,n)
    cin>>height[i];
    
    ll dp[n];
    
    
    dp[0]=0;
    dp[1]=abs(height[1]-height[0]);
    
    forRange(i,2,n)
    {
        ll ans1=dp[i-1] + abs(height[i-1]-height[i]);
        ll ans2=dp[i-2] + abs(height[i-2]-height[i]);
        
        dp[i]=min(ans1,ans2);
        
    }
    
    print(dp[n-1]);
    nl;
    
}
 
 
 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
//--------------------------------END-----------------------------//
int main()
{
    fast;
    ll t=1;
    //vsInput();
    
    
    cout << fixed << setprecision(10);
    //cin>>t;
    
    
    while(t) {
        t--;
        code();
    }
 
    return 0;
}


Measured memory_bytes: 4728
import sys
MOD=10**9+7
def solve(N:int,K:int,A:list)->int:
    #dp[i][j]:=i人目までの子供にj個の飴を配る場合の数
    dp=[[0]*(K+1) for i in range(N+1)]
    for i in range(N):dp[i][0]=1
    sum=[0]*(K+2)
    for i in range(N):
        for j in range(K+1):#累積和
            sum[j+1]=(sum[j]+dp[i][j])%MOD
        for j in range(K+1):
            dp[i+1][j]=(sum[j+1]-sum[max(0,j-A[i])]+MOD)%MOD
            dp[i+1][j]%=MOD
    return dp[N][K]
def main(lines):
    N,K=map(int,lines[0].split())
    A=list(map(int,lines[1].split()))
    print(solve(N,K,A))
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)


Measured memory_bytes: 120176
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n;
    scanf("%d", &n);
    lld a[n], b[n];
    rep(i, 0, n){
        scanf("%lld", &a[i]);
    }
    rep(i, 0, n){
        scanf("%lld", &b[i]);
    }
    lld cnt_a = 0, cnt_b = 0;
    rep(i, 0, n){
        if(a[i] < b[i]){
            lld buf = (b[i] - a[i] + 1) / 2;
            a[i] += buf * 2;
            cnt_b += buf;
        }
    }
    rep(i, 0, n){
        if(b[i] < a[i]){
            cnt_b -= a[i] - b[i];
        }
    }
    if(cnt_b >= 0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
 
bool used[110];

bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
	return a.first * a.first + a.second * a.second > b.first*b.first + b.second * b.second;
}
 
void solve(int n) {
	vector<pair<int, int>>p(n), q(n);
	for (int i = 0;i < n;i++) {
		cin >> p[i].first >> p[i].second;
	}
	for (int i = 0;i < n;i++) {
		cin >> q[i].first >> q[i].second;
	}
	int ans = 0;
	sort(q.begin(), q.end());
	for (int i = 0;i < n;i++) {
		int dist = -1;
		int flag = 0;
		for (int j = 0;j < n;j++) {
			if (!used[j]) {
				int x = q[i].first - p[j].first;
				int y = q[i].second - p[j].second;
				if ((x > 0) && (y > 0) && p[j].second > dist) {
					dist = p[j].second;
					flag = j;
				}
			}
		}
		if (dist > -1) {
			ans++;
			used[flag]=true;
		}
	}
	cout << ans << endl;
}
	
int main(void){
	int n;
	cin >> n;
	solve(n);
	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    map<string,int> m;
	string s;
	int n,res=1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		auto it=m.find(s);
		if( it == m.end() ) m[s]=1;
		else m[s]++,res=max(res,m[s]);
	}
	for(auto v:m)
	{
		if(v.second == res)
			cout<<v.first<<"\n";
	}
    return 0;
}


Measured memory_bytes: 23808
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a, const void *b){
    return *(const int *)a - *(const int *)b;
}

int main(void){
    int N,i,j;
    scanf("%d",&N);
    int S[N];
    for (i=0;i<N;i++){
        scanf("%d",&S[i]);
            }
    qsort(S,N,sizeof(int),cmp);
    
    int cnt=0;
    for (j=0;j<N;j++){
        if(S[j]==S[j+1]){
            j++;
        }
        else{
            cnt++;
        }
    }
    
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
using namespace std;
const int N = 1e5 + 9;
int a[N << 1], f[N << 1], n;
bool check(int x){
    int sum = 0;
    for(int i = 1; i < 2*n; i++) f[i] = a[i] >= x, sum += f[i];
    for(int i = n-1; i >= 1; i--){
        int xx = 2*n-i;
        if(f[xx] == f[xx - 1]) return f[xx]; 
        if(f[i] == f[i+1]) return f[i]; 
    }
    return sum >= n;
}
int erfen(int l, int r){
    while(l < r){
        int mid = (l + r + 1) / 2;
        if(check(mid)) l = mid;
        else r = mid - 1;
    }
    return l;
}
int main(){
    scanf("%d", &n);
    for(int i = 1; i < 2*n; i++) scanf("%d", &a[i]);
    printf("%d", erfen(1, 2*n-1));
    return 0;
}

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

struct K
{
    long long int a,b;
} Katana[100010];

bool comp(K x,K y)
{
    return x.b<y.b;
}

int main()
{
    ios::sync_with_stdio(false);
    long long int n,h;
    while(cin>>n>>h)
    {
        long long int sum=0;
        long long int ans=0;
        long long int maxn=0;
        for(int i=0; i<n; i++)
        {
            cin>>Katana[i].a>>Katana[i].b;
        }
        sort(Katana,Katana+n,comp);
        for(int i=0; i<n; i++)
        {
            if(maxn<Katana[i].a)
            {
                maxn=Katana[i].a;
            }
        }
        for(int i=n-1;i>=0;i--)
        {
            if(Katana[i].b>maxn&&h>0)
            {
                h-=Katana[i].b;
                ans+=1;
            }
        }
        if(h>0)
        {
            ans+=ceil(1.0*h/maxn);
            cout<<ans<<endl;
        }
        else
        {
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

using namespace std;

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  
  bool isOK = true;
  
	if(!(A==B && B == C && A == C))isOK = false;
  
  if(isOK){
  	cout<<"Yes";
  }else{
  	cout<<"No";
  }
  return 0;
}


Measured memory_bytes: 256
gets.to_i.times do
  a = gets.chomp.split(//).reverse
  b = gets.chomp.split(//).reverse
  if a.length > 80 or b.length > 80
    puts "overflow"
  else
    a.push(*Array.new(80 - a.length,0))
    b.push(*Array.new(80 - b.length,0))
    result = []
    temp = 0
    80.times do |i|
      result.unshift((a[i].to_i + b[i].to_i + temp) % 10)
      temp = ((a[i].to_i + b[i].to_i + temp) / 10)
    end
    if temp == 0
      puts result.join.to_i
    else
      puts "overflow"
    end
  end
end

Measured memory_bytes: 6132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
int main()
{
   fast ;
   /*ll n,k ;
   cin>>n>>k ;
   vector<ll>a(n) ;
   for(ll i=0;i<n;i++)
    cin>>a[i] ;


    sort(all(a)) ;

   ll lo=-1e18 ;
   ll hi=1e18 ;
   ll mx=lo ;
   while(lo<=hi)
   {
       ll mi=(lo+hi)/2 ;
       ll num=0 ;
       for(ll i=0;i<n;i++)
       {

       }

   }
   */
   ll n ;
   cin>>n ;
   map<string,ll>ma ;
   ll mx=0 ;
   for(ll i=0;i<n;i++)
   {
       string s ;
       cin>>s  ;
       ma[s]++ ;
       mx=max(mx,ma[s]) ;

   }
   vector<string>ans ;
   for(auto it:ma)
   {
       if(it.ss==mx)
       {
           ans.pb(it.ff) ;
       }
   }
   sort(all(ans)) ;
   for(string s:ans)
    cout<<s<<endl ;




}


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

int main() {
  double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
  while(cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
    double a,b,c,d;
    if(xa2>xb2) a=xb2;
    else a=xa2;
    if(xa1>xb1) b=xa1;
    else b=xb1;
    if(ya2>yb2) c=yb2;
    else c=ya2;
    if(ya1>yb1) d=ya1;
    else d=yb1;
    
    if(a<b || c<d) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion



int n, p;

string s;
void solve()
{
    cin>>n>>p>>s;
    int ans = 0;
    if (p == 2)
    {
        forn(i, n)
        {
            if ((s[i] - '0')%2 == 0) ans += i+1;
        }
        cout << ans << '\n';
        return;
    }
    if (p == 5)
    {
        forn(i, n)
        {
            if ((s[i] - '0')%5==0) ans += i+1;
        }
        cout << ans << '\n';
        return;
    }
    map<int,int> cnt;
    cnt[0] = 1;
    int now = 0;
    int p2 = 1;
    for(int i=n-1;i>=0;--i)
    {
        now = (now + (s[i] - '0')*p2)%p;
        p2 = p2*10%p;
        ans += cnt[now];
        cnt[now]++;
    }
    cout << ans << '\n';
}

signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    //cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 4116
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n; cin>>n; 
	ll arr[n]; ll sum=0;
	for(int i=0;i<n;i++)
	cin>>arr[i];
	for(int i=0;i<n-1;i++)
	{
		if(arr[i+1]<arr[i])
		{
			sum+=(arr[i]-arr[i+1]); arr[i+1]=arr[i];
			
		}
	}
	cout<<sum<<endl;
	
		
	

  return 0;

}

    






Measured memory_bytes: 5124
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)
	W := make([]int, N)
	sum := 0
	for i := 0; i < N; i++ {
		fmt.Scan(&W[i])
		sum += W[i]
	}

	ans := sum
	p := 0
	for i := 0; i < N; i++ {
		p += W[i]
		ans = int(math.Min(
			float64(ans),
			math.Abs(float64(p-(sum-p))),
		))
	}
	fmt.Println(ans)
}


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

typedef long long int ll;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")
#pragma GCC optimize ("-fno-defer-pop")
ll mod = (1e9)+7;
ll n,m;
map <ll,ll> mp;
ll dp[100005];
ll solve(ll id)
{

    if(id>n)return 0;
    if(id==n)return 1;

    if(dp[id]==-1)
    {

        if(mp[id]==1){
            return 0;
        }

        dp[id] = (solve(id+1)+solve(id+2))%mod;

    }

    return dp[id]%mod;
}

int main()

{

    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>n>>m;

    for(ll i=0;i<m;i++)
    {
        ll x;
        cin>>x;
        mp[x]++;
    }

    cout<<solve(0)%mod<<endl;




}










Measured memory_bytes: 12032
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
A = np.array(read().split(),np.int64)

A -= np.arange(1,N+1)

# Aの中央値

A.sort()
x = A[N//2]
answer = np.abs(A-x).sum()
print(answer)

Measured memory_bytes: 25036
#include<stdio.h>
#include<string.h>

int lcs(char x[], char y[]){
  int m,n;
  int i,j;
  int c[1001][1001];

  m = strlen(x);
  n = strlen(y);

  for(i=0;i<=m;i++) c[i][0] = 0;
  for(j=0;j<=n;j++) c[0][j] = 0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1]==y[j-1]) c[i][j] = c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1]) c[i][j] = c[i-1][j];
      else c[i][j] = c[i][j-1];
    }
  }
  return c[m][n];
}

int main(){
  int q,i;
  char x[1000],y[1000];

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s",x);
    scanf("%s",y);
    printf("%d\n",lcs(x,y));
  }


  return 0;
}


Measured memory_bytes: 5628
#include <iostream>

using namespace std;

int main(){
  int n,x;
  int ans = 0;

  while(1){
    ans = 0;
    cin >> n >> x;

    if( n == 0 && x == 0){
      break;
    }
    for( int i = 1; i <= n; ++i){
      for( int j = i+1; j <= n; ++j){
        for( int k = j+1; k <= n; ++k){
          if( x == i+j+k) ++ans;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
int n,a,b,ans,p,v[10002],v1[10002],pw[200002];
char s[200002];
signed main(){
	scanf("%lld%lld%s",&n,&p,s+1);
	v[0]=1;
	if(p==2){
		for(re int i=1;i<=n;++i){
			if((s[i]-'0')&1)continue;
			ans+=i;
		}
		printf("%lld",ans);
	}
	else if(p==5){
		for(re int i=1;i<=n;++i){
			if((s[i]-'0')%5)continue;
			ans+=i;
		}
		printf("%lld",ans);
	}
	else{
		pw[0]=1;
	for(re int i=1;i<=n;++i)pw[i]=pw[i-1]*10%p;
	for(re int i=n;i;--i){
		a+=(s[i]-48)*pw[n-i];
		a%=p;
		ans+=v[a];
		++v[a];
	}
	printf("%lld",ans);	}
}


Measured memory_bytes: 2048
S = input()

count = 0
max_len = 0
for i in range(len(S)):
  if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
    count += 1
  else:
    max_len = max([max_len, count])
    count = 0
    
max_len = max([max_len, count])
print(max_len)

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

using namespace std;

int main(){
    string s;
    int ans = 0;
    cin >> s;
    for (int i = 0; i < 4; i++){
        if (s[i] == '-')
            ans--;
        else 
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 998244353; //1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+2;

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

      int n,k,s;
      cin>>n>>k>>s;
      for(int i=0;i<k;i++)
      {
      	cout<<s<<" ";
      }
      if(s==1e9)
      {
      	for(int i=k;i<n;i++) cout<<"1 ";
      }
 	else{
 		for(int i=k;i<n;i++) cout<<1000000000<<" ";
 	}
}
// h*k>=n
// I never lose. I either win or I learn

Measured memory_bytes: 1280
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a + b < 10) {
		cout << a + b << endl;
	}
	else {
		cout << "error" << endl;
	}
	return 0;
}



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


using ll = long long int;

/// <summary>
/// GCDを計算します
/// </summary>
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
	if (a < b) {
		NumType tmp = a;
		a = b;
		b = tmp;
	}

	NumType r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

/// <summary>
/// 約数を数えます
/// </summary>
template <typename NumType>
NumType cntDivisor(const NumType& num) {
	NumType cnt = 0;
	for (NumType i = 1; i * i <= num; ++i) {
		if (num % i == 0) {
			cnt++;
			if (i * i != num) cnt++;
		}
	}

	return cnt;
}

/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < end; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"


///////////////////////////////////////////////////////////////////////////


int main() {
	// 入出力を早くするための魔法の言葉
	cin.tie(0);ios::sync_with_stdio(false);

	ll X, A;
	cin >> X >> A;

	if (X < A) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}
}

Measured memory_bytes: 256
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

ab = na()
ab.append(ab[0] + ab[1])

flag = False
for i in range(3):
    if ab[i] % 3 == 0:
        flag = True

if flag:
    print("Possible")
else:
    print("Impossible")

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] Array = new int[n];
		int k = sc.nextInt();
		int count=0;
		for(int i = 0; i < n; i++) {
			Array[i] = sc.nextInt();
			if(Array[i]>=k) {
				count++;
			}
			
		}
		System.out.println(count);

	}

}


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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    string S;

    cin >> S;

    int ans = S.length() + 1;

    for(int i = 0; i <= 1; i++) {
        int m = 0;
        for(int j = 0; j < S.length(); j++) {
            if(int(S[j]) - 48 == (i + j) % 2) {
                m++;
            }
        }
        if(ans > m) {
            ans = m;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int x = sc.nextInt();
	int a = sc.nextInt();
	int b = sc.nextInt();
	sc.close();
	
	if(Math.abs(a - x) < Math.abs(b - x)) {
		System.out.println("A");
	}else {
		System.out.println("B");
	}
}
}


Measured memory_bytes: 21972
#include <stdio.h>

class Dice4{
public:
	int number[6];

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isSameDice(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < 24; i++){
			roll(order[i]);
			for(int j = 0; j < 6; j++){
				if(inputed[j] != number[j])
					break;
				if(j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

};

int main(){
	int n,k,j;
	scanf("%d",&n);
	Dice4 array[n];
	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d %d %d",&array[i].number[0],&array[i].number[1],&array[i].number[2],
				&array[i].number[3],&array[i].number[4],&array[i].number[5]);
	}
	for(k = 0; k < n-1; k++){
		for(j = k+1; j < n; j++){
			if(array[k].isSameDice(array[j].number))
				break;
		}
		if(j < n) break;
	}
	if(k == n-1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}





Measured memory_bytes: 2700
import java.util.*;
import static java.lang.System.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    long N = sc.nextLong();
    long M = sc.nextLong();
    long ans;
    if(N > M){
      long tmp = N;
      N = M;
      M = tmp;
    }
    if(N == 1){
      if(M == 1) ans = 1;
      else ans = M - 2;
    }else{
      ans = (N-2) * (M - 2);
    }
    out.println(ans);
  }

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

Measured memory_bytes: 21844
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

#include <cassert>
#include <iosfwd>

using namespace std;
using large = long long;

template <int M> class ModularInteger {
    static_assert(M >= 2);

public:
    static constexpr int modulus = M;

    ModularInteger(long long x = 0) : value(x % M) {}

    ModularInteger& operator+=(const ModularInteger& Mi) noexcept {
        value += Mi.value;
        auto x = value - M;
        if (x >= 0)
            value = x;
        return *this;
    }

    ModularInteger& operator-=(const ModularInteger& Mi) noexcept {
        value -= Mi.value;
        if (value < 0)
            value += M;
        return *this;
    }

    ModularInteger& operator*=(const ModularInteger& Mi) noexcept {
        value = large{value} * large{Mi.value} % M;
        return *this;
    }

    friend std::ostream& operator<<(std::ostream& stream, const ModularInteger& Mi) { return (stream << Mi.value); }

    friend std::istream& operator>>(std::istream& stream, ModularInteger& Mi) {
        long long v = 0;
        stream >> v;
        v %= M;
        Mi.value = (v < 0 ? v + M : v);
        return stream;
    }

    friend constexpr long long unwrap(ModularInteger Mi) noexcept { return Mi.value; }

    friend constexpr ModularInteger operator*(ModularInteger a, ModularInteger b) { return a *= b; }

private:
    long long value = 0;
};

template <int M> class Modular {
    static_assert(M >= 2);

public:
    static constexpr int modulus = M;
    using IntegerType = ModularInteger<M>;

    static long long power(long long base, long long exp) noexcept {
        assert(0 <= base && base < M);
        assert(0 <= exp && exp < M);
        if (exp == 0)
            return 1;
        if (exp == 1)
            return base;

        auto p = power(base * base % M, exp / 2);
        if (exp % 2 == 1) {
            p *= base;
            p %= M;
        }
        return p;
    }
    static long long inverse(long long x) noexcept { return power(x, M - 2); }
};

using mod = Modular<1'000'000'007>;
using modint = mod::IntegerType;

int main() {
    large n, a, b;
    cin >> n >> a >> b;

    auto cases = modint(mod::power(2, n) - 1);

    assert(0 < a);
    assert(a < b);
    assert(b <= n);

    const auto C = [](large n, large k) {
        auto num = modint(1);
        auto den = modint(1);
        for (auto i = 0; i < k; ++i) {
            num *= (n - i);
            den *= (k - i);
        }
        auto c = num;
        c *= mod::inverse(unwrap(den));
        return c;
    };
    cases -= C(n, a);
    cases -= C(n, b);

    cout << cases << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int x;
	cin >> x;
	int cnt=x/100;
	x%=100;
	cout << (x<=cnt*5 ? 1:0) << endl;





}


Measured memory_bytes: 256
io = STDIN
nn=io.gets.to_i
s=Hash.new{|h,k|h[k]=0}
nn.times do
  ch=io.gets.chomp[0]
  s[ch]+=1 if ch =~/[MARCH]/
end
ss=s.values
if ss.size<3
  puts 0
else
  ans=0
  n=ss.size
  ss.combination(3) do |cm|
    ans+=cm.inject(:*)
  end
  puts ans
end


Measured memory_bytes: 2300
#include <stdio.h>

void getFA(int *src, int *dst, int n){
  for (int i=0; i<n; i++){
    int cnt=0;
    for (int j=0; j<n; j++){
      if (src[i]==src[j]) cnt++;
    }
    dst[i] = cnt;
  }
}

#define N 12

int main(void){
  int n;
  int cnt;
  int a[N],b[N];
  bool modified;

  while (scanf("%d",&n), n){
    for (int i=0; i<n; i++){
      scanf("%d",&a[i]);
    }
    cnt = 0;
    while (true){
      modified = false;
      getFA(a,b,n);
      for (int i=0; i<n; i++){
	if (a[i]!=b[i]) modified = true;
	a[i] = b[i];
      }
      if (modified){
	cnt++;
      } else {
	break;
      }
    }
    printf("%d\n", cnt);
    for (int i=0; i<n-1; i++){
      printf("%d ",b[i]);
    }
    printf("%d\n", b[n-1]);
  }

  return 0;
}

Measured memory_bytes: 2592
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        char c ='a';
                char pre='a';
        for(int i = 0; i<4; i++) {
            pre = c;
            c = n.charAt(i);
            if(pre == c) {
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");
    }
}

Measured memory_bytes: 22612
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int r = s[0];
            int D = s[1];
            int x = s[2];

            long n = r * x - D;
            WriteLine(n);
            for (int i = 0; i < 9; i++)
            {
                WriteLine(r * n - D);
                n = r * n - D;
            }

        }
    }
}


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

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

  string ans = "-1 -1 -1";
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N - i; ++j) {
      if (10000 * i + 5000 * j + 1000 * (N-i-j) == Y) {
        ans = to_string(i) + ' ' + to_string(j) + ' ' + to_string(N-i-j);
        goto LOOPEND;
      }
    }
  }

LOOPEND:

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define ull unsigned ll
#define FORR(i, a, b)   for(ll i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define MOD1 1000000007
#define MOD2 998244353
#define F first
#define S second
#define IOS std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define dbg(x) cout<<#x<<" = "<<x<<"\n";
#define print(a) for(auto x : a)    cout<<x<<" "; cout<<"\n";
using namespace std;
 
void OFFLINE(){
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    #endif
}
 
int main(){
 
    IOS;
    // OFFLINE();
    //check for corner test cases
    
    int n;
    cin >> n;
    map<string, int> M;

    string s;
    for(int i = 0; i < n; i++)
        cin >> s, M[s]++;
    cout<<"AC x "<<M["AC"]<<"\n";
    cout<<"WA x "<<M["WA"]<<"\n";
    cout<<"TLE x "<<M["TLE"]<<"\n";
    cout<<"RE x "<<M["RE"]<<"\n";
 
    //check for corner test cases
    return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&a!=c){
    cout<<"Yes"<<endl;
  }
  else if(a==c&&a!=b){
    cout<<"Yes"<<endl;
  }
  else if(b==c&&a!=c){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;

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

typedef ll _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    ll ans = 0;

    FOR(i,1,n+1){
        if(!(i%3==0 || i%5==0)) ans += i;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  queue<ll> que, que2;
  
  if(n >= 357){
    que.push(3);
    que.push(5);
    que.push(7);
  } else {
    cout << 0 << endl;
    return 0;
  }
  while(true){
    ll tmp = que.front();
    que2.push(tmp);
    que.pop();
    if(tmp * 10 + 3 <= n) {
      que.push(tmp * 10 + 3);
    }else{
      break;
    }
    if(tmp * 10 + 5 <= n){
      que.push(tmp * 10 + 5);
    }else{
      break;
    }
    if(tmp * 10 + 7 <= n){
      que.push(tmp * 10 + 7);
    }else{
      break;
    }
  }
  int cnt = 0;
  while(!que2.empty()){
    que.push(que2.front());
    que2.pop();
  }
  while(!que.empty()) {
    ll tmp = que.front();
    que.pop();
    bool three = false, five = false, seven = false;
    while(tmp > 0){
      if(tmp % 10  == 3){
        three = true;
      }else if(tmp % 10 == 5){
        five = true;
      }else if(tmp % 10 == 7){
        seven = true;
      }
      tmp /= 10;
      if(three && five && seven){
        cnt++;
        break;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  string s; cin >> s;
  rep(i,5){
    cout << s[i];
  }
  cout << " ";
  rep(i,7){
    cout << s[i+6];
  }
  cout << " ";
  rep(i,5){
    cout << s[i+14];
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

struct Point {
    ll x, y;
};

int main(){
    int n, K;
    cin >> n >> K;
    vector<Point> point(n);
    vector<ll> x(n), y(n);

    rep(i, n){
        cin >> x[i] >> y[i];
        point[i] = {x[i], y[i]};
    }

    sort(all(x));
    sort(all(y));

    ll ans = (x[n-1] - x[0]) * (y[n-1] - y[0]);

    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=0; k<n; k++){
                for(int l=k+1; l<n; l++){
                    int cnt = 0;
                    rep(idx, n){
                        ll xi = point[idx].x;
                        ll yi = point[idx].y;
                        if(x[i] <= xi && xi <= x[j] && y[k] <= yi && yi <= y[l]) cnt++;
                    }
                    ll s = abs(x[i] - x[j]) * abs(y[k] - y[l]);
                    if(cnt >= K){
                        ans = min(ans, s);
                    } 
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String line = sc.nextLine();
        
        if(line.contains("7")) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
        
    }
}

Measured memory_bytes: 27000
#include<iostream>
int main()
{
	int num[4][3][10];
	for(int b = 0; b < 4; b++)
	{
		for(int f = 0; f < 3; f++)
		{
			for(int r = 0; r < 10; r++)
			{
				num[b][f][r] = 0;
			}
		}
	}
	int info;
	std::cin >> info;
	for(int i = 0; i < info; i++)
	{
		int b, f, r, v;
		std::cin >> b >> f >> r >> v;
		num[b - 1][f - 1][r - 1] += v;
	}
	for(int b = 0; b < 4; b++)
	{
		for(int f = 0; f < 3; f++)
		{
			for(int r = 0; r < 10; r++)
			{
				std::cout << ' ' << num[b][f][r];
			}
			std::cout << std::endl;
		}
		if(b != 3)
		{
			std::cout << "####################" << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3076
N, K = map(int,input().split())
A = list(map(int,input().split()))

ans = 10**18
for bit in range(1<<N):
    highest, cost, cnt = 0, 0, 0
    for i in range(N):
        if bit>>i & 1:
            if A[i] <= highest:
                cost += highest-A[i]+1
                highest += 1
            else:
                highest = max(highest,A[i])
            cnt += 1
        else:
            highest = max(highest,A[i])
    if cnt >= K:
        ans = min(ans, cost)

print(ans)


Measured memory_bytes: 73056
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int n;
// vector< vector< pair<int, int> > > G;
bool fin = false;
    vector<int> flag(n, 0);
    vector<int> res(n, 0);

using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;
Graph G;
int dfs(int v, int p, int c){
    res[v] = c;
    for(auto i : G[v]){
        if(i.first == p) continue;
        if(i.second & 1) dfs(i.first, v, 1-c);
        else dfs(i.first, v, c);
    }
}

int main(int argc, char *argv[]){
    cin >> n;
    // rep(i, n) flag[i] = 0;
    G.assign(n, vector<Edge>());
    rep(i, n - 1){
int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    // rec(flag, 0);
    // cout << int(false) << endl;
    res.assign(n, 0);
    dfs(0, -1, 1);
    for(auto i : res) cout << i << endl;
    return 0;
}




// void pri(vector<int> flag){
//     rep(i, n){ cout << flag[i] << endl;}
//     fin = true;
// }

// // i番目の頂点
// void rec(vector<int> flag, int i){
//     if(i == n){
//         pri(flag);
//         return;
//     }
//     if(fin == true) return;
//     rep(j, n){
//         if(i == j) continue;
//         if(G[i][j] != 0){
//             if(G[i][j] % 2 == 0){
//                 flag[i] = flag[j] = 1;
//             }
//         }
//     }
//     rec(flag, i + 1);
// }

Measured memory_bytes: 8960
#include<stdio.h>
#include<string.h>

int jin[15][15],n,i,j,x,y;

int main(){
	while(0<=scanf("%d",&n)){
		if(n==0)break;
		memset(jin,0,sizeof(jin));
		for(i=1;i<=n*n;i++){
			if(i==1){
				jin[n/2][n/2+1]=i;
				x=n/2+100*n;
				y=n/2+1+100*n;
				continue;
			}
			++x;
			++y;
			if(jin[(x)%n][(y)%n]==0){
				jin[(x)%n][y%n]=i;
				continue;
			}
			
			j=1;
			while(j){
				--x;
				++y;
				if(jin[x%n][y%n]==0){
					jin[x%n][y%n]=i;
					j=0;
				}
			}
		}
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				printf("%4d",jin[j][i]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
const int INF = 1e18, MOD = 1e9 + 7;
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
signed main() {
    INCANT;
    int n, k, cnt = 1, res = 0, mass = 0;
    cin>>n>>k;
    while(n>=0){
        if((mass + cnt - 1)/ cnt <= k){
            mass += cnt;
            n -= cnt;
            res++;
        }else{
            cnt++;
        }
    }
    cout<<--res<<endl;
}



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

int main(void){
  int A, B, N, MAX, MIN, tmp;
  cin >> N >> A >> B;
  
  MAX = min(A, B);
  
  tmp = A + B - N;
  if(tmp > 0){
    MIN = tmp;
  }
  else{
    MIN = 0;
  }
  cout << MAX << " " << MIN << endl;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    if(k == 7 or k == 1) {
        cout << 1 << endl;
        return 0;
    }
    int now = 1;
    if(k % 7 == 0) k /= 7;
    rep(i, k<<1) {
        if(now == 0) {
            cout << i+1 << endl;
            return 0;
        }
        now *= 10;
        now += 1;
        now %= k;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace _1_A
//{
class Program
{
    static void Main(string[] args)
    {
        string a = Console.ReadLine();
        string[] array = a.Split(' ');

        int w = int.Parse(array[0]);
        int h = int.Parse(array[1]);
        int x = int.Parse(array[2]);
        int y = int.Parse(array[3]);
        int r = int.Parse(array[4]);

        if (x - r < 0 || y - r < 0)
            Console.WriteLine("No");
        else if (x + r > w || y + r > h)
            Console.WriteLine("No");
        else
            Console.WriteLine("Yes");

        //Console.Read();
    }
}
//}

Measured memory_bytes: 8952
#include <iostream>

using namespace std;

int main(){
	string s;
	int k;
	
	cin >> s >> k;
	
	for(int i = 0;i < s.size()-1;i++){
		int n = (26-(s[i]-'a'))%26;
		if(n <= k){
			k -= n;
			cout << 'a';
		}else{
			cout << s[i];
		}
	}
	cout << (char)(((s[s.size()-1] - 'a') + k%26)%26 + 'a') << endl;
	
	return 0;
}

Measured memory_bytes: 512
abc = list(map(int,input().split()))
guki = [abc[0] % 2,abc[1] % 2,abc[2] % 2]
cnt_gusu = 0
cnt = 0
for i in abc:
    if i % 2 == 0:
        cnt_gusu += 1
if cnt_gusu == 2:
    cnt += 1
    for i in range(3):
        if abc[i] % 2 == 0:
            abc[i] += 1
elif cnt_gusu == 1:
    cnt += 1
    for i in range(3):
        if abc[i] % 2 == 1:
            abc[i] += 1
set_abc = set(abc)
abc.sort()
if len(set_abc) == 1:
    print(cnt)
elif len(set_abc) == 2:
    maxv = max(abc)
    jud = 0
    for i in abc:
        if i == maxv:
            jud += 1
    if jud == 2:
        cnt += (abc[2] - abc[0]) // 2
    else:
        cnt += (abc[2] - abc[0])
    print(cnt)
else:
    zouka = abc[2] - abc[1]
    cnt += zouka + ((abc[2] - (abc[0]+zouka) ) // 2)
    print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>

int main(){
	std::string s;
	std::cin >> s;
	// std::cout << s[0] << std::endl;
	// std::cout << s.length() << std::endl;

	int c;
	for(int i; i<= s.length(); i++){
		if( s[i] == '1')	c++;
	}

	std::cout << c << std::endl;
}

Measured memory_bytes: 256