akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)m; i < (int)n; i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)m; i < (unsigned int)n; i++ )
#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( a, b )
#define fst first
#define snd second

int dijkstra( vector< vector< pair<int,int> > > graph, const int start, const int goal )
{
	vector<int> distance( graph.size() );
	fill( ALL( distance ), INT_MAX );

	priority_queue< pair<int,int>, vector< pair<int,int> >, greater< pair<int,int> > > que; // 累計コスト, ノード番号
	que.push( MP( 0, start ) );

	while ( !que.empty() )
	{
		int total = que.top().fst;
		int node = que.top().snd;
		que.pop();

		if ( total < distance[ node ] )
		{
			distance[ node ] = total;

			REP( i, 0, graph[ node ].size() )
			{
				int to = graph[ node ][i].fst;
				int cost = graph[ node ][i].snd;

				que.push( MP( total + cost, to ) );
			}
		}
	}

	return distance[ goal ];
}

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

	vector< vector< pair<int,int > > > graph( n );

	REP( i, 0, m )
	{
		string buffer;
		cin >> buffer;

		REP( j, 0, buffer.length() )
		{
			if ( buffer[j] == ',' )
			{
				buffer[j] = ' ';
			}
		}

		int from, to, forward, back;
		istringstream( buffer ) >> from >> to >> forward >> back;

		graph[ from - 1 ].PB( MP( to - 1, forward ) );
		graph[ to - 1 ].PB( MP( from - 1, back ) );
	}
	
	string buffer;
	cin >> buffer;

	REP( j, 0, buffer.length() )
	{
		if ( buffer[j] == ',' )
		{
			buffer[j] = ' ';
		}
	}

	int start, goal, given, pay;
	istringstream( buffer ) >> start >> goal >> given >> pay;

	cout << given - pay - dijkstra( graph, start - 1, goal - 1 ) - dijkstra( graph, goal - 1, start - 1 ) << endl;

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  char ch[4][4];
  FOR(i,1,3) FOR(j,1,3) cin >> ch[i][j];
  FOR(i,1,3) cout << ch[i][i];
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    char c;scanf(" %c",&c);
    printf("%c\n",c+1);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cstdlib>
using namespace std;


int main(void)
{
    ios::sync_with_stdio(false);
    
    int input[10001];
    
    #ifdef DEBUG
    freopen("input.txt", "r", stdin);
    #endif
    
    int N;
    cin >> N;
    for (int i=0;i<N;i++)
    {
        cin >> input[i];
    }
    
    int ans = 0;
    for (int i=0;i<N;i++)
    {
        while (input[i] % 2 == 0){
            ans++;
            input[i] /= 2;
        }
    }
    
    printf("%d",ans);
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define int ll

struct Modcomb{
  int mod; //$BAG?t(B
  std::vector<long long int>fac;  //$B3,>h(B
  std::vector<long long int>finv; //$B3,>h$N5U85(B
  std::vector<long long int>inv;  //$B5U85(B

  //nCr=n!/r!(n-r)!
  Modcomb(int max,int mod){
    this->mod=mod;
    fac.resize(max+1,0);
    finv.resize(max+1,0);
    inv.resize(max+1,0);
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<=max;i++){
      fac[i]=(fac[i-1]*i%mod)%mod;
      inv[i]=mod-inv[mod%i]*(mod/i)%mod;
      finv[i]=finv[i-1]*inv[i]%mod;
    }
  }

  int slove(int n,int r){
    if(n<r)return 0;
    if(n<0||r<0)return 0;
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod;
  }
};

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

  int N,K;
  cin>>N>>K;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(rng(A));

  vector<ll>sum(N+1,0);
  sum[0]=0;
  for(int i=1;i<=N;i++)sum[i]=(sum[i-1]%MOD+A[i-1]%MOD)%MOD;

  Modcomb modcomb(N,MOD);
  ll ans=0;
  for(int i=K;i<=N;i++){
    ans+=(((sum[N]-sum[i-1]-sum[N-i+1])%MOD)*modcomb.slove(i-2,K-2))%MOD;
  }
  cout<<ans%MOD<<endl;
  return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

ll dp[100010];

