akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static Scanner scanner = new Scanner();
    static int mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int m1 = scanner.nextInt();
        int d1 = scanner.nextInt();
        int m2 = scanner.nextInt();
        int d2 = scanner.nextInt();
        System.out.println(m2 - m1);
    }

    public static void main(String[]$) {
        try {
            new Main().solve();
            System.out.flush();
        } catch (Throwable t) {
            System.out.flush();
            t.printStackTrace();
        }
    }
}

class System {
    static PrintWriter out = new PrintWriter(java.lang.System.out);

    static void exit() {
        java.lang.System.exit(0);
    }
}

class Scanner {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}


Measured memory_bytes: 23252
#include<vector>
#include<algorithm>

std::vector<int> primeNumbers = {2, 3};
std::vector<bool> isPrime;

void eratosthenes(int n){
    int i, j;
    int s = 4;

    isPrime.assign(std::max(n + 1, 2), true);
    isPrime[0] = false;
    isPrime[1] = false;

    for(i = 4 ; i <= n ; i += 2){
        isPrime[i] = false;
    }
    for(i = 9 ; i <= n ; i += 6){
        isPrime[i] = false;
    }

    for(i = 5 ; i * i <= n ; i += s){
        if(isPrime[i]){
            primeNumbers.emplace_back(i);
            for(j = i * i ; j <= n ; j += i){
                isPrime[j] = false;
            }
        }
        s ^= 6;
    }
    for( ; i <= n ; i += s){
        if(isPrime[i]){
            primeNumbers.emplace_back(i);
        }
        s ^= 6;
    }

    return;
}

#include<iostream>
using namespace std;

#define N 100000

int main(){
    eratosthenes(N);

    vector<int> sum(N + 1, 0);
    for(int i = 1 ; i <= N ; ++i){
        if(isPrime[i] && isPrime[(i + 1) / 2]){
            ++sum[i];
        }
        sum[i] += sum[i - 1];
    }

    int q;
    cin >> q;

    while(q--){
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << endl;
    }

    return 0;
}

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

int main() {
	int n,m;
	cin >> n;
	vector<int> a;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin >>m;
			a.push_back(m);
		}
		sort(a.begin(),a.end());
		bool ans=(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]);
		if(ans)
		cout <<"YES" << endl;
		else
		cout <<"NO" << endl;
		a.clear();
	}
 	return 0;
}

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

using ll = long long;

ll n, s;

ll calc(ll n, ll mid){
	ll sum = 0;
	ll tmp = n;
	while(tmp){
		sum += tmp % mid;
		tmp /= mid;
	}
	return sum;
}

int main(){
	cin >> n >> s;
	if(n < s){
		cout << -1 << '\n';
		return 0;
	}

	if(n == s){
		cout << n + 1 << '\n';
		return 0;
	}
	ll tmp = n - s;
	ll ans = 1e12;
	
	for(ll i = 2; (i - 1) * (i - 1) <= tmp; i ++){
		if(tmp % (i - 1)) continue;
		ll ret = calc(n, i);
		if(ret == s){
			ans = min(ans, i);
		}
		
		ll d = tmp / (i - 1);
		ret = calc(n, d + 1);
		if(ret == s){
			ans = min(ans, d + 1);
		}
	}
	
	if(calc(n, tmp + 1) == s){
		ans = min(ans, tmp + 1);
	}
	if(ans == 1e12) cout << -1 << '\n';
	else cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
int main()
{
ios_base::sync_with_stdio(false);
cout.tie(NULL);
cin.tie(NULL);
              ll i,j,n,m,coun=0,flag,x,y;
  cin>>n>>m;
  vector<ll>H(n+1);
  vector<vector<ll>>A(n+1);
  map<pair<ll,ll>,ll>mp;
  for(i=1;i<=n;i++)
  {
    cin>>H[i];
  }
  for(i=0;i<m;i++)
  {
    cin>>x>>y;
    if(mp[{x,y}]==0 && mp[{y,x}]==0)
    {
      A[x].push_back(y);
      A[y].push_back(x);
      mp[{x,y}]=1;
      mp[{y,x}]=1;
    }
  }
  for(i=1;i<=n;i++)
  {
    if(A[i].size()==0)
    {
      coun++;
      continue;
    }
    flag=0;
    for(j=0;j<A[i].size();j++)
    {
      if(H[i]<=H[A[i][j]])
      {
        flag=1;
        break;
      }
    }
    if(flag==0)
      coun++;
  }
  cout<<coun;
              return(0);
}

Measured memory_bytes: 22416
//In the Name of Allah Most Gracious, Most Merciful//
/*If you want something you've never had, you have  to do something you never did.*/

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


#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define M 100007
#define INF 1e9
#define INFL 1e18
#define PI acos(-1)
#define mp make_pair

//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
int n;
int dp[100100];
int arr[100100];
int k;


int mydp(int i)
{
    if(i==n)
    {
        return 0;
    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    int ret1=INF;
    //cout<<i<<endl;
    for(int j=i+1;j<=min(n,i+k);j++)
    {
      //  cout<<"asdf"<<endl;
        ret1=min(ret1,abs(arr[i]-arr[j])+mydp(j));
    }
    //cout<<ret1<<endl;
    dp[i]=ret1;
    return dp[i];
}
int main()
{

   //  #ifndef ONLINE_JUDGE
   //    freopen("input.txt","r",stdin);
   //    freopen("output.txt","w",stdout);
  //   #endif

  cin>>n>>k;
  for(int i=1;i<=n;i++)
  {
      cin>>arr[i];
  }
  for(int i=0;i<=100000;i++)
  {
      dp[i]=-1;
  }
  int ans=mydp(1);
  cout<<ans<<endl;
}



Measured memory_bytes: 10572
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] input = Console.ReadLine().Split(' ');
		int[] p = new int[n];
        for(var i = 0; i < n; i++)
		{
			p[i] = int.Parse(input[i]);
		}
		int ans = 0;
        for(var i = 1; i < n - 1; i++)
		{
			if ((p[i] > p[i - 1] && p[i] < p[i + 1]) || (p[i] < p[i - 1] && p[i] > p[i + 1]))
			{
				ans++;
			}
		}
		Console.WriteLine(ans);
		
    }
}

