akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i,n) for (ll i=0; i < (ll)(n); i++)

int main(void){
    string s,t;
    cin>>s>>t;
    int sl = s.size();
    int tl = t.size();
    int same=0;
    for(int i=0;i<sl-tl+1;i++){
        int count=0;
        for(int j=0;j<tl;j++){
            if(s[j+i]==t[j])count++;
            same=max(same,count);
        }
    }
    int ans=tl-same;

    cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    priority_queue<int> pq;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        pq.push(A);
    }
    for (int i = 0; i < M; ++i) {
        int a = pq.top();
        pq.pop();
        pq.push(a / 2);
    }
    ll ans = 0;
    while (!pq.empty()) {
        ll a = pq.top();
        pq.pop();
        ans += a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include <cstdio>
#include <algorithm>
#include <map>


using namespace std;
#define rep(i,n) for(i=0;i<n;i++)

typedef pair<int,int> P;

int f[400];
int can[400];
int w[400];

int main(){
	
	int i,j,k;
	int n,m,s,l,p,M;
	bool g;
	
	rep(i,400)f[i]=0;
	
	scanf("%d",&n);
	k=0;
	
	rep(i,n){
		scanf("%d %d %d",&s,&l,&p);
		for(j=s;j<=l;j++){
			f[j]= max(f[j],p);
		}
	}
	
	//rep(i,40){printf(" $%3d:%3d\n",i,f[i]);}
	
	rep(i,400){
		if(f[i]==0)continue;
		for(j=i;j<400;j++){
			if(j-i==0 ||( j-i>0 && can[j-i]!= 0)){
				can[j] = max(can[j],can[j-i]+f[i]);
			}
		}
		//rep(j,40){printf("!%2d  %3d:%3d\n",i,j,can[j]);}
	}
	
	//rep(i,40){printf(" #%3d:%3d\n",i,can[i]);}
	
	
	
	scanf("%d",&m);
	
	rep(i,m){
		scanf("%d",&w[i]);
	}
	
	
	g=false;
	rep(i,m){
		if(can[w[i]]==0){
			g=true;
			break;
		}
	}
	if(g){
		puts("-1");
	}else{
		rep(i,m){
			printf("%d\n",can[w[i]]);
		}	
	}
	
	
}

Measured memory_bytes: 1032
import sys


def main():
    n = int(sys.stdin.readline().strip())
    k = int(sys.stdin.readline().strip())

    digits = 0
    nc = n
    while nc:
        nc //= 10
        digits += 1

    dp = [[0] * (k+2) for _ in range(2)]
    dp[0][0] = 1

    for i in range(digits):
        digit = (n // (10 ** (digits - 1 - i))) % 10
        ndp = [[0] * (k+2) for _ in range(2)]
        for j in range(k+1):
            ndp[1][j] += dp[1][j]  # 0
            ndp[1][j+1] += dp[1][j] * 9

            if digit == 0:
                ndp[0][j] += dp[0][j]
            else:
                ndp[1][j] += dp[0][j]  # 0
                ndp[1][j+1] += dp[0][j] * (digit-1)  # less
                ndp[0][j+1] += dp[0][j]  # same
        dp = ndp
    print(dp[1][k] + dp[0][k])


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
//Palindrome-phobia

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define nxvarep(n,x,a) ll n,x;cin>>n>>x;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    string s;cin>>s;
    int a=0,b=0,c=0;
    rep(i,0,s.size()){
        if(s[i]=='a')a++;
        else if(s[i]=='b')b++;
        else c++;
    }
    int ma = max(a,max(b,c));
    int mi = min(a,min(b,c));
    if(ma-mi<2)cout<<"YES"<<nnn;
    else cout<<"NO"<<nnn;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
	unsigned short set;            	/* 使用できる最大値格納用変数 */
	unsigned long tag;            	/* 目標値格納用変数 */
	signed short mid;            	/* 計算用変数 */
	unsigned short agg[100];       	/* 計算結果格納用配列 */
	int i, j;           	/* ループ変数 */
	int input_count = 0;	/* 入力数カウンタ */
	int num_count = 0;  	/* 目標を満足する値のカウンタ */
	
	/* 配列の初期化 */
	for(i = 0;i < 100;i++){
		agg[i] = 0;
	}
	
	/* 数値の入力、演算を無限ループ */
	while(1){
		/* 使用できる最大値、目標値の入力 */
		scanf("%d %ld", &set, &tag);
		
		/* 終了処理 */
		if(set == 0 && tag == 0){
			break;
		}
		/* カウンタをリセット */
		num_count = 0;
		
		/* 目標を満足する値をカウント */
		for(i = 1;i < set;i++){
			for(j = i;j <= set;j++){
				/* i + j と目標値の差をmidに代入 */
				mid = tag - (i + j);
				/* midがiとjの間にある場合カウント*/
				if(mid > i && mid < j){
					num_count++;
				}
			}
		}
		
		/* カウントした結果を格納 */
		agg[input_count] = num_count;
		/* 入力数をカウント */
		input_count++;
	}
	
	/* 結果の出力 */
	for(i = 0;i < input_count;i++){
		printf("%d\n", agg[i]);
	}
	
	return 0;
}



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

int main()
{
  char c;
  int result[26] = {0};

  while (cin >> c)
    if (isalpha(c)) result[tolower(c)-'a']++;
  for (int i = 0; i < 26; i++)
    cout << (char)(i+'a') << " : " << result[i] << endl;
  return 0;
}


Measured memory_bytes: 3088
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int N=3010;
string s,ans;int n,a[N],b[N],lst,tot,cnt;
bool check(int x,int y){return max(a[x],b[x])<min(a[y],b[y]);}
int main(){
    cin>>n>>s;a[0]=b[0]=-1;
    rep(i,0,2*n-1){
        if(s[i]=='a') a[++cnt]=i;
        else b[++tot]=i;
    }lst=n+1;
    per(i,n,1) if(check(i-1,i)){
        if(a[i]<b[i]){
            int tt=a[i]-1;
            rep(j,i,lst-1) if(a[j]>tt) ans=max(ans,"ab"+ans),tt=b[j];
        }
        else{
            int cnt=0,L=b[i],R=a[lst-1];string str=ans;
            per(j,R,L) cnt+=s[j]=='a'?1:-1,cnt>=0?ans=max(ans,string(cnt,'b')+s.substr(j,R+1-j)+str):"";
        }
        lst=i;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
	return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a;
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        cin >> a;
        cnt[a]++;
    }
    if (cnt.find(0) != cnt.end() && cnt[0] == n) {
        cout << "Yes" << endl;
    } else if (n % 3 != 0) {
        cout << "No" << endl;
    } else if (cnt.size() == 2 && cnt.find(0) != cnt.end() && cnt[0] == n / 3) {
        cout << "Yes" << endl;
    } else if (cnt.size() != 3) {
        cout << "No" << endl;
    } else {
        map<int, int>::const_iterator it = cnt.begin();
        int b = 0;
        for (int i = 1; i <= 3; i++) {
            if ((*it).second != n / 3) {
                cout << "No" << endl;
                return 0;
            }
            b ^= (*it).first;
            it++;
        }
        if (b == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3840
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.math.BigDecimal;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long K = in.nextLong();
            if(K==0){
                out.println(2);
                out.println(1+" "+1);
                return;
            }
            if(K==1){
                out.println(2);
                out.println(0+" "+2);
                return;
            }
            if(K<=50){
                out.println(K);
                for(int i=0; i<K; i++){
                    out.print(K+" ");
                }
                out.println();
                return;
            }
            long s = K/50;
            long t = K%50;
            long a[] = new long[50];
            for(int i=0; i<50; i++){
                a[i] = 50+s-1;
            }
            for(int h=0; h<t; h++){
                for(int i=0; i<50; i++){
                    if(i==0){
                        a[0] = a[0] + 50;
                    }
                    else{
                        a[i] = a[i] - 1;
                    }
                }
                Arrays.sort(a);
            }   
            out.println(50);
            for(int i=0; i<50; i++){
                out.print(a[i]+" ");
            }
            out.println();
            
        }
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
string a="AC";
int main()
{
    int n,m;
    string s;
    cin >> n >> m >> s;
    int dp[n+2]={0};
    //memset(dp,0,sizeof(dp));
    for(int i=1;i<n+2;i++){
        if(s[i-1]=='A' && s[i]=='C'){
            dp[i]=dp[i-1]+1;
        }
        else dp[i]=dp[i-1];
    }
    while(m--){
        int l,r;
        cin >> l >> r;
        cout << dp[r-1]-dp[l-1] << endl;
    }
}


Measured memory_bytes: 1408
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
  vector<int> h, w;
  short in_h, in_w;

  while(1)
  {
    scanf("%hd %hd", &in_h, &in_w);
    if(in_h == 0 && in_w == 0)break;
    h.push_back(in_h);
    w.push_back(in_w);
  }
  for(int i=0; i < h.size(); i++)
  {
    for (int j=0; j<h[i]; j++)
    {
      for(int k=0; k<w[i]; k++)
      {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;

}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n,m;
  cin>>n>>m;
  auto adj = vec<int>(n,n);
  vector<pair<int,int>> edges(m);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    adj[a][b] = adj[b][a] = 1;
    edges[i] = {a,b};
  }

  int ans = 0;
  auto is_connected = [&](){
    vector<int> seen(n,false);
    queue<int> que;
    que.emplace(0);
    int cnt = 0;
    while(!que.empty()){
      int v = que.front();
      que.pop();
      if(seen[v])continue;
      seen[v] = 1;
      cnt++;
      rep(i,n){
        if(adj[v][i]){
          que.emplace(i);
        }
      }
    }
    dump(cnt,seen);
    return cnt!=n;
  };
  for(auto& e:edges){
    adj[e.first][e.second] = adj[e.second][e.first] = 0;
    ans += is_connected();
    adj[e.first][e.second] = adj[e.second][e.first] = 1;
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
queue = []
sum_prc_time = 0

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

def main_prc(prc_dat):
  global queue
  global sum_prc_time

  prc_time = int(prc_dat[-1])
  diff = prc_time - max_time

  if diff <= 0:
    sum_prc_time += prc_time
    print(f"{prc_dat[0]} {sum_prc_time}")
  else:
    sum_prc_time += max_time
    queue.append([prc_dat[0], diff])

for i in range(n):
  main_prc(input().split())

while 0 < len(queue):
  main_prc(queue.pop(0))


Measured memory_bytes: 8128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int H, W;
    cin >> H >> W;
    char S[W][H];
    rep(y, H)
    {
        rep(x, W)
        {
            cin >> S[x][y];
        }
    }
    vvint Vx(W, vint(H)), Vy(W, vint(H)), V(W, vint(H));
    rep(y, H)
    {
        rep(x, W)
        {
            if(Vx[x][y]>0)
            {
                continue;
            }
            int num = 0, nx = x;
            while (nx < W and 0 <= nx and S[nx][y] == '.')
            {
                nx++;
                num++;
            }
            nx = x - 1;
            while (nx < W and 0 <= nx and S[nx][y] == '.')
            {
                nx--;
                num++;
            }
            nx = x;
            while (nx < W and 0 <= nx and S[nx][y] == '.')
            {
                Vx[nx][y] = num;
                nx++;
            }
            nx = x - 1;
            while (nx < W and 0 <= nx and S[nx][y] == '.')
            {
                Vx[nx][y] = num;
                nx--;
            }
        }
    }
    rep(x, W)
    {
        rep(y, H)
        {
            if(Vy[x][y]>0)
            {
                continue;
            }
            int num = 0, ny = y;
            while (ny < H and 0 <= ny and S[x][ny] == '.')
            {
                ny++;
                num++;
            }
            ny = y - 1;
            while (ny < H and 0 <= ny and S[x][ny] == '.')
            {
                ny--;
                num++;
            }
            ny = y;
            while (ny < H and 0 <= ny and S[x][ny] == '.')
            {
                Vy[x][ny] = num;
                ny++;
            }
            ny = y - 1;
            while (ny < H and 0 <= ny and S[x][ny] == '.')
            {
                Vy[x][ny] = num;
                ny--;
            }
        }
    }
    int ans = 0;
    rep(x, W)
    {
        rep(y, H)
        {
            ans = max(Vx[x][y] + Vy[x][y], ans);
        }
    }
    cout << ans - 1;
    return 0;
}

Measured memory_bytes: 51328
#include<stdio.h>
int main()
{
    int n,x,t,div1;
    float div;
    scanf("%d%d%d",&n,&x,&t);
    div=(1.0*n)/x;
    div1=div;
    if(div1==div)
    {
        div1=div;
    }
    else
    {
        div1=(int)div+1;
    }
    printf("%d",div1*t);
    return 0;
}

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

using namespace std;

int main(void) {
	int m,nmin,nmax;
	while (cin >> m >> nmin >> nmax, m) {
		vector<int> p(m);
		for (int i = 0; i < m; ++i) {
			cin >> p[i];
		}
		int res = 0;
		int gap = 0;
		for (int i = nmin; i <= nmax; ++i) {
			if (p[i-1] - p[i] >= gap) {
				res = i;
				gap = p[i-1] - p[i];
			}
		}
		cout << res << endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;

bool Solve() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());

    for (size_t i = 1; i < s.size(); ++i)
        if (s[i - 1] == s[i]) return false;
    return true;
}

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

    if (Solve()) cout << "yes\n";
    else cout << "no\n";

    return 0;
}


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

int Peaks(vector<vector<int>> adj,int heights[],int obs) {
    int countPeaks = 0;
    for(unsigned int i=1;i<adj.size();i++) {
        bool moreHeight = true;
        for(unsigned int j=0;j<adj[i].size();j++) {
            if(heights[i] <= heights[adj[i][j]]) {
                moreHeight = false;
                break;
            }
        }
        if(moreHeight) {
            countPeaks++; 
        }
    }
    return countPeaks;
}

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int obs,roads,o1,o2;
    cin >> obs >> roads;
    int heights[obs+1];
    for(int i=1;i<=obs;i++) cin >> heights[i];
    vector<vector<int>> adj(obs+1);
    while(roads-- > 0) {
        // make an adjacency list of roads that have observatories conncected to each other then apply bfs
        cin >> o1 >> o2;
        adj[o1].push_back(o2);
        adj[o2].push_back(o1);
    }
    // adjacency list set and ready to roll
    cout << Peaks(adj,heights,obs) << "\n";
}

Measured memory_bytes: 13664
# -*- coding: utf-8 -*-

import math

x = int(input())

# 階乗
a = math.factorial(x)

# 素数判定用関数
def is_prime_2(num):
    if num < 2:
        return False
    if num == 2 or num == 3 or num == 5:
        return True
    if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
        return False
    # 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    num_sqrt = math.sqrt(num)
    while prime <= num_sqrt:
        if num % prime == 0:
            return False
        prime += step
        step = 6 - step
    return True

# xまでの間にある素数を列挙
sosu_list = []
for i in range(x+1):
    if is_prime_2(i):
        sosu_list.append(i)

# 素因数分解していく中で、使った素数のカウントを取る
sosu_cnt = {}
for sosu in sosu_list:
    while a % sosu == 0:
        if sosu in sosu_cnt:
            sosu_cnt[sosu] += 1
        else:
            sosu_cnt[sosu] = 1
        a //= sosu

# 素数カウントを使って、約数の個数を求める
ans = 1
for key, value in sosu_cnt.items():
    sosu_cnt[key] += 1
    ans = (ans * sosu_cnt[key]) % (10 ** 9 + 7)
print(ans)

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

struct set {
	int power, motor, cable;
};



int main() {
	while (1) {
		int a, b, c;
		cin >> a >> b >> c;

		if (a == 0) break;

		vector<int> result(a + b + c, 2);
		int exp;
		vector<set> cexp, fexp;
		cin >> exp;

		for (int i = 0; i < exp; i++) {
			int d, e, f, g;
			cin >> d >> e >> f >> g;
			if (g) cexp.push_back({ d - 1,e - 1,f - 1 });
			else fexp.push_back({ d - 1,e - 1,f - 1 });
		}


		for (int i = 0; i < cexp.size(); i++) {
			result[cexp[i].power] = result[cexp[i].motor] = result[cexp[i].cable] = 1;
		}


		for (int i = 0; i < fexp.size(); i++) {
			int temp = 0;
			if (result[fexp[i].power] == 1) temp += 1;
			if (result[fexp[i].motor] == 1) temp += 2;
			if (result[fexp[i].cable] == 1) temp += 4;

			if ((temp ^ 7) == 1) result[fexp[i].power] = 0;
			if ((temp ^ 7) == 2) result[fexp[i].motor] = 0;
			if ((temp ^ 7) == 4) result[fexp[i].cable] = 0;

		}

		for (int i = 0; i < result.size(); i++) {
			cout << result[i] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
	
	int n,v,ans,a[100005],b[100005];
int main()
{
    std::ios::sync_with_stdio(false);
    cin>>n>>v;
    for (int i=1;i<=n;i++) 
	cin>>a[i]>>b[i];
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    for(int i=n;i>=1&&b[i]>a[n]&&v>0;v-=b[i],i--,ans++);
    if(v>0) ans=ans+v/a[n]+(v%a[n]!=0);
    cout<<ans;
}

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

int main() {
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)
    cout<<"1"<<endl;
  if(b==0)
    cout<<"2"<<endl;
  if(c==0)
    cout<<"3"<<endl;
  if(d==0)
    cout<<"4"<<endl;
  if(e==0)
    cout<<"5"<<endl;
  
}


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

using namespace std;

#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
#define ll long long
const int maxn=1e6+10;
const int mod=1e9+7;
const double pi=acos(-1);

int main()
{
    ll n,k;
    sll2(n,k);
    int ans=1;
    ll s=k;
    while(s<=n)
    {
        s*=k;
        ans++;
    }
    cout<<ans;
    return 0;
}


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

int main() {
    cout << fixed << setprecision(10);
    
    int N, M; cin >> N >> M;
    vector<vector<int>> edge(N);
    rep(i, M) {
        int x, y;
        int trsh;
        cin >> x >> y >> trsh;
        x -= 1;
        y -= 1;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    vector<int> alrdy(N, 0);

    int ans = 0;

    rep(i, N) {
        if (alrdy[i] == 1) {
            continue;
        }

        ans += 1;
        stack<int> dfs;
        dfs.push(i);
        alrdy[i] = 1;

        while(!dfs.empty()) {
            int now_node = dfs.top();
            dfs.pop();

            for(int next_node: edge[now_node]) {
                if (alrdy[next_node] == 1) {
                    continue;
                }

                dfs.push(next_node);
                alrdy[next_node] = 1;
            }
        }
    }

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

Measured memory_bytes: 6904
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <cstring>
#include <stack>
#include <deque>
using namespace std;

int main(){
    long long a, b, m, x, y, z;
    cin >> a >> b >> m;
    long long s[a], t[b], ms = INT32_MAX, mt = INT32_MAX;
    for(long long i = 0; i < a; i++){
        cin >> s[i];
        ms = min(ms, s[i]);
    }
    for(long long i = 0; i < b; i++){
        cin >> t[i];
        mt = min(mt, t[i]);
    }
    long long mi = INT32_MAX;
    for(long long i = 0; i < m; i++){
        cin >> x >> y >> z;
        x--; y--;
        mi = min(mi, s[x] + t[y] - z);
    }
    cout << min(ms+mt, mi) << '\n';
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
int main()
{
	int i=0, k=0;
	int ret;
	int bangou[100];
	double weight[100];
	double height[100];
	double bmi[100];
	int output[100];
	while(1){
		ret=scanf("%d,%lf,%lf",&bangou[i],&weight[i],&height[i]);
		if(ret==EOF){
			break;
		}
		bmi[i]=weight[i]/(height[i]*height[i]);
		if(bmi[i]>=25.0){
			output[k]=bangou[i];
			k++;
		}
		i++;
	}
	for(i=0; i<k; i++){
		printf("%d\n",output[i]);
	}
	if(k==0){
		printf("該当なし");
	}
	return 0;
}

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

#define ll long long int

const ll sz=1e5+100;
const ll mod=1e9+7;

ll dp[sz];

int main()
{
    ll m,p,q,i,j,k,l,n;
    cin>>n>>k;

    ll ara[n+1];

    for(i=1;i<=n;i++) cin>>ara[i];

    for(ll j=1;j<=n;j++){
        ll sum[k+1];
        dp[0]=sum[0]=1;
        for(i=1;i<=k;i++) sum[i]=(sum[i-1]+dp[i])%mod;
        ll temp[k+1];
        memset(temp,0,sizeof temp);

        for(i=1;i<=k;i++){
            ll l=max(0ll, i-ara[j]);
            ll r=max(0ll, i-max(0,1));
            if(l<=r){
                if(l==0) temp[i]=sum[r];
                else temp[i]=(((sum[r]-sum[l-1])%mod)+mod)%mod;
            }
        }

        for(i=1;i<=k;i++) dp[i]=(dp[i] + temp[i])%mod;
    }


    cout<<dp[k]<<'\n';
}


Measured memory_bytes: 5920
from collections import deque

N,u,v = map(int,input().split())
u -= 1
v -= 1
adj = [ [] for _ in range(N) ]
for _ in range(N-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  adj[a].append(b)
  adj[b].append(a)


def bfs(v):
  visited = [False] * N
  q = deque([v])
  span = [-1] * N

  s = 0
  while q:
    l = len(q)
    newq = deque([])

    for _ in range(l):
      node = q.popleft()
      visited[node] = True
      span[node] = s

      for nei in adj[node]:
        if not visited[nei]:
          newq.append(nei)

    q = newq
    s += 1

  return span

t = bfs(u)
a = bfs(v)

ans = 0
for i in range(N):
  if t[i] <= a[i]:
    ans = max(ans, a[i]-1)

print(ans)

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

n,*H = list(map(int,read().split()))
h = [0]
h.extend(H)

dp = [100] * (n+1)
dp[1] = 0
dp[2] = abs(h[2]-h[1])

for i in range(3,n+1):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])


Measured memory_bytes: 11608
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll x; cin >> x;
    ll ans = x/11*2;
    ll rest = x%11;
    if(rest >= 7) ans += 2;
    else if(rest > 0) ans++; 
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
 
n = int(readline())
if n % 2 == 1:
    print(0)
else:
    n //= 2
    answ = 0
    while n:
        n //= 5
        answ += n
    print(answ)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;

vector<P> to[100005][3];
bool used[100005][3];
int dist[100005][3];

void bfs(int x) {
    queue<P> q;
    used[x][0] = true;
    dist[x][0] = 0;
    q.push(P(x, 0));
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        for (auto e: to[p.first][p.second]) {
            if (used[e.first][e.second]) continue;
            q.push(e);
            used[e.first][e.second] = true;
            dist[e.first][e.second] = dist[p.first][p.second] + 1;
        }
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        to[u][0].emplace_back(v, 1);
        to[u][1].emplace_back(v, 2);
        to[u][2].emplace_back(v, 0);
    }
    int s, t;
    cin >> s >> t;
    s--; t--;
    bfs(s);

    int ans = dist[t][0]/3;
    if (ans==0) ans = -1;
    
    cout << ans << endl;
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------
		int n = Integer.parseInt(sc.next());
		String s = sc.next();
		String ret = "";

		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			int a = c - 'A';
			a = (a + n) % 26;
			ret += (char) ('A' + a);
		}

		out.println(ret);

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
}

Measured memory_bytes: 44732
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main() {
   ll n; cin >> n;
   vvl G(n);
   rep(i,n-1){
       ll a,b; cin >> a >> b;
       a--; b--;
       G[a].push_back(b);
       G[b].push_back(a);
   }
   vl c(n);
   rep(i,n) cin >> c[i];
   sort(all(c));
   ll sum = 0;
   rep(i,n-1) sum += c[i];
   cout << sum << endl;
   queue<ll> q;
   q.push(0);
   vl ans(n,-1);
   ans[0] = c.back(); c.pop_back();
   while(!q.empty()){
       ll u = q.front(); q.pop();
       for(auto v : G[u]){
           if(ans[v] != -1) continue;
           ans[v] = c.back(); c.pop_back();
           q.push(v);
       }
   }
   rep(i,n) cout << ans[i] << " ";
}


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

int main() {
  int c[3][3], c_min[3] = {200, 200, 200};

  int i, j;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      cin >> c[i][j];
      c_min[i] = min(c_min[i], c[i][j]);
    }
    for (j = 0; j < 3; j++) {
      c[i][j] -= c_min[i];
    }
  }

  bool result = true;

  for (i = 0; i < 3; i++) {
    if (!(c[0][i] == c[1][i] && c[1][i] == c[2][i])) {
      result = false;
    }
  }
  cout << (result ? "Yes" : "No") << endl;


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    // Your code here!
    int x,n,l[105],d[10005],o=1,ans=0;
    
    scanf("%d%d",&n,&x);
    
    for(int i=1;i<=n;i++){
        scanf("%d",&l[i]);
    }
    
    d[1]=0;
    
    for(int i=2;i<=n+1;i++){
        d[i]=d[i-1]+l[i-1];
    }
    
    while(d[o]<=x){
        o++;
        ans++;
        if(n+1==ans){
            break;
        }
    }
    
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <fstream>
#include <set>
#include <cmath>
#include <array>
#include <iomanip>
#include <cassert>

using namespace std;

void Yes(std::vector<int>& answer) {

    cout << "Yes" << endl;
    for (int i = 1; i < (int)answer.size(); i++) {
        cout << answer[i] << " ";
        assert(answer[i] != -1);
    }
    exit(0);
}

void No() {
    cout << "No" << endl;
    exit(0);
}

int main(void) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    std::vector<pair<int, int>> x(n);
    int tmp = 1;
    for (auto& el : x) {
        cin >> el.first;
        el.second = tmp;
        tmp++;
    }
    std::sort(x.begin(), x.end());

    std::vector<int> answer(n * n + 1, -1);
    std::vector<int> counts(n + 1, n);

    int cur = 1;

    for (auto& pr : x) {
        if (answer[pr.first] != -1) {
            No();
        }
        answer[pr.first] = pr.second;
        counts[pr.second]--;
        int cnt = pr.second - 1;
        while (cnt-->0) {
            if (answer[cur] != -1) {
                cur++;
                cnt++;
                continue;
            }
            answer[cur] = pr.second;
            counts[pr.second]--;
            cur++;
        }

        if (cur > pr.first) {
            No();
        }
    }

    cur = n * n;
    std::reverse(x.begin(), x.end());
    for (auto& pr : x) {
        int i = pr.second;
        while (counts[i]-->0) {
            if (answer[cur] == -1) {
                answer[cur] = i;
            } else {
                counts[i]++;
            }
            cur--;
        }
        if (cur < pr.first) {
            No();
        }

    }
    assert(cur = n * n + 1);

    Yes(answer);
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define inf 2147483647
#define N 100010
using namespace std;
int n, k;
int A[N];
int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++ i)
		scanf("%d", &A[i]);
	int Min = inf;
	for(int i = 1; i + k - 1 <= n; ++ i)
		Min = min(Min, A[i + k - 1] - A[i] + min(abs(A[i + k - 1]), abs(A[i])));
	printf("%d", Min);
	return 0;
}

Measured memory_bytes: 640
#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 a, b, c, d, e;
    
    cin >> a >> b >> c >> d >> e;

    if(a == 0) cout <<1 <<endl ;

    
    if(b == 0) cout <<2 <<endl ;

    
    if(c == 0) cout <<3 <<endl ;

    
    if(d == 0) cout <<4 <<endl ;

    
    if(e == 0) cout <<5 <<endl ;

}




Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define MAXS 8005
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string S;
int X, Y;
vi vert, hori;
bool dp[MAXS][MAXS];

