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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  map<char,int> qwerty;
  string q0="qwertasdfgzxcvb",q1="yuiophjklnm";
  REP(i,SZ(q0)) qwerty[q0[i]]=0;
  REP(i,SZ(q1)) qwerty[q1[i]]=1;
  for(;;){
    int answer=0;
    string s;
    cin >> s;
    if(s=="#") return 0;
    int last=0;
    REP(i,SZ(s)){
      if(i) answer+=qwerty[last]^qwerty[s[i]];
      last=s[i];
    }
    cout << answer << endl;
  }
}

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

int main(){
  int N;
  int count = 0;
  bool flag = true;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++ ){
   cin >> A.at(i);
  }
  while(true){
    for(int i = 0; i < N; i++ ){
      if(A.at(i) % 2 != 0){
        flag = false;
        break;
      }else{
        A.at(i) /= 2;
      }
    }
    if(flag == false){
      break;
    }
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,b,e) for(int i=b; i<e; i++)

int main(){
	int n, a, f = 0, t = 0;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d", &a);
		if(a%4==0) f++;
		else if(a%2==0) t++;
	}
	if(2*f+t-!!t>=n-1) puts("Yes");
	else puts("No");
	return 0;
}



Measured memory_bytes: 3696
#include <iostream>
using namespace std;
int main(){
    int N,temp,rt,m;
    cin>>N;
    cin>>m;
    rt = -1000000000;
    for(int i = 1;i<N;i++){
        cin>>temp;
        rt = max(temp-m,rt);
        if(temp<m)
            m = temp;
    }
    cout<<rt<<endl;
}



Measured memory_bytes: 3108
#include <iostream>
using namespace std;
typedef long long ll;
int k;

int main() {
  cin >> k;
  
  // kが10と互いの素かどうか
  if (k % 2 == 0 || k % 5 == 0) {
    cout << "-1";
  } else {
    ll kk = 9 * k;
    if (k % 7 == 0) kk /= 7;
    int ans = 1;
    ll remain = 10;
    while (true) {
      remain %= kk;
      if (remain == 1) break;
      ans += 1;
      remain *= 10;
    }
    cout << ans;
  }
}

Measured memory_bytes: 3668
from collections import deque

s = input()
t = input()

s_deque = deque(s)
t_deque = deque(t)

content = "No"
for i in range(len(s)):
    s_deque.rotate(1)
    if s_deque == t_deque:
        content = "Yes"
        break

print(content)


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

int main(){
    //input
    long long N;
    cin >> N;
    vector<long long> A, B, C;
    long long i, sub;
    for(i = 0; i < N; i++){
        cin >> sub;
        A.push_back(sub);
    }
    for(i = 0; i < N; i++){
        cin >> sub;
        B.push_back(sub);
    }
    for(i = 0; i < N; i++){
        cin >> sub;
        C.push_back(sub);
    }

    //calc
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    vector<long long>::iterator iteA, iteB, iteC;
    long long bc[N], bc_sum[N];
    long long counta = 0;

    for(iteB = B.begin(); iteB != B.end(); ++iteB){
        if(*iteB < C[N-1]){
            iteC = upper_bound(C.begin(),C.end(),*iteB);
            bc[iteB - B.begin()] = N - (iteC - C.begin());
        }else{
            bc[iteB - B.begin()] = 0;
        }
    }
    bc_sum[N-1] = bc[N-1];
    for(i = N-2; i >= 0; i--){
        bc_sum[i] = bc_sum[i+1] + bc[i];
    }
    for(iteA = A.begin(); iteA != A.end(); ++iteA){
        if(*iteA < B[N-1]){
            iteB = upper_bound(B.begin(),B.end(),*iteA);
            counta += bc_sum[iteB - B.begin()];
        }
    }

    //answer
    cout << counta << endl;
    system("pause");
    return 0;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < 3; i++) {
		if (N % 10 == 7) {
			cout << "Yes" << endl;
			return 0;
		}
		N /= 10;
	}
	cout << "No" << endl;
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)

struct UnionFind {
  vector<int> par, rank;

  UnionFind(int n){
    par.resize(n+1);
    fill(par.begin(), par.end(), -1);
    rank.resize(n+1);
  }

  int root(int x){
    if(par[x] < 0){
      return x;
    }

    par[x] = root(par[x]);

    return par[x];
  }

  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);

    if(rx!=ry){
      if(rank[rx] >= rank[ry]){
        par[ry]=rx;

        if(rank[rx]==rank[ry]){
          rank[rx] += 1;          
        }
      }else{
        par[rx] = ry;
      }
    }
  }

  bool is_same(int x, int y){
    return root(x)==root(y);
  }

  int count(int x){
    return -par[root(x)];
  }
};

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> pp;
  rep(i,n){
    int t;
    cin>>t;
    pp.push_back(t);
  }
  UnionFind uf = UnionFind(n);

  rep(i,m){
    int x,y;
    cin>>x>>y;
    uf.unite(x,y);
  }

  int result=0;
  rep(i, n){
//    cout<<i+1<<' '<<pp[i]<<endl;
    if(uf.is_same(i+1,pp[i])){
      result++;
    }
  }