Measured memory_bytes: 13140
using System;

class Program
{
    public static void Main(){
        var n=int.Parse(Console.ReadLine());
        var r0=int.Parse(Console.ReadLine());
        var r1=int.Parse(Console.ReadLine());
        var min=Math.Min(r0, r1);
        var result=r1-r0;
        for(var i=2; i<n; i++){
            var r=int.Parse(Console.ReadLine());
            if(r-min>result){
                result=r-min;
            }
            if(r<min){
                min=r;
            }
        }
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 9240
n = gets.to_i
ln = gets.split.map(&:to_i)
ln.sort!{|a,b| b<=> a}

cnt = 0
for tar in 0..(n-3)
  lid = tar+1
  rid = n-1
  while lid < n-1 && lid < rid
    if ln[tar] >= ln[lid]+ln[rid]
      rid -= 1
    else
      cnt += rid-lid
      lid += 1
    end
  end
end
puts cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
 
void solve(){
    int n;
    cin>>n;
    
    vector<double> dp(n+1);
    double p_heads;
    
    dp[0]=1;
    
    for(int coin=0;coin<n;++coin){
        double p_heads;
        cin>>p_heads;
        
        for(int i=coin+1;i>=0;--i)
            dp[i]=((i==0) ? 0 : dp[i-1]*p_heads) + dp[i]*(1.0-p_heads);
        
    }
    
    double ans=0.0;
    
    for(int heads=0;heads<=n;++heads){
        
        int tails=n-heads;
        
        if(heads>tails)        
            ans+=dp[heads];
    
    }
    
    cout<<setprecision(10)<<fixed<<ans;
}

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

    solve(); cout<<endl;
    return 0;
}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    ll rem;
    cin >> n;
    ll count = 0;
    ll count1 = 0;
    while(n>0){
        rem = n % 10;
        n = n / 10;
        count1++;
        if (rem == 7)
            count++;
    }
    if(count>0&&count1==3)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (a); (i)++)
#define reps(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()

#define MAX 1000000

int dp[MAX];
int dpk[MAX];
vector<int> v;
vector<int> vk;
int vn = 0;
int s = 1;


int main()
{
	v.pb(1);
	vk.pb(1);
	for (int i = 2; ;i++) {
		s += i;
		if (s + v[vn] >= MAX) break;
		v.pb(s+v[vn]);
		vn++;
		if (v[vn] % 2) vk.pb(v[vn]);
	}
	v.pb(MAX+1);
	vk.pb(MAX+1);
	reps(i, 1, MAX) {
		dp[i] = dp[i-1] + 1;
		for (int j = 1; v[j] <= i; j++) {
			dp[i] = min(dp[i], dp[i-v[j]] + 1);
		}
	}
	reps(i, 1, MAX) {
		dpk[i] = dpk[i-1] + 1;
		for (int j = 1; vk[j] <= i; j++) {
			dpk[i] = min(dpk[i], dpk[i-vk[j]] + 1);
		}
	}
	int n;
	cin >> n;
	while(n) {
		cout << dp[n] << " " << dpk[n] << endl;
		cin >> n;
	}
}


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

using Int = long long;
using std::vector;

struct Query {
    int q;
    Int x, s, t;
    Query() {}
};

int main() {
    int n, q;
    Int l, r;
    std::cin >> n >> q >> l >> r;

    vector<Int> a(n);
    for (auto& x : a) std::cin >> x;
    std::sort(a.begin(), a.end());

    vector<Query> queries(q);
    for (auto& t : queries) {
        std::cin >> t.q >> t.x >> t.s >> t.t;
    }

    auto eval = [&](Int x) {
        for (auto t : queries) {
            if (t.q == 1) {
                if (x < t.x) continue;
                x += t.s;
                x *= t.t;
            } else {
                if (x > t.x) continue;
                x -= t.s;
                bool neg = (x < 0);
                x = std::abs(x);
                x /= t.t;
                if (neg) x = -x;
            }
        }
        return x;
    };

    int li;
    {
        int ok = n, ng = -1;
        // eval(A_ok) >= L
        while (ok - ng > 1) {
            int mid = (ok + ng) / 2;
            (eval(a[mid]) >= l ? ok : ng) = mid;
        }
        li = ok;
    }

    int ri;
    {
        int ok = -1, ng = n;
        // eval(A_ok) <= R
        while (ng - ok > 1) {
            int mid = (ok + ng) / 2;
            (eval(a[mid]) <= r ? ok : ng) = mid;
        }
        ri = ok;
    }

    std::cout << ri - li + 1 << std::endl;
    return 0;
}



