akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int N;
int A[305][305];
bool check[305][305];

signed main(){
  cin>>N;
  memset(check,true,sizeof(check));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cin>>A[i][j];
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){

        if(A[i][j]>A[i][k]+A[k][j]){
          cout<<"-1"<<"\n";
          return 0;
        }

        if(A[i][j]==A[i][k]+A[k][j]&&A[i][k]>0&&A[k][j]>0){
          check[i][j]=false;
        }

      }
    }
  }

  int sum=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=i;j++){
      if(check[i][j]==true){
        sum+=A[i][j];
      }
    }
  }

  cout<<sum<<"\n";
  return 0;
}


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

int main() {
    int n;
    cin>>n;
    int ans = 0;
    REP(i,n)REP(j,n)REP(k,n) ans += gcd(gcd(i,j),k);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3676
package main

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

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	var Ns string
	var a string
	var N int
	Ns = sc.Text()
	N, _ = strconv.Atoi(Ns)
	ai := make([]int, 0, N)
	sc.Scan()
	sc.Scan()
	a = sc.Text()
	ais := strings.Split(a, " ")
	count := 0
	for i, n := range ais {
		tmp, _ := strconv.Atoi(n)
		ai = append(ai, tmp)
		if i%2 == 0 && tmp%2 == 1 {
			count += 1
		}
	}
	fmt.Println(count)

}

Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std ; 
//#define int long long
const int MAXN = 2*2000 + 500 , MOD = 924844033 ; 

int n , k , t[MAXN][MAXN] , dp[MAXN][MAXN] , fact[MAXN] , ans , sum , sz ;
vector<int>vec ; 

int32_t main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> k ;
	
	fact[0]=1 ; 
	for(int i=1 ; i<MAXN ; i++)
		fact[i] = (1LL*fact[i-1]*i)%MOD ;
	
	for(int i=0 ; i<MAXN ; i++)
	{
		t[i][0] = 1 ; 
		t[i][1] = i ; 
		for(int j=2 ; j<=i ; j++)
			t[i][j] = ( 1LL*t[i-1][j] + 1LL*t[i-2][j-1])%MOD ; 
	}
	
	vec.push_back(0) ; 
	for(int i=1 ; i<=k ; i++)
	{
		int cnt=0 ; 
		for(int j=i ; j<=n ; j+=k)
			cnt++;
		cnt-- ; 
		vec.push_back(cnt) ; 
		vec.push_back(cnt) ; 
	}
	
	
	sz = vec.size() ; 
	dp[0][0]=1 ; 
	for(int i=1 ; i<sz ; i++)
	{
		for(int j=0 ; j<=sum ; j++)
			for(int x=0 ; x<=vec[i] ; x++)
			{
				int what = (1LL*dp[i-1][j]*t[vec[i]][x] )%MOD; 
				dp[i][j+x] =(1LL*dp[i][j+x] + 1LL*what) %MOD ; 
			}
		sum+=vec[i];
	}
	
	for(int i=0 ; i<=n ; i++)
	{
		int what = ((1LL*dp[sz-1][i] * 1LL*fact[n-i] )%MOD )*((i%2==1)? -1 : 1); 
		ans = (1LL*ans+1LL*what+1LL*MOD)%MOD ; 
	}
	cout << ans << endl ;
}

Measured memory_bytes: 150784
N= int(input())
l = [list(map(int, input().split())) for _ in range(N)]

l.sort(key=lambda x: x[1])
count = 0
for i in range(N):
    count += l[i][0]
    if not count <= l[i][1]:
        print('No')
        quit()
print('Yes')

Measured memory_bytes: 53600
using System;

namespace SharingCookies
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力
            String[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            String ans;

            //処理
            if( a%3==0 || b%3==0 || (a+b)%3==0){
                ans = "Possible";
            }else{
                ans = "Impossible";
            }

            //出力
            Console.WriteLine(ans);
        }
    }
}


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

int main() {
  int x,y;
  string chk = "No";
  cin >> x >> y;
  
  if(x == 2 && x == y){
    chk = "Yes";
  }else if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12){
    if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12){
      chk = "Yes";
    }
  }else if(x == 4 || x == 6 || x == 9 || x == 11){
    if(y == 4 || y == 6 || y == 9 || y == 11){
      chk = "Yes";
    }
  }
  
  cout << chk;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - CF
https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_a