//  rep(i,n){
//    cout<<pp[i]<<' ';
//  }
//  cout<<endl;

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 1528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	// O(|E|log|V|) implementation of Dijkstra algorithm.
	static long[] dist;
	static long INF = 100000000000000000L;
	static ArrayList<ArrayList<Edge>> adj;
	
	static class Edge {
		int to;
		long w;
		Edge(int _to, long _w) {
			this.to = _to;
			this.w = _w;
		}
		
		@Override
		public String toString() {
			return "(to=" + to + ", w=" + w + ")";
		}
		
	}
	
	static class NextNode {
		int id;
		long cost;
		NextNode(int _id, long _cost) {
			id = _id; cost = _cost;
		}
	}
	
	static void initG(int V) { // V: the number of vertexes
		for(int i=0; i<V; i++) {
			adj.add(new ArrayList<Edge>());
		}
	}

	static void dijkstra(int s) {
		Arrays.fill(dist, INF);
		dist[s] = 0;
		PriorityQueue<NextNode> pq = new PriorityQueue<NextNode>(new Comparator<NextNode>() {
			public int compare(NextNode n1, NextNode n2) {
				if(n1.cost > n2.cost) return 1;
				else if(n1.cost==n2.cost) return 0;
				else return -1;
			}
		});
		pq.add(new NextNode(s, 0));
		while(!pq.isEmpty()) {
			NextNode cn = pq.poll();
			if(cn.cost > dist[cn.id]) continue;
			for(Edge e : adj.get(cn.id)) {
				if(cn.cost + e.w < dist[e.to]) {
					dist[e.to] = cn.cost + e.w;
					pq.add(new NextNode(e.to, dist[e.to]));
				}
			}
		}
	}
	
	// verified at http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2715447#1
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int V = sc.nextInt();
		int E = sc.nextInt();
		int r = sc.nextInt();
		dist = new long[V];
		adj = new ArrayList<ArrayList<Edge>>(V);
		initG(V);
		for(int i=0; i<E; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int d = sc.nextInt();
			adj.get(s).add(new Edge(t, d));
		}
		dijkstra(r);
		for(int i=0; i<V; i++) {
			if(dist[i] == INF) {
				pw.println("INF");
			} else {
				pw.println(dist[i]);
			}
		}
		pw.close();
	}
	
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
	
}



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