int main(void){
    ll a,b,x;
    cin>>a>>b>>x;
    if(a*a*b==x){
        cout<<0<<endl;
        return 0;
    }
    double x1=(double)2*(a*a*b-x)/(a*a*a);
    double x2=(double)a*b*b/(2*x);
    double ans1=(double)atan(x1);
    double ans2=(double)atan(x2);
    //cout<<180.0*ans1/(atan(1)*4)<<endl;
    //cout<<180.0*ans2/(atan(1)*4)<<endl;
    double ans=0.0;
    if(x>=a*a*b/2){
        ans=180.0*ans1/(atan(1)*4);
    }
    else{
        ans=180.0*ans2/(atan(1)*4);
    }
    printf("%.9lf\n",ans);
    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    int indexOfOne;
    vector <int> A(N);
    rep (i, N) {
        cin >> A[i];
        if (A[i] == 1) indexOfOne = i;
    }

    int ans = 1e9;
    rep (i, K) {
        int left = indexOfOne - i <= 0 ? 0
                                       : (indexOfOne - i) / (K - 1) + ((indexOfOne - i) % (K - 1) != 0);
        int right = indexOfOne + K - i >= N ? 0
                                            : (N - indexOfOne - K + i) / (K - 1) + ((N - indexOfOne - K + i) % (K - 1) != 0);
        ans = min(ans, left + right + 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};



int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int m,d,m2,d2;
    cin >> m >> d >> m2 >> d2;
    if(m == m2) print(0);
    if(m != m2) print(1);

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String str = in.next();
        String str2 = "abcdefghijklmnopqrstuvwxyz";
        int counter[] = new int[str2.length()];
        Arrays.fill(counter,0);
        in.close();

        int flag = 0;

        char moji[] = str.toCharArray();
        char moji2[] = str2.toCharArray();
        Arrays.sort(moji);
        for(int cnt = 0; cnt < str.length(); cnt++){
        	for(int cnt2 = 0; cnt2 < str2.length(); cnt2++){
        		if(moji[cnt] == moji2[cnt2]){
        			counter[cnt2]++;
        		}
        	}
        }
    	for(int cnt = 0; cnt < str2.length(); cnt++){
    		if(counter[cnt] == 0){
    			System.out.println(moji2[cnt]);
    			flag++;
    			break;
    		}
    	}
    	if(flag == 0){
    		System.out.println("None");
    	}



    }
}

Measured memory_bytes: 25664
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N,M,x,y,X,Y;
        N=sc.nextInt();
        M=sc.nextInt();
        X=sc.nextInt();
        Y=sc.nextInt();
        int maxX=sc.nextInt();
        for(int i=0;i<N-1;i++){
            x=sc.nextInt();
            if(maxX<x)maxX=x;
        }
        int minY=sc.nextInt();
        for(int i=0;i<M-1;i++){
            y=sc.nextInt();
            if(minY>y)minY=y;
        }
        if(maxX>=minY||maxX>=Y||minY<=X){
            System.out.println("War");
        }else{
            System.out.println("No War");
        }
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll k;
    cin>>k;
    forr(i, k)
    	cout<<"ACL";
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3800
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/rand"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	d := intScanner()
	c := intSliceScanner(26)
	s := make([][]int, d)
	for i := 0; i < d; i++ {
		s[i] = intSliceScanner(26)
	}
	best := -mod
	bestSchedule := make([]int, d)
	changeNum := 100
	for x := 0; x < 1; x++ {
		schedule := make([]int, d)
		for i := 0; i < d; i++ {
			schedule[i] = rand.Intn(26)
		}
		score := calcScore(schedule, c, s, d)
		t = float64(score) * 10.
		for y := 0; y < 120000; y++ {
			changes := make([]int, changeNum)
			pres := make([]int, changeNum)
			for i := 0; i < changeNum; i++ {
				changes[i] = rand.Intn(d)
				pres[i] = schedule[changes[i]]
				schedule[changes[i]] = rand.Intn(26)
			}
			nextScore := calcScore(schedule, c, s, d)
			if prob(score, nextScore) >= math.Abs(rand.Float64()) {
				score = nextScore
			} else {
				for i := 0; i < changeNum; i++ {
					schedule[changes[i]] = pres[i]
				}
			}
			if nextScore >= best {
				best = nextScore
				copy(bestSchedule, schedule)
			}
			t *= 0.999
			if (y+1)%100 == 0 && changeNum > 1 {
				changeNum--
			}
		}
	}
	for i := 0; i < d; i++ {
		fmt.Println(bestSchedule[i] + 1)
	}
}
func calcScore(schedule []int, c []int, s [][]int, d int) int {
	score := 0
	last := make([]int, 26)
	for i, v := range schedule {
		score += s[i][v]
		for j, _ := range last {
			last[j]++
		}
		last[v] = 0
		for j, v := range last {
			score -= c[j] * v
		}
	}
	return score
}
func prob(before int, after int) float64 {
	if before <= after {
		return 1.0
	}
	return math.Exp((float64(after) - float64(before)) / float64(t))
}