Measured memory_bytes: 10412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

string s[2];
vector<vector<int>> cnt[2];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s[0] >> s[1];
  for (int i = 0; i < 2; i++) {
    cnt[i].resize(4010, vector<int>(26, 0)); 
    for (int j = 0; j < s[i].size(); j++) {
      cnt[i][j+1] = cnt[i][j];
      cnt[i][j+1][s[i][j]-'a']++;
    }
  }
  for (int d = min(s[0].size(), s[1].size()); d >= 1; d--) {
    map<vector<int>, int> mp;
    for (int i = d; i <= s[0].size(); i++) {
      vector<int> tmp = cnt[0][i];
      for (int j = 0; j < 26; j++) {
        tmp[j] -= cnt[0][i-d][j];
      }
      mp[tmp]++;
    }
    for (int i = d; i <= s[1].size(); i++) {
      vector<int> tmp = cnt[1][i];
      for (int j = 0; j < 26; j++) {
        tmp[j] -= cnt[1][i-d][j];
      }
      if (mp[tmp]) {
        cout << d << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 5532
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
    int a,N,n,i,m;
    int sumB;
    int A[20],B[20],C[20];
    int sum = 0;
    cin >> N;
    for(i=0;i<N;i++){
        cin >> A[i];
        }
     for(i=0;i<N;i++){
        cin >> B[i];
     }
      for(int i=0;i<N-1;i++){
        cin >> C[i];
    }
    for(i = 0;i<N;i++){
        sum += B[A[i]-1];   
        sumB = sum;   
    }
    for(i = 0;i<N;i++){
    if(A[i]+1==A[i+1]){
            
            sumB += C[A[i]-1]; 
    }
    }

    
    cout << sumB << endl;
    return 0;
} 

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

using namespace std;

int get(){
	static char c;
	for(c=getchar();c!='#'&&c!='.';c=getchar());
	return c=='#';
}

const int N=2005;
int n,m,up[N],ch[N],ans,qu[N],qr;

int main(){
	scanf("%d%d",&n,&m);
	ans=max(n,m);
	for(int i=1;i<=n;i++){
		int a=get(),b;
		qr=0;
		for(int x=1;x<m;x++){
			b=get();
			if((a==b)!=ch[x])ch[x]^=1,up[x]=0;
			up[x]++,a=b;
			while(qr&&up[qu[qr]]>up[x])ans=max(ans,up[qu[qr]]*(x-qu[qr-1])),qu[qr--]=0;
			qu[++qr]=x;
		}
		while(qr)ans=max(ans,up[qu[qr]]*(m-qu[qr-1])),qu[qr--]=0;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<bool>	vb;



void solve(){
	ll n;
	cin >> n;
	vll a(n);
	ll ans = 0;
	rep(i,0,n){
		cin >> a[i];
		if(a[i] % 2 == 1 && i % 2 == 0) ans++;
	}
	cout << ans << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
#define INF 1000000000
#define MOD 1000000007
#define MAXN 1000005
 
using namespace std;

 ll mod=1e9+7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

ll expo2(ll base,ll exponent)
{
	ll ans=1;
	while(exponent!=0)
	{
		if(exponent & 1) ans=(1LL*ans*base);
		base=(1LL*base*base);
		exponent>>=1;
	}
	return ans;
}

// vector<bool>  prime(90000002,true);
// void Sieve() 
// { 
   
//     for (int p=2; p*p<=90000001; p++) 
//     { 
//         // If prime[p] is not changed, then it is a prime 
//         if (prime[p] == true) 
//         { 
//             for (int i=p*p; i<=90000001; i += p) 
//                 prime[i] = false; 
//         } 
//     } 
// }


// stores smallest prime factor for every number 
ll spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (ll j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

vector<ll>vis(1000001,0);


int main()
{
    
    // #ifndef ONLINE_JUDGE
    //     freopen ("data.in","r",stdin);
    //     freopen ("E.out","w",stdout);
    // #endif
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // Sieve();
    sieve();
    int tests=1;
    // cin>>tests;
    while(tests--)
    {	
    	ll i,j,n;
    	cin>>n;
    	vector<ll>a(n);
    	rep(i,0,n-1) cin>>a[i];
    	ll g=__gcd(a[0],a[1]);
    	for(i=2;i<n;i++) g=__gcd(g,a[i]);

    	bool flag=true;

    	rep(i,0,n-1)
    	{
    		set<ll>st;
    		ll tmp=a[i];
    		while(tmp>1)
    		{
    			st.insert(spf[tmp]);
    			tmp/=spf[tmp];
    		}
    		for(auto x:st)
    		{
    			if(vis[x]) {flag=false;break;}
    			else vis[x]=1;
    		}
    		if(!flag) break;
    	}

    	if(flag) cout<<"pairwise coprime";
    	else if(g==1) cout<<"setwise coprime";
    	else cout<<"not coprime";

    }
    	return 0;
    
}

Measured memory_bytes: 26756
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a <= c and c <= b)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import re
n = int(input())
MOD = 10**9 + 7

string = "ACGT"

# AGC
# A*GC
# GAC
# ACG
# AG*C

table = [{} for i in range(n + 1)]
def dfs(s="", depth=n):
    if table[depth].get(s) is not None:
        return table[depth][s]
    if re.search(r"(AGC|A.GC|GAC|ACG|AG.C)", s):
        table[depth][s] = 0
        return 0
    if depth == 0:
        table[depth][s] = 1
        return 1

    cnt = 0
    for i in string:
        cnt += dfs(s[-3:] + i, depth - 1)
        if cnt >= MOD:
            cnt %= MOD
    table[depth][s] = cnt
    return cnt

print(dfs())


Measured memory_bytes: 12872
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define ALL(a) (a).begin(),(a).end()
#define MOD 1e9+7
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int h, w;
vector<string> s;
vector<vector<int>> min_dist;

int dx[] = { 0,-1,0,1 };
int dy[] = { -1,0,1,0 };

int inf = 1000;

void bfs(int i,int j)
{
	rep(k, 4)
	{
		int x = j + dx[k];
		int y = i + dy[k];
		if (0<=x && x< w && 0 <= y && y < h && s[y][x]=='.' && min_dist[y][x]>min_dist[i][j] + 1)
		{
			min_dist[y][x] = min_dist[i][j] + 1;
			bfs(y, x);
		}
	}
}

int main()
{
	cin >> h >> w;
	s = vector<string>(h);
	rep(i, h)cin >> s[i];
	min_dist = vector<vector<int>>(h, vector<int>(w, inf));
	min_dist[0][0] = 0;
	bfs(0, 0);
	int white_cell = 0;
	rep(i, h)rep(j, w)if (s[i][j] == '.')white_cell++;
	if (min_dist[h - 1][w - 1] == inf)co(-1);
	else co(white_cell - min_dist[h - 1][w - 1] - 1);
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>

long long gcd(long long, long long);
long long lcm(long long, long long);

int main(){
    long long A, B ,C, D;
    scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
    long long ans;
    ans = (B - A + 1) - ( B/C + B/D - B/lcm(C, D) - ( (A-1)/C + (A-1)/D - (A-1)/lcm(C, D) ) );

    printf("%lld\n", ans);
}

long long gcd(long long p, long long q){
    long long r;
    while(q > 0){
        r = p % q;
        p = q;
        q = r;
    }

    return p;
}

long long lcm(long long m, long long n){
    long long p = m,q = n,r;
    while(q > 0){
        r = p % q;
        p = q;
        q = r;
    }

    return (m * n) / p; 
}

Measured memory_bytes: 128
import java.util.*;

class Main {
	static int V = 100005;
	static boolean[] visited = new boolean[V*2];
	static ArrayList<ArrayList<Integer>> _to;
	static int[] cnt;
	static void dfs(int v) {
		if (visited[v]) {
			return;
		}
		visited[v]=true;
		cnt[v/V]++;
		for (Integer u: _to.get(v)) {
			dfs(u);
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		_to = new ArrayList<ArrayList<Integer>>();
		for (int i=0;i<V*2;i++) {
			ArrayList<Integer> tmp = new ArrayList<Integer>();
			_to.add(tmp);
		}
		for (int i=0;i<N;i++) {
			int x=Integer.parseInt(sc.next());
			int y=Integer.parseInt(sc.next());
			y+=V;
			_to.get(x).add(y);
			_to.get(y).add(x);
		}
		long ans = 0L;
		for (int i=0;i<2*V;i++) {
			if (visited[i]) {
				continue;
			}
			cnt = new int[2];
			dfs(i);
			ans += (long)cnt[0]*cnt[1];
		}
		ans-=N;
		System.out.println(ans);
	}
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;
typedef pair< int, P > PP;

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

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

    int h, w;
	cin >> h >> w;
	REP(i, h) {
		string s;
		cin >> s;
		int l = -1;
		REP(j, w) {
			if (s[j] == 'c') l = j;
			cout << (l == -1 ? -1 : j - l) << (j == w - 1 ? "" : " ");
		}
		cout << endl;
	}


    return 0;
}





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

int main() {
	int n; cin >> n;
	vector<int>dp(n+1, 1e9); dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		int adj = 1;
		while (adj <= i) {
			dp[i] = min(dp[i], dp[i - adj] + 1);
			adj *= 9;
		}
		adj = 1;
		while (adj <= i) {
			dp[i] = min(dp[i], dp[i - adj] + 1);
			adj *= 6;
		}
	}
	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    int[] as;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        boolean odd = n % 2 == 1;
        int[] check = new int[n];
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (a % 2 == 1 == odd) {
                System.out.println(0);
                return;
            }
            check[a]++;
            if (check[a] > 2) {
                System.out.println(0);
                return;
            }
        }
        if (odd && check[0] != 1) {
            System.out.println(0);
            return;
        }
        long ans = pow(2, n / 2, 1000000007);
        System.out.println(ans);
    }

    long pow(long x, int n, int MOD) {
        long ans = 1;
        while (n > 0) {
            if ((n & 1) == 1) {
                ans = ans * x % MOD;
            }
            x = x * x % MOD;
            n >>= 1;
        }
        return ans;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 34020
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  vector<vector<int>> a(3,vector<int>(n));rep(i,n)rep(j,3)cin>>a[j][i];
  vector<vector<int>> dp(3,vector<int>(n+1,0));

  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(j != k)chmax(dp[j][i+1],dp[k][i] + a[k][i]);
      }
    }
  }
  print(max(dp[0][n],max(dp[1][n],dp[2][n])));
  return 0;
}

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

int main()
{
    int arr[3];
    for (int i = 0; i < 3; i++)
    {
        scanf("%d", &arr[i]);
    }

    for (int i = 0; i < 3; i++)
    {
        for (int j = i + 1; j < 3; j++)
        {
            if (arr[i] > arr[j])
            {
                int stash = arr[i];
                arr[i] = arr[j];
                arr[j] = stash;
            }
        }
    }
    printf("%d %d %d\n", arr[0], arr[1], arr[2]);
}


Measured memory_bytes: 3208
#pragma comment(linker, "/STACK:128777216")

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <sstream>
 
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
 
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <string.h>
 
#include <memory.h>
#include <cassert>
#include <time.h>
 
using namespace std;
 
#define forn(i,n) for (int i = 0; i < (int)(n); i++)
#define fornd(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define forab(i,a,b) for (int i = (int)(a); i <= (int)(b); i++)
#define forabd(i, b, a) for (int i = (int)(b); i >= (int)(a); i--)
#define forit(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
 
#define _(a, val) memset (a, val, sizeof (a))
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
 
typedef long long lint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;
 
const lint LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;
 
#ifdef MY_DEBUG
#define dbgx( x ) { cerr << #x << " = " << x << endl; }
#define dbg( ... ) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#else
#define dbgx( x ) {  } 
#define dbg( ... ) {  } 
#endif
 
void prepare(string s)
{
#ifdef MY_DEBUG
    freopen ("input.txt", "r", stdin);
    // freopen ("output.txt", "w", stdout);
#else
    if (s.length() != 0)
    {
        freopen ((s + ".in").c_str(), "r", stdin);
        freopen ((s + ".out").c_str(), "w", stdout);
    }
#endif
}

const int NMAX = 1000005;

int n, m;
vector<int> g[NMAX];
int ans[NMAX];
queue<int> q;

void read() {
  scanf("%d %d", &n, &m);
  forn(i, m) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }
}

void solve() {
  _(ans, -1);
  ans[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int v = q.front(); q.pop();
    for (int u : g[v]) {
      if (ans[u] == -1) {
        ans[u] = v;
        q.push(u);
      }
    }
  }
  forn(i, n) {
    if (ans[i] == -1) {
      printf("No\n");
      return;
    }
  }
  printf("Yes\n");
  forn(i, n) if (i) {
    printf("%d\n", ans[i] + 1);
  }
}

int main() {
	prepare("");
    read();
    solve();

    return 0;
}


Measured memory_bytes: 35196
#include<stdio.h>

int main(void)
{
int n,x,l[10000],i;

scanf("%d %d",&n,&x);

for(i=0;i<n;i++)
{
scanf("%d",&l[i]);
}
int d[100];
  int c=0;
d[0]=0;
  for(i=1;i<n+1;i++)
{
    d[i]=d[i-1]+l[i-1];
}


for(i=0;i<n+1;i++)
{
    if(d[i]<=x)
    {
        c++;
    }
}

printf("%d",c);
return 0;
}

Measured memory_bytes: 128
import * as fs from 'fs';

//in
// 6
// abcabc
//out
// Yes
const main = (inp: string) => {

    const n: number = parseInt(inp.split('\n')[0]);
    const s: string = inp.split('\n')[1];

    if (n % 2 === 1) {
        console.log('No');
        return;
    }

    if (s.substr(0, n / 2) === s.substr(n / 2)) {
        console.log('Yes');
    } else {
        console.log('No');
    }
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define ctz __builtin_ctz

typedef std::pair <int, int> pr;
const int N = 200054, LN = 20, LN2 = 262154;

int n, V, ALL, cnt = 0;
int x[N];
int L[LN][N], R[LN][N];
int f[LN2], g[LN2];
pr seg[LN2], qry[LN2];

inline void up(int &x, const int y) {x < y ? x = y : 0;}
inline void down(int &x, const int y) {x > y ? x = y : 0;}

int main() {
	int i, j, S, layer;
	scanf("%d%d", &n, &V);
	for (i = 0; i < n; ++i) scanf("%d", x + i);
	for (layer = 0; ; V >>= 1, ++layer) {
		int *l = L[layer], *r = R[layer];
		for (*l = 0, i = 1; i < n; ++i) l[i] = (x[i] <= x[i - 1] + V ? l[i - 1] : i);
		for (--i, r[i] = i; --i >= 0; ) r[i] = (x[i] >= x[i + 1] - V ? r[i + 1] : i);
		if (!V) break;
	}
	ALL = ~(-1 << layer);
	std::fill(g, g + (ALL + 1), n - 1);
	for (i = 0; i <= ALL; ++i)
		for (S = ALL ^ i; S; S &= S - 1)
			j = ctz(S),
			up(f[i | 1 << j], f[i] == n ? n : R[j + 1][f[i]] + 1),
			down(g[i | 1 << j], (~g[i] ? L[j + 1][g[i]] : 0) - 1);
	for (i = 0; i <= ALL; ++i) seg[i] = pr(g[i], -f[ALL ^ i]);
	std::sort(seg, seg + (ALL + 1));
	qry[cnt++] = pr(seg->first, -seg->second);
	for (i = 1; i <= ALL; ++i)
		if (seg[i].second < seg[i - 1].second) qry[cnt++] = pr(seg[i].first, -seg[i].second);
	for (i = 0; i < n; ) {
		j = R[0][i], S = std::lower_bound(qry, qry + cnt, pr(j, INT_MAX)) - qry - 1;
		if (S >= 0 && i <= qry[S].second)
			for (; i <= j; ++i) puts("Possible");
		else
			for (; i <= j; ++i) puts("Impossible");
	}
	return 0;
}

Measured memory_bytes: 38016
#include <iostream>
#include <string>
using namespace std;
int main() {
	int n;
	cin >> n;
	string w[n];
	int l[n];
	int cun = 0;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		l[i] = w[i].length();
		if (i != 0) {
			if (w[i - 1][l[i - 1] - 1] != w[i][0]) {
				cun++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (w[i] == w[j]) {
				cun++;
			}
		}
	}
	if (cun == 0) {
		cout << "Yes" << "\n";
	} else {
		cout << "No" << "\n";
	}
}

Measured memory_bytes: 3608
N, K, Q = map(int, input().split())
list_winner = []
list_point =[]

for _ in range(Q):
    A = int(input())
    list_winner.append(A)

for i in range(N):
    list_point.append(K)
    
    
def add(n):
    return n-Q
    
list_point_new = []

for i in list_point:
    list_point_new.append(add(i))
    
for i in range(Q):
    a = list_winner[i]-1
    list_point_new[a] = list_point_new[a] + 1
    
for i in range(N):
    if list_point_new[i] <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 12556
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];

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

		boolean flag = true;
		int cnt = 0;
		while (flag) {
			flag = false;
			for (int j = n - 1; j >= 1; j--) {
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					cnt++;
					flag = true;
				}
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i : a) {
			sb.append(i);
			sb.append(" ");
		}

		System.out.println(sb.toString().trim());
		System.out.println(cnt);
	}
}

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