bool check(int goal, vi vec){
    int n = vec.size();

    fill(dp[0], dp[n], 0);

    dp[0][0] = 1;

    for(int i = 1; i <= n; i++){
        int val = vec[i-1];
        
        rep(j,MAXS){
            if(dp[i-1][j] == 1){
                if(j-val>=0) dp[i][j-val] = 1;
                if(j+val<MAXS) dp[i][j+val] = 1;
            }
        }
    }

    return dp[n][goal];
}

int main(){
    cin >> S >> X >> Y;
    if(S[S.size()-1]!='T') S += 'T'; //パディング

    int tmp = 0;
    bool state = true;

    rep(i, S.size()){
        if(S[i] == 'F'){
            tmp++;
        } else {
            if(state)
                hori.push_back(tmp);
            else
                vert.push_back(tmp);
            tmp = 0;
            state = !state;
        }
    }

    X -= hori[0];
    hori.erase(hori.begin()); //初期値だけシフトして対称性を保つ
    X = abs(X);
    Y = abs(Y);
    // printf("goal: (%d,%d)\n",X,Y);

    // printf("vertical: ");
    // rep(i,vert.size())
    //     cout << vert[i] << " ";
    // cout << endl;

    // printf("horizontal: ");
    // rep(i,hori.size())
    //     cout << hori[i] << " ";
    // cout << endl;

    if(check(Y,vert) && check(X, hori)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 33152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, x;
    cin >> n >> x;
    int ans = 1;
    int sum = 0;
    rep(i, 0, n) {
        int l;
        cin >> l;
        sum += l;
        if (sum <= x) ans++;
    }

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


Measured memory_bytes: 256
s = input()
t = input()

def z_algorithm(s):
    n = len(s)
    res = [0] * n
    i = 1
    j = 0
    while i < n:
        # i番目以降の一致文字数
        while i + j < n and s[j] == s[i + j]:
            j += 1
        res[i] = j

        # 一文字も一致しない場合，次の文字へ
        if j == 0:
            i += 1
            continue

        # 一致したところまでを埋める
        k = 1
        while i + k < n and k + res[k] < j:
            res[i + k] = res[k]
            k += 1
        
        i += k
        j -= k
        
    return res


n = len(t)
if n > len(s):
    ss = s * (n // len(s) + 1)
else:
    ss = s * 2

z = z_algorithm(t + ss * 2)
ans = 0
for i in range(n):
    c = 0
    for v in z[n + i::n]:
        if v >= n:
            c += 1
        else:
            c = 0
        ans = max(ans, c)
        
if ans <= len(ss) // n:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 87372
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	int N;
	cin >> N;
	map<string, int> m;
	string prev_s;
	cin >> prev_s;
	m[prev_s]++;
	bool flag = true;
	rep(i, 0, N - 1) {
		string current_s;
		cin >> current_s;
		if(m[current_s] != 0) {
			flag = false;
		}
		if(prev_s[prev_s.size() - 1] != current_s[0]) {
			flag = false;
		}

		m[current_s]++;
		prev_s = current_s;
	}

	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define INF 50000000000
struct vertex{
	std::vector<int> edge_to;
	std::vector<int> edge_cost;
	bool done;
	long long int mincost;
};
std::vector<vertex> G(100000);
typedef std::pair<int,int> P;
void shortest_path(int v);
int prim(int x);
int V,E;
int r;
int main(void){
	std::cin>>V>>E;
	for(int i=0;i<E;i++){
		int from,to,cost;
		std::cin>>from>>to>>cost;
		G[from].edge_to.push_back(to);
		G[from].edge_cost.push_back(cost);
		G[to].edge_to.push_back(from);
		G[to].edge_cost.push_back(cost);		
	}
	std::cout<<prim(0)<<std::endl;
	//shortest_path(r);
/*	for(int i=0;i<V;i++){
		if(G[i].mincost!=INF){
			std::cout<<G[i].mincost<<std::endl;
		}else {
			std::cout<<"INF"<<std::endl;
		}	
	}*/
	return 0;
}
void shortest_path(int v){
	for(int i=0;i<V;i++){
		G[i].mincost=INF;
	}
	G[v].mincost=0;
	std::priority_queue<P,std::vector<P>, std::greater<P> > que;
	que.push(P(0,v));//first:cost,second vertex
	while(!que.empty()){
		P p=que.top();que.pop();
		int from=p.second;
		if(G[from].mincost<p.first){
			continue;
		}
		for(int i=0;i<G[from].edge_to.size();i++){
			int to=G[from].edge_to[i];
			int cost_to=G[from].edge_cost[i];
			if(G[to].mincost>G[from].mincost+cost_to){
				G[to].mincost=G[from].mincost+cost_to;
				que.push(P(G[to].mincost,to));
			}
		}
	}
}
int prim(int x){
	for(int i=0;i<V;i++){
		G[i].mincost=INF;
		G[i].done=false;
	}
	G[x].mincost=0;
	int res=0;
	while(1){
		int v=-1;
		for(int u=0;u<V;u++){
			if(!G[u].done && (v==-1 || G[u].mincost<G[v].mincost)){
				v=u;
			}
		}
		if(v==-1){
			break;
		}
		G[v].done=true;
		res+=G[v].mincost;
//		std::cout<<v<<" "<<res<<std::endl;
		/*for(int u=0;u<V;u++){
			int mem=-1;
			for(int i=0;i<G[v].edge_to.size();i++{
				if(G[v].edge_to[i]==u){
					mem=i;
				}
			}
			if(mem!=-1){
				mincost[u]=std::min(G[u].mincost,G[v].edge_cost[mem]);
			}
		}*/
		for(int i=0;i<G[v].edge_to.size();i++){
			int to=G[v].edge_to[i];
			int to_cost=G[v].edge_cost[i];
			if(G[to].mincost>to_cost){
				G[to].mincost=to_cost;
			}
		}
	}
	return res;
}

Measured memory_bytes: 11996
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder sb=new StringBuilder("");
		int H=sc.nextInt(),W=sc.nextInt();
		while (H!=0||W!=0){
			for(int a=1;a<=H;a++){
				for (int b=1;b<=W;b++){
					if((a%2==1&&b%2==1)||(a%2==0&&b%2==0)){
						sb.append("#");
					}else if((a%2==0&&b%2==1)||(a%2==1&&b%2==0)){
						sb.append(".");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
			H=sc.nextInt();W=sc.nextInt();
		}
		System.out.print(sb);
		}
}

Measured memory_bytes: 20992
s = input()

for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        break
 
    if i < len(s) - 2 and s[i] == s[i + 2]:
        print(i + 1, i + 3)
        break
else:
    print(-1, -1)


Measured memory_bytes: 39408
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
int main()
{
	ll n; cin>>n; ll a[n];
	ff(0,n) cin>>a[i];
	ll d=*min_element(a,a+n);
	ll x=d;
	while(1)
	{
		ff(0,n) if(a[i]%d!=0) d=a[i]%d;
		if(d==x) break;
		if(d==1) break;
		x=d;	
	}
	cout<<d;
}

Measured memory_bytes: 4336
#pragma GCC optimize("O3")
#include <bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.size();i++){
        sum+=int(s[i]-'0');
        sum%=9;
    }
    cout<<(sum==0?"Yes":"No")<<"\n";
}


Measured memory_bytes: 3736
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<set>
#include<algorithm>
#include<map>
#include<ctime>
#define mp make_pair
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const double eps = 1e-8;
const int maxn = 200009;
const int inf = 100000009;
const int mod = 10007;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int tmp = a + b + c;
	if (tmp >= 22) cout << "bust";
	else cout << "win";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t1,t2,a1,a2,b1,b2;
int main()
{

    scanf("%lld%lld%lld%lld%lld%lld",&t1,&t2,&a1,&a2,&b1,&b2);
    ll a=a1-b1,b=a2-b2;
    if(a<0) a*=-1,b*=-1;
    ll k=t1*a+t2*b;
    if(k==0) {printf("infinity\n");return 0;}
    if(k>0){printf("0\n");return 0;}
    ll ans=a*t1/(-k)-b*t2/(-k);
    if(-b*t2%(-k)==0) ans--;
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n, a, b;
    cin >> n >> a >> b;
    
    ll ans = n/(a+b)*a+ min(n%(a+b), a);
    cout << ans;
    
}









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

const int MAXN = 1e5;
const int P = 1e9 + 7;

inline int add(int a, int b) { return a + b >= P ? a + b - P : a + b; }
inline void inc(int &a, int b) { a = add(a, b); } 

int n, m, a[MAXN + 9], b[MAXN + 9];
struct Data { int x, y; } p[MAXN + 9];

inline bool cmp(const Data &f, const Data &g) {
  return f.y == g.y ? f.x > g.x : f.y < g.y;
}

int ind[MAXN + 9], tot = 0;

void Discretize() {
  std::sort(ind + 1, ind + tot + 1);
  for (int i = 1; i <= tot; ++i) p[i].x = std::lower_bound(ind + 1, ind + tot + 1, p[i].x) - ind;
}

struct BinaryIndexdTree {
  #define lowbit(x) (x & -x)

  int c[MAXN + 9];

  void Add(int x, int delta) { for (; x <= n; x += lowbit(x)) inc(c[x], delta); }

  int Query(int x) {
    int res = 0;
    for (; x; x -= lowbit(x)) inc(res, c[x]);
    return res;
  }
} BIT;

int ans = 1, dp[MAXN + 9];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= m; ++i) scanf("%d", &b[i]);

  for (int i = 1, j = 1; i < m && j <= n; ++i) {
    while (j <= n && a[j] <= b[i]) ++j;
    if (j > n) break;
    while (j <= n && a[j] < b[i + 1]) {
      ind[++tot] = a[j] - b[i];
      p[tot] = (Data){ ind[tot], b[i + 1] - a[j] };
      ++j;
    }
  }

  Discretize();

  std::sort(p + 1, p + tot + 1, cmp);

  for (int i = 1; i <= tot; ++i) {
    if (p[i].x == p[i - 1].x && p[i].y == p[i - 1].y) continue;
    dp[i] = add(BIT.Query(p[i].x - 1), 1);
    inc(ans, dp[i]);
    BIT.Add(p[i].x, dp[i]);
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <utility>
using namespace std;

int main() {
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
N,L=gets.split.map(&:to_i)
sum=0
min=10**10
list=[]
(1..N).each do |i|
  sum += (L+i-1)
  list << (L+i-1)
end
list.sort_by!{|x| (sum - (sum - x)).abs}
p sum - list[0]

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

		String S = sc.next();
		S = "A" + S;
		if( S.length()==3 ){      
		for( int i=1; i<=S.length()-2; i++ ){
			char ch1 = S.charAt(i);
			char ch2 = S.charAt(i+1);
			if( ch1==ch2 ){
				System.out.println(i+" "+(i+1));
				break;
			}
			if( i==S.length()-2 ){
				System.out.println("-1"+" "+"-1");
			}
		}
        }else{
		for( int i=1; i<=S.length()-3; i++ ){
			char ch1 = S.charAt(i);
			char ch2 = S.charAt(i+1);
			char ch3 = S.charAt(i+2);
			if( ch1==ch2 || ch1==ch3 || ch2==ch3 ){
				System.out.println(i+" "+(i+2));
				break;
			}
			if( i==S.length()-3 ){
				System.out.println("-1"+" "+"-1");
			}
		}         
        }          
	}
}


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

int gcd (int a,int b){
    while(b){
        int t=a%b;
        a=b;
        b=t;
    }
    return a;
}
  
int n, a[100005], b[100005], c[100005], res;
int main () {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
      
    b[1] = a[1];
    for (int i = 2; i <= n; i++) b[i] = gcd(b[i-1], a[i]);
    c[n] = a[n];
    for (int i = n-1; i >= 1; i--) c[i] = gcd(c[i+1], a[i]);
    for (int i = 2; i < n; i++) res = max(gcd(b[i-1], c[i+1]), res);
    cout << max(res, max(c[2], b[n-1])) << endl;
    return 0;
}

Measured memory_bytes: 4756
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
s2 = ""
t2 = ""
for i in range(len(s)):
    s2+=s[i]
for i in range(len(t)):
    t2+=t[i]
dic = [s2,t2]
dic.sort() 
if s2 == t2:
    print("No")
    sys.exit()   
if dic[0] == s2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include<stdio.h>

int main(void) {

	unsigned long a, b, k;

	scanf("%lu %lu %lu", &a, &b, &k);

	if (k < a)
		printf("%lu %lu", a-k, b);
	else if ((k - a) < b) {
		printf("%lu %lu", 0, b-(k-a));
	}
	else
		printf("0 0");

	return 0;
}



Measured memory_bytes: 128