Measured memory_bytes: 6176
import math
n,d=map(int,input().split())
x = []
for _ in range(n):
    l = list(map(int, input().split()))
    x.append(l)
cnt = 0
for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x[i][k] - x[j][k])**2
        if math.sqrt(tmp) == int(math.sqrt(tmp)):
            cnt += 1
print(cnt)


Measured memory_bytes: 9096
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;
  int  cnt;

  buf = malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int main()
{
  int64 X,Y,Z;
  
  get_N1234(&X, &Y, &Z, NULL);

  printf("%lld %lld %lld", Z, X, Y);
  return 0;
}



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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int weight[101],value[101],n,w;
int cc[100001][101];
int dp(int wei, int ind)
{
	if(wei>w)
		return -1e15;
	if(ind>=n)
		return 0;
	if(cc[wei][ind]!=-1)
		return cc[wei][ind];
	int best=max(dp(wei,ind+1),dp(wei+weight[ind],ind+1)+value[ind]);
	cc[wei][ind]=best;
	return best;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    cin>>n>>w;
    memset(cc,-1,sizeof(cc));
    f1(i,0,n)
    cin>>weight[i]>>value[i];
    cout<<dp(0,0);

    return 0;
}

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

string a = "abcdefghijklmnopqrstuvwxyz";