int main(int argc, char const *argv[])
{
	int a,b;
	cin>>a>>b;
	if (a>8||b>8)
	{
		cout<<":(\n";
	}
	else
	{
		cout<<"Yay!\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;

int main()
{
	ll int n;
	cin>>n;
	string s,ans;
	s="abcdefghijklmnopqrstuvwxyz";
	
	while(n>0)
	{
		n-=1;
		ll int d=n%26;
		ans+=s[d];
		n=n/26;
		
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	
}
	
		
	
	
	
	




Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;

int main(){
string s;
cin >>s;
int n=s.length();
int cnt[26]={0};

for(int i=0;i<n;i++)
 cnt[s[i]-97]++;

for(int i=0;i<26;i++)
if(cnt[i]%2!=0) {cout << "No"<<endl; return 0;}

cout<<"Yes"<<endl;
}


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

int main() {
  int n, x;
  cin >> n >> x;
  int a, d = 0;
  int count = 1;
  for (int i = 0; i < n; i++) {
    cin >> a;
    d += a;
    if (d > x) {
      break;
    }
    else {
      count++;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

R = I()
print(R*2*math.pi)


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    cout<<c;
  }else if(b==c){
    cout<<a;
  }else if(a==c){
    cout<<b;
  }

  return 0;
}


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

int main(void)
{
	int A, B, N;

	cin >> N >> A >> B;

	if (N * A > B)
		cout << B;
	else
		cout << N * A;

	return 0;
}

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

public class Main {

	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int m = Integer.parseInt(st.nextToken());
		int n = Integer.parseInt(st.nextToken());
		int[] c = new int[n];
		st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < n; i++) {
			c[i] = Integer.parseInt(st.nextToken());
		}
		reader.close();
		int ans = getMinNoOfCoins(m, c);
		System.out.println(ans);
	}
	
	private int getMinNoOfCoins(int m, int[] coins) {
		int[] dp = new int[m+1];
		for (int i = 1; i < dp.length; i++) {
			dp[i] = Integer.MAX_VALUE;
		}
		for (int coin : coins) {
			for (int i = coin; i <= m; i++) {
				dp[i] = Math.min(dp[i], dp[i-coin] + 1);
			}
		}
		return dp[m];
	}

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


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

int main()
{
  	int n;
  	string str;
	cin>>n>>str;
  	map<char,int> char_count;
  	int ans=0;
  	for(int i=0 ; i<str.length() ; ++i)
    {
    	char_count[str[i]]=1;
      	map<char,bool> checked;
      	for(int j=i+1 ; j<str.length() ; ++j)
        {
        	if(char_count[str[j]])
            checked[str[j]]=true;
        }
		ans=max(ans,(int)checked.size());
    }
  	cout<<ans<<endl;
  	return 0;
}


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

using namespace std;
using ll = long long int;

class UF {
public:
    vector<int> p, sz;
    UF(size_t n) : p(n) {
        for(size_t i=0; i<n; i++)
            p[i] = i;
        sz.assign(n, 1);
    };
    int find(int x) {
        if(p[x] == x) return x;
        return p[x] = find(p[x]);
    };
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        sz[y] += sz[x];
        p[x] = y;
    };
};

int main(void) {
    ll n, m, k;
    cin >> n >> m >> k;

    UF uf(n);
    vector<ll> r(n);

    for(ll i=0; i<m; i++) {
        ll c, d;
        cin >> c >> d;
        c--, d--;
        r[c]--, r[d]--;
        uf.unite(c, d);
    }

    vector<pair<ll,ll>> blk(k);
    for(ll i=0; i<k; i++) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        blk[i] = make_pair(a, b);
    }

    for(ll i=0; i<n; i++)
        r[i] += uf.sz[uf.find(i)] - 1;

    for(ll i=0; i<k; i++) {
        if(uf.find(blk[i].first) == uf.find(blk[i].second))
            r[blk[i].first]--, r[blk[i].second]--;
    }

    for(auto &e: r) cout << e << ' ';
    cout << endl;
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
  char str[200000]={};
  int i,j;

  scanf("%s",str);

  for(i=0;str[i]!='A';i++);

  for(j=0;str[199999-j]!='Z';j++);

  printf("%d\n",200000-i-j);

  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
using namespace std;
const int N=100005;
int n,x,y,z,head[N],sum,s,t,maxx;
int step[N],next[N][2],cnt[N],p;
struct edge
{	int to,next;}a[N<<1];
int read()
{	char x=getchar();
	while(x<48||x>57) x=getchar();
	int ans=0;
	while(x>=48&&x<=57)
	{	ans=(ans<<1)+(ans<<3)+(x^48);
		x=getchar();
	}
	return ans;
}
void insert(int x,int y)
{	sum++;a[sum].to=y;a[sum].next=head[x];head[x]=sum;}
void find(int num,int fa)
{	step[num]=step[fa]+1;
	if(step[num]>maxx){maxx=step[num];s=num;}
	int x;
	for(int i=head[num];i;i=a[i].next)
	{	x=a[i].to;
		if(x!=fa) find(x,num);
	}
}
bool judge(int num,int fa)
{	next[num][0]=fa;
	int x;
	for(int i=head[num];i;i=a[i].next)
	{	x=a[i].to;
		if(x==fa) continue;
		if(judge(x,num)) return true;
		cnt[num]++;
		if(cnt[x])
		{	if(next[num][1]) return true;
			next[num][1]=x;
		}
	}
	if(cnt[num]&&!next[num][1]) t=num;
	return false;
}
int main()
{	n=read();
	for(int i=1;i<n;i++)
	{	x=read();y=read();
		insert(x,y);insert(y,x);
	}
	find(1,0);
	if(judge(s,0)){printf("-1\n");return 0;}
	s=next[s][1];x=s;y=t;
	p=1;next[s][0]=0;
	while(x!=y&&next[x][0]!=y)
	{	if(cnt[x]<cnt[y]) break;
		if(cnt[x]>cnt[y])
		{	z=s;s=t;t=z;p=0;break;}
		x=next[x][1];y=next[y][0];
	}
	printf("1 ");x=y=2;
	while(s)
	{	for(cnt[s]--;cnt[s];cnt[s]--)
		printf("%d ",++x);
		printf("%d ",y);
		x++;y=x;
		s=next[s][p];
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 8960
// OURL: https://atcoder.jp/contests/abc076/tasks/abc076_c
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
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 V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

string S,T;

bool match(int si) {
  if (si+T.size() > S.size()) return false;
  RREP(i,si,si+T.size()) {
    if (S[i] != T[i-si] && S[i] != '?') return false;
  }
  return  true;
}

string create_ans(int si) {
  string s = S;
  RREP(i,si,si+T.size()) {
    s[i] = T[i-si];
  }
  REP(i,s.size()) {
    if (s[i] == '?') s[i] = 'a';
  }
  return s;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> S;
  cin >> T;
  vector<string> ansers;
  REP(i,S.size()) {
    if (match(i)) {
      ansers.push_back(create_ans(i));
    }
  }
  if (ansers.size() > 0) {
    sort(ansers.begin(), ansers.end());
    cout << ansers[0] << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main (String [] args){
		List <Integer> list = new ArrayList<Integer>();
		HashMap <Integer, Integer>hm = new HashMap<Integer, Integer>();
//		int v1 = Integer.parseInt(sc.next());
//		int v2 = Integer.parseInt(sc.next());
		String s1 = sc.next();		
		String ans_str = "";
		int ans_int = 0;
		Pattern camma = Pattern.compile("[,]");
		StringBuilder sb = new StringBuilder(s1);
		s1 = camma.matcher(s1).replaceAll(" ");			

		
		System.out.println(s1);
		System.out.flush();
		sc.close();
	}
}

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

void solve(long long N, std::vector<long long> A)
{
    vector<long long> sort_a(N);
    for (int i = 0; i < N; i++)
    {
        long long index = A[i];
        sort_a[index - 1] = i + 1;
    }

    for (int i = 0; i < N; i++) //auto dame
    {
        if (i == N - 1)
        {
            cout << sort_a[i] << endl;
            break;
        }

        cout << sort_a[i] << ' ';
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2432
#include<set> 
#include<map> 
#include<queue>
#include<cmath>
#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
double b;
int main()
{
	scanf("%d",&n);
	b=(double)n/3;
	b=b*b*b;
	printf("%.6lf",b);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int count,max;
	int i;
	int ball[10];
	int left,right;
	scanf("%d",&max);
	for(count=0;count<max;count++) {
		for(i=0;i<10;i++)scanf("%d",&ball[i]);
		left=0;right=0;
		for(i=0;i<10;i++) {
			if(ball[i]<left && ball[i]<right)break;
			if(ball[i]<left)right=ball[i];
			else if(ball[i]<right)left=ball[i];
			else {
				if(left<right)right=ball[i];
				else left=ball[i];
			}
		}
		if(i>=10)printf("YES\n"); else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 0
A = []
H, W = map(int, input().split())
while H != 0 or W != 0:
    A.append([H,W])
    H, W = map(int, input().split())
for i in range(len(A)):
    for j in range(A[i][0]):
        if A[i][1] % 2 == 0 and j % 2 == 0:
            print('#.' * int(A[i][1] / 2))
        elif A[i][1] % 2 == 0 and j % 2 == 1:
            print('.#' * int(A[i][1] / 2))
        elif A[i][1] % 2 == 1 and j % 2 == 0:
            print('#.' * (A[i][1] // 2) + '#')
        elif A[i][1] % 2 == 1 and j % 2 == 1:
            print('.#' * (A[i][1] // 2) + '.')
    print('')


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

int main () {
  long long x,k,d; cin >> x >> k >> d;
 
  if(x == 0) {
    if(k % 2 == 0) {
      cout << 0 << endl;
    } else {
      cout << d << endl;
    }
    return 0;
  }
  
  long long over = abs(x) / d;
  long long ans = abs(x);
  if(k < over) {
    ans = ans - (d * k);
  } else {
    long long remain = (k - over) % 2;
    ans = ans - (d * over);
    if(remain == 1) {
       ans = abs(ans - d);
    }
  }
    
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String s=sc.next();
        if(s.equals("ABC")){
            System.out.println("ARC");
        }
        else{
            System.out.println("ABC");
        }
        
    }
}

Measured memory_bytes: 35604
#include<iostream>
using namespace std;
int main(){

    int n,g,i,j,t,k,res,ans=0;
    cin >> n;
    for(i=1;i<=n;i++) {
        cin >> res;
        if(i%2==1 and res%2==1) ans++;
    }
    cout << ans;
}


Measured memory_bytes: 3596
#include <iostream>

using namespace std;

#define ll long long

ll d[51][2501];

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

    d[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        for (int j = i - 1; j >= 0; j--)
            for (int s = 0; s <= j * 50; s++)
                d[j + 1][s + x] += d[j][s];
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++)
        ans += d[i][i * a];

    cout << ans;

    return 0;
}


Measured memory_bytes: 896
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream> 

#define MOD 1000000007
typedef long long ll;
 
using namespace std;
 
int main(){
    ll N,K;
    cin >> N >> K;
    ll sum = 0;
    for(ll i = K ; i <= N+1 ; i++){
        ll max,min;
        max = ( N + (N - i + 1) ) * i /2;
        min =  (i - 1) * i /2;
        sum += (max - min + 1) % MOD;
        sum %= MOD; 
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int a, b, c;

bool is_drow() {
  int sum = a + b;
  int c = 0;
  for(int i=1; i<=10; i++) {
    if(sum+i > 20) {
      break;
    }
    if(i != a && i != b && i != c) {
      c++;
    }
  }
  if(c >= 4) {
    return true;
  }
  return false;
}
int main() {
  while(cin >> a) {
    cin >> b >> c;
    if(is_drow()) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2996
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b;
    char op;
    cin >> a >> op >> b;
    if(op=='-'){
        cout << a-b;
    }
    else{
        cout << a+b;
    }
}

Measured memory_bytes: 256
def frac(n):
    if n==1:
        return 1
    else:
        return n*frac(n-1)

n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
    x[i],y[i]=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(i+1,n):
        ans+=((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5
print(ans*frac(n-1)*2/frac(n))

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

int check(int Q, vector<tuple<int, int, int, int>> &board, vector<int> &vec){
    int ans = 0;

    for(int i=0; i<Q; i++){
        if((vec[get<1>(board[i]) - 1] - vec[get<0>(board[i]) - 1]) == get<2>(board[i])){
            ans += get<3>(board[i]);
        } 
    }

    return ans;
}

//i 今何重目か, j 何以上か
int all(int &N, int &M, int &Q, int i, int j, vector<tuple<int, int, int, int>> &board, vector<int> &vec){
    
    int ans = 0;
    
    //ベースケース
    if(i == N - 1){

        for(int k=j; k<=M; k++){
            vec[i] = k;

            int TRY;
            TRY = check(Q, board, vec);

            ans = max(ans, TRY);
        }

        return ans;
    }

    for(int k=j; k<=M; k++){
        vec[i] = k;

        int TRY;
        TRY = all(N, M, Q, i+1, k, board, vec);

        ans = max(ans, TRY);
    }

    return ans;
}

int main(){
    int N ,M ,Q;
    cin >> N >> M >> Q;

    vector<tuple<int ,int, int, int>> board(Q);
    for(int i=0; i<Q; i++){
        int a, b ,c, d;
        cin >> a >> b >> c >> d;

        board[i] = make_tuple(a, b, c, d);
    }

    vector<int> vec(N);

    int A;

    A = all(N, M, Q, 0, 1, board, vec);

    cout << A << endl;


}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i=0; i<n; i++){
    map <char, int> alphabet;
    int tmp = 0;
    for(int j=0; j<i;j++){
      alphabet[s[j]]=0;
    }
    for(int k=i; k<n;k++){
      if(alphabet.count(s[k])) alphabet.at(s[k])=1;
      else continue;
    }
    for(char ch = 'a';ch<='z'; ch++){
      if(alphabet.count(ch)) tmp+=alphabet.at(ch);
    }
    ans = max(tmp,ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict


def main():
    N = int(input())
    heights = list(map(int, input().split()))

    """
    for j>i, j-i = Ai + Aj
    i + Ai = j -Aj
    """

    L = defaultdict(int)
    R = defaultdict(int)

    for i, height in enumerate(heights):
        if i + height < N:
            L[i + height] += 1
        
        if i - height > 0:
            R[i - height] += 1

    total_count = 0
    for x, count_l in L.items():
        if x in R:
            count_r = R[x]
            total_count += count_l * count_r

    print(total_count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 36612
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return 1; } return 0; }

int main() {
  int N; cin >> N;
  long long a[100010][3];
  for (int i = 0; i < 100010; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];
  
  long long dp [100010][3] = {};
  
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        if (j == k) continue;
        chmax(dp[i+1][k], dp[i][j] +a[i][k]);
      }
    }
  }
  
  long long res = 0;
  for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s,t;
    cin >> s >> t;
    ll n=t.size();
    ll x=s.size();
    if(x<n){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    ll check=MOD;
    for(ll i=x-n;i>=0;i--){
        bool judge=true;
        for(ll j=0;j<n;j++){
            if(s[i+j]!='?'&&s[i+j]!=t[j]){
                judge=false;
            }
        }
        if(judge){
            check=i;
            break;
        }
    }
    if(check==MOD){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    string ans=s;
    for(ll i=0;i<x;i++){
        if(check==i){
            for(ll j=0;j<n;j++){
                ans[i+j]=(t[j]);
            }
            i+=n;
        }

        if(ans[i]=='?'){
            ans[i]='a';
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define ceil(a,b) (((a)+(b)-1)/(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n; cin >>n;
  vector<li> v(n);
  rep(i,n) cin >>v[i];
  li s=1;
  rep(i,n) if(!v[i]) s=0;
  li m=1e18;
  rep(i,n){
    if(v[i] and ceil(m,v[i])<s){
      print(-1);
      return 0;
    }
    s*=v[i];
    if(s>m){
      print(-1);
      return 0;
    }
  }
  print(s);
}


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

int main() {
  int N;
  cin >> N;
  int moti[N] = {0};
  int num[101] = {0};
  rep(i,N){
    cin >> moti[i];
  }
  rep(i,N){
    num[moti[i]]++;
  }
  int res = 0;
  rep(i,101){
    if(num[i]>0){
      res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
N = int(input())
A = map(int, input().split())
S = sorted([[a, i] for i, a in enumerate(A)], key=lambda x: x[0], reverse=True)
S.append([0, N])
B = [0 for i in range(N)]
num = S[0][1]
for i in range(1, N + 1):
  if S[i - 1][0] > S[i][0]:
   B[num] += (S[i - 1][0] - S[i][0]) * i
  num = min(num, S[i][1])
for b in B:
  print(b)

Measured memory_bytes: 27108
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



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


int main(){
    int n,gomi;cin>>n>>gomi;
    int a[n];for(int i=0;i<=n-1;i++)cin>>a[i];
    int min=a[0],maxd=0;int count=0;int maxcount=0;
    for(int i=1;i<=n-1;i++){
        if(a[i]-min>maxd){
            maxd=a[i]-min;
            if(count>maxcount)maxcount=count;
            count=1;
        }else if(a[i]-min==maxd)count++;
        
        if(a[i]<min)min=a[i];
    }
    maxcount=max(maxcount,count);
    cout<<maxcount<<endl;
    
    
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int dp1[2002][2002];
int dp2[2002][2002];

int main(){
    int h,w;cin >> h >> w;
    string s[h];
    for(int i=0;i<h;i++) cin >> s[i];
    for(int i=0;i<h;i++){
        if(s[i][0]=='.') dp1[i][0]=1;
        for(int j=1;j<w;j++){
            if(s[i][j]=='#') dp1[i][j]=0;
            else dp1[i][j] = dp1[i][j-1]+1;
        }
        int tmp=0;
        for(int j=w-1;j>=0;j--){
            if(dp1[i][j]==0){
                tmp=0;
                continue;
            }
            else{
                tmp=max(tmp,dp1[i][j]);
                dp1[i][j]=tmp;
            }
        }
    }
    for(int i=0;i<w;i++){
        if(s[0][i]=='.') dp2[0][i]=1;
        for(int j=1;j<h;j++){
            if(s[j][i]=='#') dp2[j][i]=0;
            else dp2[j][i] = dp2[j-1][i]+1;
        }
        int tmp=0;
        for(int j=h-1;j>=0;j--){
            if(dp2[j][i]==0){
                tmp=0;
                continue;
            }
            else{
                tmp=max(tmp,dp2[j][i]);
                dp2[j][i]=tmp;
            }
        }
    }
    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#') continue;
            ans=max(ans,dp1[i][j]+dp2[i][j]-1);
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
	int W,H,N;
	cin >> W >> H >> N;
	int xmin=0,xmax=W,ymin=0,ymax=H;
	for(int i=0;i<N;i++){
		int x,y,a;
		cin >> x >> y >> a;
		if(a==1)xmin=max(xmin,x);
		if(a==2)xmax=min(xmax,x);
		if(a==3)ymin=max(ymin,y);
		if(a==4)ymax=min(ymax,y);
	}
	cout << max(0,(xmax-xmin))*max(0,(ymax-ymin)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int  n;
    cin>>n;
     int ans=1;
     int x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x==ans)
         ans++;
    }
    if(ans==1)
     cout<<-1<<endl;
    else
     cout<<n-ans+1<<endl;
}

Measured memory_bytes: 3640
import java.util.*

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val A = scanner.nextInt()
	val B = scanner.nextInt()
	println(
			when {
				A > B -> A * 2 - 1
				A < B -> B * 2 - 1
				else -> A + B
			}
	)
	scanner.close()
}


Measured memory_bytes: 31012
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

typedef pair<long long int,int> P;


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

	int n;
	cin >> n;

	int a[n];
	cin >> a[0];
	int ans=0;
	int cnt=1;
	for(int i=1;i<n;i++){
		cin >> a[i];
		if(a[i-1] == a[i]){
			cnt++;
			if(cnt % 2 == 0){
				ans++;
			}
		}
		else cnt=1;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
N , Ma, Mb = map(int, input().split())

a = [0] * N
b = [0] * N
c = [0] * N

for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())

# TLEになってしまうためinfを5000とかで設定する
INF = 5000
# さらに計算量を落とすため10 * N + 1などを定数で設定する

# 最小値を求める問題なのでinfで初期化
# dp[i][sun_a][sum_b]で考えていく
dp = [[[INF for _ in range(401)] for _ in range(401)] for _ in range(41)]

# 初期選択状態を0とする

dp[0][0][0] = 0
for i in range(N):
    for j in range(401):
        for k in range(401):
            if dp[i][j][k] == INF:
                continue
            
            # 選ばなかった場合
            dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
            # 選んだ場合
            dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i])


ans = INF
# 0スタートは何を選んでいない状態となり最小値が0になってしまうため1から開始する

# TLEになったため変更
#for i in range(1,10 * N + 1):
#    for j in range(1,10 * N + 1):
#        if i * Mb != j * Ma:
#            continue
#        ans = min(ans, dp[N][i][j])
#

for i in range(1, 401):
        if i*Ma>10*N or i*Mb>10*N:
            break
        ans = min(ans, dp[N][i*Ma][i*Mb])

if ans == INF:
    print(-1)
else:
    print(ans)

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

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if ( k >= s.size()){
        cout << s << endl;
        return 0;
    }else
    {
        cout << s.substr(0,k) << "..." <<endl;
        return 0;
    }
    
}

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

int main() {

  long long N, T;
  long long t[N];
  cin >> N >> T;
  for ( int i=0; i<N; i++ ) {
    cin >> t[i]; 
  }
  long long sum_t = 0;
  long long limit_old = 0;
  long long limit = 0;
  long long now = 0;
  for ( int i=0; i<N; i++ ) {
    now = t[i];
    limit_old = limit;
    limit = now + T;
    if ( now > limit_old ) {
      sum_t += T;
    } else {
      sum_t += (limit - limit_old);
    }
  }

  cout << sum_t << endl;
 
  return 0;
}

Measured memory_bytes: 3456
N, M = gets.split.map(&:to_i)
R = Hash.new {|h, i| h[i] = []}
M.times do
  a, b, c = gets.split.map(&:to_i)
  R[a] << [b, c]
end
     
T = Array.new(N + 1, -Float::INFINITY)
 
def calc(node, step = 0, cost = 0, n_pass = 0)
  return true if cost <= T[node] 
  return false if n_pass >= 2
  return false if node == N && step > N
  return true if step >= 2 * N
  T[node] = cost
  np = (node == N ? n_pass + 1 : n_pass)
  R[node].all? {|x| calc(x[0], step + 1, cost + x[1], np)}
end
     
puts calc(1) ? T[N] : 'inf'

Measured memory_bytes: 10108
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long

using namespace std;
const int MOD=1000000007;
const int INF=9000000009;
const double eps=1e-10;

signed main(){
  int n,k;
  cin>>n>>k;
  if(k==0)cout<<n*n<<endl;
  else{
    int ans=0;
    for(int b=k+1;b<n+1;b++){
      ans+=(b-k)*(n/b);
      ans+=(0<n%b-k+1?n%b-k+1:0);
    }
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

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

        String a = sc.next();

        char b = a.charAt(0);
        
        System.out.println((char) ((int)b + 1) );
    }
}


Measured memory_bytes: 35624
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;

int n;
int a[MAXN];

int b[MAXN];

ll solve() {
	REP(i,n) b[i]=a[i]-i;
	//printf("x:"); REP(i,n) printf(" %2d",-i); puts("");
	//printf("b:"); REP(i,n) printf(" %2d",b[i]); puts("");

	if(b[0]!=0) return -1;
	FOR(i,1,n) if(b[i]>b[i-1]||b[i]<-i) return -1;

	ll ret=0;
	REP(i,n) if(i+1>=n||b[i]!=b[i+1]) ret+=i+b[i];
	return ret;
}

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]);
	printf("%lld\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std ;
int main () {
  // input
  int N , M , C ; cin >> N >> M >> C ;
  vector <int > B ( M );
  for ( int i = 0; i < M ; ++ i ) {
    cin >> B [ i ];
  }
  vector < vector <int >> A (N , vector <int >( M ));
  for ( int i = 0; i < N ; ++ i ) {
    for ( int j = 0; j < M ; ++ j ) {
    cin >> A [ i ][ j ];
    }
  }
  // compute
  int ans = 0;
  for ( int i = 0; i < N ; ++ i ) {
    // check whether i-th source code solves this problem
    int sum = 0;
    for ( int j = 0; j < M ; ++ j ) {
      sum += A [ i ][ j ] * B [ j ];
    }
    if ( sum + C > 0) { ++ ans; }
  }
  // output

  cout << ans << endl ;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,m;
    cin >> n >> m;
    ll remi=1;
    FORR (i,(ll)sqrt(m)+1,1){
        if(m%i == 0 ){
           if(m/i >= n){
               remi = max(remi,(ll)i);
           }
           if(i >= n){
               remi = max(remi,(ll)m/i);
           }
        }
    }
    cout << remi << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> count(200000,0);
    for(int i=0;i<n-1;i++){
        int a;
        cin>>a;
        count[a-1]++;
    }
    for(int i=0;i<n;i++){
        cout<<count[i]<<endl;
    }
    return 0;
}


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

int main() {
    int n,a,b,c,d,ren=0,ind=5000000,ind2=0,v=0,u=0,ind3=0,p=2;
  cin >> n >> a >> b >> c >> d;
  char s[n+2];
  s[0] = 'w';
  for(int i=1;i<=n;i++){
    cin >> s[i];
    if(s[i]=='#' && s[i-1]=='#'){
      if(i-1<c||i-1<d){
        if(i-1>a) ren=1;
      }
    }
  }
  
  if(ren==1){
      cout << "No" << endl;
      p=0;
  }
  
  
  if(p!=0){
  if(c>d){
    for(int i=a;i<d;i++){
      if(s[i]=='.'){
        if(s[i+1]=='.'&&s[i+2]=='.'){
         ind3=i+1;
          if(ind3>=b) v=1;
        }
      }      
      
      
      if(v==1){
        cout << "Yes" << endl;
        break;
      }
      
    }
    
    if(v==0) cout << "No" << endl;
  }
  else cout << "Yes" << endl;
  }
  
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int INF = 1001001001;
 
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  --x; --y;
  vector<int> ans(n);
  rep(sv,n) {
    vector<int> dist(n, INF);
    queue<int> q;
    auto push = [&](int v, int d) {
      if (dist[v] != INF) return;
      dist[v] = d;
      q.push(v);
    };
    push(sv, 0);
    while (!q.empty()) {
      int v = q.front(); q.pop();
      int d = dist[v];
      if (v-1 >= 0) push(v-1, d+1);
      if (v+1 < n) push(v+1, d+1);
      if (v == x) push(y, d+1);
      if (v == y) push(x, d+1);
    }
    rep(i,n) ans[dist[i]]++;
  }
  rep(i,n) ans[i] /= 2;
  for (int i = 1; i <= n-1; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3652
from fractions import gcd

A,B,C,D = map(int,input().split())

adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
countC = bdivc - adivc + 1

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
countD = bdivd - adivd + 1

lcm = (int)(C * D / gcd(C, D))
adivlcm = A // lcm
if A%lcm != 0:
    adivlcm = A // lcm + 1
bdivlcm = B // lcm
countlcm = bdivlcm - adivlcm + 1

print(B-A+1-(countC+countD-countlcm))

Measured memory_bytes: 5500
#include<stdio.h>

int n, A[50];


int solve (int i, int m) {
 if ( m == 0 ) return 1;
 if ( i >= n) return 0;
 int res = solve(i+1, m) || solve(i+1, m-A[i]);
 return res;
 }
 
 
 int main() {
   int q, M, i;
   
   scanf("%d", &n);
   for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
   scanf("%d", &q);
   for ( i = 0; i < q; i++ ){
   scanf("%d", &M);
   if ( solve(0, M) ) printf("yes\n");
   else printf("no\n");
   }
   
   return 0;
   }


Measured memory_bytes: 2140
import java.io.*;

class Main {
	public static void main(String args[]) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String s[], t;
			int i, j, ans, l, m;
			boolean flag = false;
			while((t = reader.readLine()) != null) {
				s = t.split(" ");
				i = s[0].length()-1 >= s[1].length()-1 ? s[0].length()-1 : s[1].length()-1;
				j = s[0].length()-1 <= s[1].length()-1 ? s[0].length()-1 : s[1].length()-1;
				l = s[0].length()-1 >= s[1].length()-1 ? 0 : 1;
				int a[][] = {new int[i+1], new int[j+1]};
				for(int k = 0;k < i+1;k++) {
					a[0][k] = s[l].charAt(k)-'0';
				}
				int f = Math.abs(l-1);
				for(int k = 0;k < j+1;k++) {
					a[1][k] = s[f].charAt(k)-'0';
				}
				while(i>=0) {
					if(j >= 0)
						m = a[1][j];
					else
						m = 0;
					a[0][i] = a[0][i] + m;
					if(a[0][i]>9) {
						if(i>0) {
							a[0][i] %= 10; 
							a[0][i-1]++;
						}
						else if(i==0){
							flag = true;
							break;
						}
					}
					i--;
					j--;
				}
				ans = flag ? a[0].length+1 : a[0].length;
				System.out.println(ans);
				flag = false;
			}
		}
		catch(IOException e) {
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 17044
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

#define INF INT_MAX
class SegmentTree{
public:

  int n;
  vector<ll> tree;

  SegmentTree(int size){
    n=1;
    while(n<size) n*=2;

    tree.resize(2*n-1,0);
  }

  SegmentTree(vector<int> v){
    int vSize=v.size();
    n=1;
    while(n<vSize) n*=2;

    tree.resize(2*n-1,0);

    for(int i=0;i<vSize;i++) tree[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--) tree[i]=max(tree[2*i+1],tree[2*i+2]);
  }

  void update(int index,ll value){
    index+=n-1;

    tree[index]=value;
    while(index>0){
      index=(index-1)/2;
      tree[index]=max(tree[2*index+1],tree[2*index+2]);
    }
  }

  ll getMax(int a,int b,int k,int l,int r){
    if(r<0) r=n;

    if(r<=a||b<=l) return 0;
    else if(a<=l&&r<=b) return tree[k];
    else{
      ll lval=getMax(a,b,2*k+1,l,(l+r)/2);
      ll rval=getMax(a,b,2*k+2,(l+r)/2,r);
      return max(lval,rval);
    }
  }
};


int main(){
  int n;
  cin>>n;
  int h[n+1]={};
  ll a[n+1]={};
  for(int i=0;i<n;i++){
    cin>>h[i];
    h[i]--;
  }
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

  SegmentTree tree(n+1);
  for(int i=0;i<n;i++){
    ll ma=tree.getMax(0,h[i],0,0,-1);
    tree.update(h[i],ma+a[i]);
  }

  cout<<tree.getMax(0,n,0,0,-1)<<endl;

  return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=2e5+7;

int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int x=0;
    for(int i=0;i<n;i++){
        if(s[i]!=t[i]){
            x=1;break;
        }
    }
    if(x){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
int N;
  in(N);
  vl A(N);
  rep(i,N) in(A[i]);
  sort(all(A));
  int m  = A[N-1];
  int wa = 0;
  rep(i,N) wa += A[i];
  if(m<wa-m) out("Yes");
  else out("No");
}

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

int main() {
  int N, M;

  cin >> N;
  vector<string> blue(N);  
  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }
  sort(blue.begin(), blue.end());

  cin >> M;
  vector<string> red(M);  
  for (int i = 0; i < M; i++) {
    cin >> red.at(i);
  }
  sort(red.begin(), red.end());

  int blue_start = 0;
  int money_max = 0;

  while (blue_start < N) {
  int cnt_blue_same = 0;
  string blue_tmp = "";
  int cnt_red_same = 0;
    for (int i = blue_start; i < N; i++) {
      cnt_blue_same++;
      if ((i+1) < N && blue.at(i) == blue.at(i+1))
        continue;
      else {
        blue_tmp = blue.at(i);
        break;
      }
    }
    for (int i = 0; i < M; i++) {
      if (red.at(i) == blue_tmp)
        cnt_red_same++;
    }
    
    if (money_max < cnt_blue_same - cnt_red_same)
      money_max = cnt_blue_same - cnt_red_same;
    
    blue_start += cnt_blue_same;
  }

  cout << money_max << endl;

}

Measured memory_bytes: 256