"""
import sys


def solve(s):
    c_positions = [float('inf')]
    f_positions = [float('-inf')]
    for i, ch in enumerate(s):
        if ch == 'C':
            c_positions.append(i)
        elif ch == 'F':
            f_positions.append(i)
    c_positions.sort()
    f_positions.sort()
    if c_positions[0] < f_positions[-1]:
        return 'Yes'
    return 'No'


def main(args):
    s = input()
    ans = solve(s)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define lb() i&-i
#define mid (l+r>>1)
#define db(x) cout << "#x:" << x << endl
#define dd() cout << "Out put!\n"
const int mod=1e9+7,eps=1e-6,pi=acos(-1.0),maxn=100010;
const int inf=0x7f7f7f7f7f7f7f7f;
using namespace std;
int v[maxn];
int n; 
int a[maxn];
signed main()
{
	ios::sync_with_stdio(0);
	int t=1;
//	cin >> t; 
	while(t--)
	{
		int n;
		cin >> n;
		int sum = 0;
		rep(i,1,n)
			cin >> a[i],v[a[i]]++,sum+=a[i];
		int q;
		cin >> q;
		rep(i,1,q)
		{
			int b,c;
			cin >> b >> c;
			int cnt  = v[b];
			sum-=cnt*b;
			sum+=cnt*c;
			v[b] = 0;
			v[c]+=cnt;
			cout << sum << endl;
		}
	} 
	return 0;
}

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

int N,K,Q,a;
int arr[100010];
int main(){
	cin>>N>>K>>Q;
	for(int i=1; i<=N; i++) {
		arr[i]=K-Q;
	} for(int i=1; i<=Q; i++) {
		cin>>a;
		arr[a]++;
	} for(int i=1; i<=N; i++) {
		if(arr[i]>0) {
			cout<<"Yes"<<endl;
		} else {
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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




int main(){

    ll n;
    cin >> n;
    ll a,b;
    ll c[n];
    ll ans = 0;
    
    rep(i,0,n){
        cin >> a >> b;
        ans -= b;
        c[i] = a+b;
    }
   
    rsort(c,c+n,ll);
    
    rep(i,0,n){
        
        ans += c[i];
   		i++;
    }

    P(ans);
	return  0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

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

	bool ok=1;
	rep(i,s.size()-1)if(s[i]!=s[i+1])ok=false;

	if(ok){
		cout<<0<<endl;
		return 0;
	}
	int ans=INF;
	rep(tar,26){
		// char tar='a'+ii;
		vi str(s.size(),-1);
		rep(i,s.size())str[i]=s[i]-'a';

	


		for(int len=s.size();len>0;len--){
			rep(i,len-1){
				if(str[i]==tar||str[i+1]==tar){
					str[i]=tar;
				}
			}
			bool ok=1;
			rep(i,len-2) if(str[i]!=str[i+1])ok=false;
			if(ok){
				chmin(ans,(int)s.size()-(len-1));
				break;
			}
			
		}

	}
	cout<<ans<<endl;

	
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    string S;
    cin >> S;
    if(S[2]==S[3]&&S[4]==S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

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

// copied src
typedef long long ll;
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
 
using namespace std;

int main(){

    ll n;
    cin >> n;

   
    ll ans = 0;
    ll a[n];
    ll s=0;
    REP(i,n) cin >> a[i];
    int right = 0;
    for(int left = 0;left<n;left++){
        
        while(right < n && (a[right]^s) == (a[right] + s)){
            s += a[right];
            right++;
        }
		ans += right -left;
      
        if(left == right)right++;
        else s -= a[left];
         
    }
    cout << ans;
    
}



Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int ac = a-c;
		int ab = a-b;
		int bc = b-c;

		String ans = "No";

		if ((Math.abs(ac) <= d) || ((Math.abs(ab) <= d) && (Math.abs(bc) <= d))) {
			ans = "Yes";
		}

		System.out.println(ans);

		scan.close();

	}

}


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

namespace ConsoleApp31 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int N = st[0];
            int H = st[1];

            int[] a = new int[N];
            int[] b = new int[N];

            for (int i = 0; i < N; i++) {
                var p = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                a[i] = p[0];
                b[i] = p[1];
            }

            int amax = a.Max();

            var throw_list = b.ToList().Where(x => x > amax).OrderByDescending(x => x);
            var throw_array = throw_list.ToArray();

            int throw_cnt = throw_list.Count();
            int throw_sum = throw_list.Sum();


            int ans = 0;

            if (throw_sum < H) {
                if ((H - throw_sum) % amax == 0) {
                    ans = throw_cnt + (H - throw_sum) / amax;
                } else {
                    ans = throw_cnt + (H - throw_sum) / amax + 1;
                }
            } else {
                int ind = 0;
                while (H > 0) {
                    H -= throw_array[ind];
                    ind++;
                }
                ans = ind;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 23616
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
#define pb push_back
#define ins insert
#define pll pair<ll,ll>
#define fi first
#define se second
#define mpr make_pair
#define vtr vector
#define itor iterator 
#define N ll(1e9+7)
#define endl '\n'
#define inf ll(1e9)
using namespace std;
//ll power(ll a,ll b,ll mod)
//{
//	if(b==0)return 1;
//	ll ans=1;
//	while(b>0)
//	{
//		if(b&1)ans=(ans*a)%mod;
//		a=(a*a)%mod;
//		b>>=1;
//	}
//	return ans;
//}
int main()
{
	ios;
	ll t=1;
	while(t--){
		ll n,k,c;
	cin>>n;
	ll ans=2,i,div1,div2;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			div1=i;
			div2=n/i;
			if(div1==div2)
			{
				ans++;
			}
			else
			{
				ll tp=n;
				while(tp%div1==0)
				{
					tp/=div1;
				}
				if(tp%div1==1)
				{
					ans++;
				}
				tp=n;
				while(tp%div2==0)
				{
					tp/=div2;
				}
				if(tp%div2==1)ans++;
			}
		}
	}
	for(i=2;i*i<=(n-1);i++)
	{
		if((n-1)%i==0)
		{
			div1=i;
			div2=(n-1)/i;
			if(div1==div2)
			{
				ans++;
			}
			else
			{
				ans+=2;
			}
		}
	}
	if(n-1==1)ans--;
	cout<<ans;
	}
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A.at(i);

  int l = 0, r = 1e9;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    auto f = [&](int x) {
      ll now = 0;
      rep(i, N) {
        now += (A.at(i) - 1) / x;
      }
      return now <= K;
    };
    if (f(mid)) r = mid;
    else l = mid;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
#define double long double
#define PI 3.141592653589793
typedef long long ll;
const int MOD = 1000000007;
const int INF = 10100000000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 1;i*i <= n;i++){
    if(n%i == 0){
      ret.push_back(i);
      if(i*i != n)ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

double a,b,x;
signed main() {
  cin>>a>>b>>x;
  if(2*x > a*a*b){
    double h = 2*(b-x/(a*a));
    cout << fixed << setprecision(10) <<atan(h/a)*180.0/PI << endl;
  }else{
    double h = 2*x/(a*b);
    cout << fixed << setprecision(10) <<atan(b/h)*180.0/PI << endl;
  }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repr(i, a, b) for (ll i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define w(tc) ll tc;cin>>tc;while(tc--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define PI 3.14159265359
static const int INF = 1e9 + 7;
using namespace std;
ll calculateMex(unordered_set<ll> Set)
{
  ll Mex = 0;

  while (Set.find(Mex) != Set.end())
    Mex++;

  return (Mex);
}
int main()
{
 bool ans;
 cin>>ans;
 cout<<!ans<<endl;
}



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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  int a[n];
  set<int> st;
  rep(i, n) cin >> a[i], st.insert(a[i]);
  cout << (st.size() % 2 ? st.size() : st.size()-1) << endl;

  return 0;
}


Measured memory_bytes: 5760
n = int(input())
a, w, t, r = 0, 0, 0, 0
for i in range(n):
    x = input()
    if x == "AC":
        a += 1
    elif x == "WA":
        w += 1
    elif x == "TLE":
        t += 1
    else:
        r += 1
print("AC x "+str(a))
print("WA x "+str(w))
print("TLE x "+str(t))
print("RE x "+str(r))

Measured memory_bytes: 9208
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define set setprecision　//小数点以下何位まで知りたいか
#define mod 1000000007
#define pi 3.14159265
#include<numeric>
using namespace std;
int gcd(int a, int b)//最大公約数
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)//最小公倍数
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}
int  main() {
	ll i, o, t, j, l, s, z;
	cin >> i >> o >> t >> j >> l >> s >> z;//t,s,zを無視
	ll ans = o*2;
	ll k = ans;
	k += 4 * ((i / 2) + (j / 2) + (l / 2));
	ll ss = ans;
	if (i != 0 && j != 0 && l != 0) {
		ss += 6;
		i--;
		j--;
		l--;
		ss += 4 * ((i / 2) + (j / 2) + (l / 2));
	}
	cout << max(ss, k) / 2 << endl;
}

Measured memory_bytes: 256
while True:
	H,W=map(int,input().split())
	if H==0 and W==0:
		break
	for j in range(H):
		if j%2==0:
			for i in range(W):
				if i%2==0:
					print("#", end="")
				else:
					if j%2==0:
						print(".", end="")
		else:
			for i in range(W):
				if i%2==0:
					print(".", end="")
				else:
						print("#", end="")
		print()
	print()



Measured memory_bytes: 7008
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int w = sc.nextInt();
		sc.close();

		if (w >= s) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
	}
}


Measured memory_bytes: 35792
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

N = int(input())
A = list(map(int, input().split()))
sumA = sum(A)

val = 0
for a in A:
    val += a * sumA
    val %= 2 * MOD
for a in A:
    val -= a * a
    val %= 2 * MOD
val //= 2
val %= MOD
print(val)

Measured memory_bytes: 105980
XY = list(map(int, input().split()))#x1,y1,x2,y2

a,b = XY[0] - XY[2], XY[1] - XY[3]
x3, y3 = b + XY[2], -a + XY[3]
c,d = XY[2] - x3, XY[3] - y3
x4, y4 = d + x3, -c + y3

print(x3, y3, x4, y4)


Measured memory_bytes: 3060
use std::vec::Vec;

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(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let n: usize = read();
    let a: Vec<usize> = read_vec();

    for e in a {
      if e % 2 == 0 {
         if !(e % 5 == 0 || e % 3 == 0) {
            println!("DENIED");
            return
         }
      }
    }
    println!("APPROVED");
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define H 0
#define V 1

const int dx[]={1,-1};
const int dy[]={1,-1};
bool vis[801][801];
bool  ismirror[9][9][2];

void solve(){
  int x = 75,y=25;
  int xdir=0,ydir=0;
  while(true){
    if (vis[y][x] && x == 75 && y == 25){
      cout << x << " " << y << endl;
      break;
    }
    vis[y][x]=true;
    if (y%100 == 0){
      if (ismirror[y/100][x/100][H]){
	ydir=1-ydir;
      }else if (y == 800 || y == 0){
	cout << x <<" " << y << endl;
	break;
      }
    }else if (x%100 == 0){
      if (ismirror[y/100][x/100][V]){
	xdir=1-xdir;
      }else if (x == 800 || x == 0){
	cout <<x <<" " << y << endl;
	break;
      }
    }
    x+=dx[xdir];
    y+=dy[ydir];
  }
  return;
}

main(){
  int n;
  while(cin>>n&& n >-1){
    rep(i,9)rep(j,9)ismirror[i][j][H]=ismirror[i][j][V]=false;
    rep(i,801)rep(j,801)vis[i][j]=false;
    rep(i,n){
      char dir;
      int x,y;
      cin>>dir>>x>>y;
      if (dir == 'x')ismirror[y][x][H]=true;
      else ismirror[y][x][V]=true;
    }
    solve();
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
  int n;
  cin >> n;
  vector<P> p;
  rep(i,n) {
    double a, b;
    cin >> a >> b;
    p.push_back({a,b});
  }
  double res = 0;
  double fact = 1;
  sort(p.begin(), p.end());
  do {
    double l = 0;
    for (int i = 0; i < n-1; i++) {
      l += sqrt((p[i].first - p[i+1].first) * (p[i].first - p[i+1].first) + (p[i].second - p[i+1].second) * (p[i].second - p[i+1].second));
    }
    res += l;
  } while (next_permutation(p.begin(), p.end()));
  for (int i = 1; i <= n; i++) fact *= i;
  printf("%.12f\n", res / fact);
  return 0;
} 

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

#define LL long long
#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;
    cin >> N;
    int a[N];
    REP(i, N)cin >> a[i];
    int c[9];
    fill(c, c + 9, 0);
    REP(i, N) {
        c[min(a[i]/400, 8)]++;
    }
    int mn = 0;
    REP(i, 8) {
        if(c[i])mn++;
    }
    int mx = mn + c[8];
    mn = max(1, mn);
    cout << mn << " " << mx << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

double a,b;
int main(){
  cin >> a >> b;
  a += b;
  cout << (int)ceil(a / 2) << endl;
}


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

long inf = 1000000007;


int main() {
	int a, b; cin >> a >> b;
	
	for (int i = 0; i < 1001; ++i) {
		if (i * 8/100== a ) {
			if (i * 10 /100 == b ) {
				cout << i << endl;
				break;
			}
		}
		if (i == 1000) {
			cout << -1 << endl;
		}
	}
}

Measured memory_bytes: 256
import math

def enough(n):
    whole_damage = B * n
    if (SUM > whole_damage*N + (A-B)*n):
        return False
    if (MAX <= whole_damage):
        return True
    arr = filter(lambda hp: hp > whole_damage, HPS)
    atk_times = 0
    for hp in arr:
        atk_times += int(math.ceil((hp - whole_damage)*1.0 / (A-B)))
        if atk_times > n:
            return False
    else:
        return True

N,A,B = map(int, raw_input().split())
HPS = [input() for i in range(N)]
MAX = max(HPS)
SUM = sum(HPS)

left = 1
right = MAX/B + 1
while left < right:
    mid = (left + right)/2
    if enough(mid):
        right = mid
    else:
        left = mid + 1
print right


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

int main(){
  int N,x;
  cin >> N >> x;
  int a[N];
  for (int i=0; i<N; i++){
    cin >> a[i];
  }
  sort(a, a+N);
  int count=0;
  for (int i=0; i<N; i++){
    x-=a[i];
    count++;
    if (x<0){
      count--;
      break;
    }
  }
  if (x>0){
    count--;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int h, w;

const int dy[16] = { 0,-1, 0, 1, 1,-1, 1,-1, 0,-2, 0, 2};
const int dx[16] = { 1, 0,-1, 0, 1, 1,-1,-1, 2, 0,-2, 0};
const char C[4] = {'R', 'U', 'L', 'D'};

struct Data{
	vector<vector<char>> c;
	int leves;
	int y, x, d;
	string s;
	Data(vector<vector<char>>& c, int leves, int y, int x, int d, string s) : c(c), leves(leves), y(y), x(x), d(d), s(s) {}
};

string bfs(Data& start){
	queue<Data> q;
	q.emplace(start);

	while(not q.empty()){
		Data p = q.front(); q.pop();
		//cout << p.y << ' ' << p.x <<' ' << p.d << endl;
		//for(auto i : p.c){ for(auto j : i){ cout << j << ' '; } cout << endl; } cout << endl;


		if(p.leves == 1) return p.s;
		if(p.s.size() >= 30) continue;

		rep(dir,4){
			if((p.d + 2) % 4 == dir) continue;
			int ny = p.y + dy[dir];
			int nx = p.x + dx[dir];
			if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;

			bool f = true;
			while(p.c[ny][nx] == '.'){
				ny += dy[dir];
				nx += dx[dir];
				if(ny < 0 || ny >= h || nx < 0 || nx >= w){
					f = false;
					break;
				}
			}
			if(not f) continue;

			p.c[p.y][p.x] = '.';
			q.emplace(p.c, p.leves - 1, ny, nx, dir, p.s + C[dir]);
			p.c[p.y][p.x] = 'o';
		}
	}
	assert(false);
	return "null";
}

int main(){
	cin >> h >> w;

	vector<vector<char>> c(h, vector<char>(w));
	int y, x, leves = 0;
	char dir;
	rep(i,h) rep(j,w){
		cin >> c[i][j];
		if(isupper(c[i][j])){
			y = i;
			x = j;
			dir = c[i][j];
			c[i][j] = 'o';
		}
		if(c[i][j] == 'o') leves++;
	}

	rep(i,4) if(C[i] == dir){
		Data data(c, leves, y, x, i, "");
		cout << bfs(data) << endl;
		return 0;
	}
}



Measured memory_bytes: 6588
// AtCoder-Template.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define FORREV(i,N,_cnt) for(auto i=N-1,cnt=_cnt; cnt > 0; --i, --cnt)
#define ALL(x) x.begin(), x.end()

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T& a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T& a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
	ifstream ifs("in.txt");
	cin.rdbuf(ifs.rdbuf());
#endif
	ll N; cin >> N; vector<ll> W(N); FOR(i, N) cin >> W[i];
	ll sum = accumulate(ALL(W), 0);
	ll tmp = 0;
	ll ans = numeric_limits<ll>::max();
	FOR(i, N-1) {
		tmp += W[i];
		chmin(ans, abs(sum - 2 * tmp));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        s: Chars,
    }

    let mut ok = true;
    if s[0]!='A' {
        ok = false;
    }
    if s[1]=='C' {
        ok = false;
    }
    if s[1].is_uppercase() {
        if s[1]!='A' {
            ok = false;
        }
    }
    let mut cnt = 0;
    for i in 2..s.len()-1 {
        if s[i]=='C' {
            if cnt==0 {
                cnt += 1;
            } else {
                ok = false;
                break;
            }
        } else {
            if s[i].is_uppercase() {
                if s[i]=='A' {
                    continue;
                } else {
                    ok = false;
                    break;
                }
            }
        }
    }

    if cnt==0 {
        ok = false;
    }

    if s[s.len()-1].is_uppercase() {
        if s[s.len()-1]!='A' {
            ok = false;
        }
    } 

    if ok==true {
        println!("AC");
    } else {
        println!("WA");
    }
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
main(){
  vector<int>v(5); for(int i=0; i<5; i++) cin>>v[i];
  if((v[0]>=v[2]+v[4])&&(v[1]>=v[3]+v[4])&&(v[2]-v[4]>=0)&&(v[3]-v[4]>=0))cout<<"Yes";
  else cout<<"No";
  cout<<"\n";
}


Measured memory_bytes: 3088
num=int(input())
water=list(map(int,input().split()))
ans=[0 for _ in range(num)]
ans[0]=sum([((-1)**i)*a  for i,a in enumerate(water)])//2
for i in range(1,num):
    ans[i]=water[i-1]-ans[i-1]
print(" ".join(list(map(lambda x:str(x*2),ans))))

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N=nextInt();

		String ans ="Yes";
		String last=nextString();
		Map<String,Boolean> map = new HashMap<>();
		map.put(last, true);
		for(int i=1;i<N;i++){
			String w = nextString();
			if(last.charAt(last.length()-1)==w.charAt(0)&&!map.containsKey(w)){
				last=w;
				map.put(last, true);
			}else{
				ans="No";
				break;
			}
		}

		System.out.println(ans);




	}




	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

int main()
{
  long long int res=0;
  long long int i,n;
  int m;
  cin>>n>>m;
  for(int j=0; j<m; j++)
  {
    cin>>i;
    res+=i;
  }
  printf("%lld", (n<res?-1:n-res));
  return 0;
}

Measured memory_bytes: 3776
s = input()
s = list(s)
q = int(input())
query = list(list(input().split()) for _ in range(q))

rs_cnt = 0

head = []
tail = []

for i in range(q):
    qry = query[i]
    if qry[0] == '1':
        rs_cnt += 1
    else:
        if qry[1] == '1':
            if rs_cnt % 2 == 0:
                head.append(qry[2])
            else:
                tail.append(qry[2])
        else:
            if rs_cnt % 2 == 0:
                tail.append(qry[2])
            else:
                head.append(qry[2])
            
if rs_cnt % 2 == 0:
    head.reverse()
    head = ''.join(head)
    s = ''.join(s)
    tail = ''.join(tail)
    print(head + s + tail)
else:
    s.reverse()
    tail.reverse()
    head = ''.join(head)
    s = ''.join(s)
    tail = ''.join(tail)
    print(tail + s + head)

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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int[] h = in.nextIntArray(n);

        int[] minCost = new int[n];
        Arrays.fill(minCost, Integer.MAX_VALUE / 2);
        minCost[0] = 0;
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                minCost[i] = Math.min(minCost[i], minCost[i - 1] + Math.abs(h[i] - h[i - 1]));
            }
            if (i > 1) {
                minCost[i] = Math.min(minCost[i], minCost[i - 2] + Math.abs(h[i] - h[i - 2]));
            }
        }
        out.println(minCost[n - 1]);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        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;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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


Measured memory_bytes: 31904
import math
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]

a.sort()
f.sort(reverse=True)

af = [[a[i]*f[i], a[i], f[i]] for i in range(n)]
af.sort(reverse=True)

def check(mid):
    count = 0
    for i in range(n):
        num = math.ceil((af[i][0] - mid) / af[i][2])
        if num > af[i][1]:
            return False
        else:
            count += num
            if count > k:
                return False
    else:
        return True

# https://qiita.com/hamko/items/794a92c456164dcc04ad
def binary_search():
    ng = -1 # left:絶対に達成不可能なもの
    ok = 10**13 # right:絶対に達成可能なもの
    while (ok - ng > 1):
        mid = (ng + ok) // 2
        if check(mid) == True:
            ok = mid
        else:
            ng = mid
    return ok
print(binary_search())


Measured memory_bytes: 129060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,m;
  cin >> n >> m;
  vec cnt(m);
  for(ll i=0;i<n;i++) {
    ll k;
    cin >> k;
    while(k--) {
      ll tmp;
      cin >> tmp;
      tmp--;
      cnt[tmp]++;
    }
  }
  ll ans=0;
  for(ll i=0;i<m;i++) {
    ans+=(cnt[i]==n);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// AOJ 2300

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

double l[30], a[30], b[30];
bool used[30];
double ret;
int n, m;

double dis(int c, int d)
{
	return pow(l[c] - l[d], 2.0) + pow(a[c] - a[d], 2.0) + pow(b[c] - b[d], 2.0);
}
double rec()
{
	double r = 0;
	for (int i = 0; i < n; i++){
		for (int j = i+1; j < n; j++){
			if (used[i] && used[j]){
				r += dis(i, j);
			}
		}
	}

	return r;
}
void dfs(int cnt, int depth, int num)
{
	if (depth == n){
		if (cnt == m){
			ret = max(ret, rec());
		}
		return;
	}

	// num を使わない
	dfs(cnt, depth + 1, num + 1);
	// num を使う
	used[num] = true;
	dfs(cnt + 1, depth + 1, num + 1);
	// きちんと使ったものはもどしておく
	used[num] = false;
}

int main(void)
{
	cin >> n >> m;
	fill(used, used + 30, false);
	for (int i = 0; i < n; i++){
		cin >> l[i] >> a[i] >> b[i];
	}

	dfs(0, 0, 0);

	printf("%.8f\n", ret);

	return 0;
}

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

int apie(int A,int P)
{
    int ans=0;
    ans=(3*A)+P;
    return ans/2;
}

int32_t main()
{
    int A,P;
    cin>>A>>P;
    cout<<apie(A,P);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ldouble long double

//setprecision()<<

using namespace std;


int maxfind(vector<int> a,int T){
    int max=-1;
    for(int i=0;i<T;i++){
        if(max<a.at(i)){
            max=a.at(i);
            //*num=i;
        }
    }
    return max;
}


signed main() {
    int K,T;
    cin>>K>>T;
    vector<int> a(T);
    for(int i=0;i<T;i++){
        cin>>a.at(i);
    }
    
    /*
    int num;
    int max1=maxfind(a,T,&num);
    a.at(num)=0;
    int max2=maxfind(a,T,&num);

    if(abs(max1-max2)==0){
        cout<<0<<endl;
    }
    else{
        cout<<abs(max1-max2)-1<<endl;
    }
*/
    int max1=maxfind(a,T);
    cout<<max(2*max1-K-1,0LL)<<endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

const LL inf = 0x3f3f3f3f3f3f3f3f;
const int N = 55, M = 110;
struct Edge {
	int to, next;
	LL a, b;
}e[M * 2];
int head[N], idx;
LL c[N], d[N];
LL dis[N][2510];
int n, m, s;

void add(int u, int v, LL a, LL b) {
	e[++idx].to = v;
	e[idx].next = head[u];
	e[idx].a = a;
	e[idx].b = b;
	head[u] = idx;
}

void spfa() {
	queue<PII> q;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= 2500; j++) {
			dis[i][j] = inf;
		}
	}
	dis[1][s] = 0;
	q.push({1, s});
	while(!q.empty()) {
		int u = q.front().first, w = q.front().second; q.pop();
		for(int i = head[u]; i; i = e[i].next) {
			int v = e[i].to;
			LL a = e[i].a, b = e[i].b;
			if(w >= a && dis[v][w - a] > dis[u][w] + b) {
				dis[v][w - a] = dis[u][w] + b;
				q.push({v, w - a});
			}
		}
		if(dis[u][min(w + c[u], (LL)2500)] > dis[u][w] + d[u]) {
			dis[u][min(w + c[u], (LL)2500)] = dis[u][w] + d[u];
			q.push({u, min(w + c[u], (LL)2500)});
		}
	}
}

int main() {
	scanf("%d%d%d", &n, &m, &s);
	s = min(s, 2500);
	while(m--) {
		int u, v;
		LL a, b;
		scanf("%d%d%lld%lld", &u, &v, &a, &b);
		add(u, v, a, b);
		add(v, u, a, b);
	}
	for(int i = 1; i <= n; i++) {
		scanf("%lld %lld", &c[i], &d[i]);
	}
	spfa();
	for(int i = 2; i <= n; i++) {
		LL res = inf;
		for(int j = 0; j <= 2500; j++) res = min(res, dis[i][j]);
		printf("%lld\n", res);
	}
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];

    cout << max(a[0],max(a[1],a[2]))-min(a[0],min(a[1],a[2])) << endl;
}


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

class Program
{
    private static int _limit;

    private readonly static string[] targets = new string[] {"3", "5", "7"};

    static void Main()
    {
        _limit = int.Parse(Console.ReadLine());
        
        Console.WriteLine(Search(0));
    }

    static long Search(long num)
    {
        if (num > _limit)
        {
            return 0;
        }

        var str = num.ToString();
        long count = 0;

        if (str.Contains("3") && str.Contains("5") && str.Contains("7"))
        {
            count++;
        }
        
        foreach (var target in targets)
        {
            count += Search(long.Parse(str + target));
        }

        return count;
    }
}

Measured memory_bytes: 15184
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        String answer = ":(";
        ArrayList <Integer> b = new ArrayList<>();
        for(int i = 0;i<6;i++){
            b.add(scan.nextInt());
        }
        int c = b.get(5);
        b.remove(   5);
        if(b.get(4)-b.get(0) <= c){
            answer = "Yay!";
        }else{
            answer = ":(";
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(answer);
        out.flush();
        scan.close();
    }
}

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

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

    sort(s.begin(),s.end());
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, k = map(lambda x: int(x), input().split())
list_a =  list(map(lambda x: int(x), input().split()))

band_score = 1
    
for i, score in enumerate(list_a[k:]):
    if list_a[i] < score:
        print('Yes')
        continue
    print('No')
    
    

Measured memory_bytes: 31676
#include<bits/stdc++.h>
using namespace std;
int arr[100001];
int d=0;
int main(void){
int n;
cin >> n;
for(int i=1;i<=n;i++){
    int a;
    cin >> a;
    arr[a]++;
}
for(int i=1;i<=100000;i++){
    if(arr[i])
        d++;
}
int c2=0;
for(int i=1;i<=100000;i++){
    if(arr[i] && arr[i]%2==0)
        c2++;
}
if(c2%2)
    cout <<d-1;
else
    cout << d;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	int i, N;
	long long A[100001], B[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld %lld", &(A[i]), &(B[i]));
	
	long long sum = 0;
	for (i = N; i >= 1; i--) {
		if ((A[i] + sum) % B[i] != 0) sum += B[i] - (A[i] + sum) % B[i];
	}
	
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1664
N = int(input())
a = [int(i) for i in input().split()]
ans = 0
A = True
while(A):
    for i in range(N):
        if (a[i]%2 == 1):
            A = False
        else:
            a[i]= a[i]//2
    ans += 1

print(ans-1)
            
            
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
string a,b;
int dp[3010][3010];

int f(int i , int j){
    if(i >= (int)a.size() or j >= (int)b.size()) return 0;
    int &e = dp[i][j];
    if(e != -1 ) return e;
    e = -1e9;
    if(a[i] == b[j]) {
        e = max( e , f(i+1 , j+1) +1)  ;
    }else{
        e = max( f(i+1 , j)  , f(i , j+1));
    }
    return e;
}

int main(){
    while(cin>>a>>b){
        memset(dp,-1,sizeof dp);
        int r = f(0,0);
        int i,j;
        i = j = 0;
        if(r == 0 ){

        }else{
            while(!(i >= (int)a.size() or j >= (int)b.size())){
                if(a[i] == b[j]){
                    cout<<a[i];
                    i++;
                    j++;
                }
                else{
                    if(dp [i+1][j] > dp[i][j+1]){
                        i++;
                    }else{
                        j++;
                    }
                }
            }
        }
        cout<<"\n";
    
    }
    return 0;
}

Measured memory_bytes: 39244
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[][] g = new boolean[n][n];
        int[] fo = new int[n];
        double[] p = new double[n];
        double[] l = new double[n];
        for(int i=0; i<m; i++) {
            int s = sc.nextInt() - 1;
            int t = sc.nextInt() - 1;
            g[s][t] = true;
            fo[s]++;
        }
        p[0] = 1d;
        for(int i=0; i<n; i++) {
            for(int j=i+1; j<n; j++) {
                if(g[i][j]) {
                    p[j] += p[i] / fo[i];
                }
            }
        }
        for(int i=n-2; i>=0; i--) {
            l[i] = 1;
            for(int j=i+1; j<n; j++) {
                if(g[i][j]) {
                    l[i] += l[j] / fo[i];
                }
            }
        }

        double res = l[0];

        for(int i=0; i<n; i++) {
            if(fo[i] < 2) continue;
            double max = 0;
            int maxj = 0;
            for(int j=i+1; j<n; j++) {
                if(g[i][j]) {
                    max = Math.max(max, l[j]);
                    if(l[j] == max) {
                        maxj = j;
                    }
                }
            }
            double l1 = 1;
            for(int j=i+1; j<n; j++) {
                if(g[i][j] && j != maxj) {
                    l1 += l[j] / (fo[i] - 1);
                }
            }
            double d = l[i] - l1;
            double l0 = l[0] - d * p[i];
            res = Math.min(res, l0);
        }

        System.out.println(res);
    }


}


Measured memory_bytes: 93252
#include <iostream>
using namespace std;
typedef long long ll;
ll n,m,MOD=1e9+7;
ll f(ll x,ll y){
    if(y==1)return x;
    if(y%2==0)return f(x,y/2)*f(x,y/2)%MOD;
    return x*f(x,y-1)%MOD;
}
int main(void){
    cin>>n>>m;
    cout<<f(n,m)<<endl;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main() {
   ll x,t;cin >>x>>t;
   ll ans=max(x-t,0LL);
   cout<<ans <<endl;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n;cin>>n;
  map<string, int> mp;
  int mx=0;
  for(int i=0;i<n;i++){
    string s;cin>>s;
    mp[s]++;
    mx = max(mp[s], mx);
  }
  vector<string> v;
  for(auto kv : mp) {
    auto k = kv.first;
    auto v = kv.second;
    if(v == mx) {
      cout<<(k)<<endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 25856
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,ans=0;  cin>>n>>k;
  int arr[n];
  for(int i=0; i<n; ++i) cin>>arr[i];
  sort(arr,arr+n);
  for(int i=0; i<k; ++i) ans+=arr[i];
  cout<<ans;
}

Measured memory_bytes: 3632