int main() {
  string s;
  cin >> s;
  vector<int> v(26, 0);
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (s.at(i) == a.at(j)) {
        v.at(j)++;
      }
    }
  }
  bool b = true;
  for (int i = 0; i < 26; i++) {
    if (v.at(i)) continue;
    else {
      cout << a.at(i) << endl;
      b = false;
      break;
    }
  }
  if(b) cout << "None" << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    int i,j;
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n)rep(j,n){
        if(i+j > n)continue;
        string t = s.substr(0,i);
        if(i+j < n)t += s.substr(i+j);
        if(t == "keyence"){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int X,N,A;
  
 	cin >> N >> A ;	//N:マス数N^2
					//A:白色に塗る数
  	X=N*N-A;		//黒色のマス数
	cout<<X;
}

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


int main()
{
	unsigned long long int n;
	cin >> n;
	for (int i = floor(sqrt(n)); i >= 1; i--)
	{
		if (n % i == 0)
		{
			cout << i + n / i - 2 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, M; cin >> N >> M;
    ll ans = 0LL;
    int cnt = 0;

    vector<pair<ll, ll>> v(N);
    for(int i=0; i<N; i++) cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end());

    for(int i=0; i<N; i++){
        if(cnt < M){
            ans += v[i].first*min(v[i].second, (ll)M-cnt);
            cnt += min(v[i].second, (ll)M-cnt);
        }
    }

    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main() {
    ll a, b, c, d; scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    printf("%lld\n", max(max(a*c, a*d), max(b*c, b*d)));
    return 0;
}


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

using u32 = uint32_t;

int main()
{
	u32 n;
	
	std::cin >> n;
	
	std::vector<u32> v;
	
	v.reserve(n);
	
	for(u32 i=0; i<n; i++)
	{
		u32 vi;
		std::cin >> vi;
		
		v.push_back(vi);
	}
	
	u32 max = 0;
	u32 cur_len = 0;
	
	for(u32 i=0; i<n-1; i++)
	{
		//std::cout << "cur_len = " << cur_len << "\n";
		if(v[i+1] > v[i])
		{
			//std::cout << v[i+1] << " > " << v[i] << "\n";
			if(cur_len > max)
			{
				max = cur_len;
			}
			cur_len = 0;
		}
		else
		{
			//std::cout << v[i+1] << " <= " << v[i] << "\n";
			cur_len++;
		}
	}
	
	if(cur_len > max)
	{
		//std::cout << "after: " << cur_len << "\n";
		max = cur_len;
	}
	
	std::cout << max << "\n";
	
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a,i,j,max=0,min=1000000000;
  for(i=0;i<n;i++){
  cin >> a;
  if(a>max) max = a;
  if(a<min) min = a;
}
cout << max-min;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

#define INF 1000000000

using namespace std;

int main() {
    int n, m, a, b, c, t;
    scanf("%d%d", &n, &m);
    vector< pair<int, int> > k(m + 1);
    for (int i = 1; i <= m; ++i) {
        t = 0;
        scanf("%d%d", &a, &b);
        for (int j = 0; j < b; ++j) scanf("%d", &c), t |= (1 << (c - 1));
        k.at(i) = {a, t};
    }
    vector< vector<int> > dp(m + 1, vector<int>(1 << n, INF));
    dp.at(0).at(0) = 0;
    for (int i = 1; i <= m; ++i) {
        dp.at(i) = dp.at(i - 1);
        for (int j = 0; j < (1 << n); ++j) dp.at(i).at(j | k.at(i).second) = min(dp.at(i).at(j | k.at(i).second), dp.at(i - 1).at(j) + k.at(i).first);
    }
    printf("%d\n", dp.back().back() == INF ? -1 : dp.back().back());
    return 0;
}


Measured memory_bytes: 16256
# 2019-11-24 12:12:53(JST)
import sys
# import numpy as np 

def main():
    a, b = map(int, sys.stdin.read().split())

    if 0 < a:
        ans = 'Positive'
    elif 0 <= b:
        ans = 'Zero'
    else:
        if (b - a + 1) % 2 == 0:
            ans = 'Positive'
        else:
            ans = 'Negative'
    
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
using namespace std;
 
int a, b, c, d;
int main(void){
    cin >> a >> b >> c >> d;
    
    if(abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
    else if(abs(a-c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include<algorithm>
#define FOR(i,m,M) for(int i = m;i<M;i++)
using namespace std;
int main()
{
	int N, K;
	cin >> N >> K;
	int h[100000];
	bool flag = 0;
	FOR(i, 0, N)
	{
		cin >> h[i];
	}
	sort(h, h + N,greater<int>());
	FOR(j, 0, N)
	{
		if (h[j] < K)
		{
			cout << j << endl;
			flag = 1;
			break;
		}
	}
	if(!flag)
	cout<<N<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i){
        cin >> A.at(i);
    }

    int sum = accumulate(A.begin(), A.end(), 0);

    if( H <= sum ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/mincostflow>

using namespace atcoder;
using namespace std;

#define ll long long int

struct phash
{
  inline size_t operator()(const tuple<int, int> &p) const
  {
    const auto h1 = hash<int>()(get<0>(p));
    const auto h2 = hash<int>()(get<1>(p));
    return h1 ^ (h2 << 1);
  }
};

int main() {
  ll n, m;
  cin >> n >> m;
  vector<string> cells;
  vector<tuple<int, int>> pieces;
  for (size_t y = 0; y < n; y++) {
    string s;
    cin >> s;
    cells.push_back(s);
    for (size_t x = 0; x < s.size(); x++) {
      auto c = s[x];
      if (c == 'o') {
        pieces.push_back(make_tuple(x, y));
      }
    }
  }

  mcf_graph<ll, ll> flow(n * m + pieces.size() + 2);
  ll from = 0;
  ll cell_offset = pieces.size() + 1;
  ll to = n * m + pieces.size() + 1;

  for (size_t i = 0; i < pieces.size(); i++) {
    flow.add_edge(from, i + 1, 1, 0);
  }
  for (size_t i = 0; i < n * m; i++) {
    flow.add_edge(cell_offset + i, to, 1, 0);
  }

  for (size_t i = 0; i < pieces.size(); i++) {
    int x = get<0>(pieces[i]);
    int y = get<1>(pieces[i]);

    queue<tuple<int, int, int>> queue;
    queue.push(make_tuple(x, y, 0));
    unordered_set<tuple<int, int>, phash> visited;
    visited.insert(make_tuple(x, y));

    while (!queue.empty()) {
      tuple<int, int, int> item = queue.front();
      queue.pop();
      int x = get<0>(item);
      int y = get<1>(item);
      int depth = get<2>(item);

      flow.add_edge(i + 1, cell_offset + y * m + x, 1, 200-depth);
      if (x + 1 < m && cells[y][x + 1] != '#' && visited.find(make_tuple(x + 1, y)) == visited.end()) {
        queue.push(make_tuple(x + 1, y, depth + 1));
        visited.insert(make_tuple(x + 1, y));
      }
      if (y + 1 < n && cells[y + 1][x] != '#' && visited.find(make_tuple(x, y + 1)) == visited.end()) {
        queue.push(make_tuple(x, y + 1, depth + 1));
        visited.insert(make_tuple(x, y + 1));
      }
    }
  }
  
  pair<ll, ll> ans = flow.flow(from, to);
  cout << 200 * pieces.size() - ans.second << endl;
  
  return 0;
}


Measured memory_bytes: 8852
#include<iostream>
using namespace std;
int main()
{
    int l,r,d,i,k=0;
    cin>>l>>r>>d;
    for(i=l;i<=r;i++)
    {
        if(i%d==0)
            k++;
    }
    cout<<k<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

#define INF 2000000000
#define SIZE 1000000
#define pb push_back
#define showint(x) cerr<<#x<<" is "<<x<<endl;
#define showarr(x,n) for(int I=0;I<n;I++) {cerr<<#x<<"["<<I<<"]"<<" is "<<x[I]<<endl;}
//#define fin cin
int mark[500][500];
int d[500][500];
int c1[250000];
int c2[250000];
int m;
int n;
void dfs(int i,int j,int c)
{
  if(mark[i][j]!=0) return;
  mark[i][j]=c;
  if(i>0)
  {
    if(d[i-1][j]!=d[i][j])
    {
      dfs(i-1,j,c);
    }
  }
  if(j>0)
  {
    if(d[i][j-1]!=d[i][j])
    {
      dfs(i,j-1,c);
    }
  }
  if(i<n-1)
  {
    if(d[i+1][j]!=d[i][j])
    {
      dfs(i+1,j,c);
    }
  }
  if(j<m-1)
  {
    if(d[i][j+1]!=d[i][j])
    {
      dfs(i,j+1,c);
    }
  }
}
int main()
{
  ifstream fin("input.txt",ios::in);
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
  cout<<setprecision(10);
  cout<<fixed;
  cin>>n>>m;
  for(int i=0;i<n;i++)
  {
    string s;
    cin>>s;
    for(int j=0;j<m;j++)
    {
      if(s[j]=='#') d[i][j]=1;
      else d[i][j]=0;
    }
  }
  int k=0;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
    {
      if(mark[i][j]==0)
      {
        k++;
        dfs(i,j,k);
      }
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
    {
      //cout<<mark[i][j]<<" ";
      if(d[i][j]==0) c1[mark[i][j]]++;
      else c2[mark[i][j]]++;
    }
    //cout<<endl;
  }
  ll ans=0;
  for(int i=0;i<250000;i++)
  {
    //cout<<c1[i]<<" "<<c2[i]<<endl;
    ans+=1ll*c1[i]*c2[i];
  }
  cout<<ans;
}
	

Measured memory_bytes: 14336
#include<stdio.h>
int main()
{
	int n,x,i,a[105],b[105];
	while(~scanf("%d%d",&n,&x))
	{for(i=0;i<n;i++)
	 scanf("%d",&a[i]);
	 b[0]=0;
	 int sum=1;
	 for(i=1;i<=n;i++)
 {b[i]=a[i-1]+b[i-1];
	  if(b[i]<=x)sum++;
	 }
	 printf("%d\n",sum);
	}
} //

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    t = list(map(lambda x: int(x) * 2, input().split()))
    v = list(map(float, input().split())) + [0]

    for i in range(1, N):
        t[i] += t[i-1]
    t += [t[-1]]
    vnow = [0.0] * (t[-1] + 1)
    vr = [0.0] * (t[-1] + 1)
    r = 0
    for i in range(1, len(vr)):
        if i < t[r]:
            vr[i] = v[r]
        elif i == t[r]:
            vr[i] = min(v[r], v[r+1])
            r += 1
        vnow[i] = min(vnow[i-1] + 0.5, vr[i])
    for i in range(len(vr)-2, -1, -1):
        vnow[i] = min(vnow[i], vnow[i+1] + 0.5)
    
    print(sum(vnow) / 2)

if __name__ == "__main__":
    main()

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

using namespace std;

typedef long long ll;

int main()
{
    ll a, b;
    cin >> a >> b;
    string a1, b1;
    for(int i = 0; i < a; i++)
        a1 += char(b + 48);
    for(int i = 0; i < b; i++)
        b1 += char(a + 48);
    if(a1 < b1)
        cout << a1;
    else
        cout << b1;
}


Measured memory_bytes: 256
#include<stdio.h>

int cost(int n, int* a, int x){
    int sum = 0;
    for(int i=0; i<n; i++){
        sum += (*(a+i) - x) * (*(a+i) - x);
    }
    return  sum;
}

int main(){
    int n, min = 101;
    scanf("%d", &n);
    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
        if(min > a[i]){
            min = a[i];
        }
    }
    int target = min;
    while(cost(n, a, target) > cost(n, a, target+1)){
        target++;
    }
    printf("%d", cost(n, a, target));

    return 0;
}

Measured memory_bytes: 256
import string
N = int(input())
S = str(input())
arr = [chr(i) for i in range(65, 65+26)]*2
arr = "".join(arr)
new_arr = ""
for s in S:
  idx = arr.find(s)
  s = arr[idx+N]
  new_arr += s
print(new_arr)



Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0; i<n ; ++i)
#define lpx(i,x,n) for(int i=x; i<n ; ++i)
#define all(v) v.begin() , v.end()
#define sz(v) (int(v.size()))
typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<char, int> pci;
typedef vector<pii> vp;
typedef vector<pci> vpc;
typedef pair<int,pii> piii;

int OO = 2e9;
const double eps = 1e-9 ;
const int N = 500000;
int mx = -1e9 , mn = 1e9 ;
int arr[N] ;

int dcmp(double x, double y)
{
    return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}



int main()
{
    int a, b; cin>> a>> b;
    cout << max(max(a+b,a-b),a*b)<<endl;

    return 0;
}
























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

using namespace std;

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

int main() {
    int n, m;
    cin >> n >> m;
    int l = 1;
    vector<int> an(n);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a /= 2;
        an[i] = a;
        l = l / gcd(a, l) * a;
    }
    for (auto e: an) {
        if ((l / e) % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m / l + 1) / 2 << "\n";
    return 0;
}


Measured memory_bytes: 640
# Dinic's algorithm
from collections import deque
class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = 10**9 + 7
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow

N=int(input())
p=[list(map(int,input().split())) for i in range(N)]
q=[list(map(int,input().split())) for i in range(N)]

work=Dinic(2*N+2)
# S=0,G=2*N+1, p:1--N,q:N+1--2*N

for i in range(1,N+1):
    work.add_edge(0,i,1)
    work.add_edge(N+i,2*N+1,1)

for i in range(N):
    for j in range(N):
        if p[i][0]<q[j][0] and p[i][1]<q[j][1]: work.add_edge(i+1,N+j+1,1)


print(work.flow(0,2*N+1))

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

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

    while (N != 0) {
        if (N % 10 == 7) {
            cout << "Yes" << endl;
            return 0;
        }
        N /= 10;
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000000000000000000;
const char END = '\n';


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

	string S; cin >> S;
	ll n = 0;
	
	rep(i,S.length())
		n += S[i] - '0';
	
	if (n % 9 != 0)
		cout << "No";
	else
		cout << "Yes";
	cout << END;
	return 0;
}

Measured memory_bytes: 3716
#include <iostream>
using namespace std;
 int main(void){
 	int S,h,m,s;
 	cin >> S;
 	h = S / 3600;
 	m = S / 60;
 	m = m % 60;
 	s = S % 60;
 	
 	cout << h <<":"<< m <<":"<< s << endl;
 }

Measured memory_bytes: 1168
N, X = (int(i) for i in input().split())
L = [int(i) for i in input().split()] 
D = [0] * (N+1)
C = 0
for i in range(N):
	D[i+1] = D[i]+L[i]

for i in range(N+1):
	if D[i] <= X:
		C += 1

print(C)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main(int argc, char const *argv[]) {
    ll n; cin>>n;
    map<int64_t, int> mp = prime_factor(n);

    vector<ll> a(100);
    vector<ll> cnt(6000,-1);
    cnt[0] = 0;
    rep(i,70) {
        a[i+1] = a[i]+i+1;
        cnt[a[i+1]] = i+1;
    }

    for (int i = 0; i < 5000; ++i) {
        cnt[i+1] = max(cnt[i+1], cnt[i]);
    }

    ll ans = 0;
    for (auto &&e: mp) {
        ans += cnt[e.second];
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3680
package main

import "fmt"

var input string
var yes = "Yes"
var no = "No"

func main() {
	var length int
	fmt.Scan(&length)
	fmt.Scan(&input)
	var answer string
	if solve(input) {
		answer = yes
	} else {
		answer = no
	}
	fmt.Println(answer)
}

func solve(input string) (result bool) {
	var l = len(input)
	result = false
	if l%2 == 1 {
		return
	}
	for i := 0; i < l/2; i++ {
		if input[i] != input[i+l/2] {
			return
		}
	}
	result = true
	return
}

Measured memory_bytes: 512
import itertools

n, m = map(int, input().split())

path = [[False] * n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True
ans = 0

# 頂点を並び替える順列を生成してループ
for i in itertools.permutations(range(n), n):
    # 頂点1が始点
    if i[0] == 0:
        # 生成した順列の中をさらにループ
        for j in range(n):
            # n - 1 まで続いたら条件を満たすパスが存在する
            if j == n - 1:
                ans += 1
                break
            # i[j] から i[j + 1] に行くパスがなければ終了
            if not path[i[j]][i[j + 1]]:
                break

print(ans)

Measured memory_bytes: 39920
from collections import deque

result = []

while True:
    w, h = map(int, input().split())
    
    if w == 0 and h == 0:
        break
        
    L = [list(map(int, input().split())) for i in range(h)]
    flag = [[-1 for _ in range(w)] for _ in range(h)]
    res = 0
    q = deque()
    
    for y in range(h):
        for x in range(w):
            if L[y][x] == 1 and flag[y][x] == -1:
                q.append([y, x])
                flag[y][x] = 0
                res += 1
                while q:
                    ny, nx = q.pop()
                    for i, j in [(0,1), (0,-1), (1,0), (-1,0), (1,1), (1, -1), (-1, 1), (-1, -1)]:
                        if 0 <= ny + i < h and 0 <= nx + j < w:
                            if L[ny + i][nx + j] == 1 and flag[ny + i][nx + j] == -1:
                                q.append([ny + i, nx + j])
                                flag[ny + i][nx + j] = 0
                            
    result.append(res)
                            
        
for res in result:
    print(res)
    
    


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

int main() {
    string s;
    cin >> s;
    string ans;
    if (s == "Sunny") {
        ans = "Cloudy";
    } else if (s == "Cloudy") {
        ans = "Rainy";
    } else {
        ans = "Sunny";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys

x1, x2, x3, x4, x5 = map(int, input().split())

if x1 == 0:
    print(1)
    sys.exit()

if x2 == 0:
    print(2)
    sys.exit()

if x3 == 0:
    print(3)
    sys.exit()

if x4 == 0:
    print(4)
    sys.exit()

if x5 == 0:
    print(5)
    sys.exit()

Measured memory_bytes: 9188
K = 4000
A = input()
B = input()
C = input()
la, lb, lc = len(A), len(B), len(C)

def check(S, T):
    R = [1] * (K * 2 + 1)
    for i in range(-len(T), len(S)):
        for j in range(max(i, 0), min(len(S), len(T)+i)):
            if S[j] != T[j-i] and S[j] != "?" and T[j-i] != "?":
                R[i] = 0
                break
    return R

AB = check(A, B)
AC = check(A, C)
BC = check(B, C)

mi = K * 3
for i_ab in range(-K, K + 1):
    if AB[i_ab] == 0: continue
    for i_ac in range(max(-K, min(i_ab, 0) - lc), min(K + 1, max(la, i_ab + lb))):
        if AC[i_ac] == 0: continue
        if BC[i_ac - i_ab] == 0: continue
        mi = min(mi, max(i_ab + lb, i_ac + lc, la) - min(i_ab, i_ac, 0))

print(mi)

Measured memory_bytes: 56540
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000
#define MAXN 100002

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

int n;
int a[MAXN];
LL fact[MAXN];
LL factinv[MAXN];
LL inv[MAXN];

LL mul(LL a, LL b) {
  return (a * b) % MOD;
}

LL choose(LL n, LL k) {
  if (n < k) return 0;
  if (n==k) return 1;
  return mul(fact[n], mul(factinv[n-k], factinv[k]));
}

int main() {
  // factorials
	fact[0] = 1; for (int i = 1; i < MAXN; i++) fact[i] = mul(i, fact[i-1]);
	inv[0] = inv[1] = 1; for (int i = 2; i < MAXN; i++) { inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD; }
	factinv[0] = 1; for (int i = 1; i < MAXN; i++) factinv[i] = mul(inv[i], factinv[i-1]);

  memset(a, -1, sizeof a);

  GI(n);
  int dup, i1, i2;
  FORN(i, n+1) {
    int tmp;
    GI(tmp);
    if (a[tmp] >= 0) {
      dup = tmp;
      i1 = a[tmp];
      i2 = i;
    }
    a[tmp] = i;
  }

  FOR1(i, n+1) {
    printf("%lld\n",
          (
            choose(n+1, i) -
            choose(
              n - (i2-i1),
              i-1) + MOD
          ) % MOD
        );
  }
    
  return 0;
}

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



//head



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if(s.back() == 's') cout << s << "es\n";
	else cout << s << "s\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const int MOD = 1000000007;
//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;

const int MAX_N = 100050 * 3;
int n, m, s, t;
vector<int> adj[MAX_N];

int main(void) {
	ios_base::sync_with_stdio(false); 
	cin.tie(0); 
	cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n >> m;
	rep(i,0,m) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		adj[u].pb(v);
	}
	cin >> s >> t;
	s--; t--;

	vector<int> dist(n * 3, -1);
	dist[s] = 0;
	queue<int> q;
	q.push(s);

	while(!q.empty()) {
		int here = q.front();
		int cost = dist[here];
		q.pop();
		int d = (here/n + 1)%3;
		d = d * n;
		here = here%n;
		for(int i=0; i<sz(adj[here]); ++i) {
			int there = adj[here][i];
			there = there + d;
			if(dist[there] == -1) {
				dist[there] = cost+1;
				q.push(there);
			}
		}
	}

	if(dist[t] != -1) {
		cout << dist[t]/3 << endl;
	} else {
		cout << -1 << endl;
	}
	
	return 0;
}


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

int main() {
	int N;
	string S;
	cin >>N;
	cin>>S;
	long long int r=0;int g=0;int b=0;
	for (int i = 0; i < N; i++){
		if(S[i]=='R')r++;
		else if(S[i]=='G')g++;
		else b++;
	}
	long long int ans=r*g*b;
	for (int step = 1; step < N; step++){
		for (int i = 0; i < N; i++){
			if(i+step*2>=N)break;
			if(S[i]!=S[i+step]&&S[i]!=S[i+step*2]&&S[i+step]!=S[i+step*2]){
				ans--;
			}
		}
	}
	cout<<ans<<endl;
};

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h,w,d; cin>>h>>w>>d; int x[h*w+1]={},y[h*w+1]={};
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            int c; cin>>c;
            x[c]=j; y[c]=i;
        } 
    }
    int b[h*w+1]={};
    for (int i=d; i <= h*w; i++) b[i]=b[i-d]+abs(x[i]-x[i-d])+abs(y[i]-y[i-d]);
    int q; cin>>q;
    for (int i = 0; i < q; i++){
        int l,r; cin>>l>>r;
        cout<<b[r]-b[l]<<'\n';
    }
}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;
int c[51][51];
int w ,h;

bool input(){
	cin >> h >> w;
	if(w==0) return false;
	for(int i = 0;i <51;i++){
		for(int j = 0;j <51 ;j++){
			c[i][j] = 2;
		}
	}

	for(int i = 0;i < w ;i++){
		for(int j = 0; j < h ;j++){
			cin >> c[i][j];
//			cout <<c[i][j];
		}
	}
	return true;
}

void dfs(int x,int y){
	c[x][y] = 0;
	for(int i = -1; i <=1 ;i++){
		for(int j = -1; j <=1 ;j++){
			int nx = x + i;
			int ny = y + j;
//			cout <<nx << ' ' << ny << endl;
			if(0 <= nx && nx < w && 0 <= ny && ny < h && c[nx][ny] == 1)dfs(nx,ny);
		}
	}
}

void solve(){
	int res = 0;
/*	for(int i=0;i < w ;i++){
		for (int j=0;j < h;j++){
			cout <<c[i][j];
		}
		cout <<endl;
	}
*/
	for(int i=0; i < w;i++){
		for(int  j=0;j < h;j++){
			if(c[i][j] ==1){
//				cout << i << ' ' << j << endl;
				res++;
				dfs(i,j);
			}
		}
	}
	cout << res << endl;

/*	for(int i=0;i < w ;i++){
		for (int j=0;j<h;j++){
			cout <<c[i][j];
		}
		cout <<endl;
	}
	*/
}

int main(){
	while(input())solve();
}




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

int main () {
   std::string s; std::cin >> s;
   long long k; std::cin >> k;

   std::string ansb;

   int not_one;


   for(int i = 0;i < 100; i++) {
      if(s[i] != '1') {
         not_one = i;
         break;
      }
   }

   if(k >= not_one + 1) {
      ansb = s[not_one];
   } else {
      ansb = '1';
   }


   std::cout << ansb << std::endl;
}

   
   

   


Measured memory_bytes: 256
N,Y= map(int, input().split())
a = 0
for i in range(N+1):
    for j in range(N-i+1):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y:
            print(i,j,(Y - (10000*i + 5000*j)) // 1000)
            a = 1
            break
    else:
        continue
    break
if a == 0:
    print("-1 -1 -1")

Measured memory_bytes: 3060