int main() {
  int x,n;

  cin >> x >> n;

  int next_n = x+1;
  int back_n = x-1;

  vector<int> p(n);
  vector<int> tmp(102);

  if(n == 0){
    cout << x;
    return 0;
  }


  int flag = 0;

  for(int i=0; i<n; i++){
    cin >> p.at(i);
  }

  sort(p.begin(),p.end()); //ソートするよ

  for(int i=0; i<n; i++){ //対象の箇所を1で印つける
    tmp.at(p.at(i)) = 1;
  }

  // for(int i=0; i<=100; i++){
  //   cout << tmp.at(i);
  // }

  //cout << tmp.at(10) << endl ;
  
    if(tmp.at(x)==0){
      cout << x;
      return 0;
    }

    //cout << back_n << endl << next_n << endl ;

    for(;;){
      if(tmp.at(back_n) == 0){
        cout << back_n << endl;
        return 0;
      }
      if(tmp.at(next_n) == 0){
        cout << next_n << endl;
        return 0;
      }
      back_n-=1;
      next_n+=1;
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

ll mod = 1e9 + 7;

int n,m,ans;
pair<int,int> p[100010];
priority_queue<int> q;

int main(){
	cin >> n >> m;
	for (int i=0;i<n;i++){
		cin>>p[i].first>>p[i].second;
	}
	sort(p,p+n);
	int i=0;
	for (int j=m-1;j>=0;j--){
		while (i<n && p[i].first+j<=m){
			q.push(p[i++].second);
		}
		if (!q.empty()){
			ans+=q.top();
			q.pop();
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1660
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int add1 = 0;
		int add2 = 0;
		int[] ans = new int[N];
		int i = 0;
		int j = 0;
		int k = 0;
		
		while(i<N){
			W[i] = sc.nextInt();
			i++;
		}
		
		for(i=0; i<N; i++){
			for(j=i+1; j<N; j++){
				add1 += W[j];
			}
			for(k=0; k<=i; k++){
				add2 += W[k];
			}
			ans[i] = add1 - add2;
			
			if(ans[i] < 0){
				ans[i] = ans[i] * -1;
			}
			
			add1 = 0;
			add2 = 0;
		}
		
		k=0;
		
		for(i=0; i<N; i++){
			for(j=i+1; j<N; j++){
				if(ans[i] > ans[j]){
					k = ans[i];
					ans[i] = ans[j];
					ans[j] = k;
				}
			}
		}
		
		System.out.println(ans[0]);
	}
}

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

#define INF 1000000000000


signed main()
 {
    int h,w;
    cin>>h>>w;
    char a[h][w];
    rep(i,h){
      rep(j,w){
        cin>>a[i][j];
      }
    }

    vector<int>safegyou(h);
    vector<int>saferetsu(w);
    rep(i,h){
      rep(j,w){
        if(a[i][j]=='#'){
          safegyou.at(i)=1;
          saferetsu.at(j)=1;
        }
      }
    }
    rep(i,h){
      rep(j,w){
        if(safegyou[i]&&saferetsu[j]){
        cout<<a[i][j];
      }
      }
      if(safegyou[i]){
        cout<<endl;
}
    }
 }


Measured memory_bytes: 256
# https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_d
n = int(input())

def dfs(s, kinds):
    if len(s) == n:
        print(s) 
    else:
        for i in range(kinds+1):
            new_kinds = kinds + (1 if i == kinds else 0)
            dfs(s + chr(ord('a') + i), new_kinds)

dfs('', 0)

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

int main(){

    int r, d, x2000;

    cin >> r >> d >> x2000;

    int xnow = x2000;
    int xnext = 0;
    for(int i=1; i<11; i++){
        xnext = r * xnow -d;
        xnow = xnext;
        cout << xnext << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#if 0
dp[i][j] = min( dp[i???1][j] , dp[i][j???c[i]]+1 )
					||
dp[i] = min ( dp[j] , dp[j-c[i]]+1 )					
#endif

#include <iostream>  
using namespace std;  
 
  
const int MAX_NUM = 50010;  
const int MAX_WEIGHT = 50000+20;  

   
int c[MAX_NUM];  
 
int dp[MAX_WEIGHT];  
  

void Solve( int n, int m )  
{     
	for (int i=0; i<m; i++ )  
	{  
		for (int j=c[i]; j<=n; j++)  
		{   
			dp[j] = min(dp[j],dp[j-c[i]]+1);      	         
		}  
	}  
	cout << dp[n] << endl;  
}  

int main()  
{    
	int n, m;  
	cin >> n >> m;        
	for (int i=0; i<m; i++ )  
	{  
		cin >> c[i];  
	}  
	for (int i=1; i<=n; i++)
	{
		dp[i] = 50000+10;
	}
	Solve( n, m );  
 
	return 0;  
}  

Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[2005], which[2005], sz[2005];
pi b[2005];

int main()
{
	IO_OP;
	
	int n, k, q, ans = INF;
	cin >> n >> k >> q;
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=0;i<n;i++)
		b[i].F = a[i], b[i].S = i;
	sort(b, b+n);
	for(int i=0;i<n;i++) {
		int y = b[i].F, x = 0;
		for(int i=0;i<n;i++)
			sz[i] = which[i] = 0;
		for(int i=0;i<n;i++) {
			if(a[i] >= y) {
				which[i] = x;
				sz[x]++;
			} else {
				x++;
			}
		}
		int mx = -1, l=0;
		for(int j=i;j<n && l<q;j++) {
			int yi = b[j].S;
			int bl = which[yi];
			if(sz[bl] >= k) {
				sz[bl]--;
				l++;
//				cout << "del " << b[j].F << endl;
				mx = max(mx, b[j].F);
			}
		}
		if(l != q || mx == -1) continue;
		ans = min(ans, mx - y);
//		cout << mx << " - " << y << " = " << mx - y << endl;
	}
	cout << ans << endl;
}



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

namespace _165B
{
    class Program
    {
        static void Main(string[] args)
        {
            long X = long.Parse(Console.ReadLine());
            long Y = 100;
            int i = 0;
            while (Y < X) {
                Y += Y/100;
                i++;
            }
            Console.WriteLine(i);

        }
    }
}


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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

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

    int mx = 0;
    for (int i=0; i<N; ++i) {
        mx = max(mx, abs(A[i] - A[i+1]));
    }
    cout << K - mx << endl;

    return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    REP(i, N) {
        cin >> a[i];
    }

    LL res = max(0, a[0] - x);
    a[0] -= res;
    FOR(i, 1, N) {
        LL y = max(0, (a[i] + a[i - 1]) - x);
        a[i] -= y;
        res += y;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL s[25],n;

LL dp(LL l,LL r,LL sl,LL sr){
	LL ret = INF;
	if(l > r) return 0;
	for(LL i = l;i <= r;i ++){
		ret = min(ret,dp(l,i - 1,sl,sl + sr) + dp(i + 1,r,sl + sr,sr) + s[i] * (sl + sr));
	}
	return ret;
}

int main(){
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> s[i];
	cout << dp(2,n - 1,1,1) + s[1] + s[n] << '\n';
	return 0;
}

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

int main( void ) {
  int N, cnt=1;
  string str;

  cin >> N >> str;
  for(int i=0;i<(N-1);i++) {
    if( str.at(i) != str.at(i+1) ) {
      cnt++;
    }
  }
  
  cout << cnt << endl;

  return ( 0 );
}


Measured memory_bytes: 512
// 深さ優先探索
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func genid(a, b int) int {
	if b < a {
		a, b = b, a
	}
	return a*100000 + b
}

func main() {
	N := readInt()

	ab := make([][2]int, N-1)
	edges := make([][]int, N)
	for i := 0; i < N-1; i++ {
		a := readInt() - 1
		b := readInt() - 1
		ab[i][0], ab[i][1] = a, b
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
	}

	colors := make(map[int]int)
	q := make([][3]int, 0)
	q = append(q, [3]int{0, -1, -1})
	for len(q) != 0 {
		currentNode, usedColor, parentNode := q[len(q)-1][0], q[len(q)-1][1], q[len(q)-1][2]
		q = q[:len(q)-1]
		color := 1
		for _, childNode := range edges[currentNode] {
			if childNode == parentNode {
				continue
			}
			if color == usedColor {
				color++
			}
			colors[genid(currentNode, childNode)] = color
			q = append(q, [3]int{childNode, color, currentNode})
			color++
		}
	}

	K := -1
	for i := 0; i < N; i++ {
		t := len(edges[i])
		if t > K {
			K = t
		}
	}
	fmt.Println(K)

	for i := 0; i < N-1; i++ {
		fmt.Println(colors[genid(ab[i][0], ab[i][1])])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 17024
S = input()
T = input()
LS = len(S)
LT = len(T)

ans = LT

for i in range(0, LS-LT+1):
    cnt = 0
    for j in range(0, LT):
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)


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

int main()
{
	string s, p[2]; int r = 0;
	cin >> s;

	int n; cin >> n; while (n--){
		int o; cin >> o;
		if (o == 1) r = !r;
		else{
			int f; string c; cin >> f >> c;
			p[(r + f) % 2] += c;
		}
	}

	reverse(p[1].begin(), p[1].end());
	s = p[1] + s + p[0];
	if (r) reverse(s.begin(), s.end());
	cout << s << endl;

	return 0;
}

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

vector<string> weather={"Sunny","Cloudy","Rainy","Sunny"};
string today;

int main() {
    cin>>today;
    for (int i=0; i<3; i++) {
        if (today==weather[i]) {
            cout<<weather[i+1]<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
    {
        static void Main(string[] args)
        {
            //3 ????????°????????? 3 ???????????°?????¨???

            //?????°??£?¨?
            int x = int.Parse(Console.ReadLine());//??£??\?????°
            int max = 0;
            var data = new List<int>();//?????°list

            while (x >= 3)
            {

                //3????????°??????
                if (x % 3 == 0)
                {
                    data.Add(x);
                }
                //3???????????°??????
                else
                {
                    if (x % 10 == 3)
                    {
                        data.Add(x);
                    }
                    else
                    {
                        for (int i = 100; i <= 10000; i *= 10)
                        {
                            if (x % i/(i/10) == 3)
                            {
                                data.Add(x);
                                break;
                            }
                        }
                    }
                }
                x -= 1;
            }
            max = data[0];
            data.Sort();
            //????????????
            foreach (int i in data)
            {
                if (max == i)
                {
                    Console.WriteLine(" {0}", i);
                }
                else
                {
                    Console.Write(" {0}", i);
                }
            }
            Console.Read();
        }
    }

Measured memory_bytes: 9396
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)

template <class T>
void cmax(T &a, T b) { a = max(a, b); }
template <class T>
void cmin(T &a, T b) { a = min(a, b); }

int N, M, Q;

void make(vector<vector<int>> &paths, vector<int> &path, int lo, int hi) {
    if (path.size() == N) {
        vector<int> vec_copy(path);
        paths.push_back(vec_copy);
        return;
    }
    for (int x = lo; x <= hi; ++x) {
        path.push_back(x);
        make(paths, path, x, hi);
        path.pop_back();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> N >> M >> Q;
    vector<int> A(Q), B(Q), C(Q), D(Q);
    F0R(i, Q) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
    }
    vector<vector<int>> paths;
    vector<int> path;
    make(paths, path, 1, M);
    int ans = 0;
    for (auto cand: paths) {
        int bns = 0;
        for (int i = 0; i < Q; ++i) {
            if (cand[B[i] - 1] - cand[A[i] - 1] == C[i])
                bns += D[i];
        }
        ans = max(ans, bns);
    }
    cout << ans << endl;

}

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

bool isprime(int x);

int main(){
  int n;
  cin >> n;
  int cnt=0;
  int a;
  for(int i=0;i<n;i++){
    cin >> a;
    if(isprime(a))
      cnt++;
  }
  cout << cnt << endl;
}

bool isprime(int x){
  if(x==2)
    return true;
  if(x<2||x%2==0)
    return false;

  int i = 3;
  while(i*i <= x){
    if(x%i==0)
      return false;
    i+=2;
  }
  return true;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define INF 2000000000
#define pb push_back 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define double long double
 
using namespace std;

int main()
{
    IOS;
    ll no = 1;
    ll h;
    cin >> h;
    ll tot = 0;
    ll val = h;
    while(val)
    {
        tot+=no;
        val/=2;
        no*=2;
    }
    cout << tot;
}   

Measured memory_bytes: 256
n  = int(input(''))

cnt=0
result="No"
for i in range(n):
    d12 = input('').split()
    d1 = d12[0]
    d2 = d12[1]
    if d1 == d2:
        cnt+=1
        if cnt ==3:
            result = "Yes"
    else:
        cnt=0


print(result)


Measured memory_bytes: 9172