akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>

using namespace std;

typedef pair<int, int> node_t;

vector<vector<int>> distmap;

bool
cmp_greater(const node_t &left, const node_t &right)
{
    return distmap[get<0>(left)][get<1>(left)] >
        distmap[get<0>(right)][get<1>(right)];
}

int
main()
{
    int h, w;
    cin >> h >> w;
    vector<string> map;
    for (int i = 0; i < h; i++) {
        string line;
        cin >> line;
        map.push_back(line);
    }

    for (int i = 0; i < h; i++) {
        vector<int> tmp;
        for (int j = 0; j < w; j++)
            tmp.push_back(h * w);
        distmap.push_back(tmp);
    }
    distmap[0][0] = 0;

    vector<node_t> nodes;
    sort(nodes.begin(), nodes.end(), greater<node_t>());
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            nodes.push_back(make_pair(i, j));

    while (!nodes.empty()) {
        sort(nodes.begin(), nodes.end(), &cmp_greater);
        node_t n = nodes.back();
        nodes.pop_back();
        int i = get<0>(n);
        int j = get<1>(n);
        if (distmap[i][j] == h * w) {
            printf("-1\n");
            exit(0);
        }
        if (i == h - 1 && j == w - 1)
            break;
        if (i > 0 && map[i - 1][j] == '.')
            distmap[i - 1][j] = min(distmap[i - 1][j], distmap[i][j] + 1);
        if (i < h - 1 && map[i + 1][j] == '.')
            distmap[i + 1][j] = min(distmap[i + 1][j], distmap[i][j] + 1);
        if (j > 0 && map[i][j - 1] == '.')
            distmap[i][j - 1] = min(distmap[i][j - 1], distmap[i][j] + 1);
        if (j < w - 1 && map[i][j + 1] == '.')
            distmap[i][j + 1] = min(distmap[i][j + 1], distmap[i][j] + 1);
    }
    int white_count = 0;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            if (map[i][j] == '.')
                white_count++;
    int need_count = distmap[h - 1][w - 1] + 1;
    printf("%d\n", white_count - need_count);
    exit(0);
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	for (int i=0;i < n;i++) {
		string s;
		cin >> s;
		if (s == "Y") {
			cout << "Four";
			return 0;
		}
	}
	cout << "Three";
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    private static Scanner scan;

    public static void main(String[] args) {
        scan = new Scanner(System.in);
        comp(scan.nextInt(), scan.nextInt(), scan.nextInt());
    }

    private static void comp(int a,int b, int c) {
        int cnt = 0;
        for (int i = a; i <= b; i++) {
            if (c % i == 0) {
                cnt ++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 17308
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

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

	vector<int> x(N);
	for (int i = 0; i < N; i++)	{
		cin >> x.at(i);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans = ans + min(K - x.at(i), x.at(i)) * 2;
	}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int height = sc.nextInt();
		int width = sc.nextInt();
		String[][] field = new String[height][width];
		for(int i = 0;i < height;i++) {
			field[i] = sc.next().split("");
		}

		for(int i = 0;i < height;i++) {
			StringBuilder answer = new StringBuilder();
			for(int j = 0;j < width;j++) {
				if(field[i][j].equals("#")) {
					answer.append(String.valueOf("#"));
				}else {
					int bombCount = 0;
					if(i !=0 && field[i-1][j].equals("#")) {
						bombCount++;
					}
					if(i !=height-1 && field[i+1][j].equals("#")) {
						bombCount++;
					}
					if(j !=width -1 && field[i][j+1].equals("#")) {
						bombCount++;
					}
					if(j !=0 && field[i][j-1].equals("#")) {
						bombCount++;
					}
					if(i !=0 && j != width-1 && field[i-1][j +1].equals("#")) {
						bombCount++;
					}
					if(i !=0 && j != 0 && field[i-1][j-1].equals("#")) {
						bombCount++;
					}
					if(i !=height -1 && j != width-1 && field[i+1][j +1].equals("#")) {
						bombCount++;
					}
					if(i !=height -1 && j != 0 && field[i+1][j-1].equals("#")) {
						bombCount++;
					}
					answer.append(String.valueOf(bombCount));
				}
				if(j == width -1) {
					System.out.println(answer);
				}
			}
		}

	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
ll inf=1e10;

int main(){
  ll N;
  cin>>N;
  for (ll h(1);h<=3500;h++){
    for (ll n(1);n<=3500;n++){
      ll ue = N*h*n;
      ll sita = 4*h*n - n*N - h*N;
      if (sita!=0&&ue%sita==0&&sita>=0){
        cout << h <<" "<< n <<" "<< ue/sita << endl;
        return 0;
      }
    }
  }
  return 0;
}


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


signed main() {
  int n;cin>>n;
  int a[300000];rep(i,3*n)cin>>a[i];
  priority_queue<int, vector<int>, greater<int>> f;
  priority_queue<int> b;
  vector<int> ans(n+1);
  int sum = 0;
  rep(i,n){
    sum += a[i];
    f.push(a[i]);
  }
  repd(i,n,2*n+1){
    ans[i-n] = sum;
    f.push(a[i]);
    sum += a[i];
    sum -= f.top();
    f.pop();
  }
  sum = 0;
  repd(i,2*n,3*n){
    sum += a[i];
    b.push(a[i]);
  }

  for(int i = 2*n-1;i >= n-1;i--){
    ans[i-n+1] -= sum;
    b.push(a[i]);
    sum += a[i];sum -= b.top();
    b.pop();
  }

  cout << *max_element(ans.begin(), ans.end()) << endl;
}


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

int main() {
	int N, H, tmp, ans = 1;
	cin >> N >> tmp;
	for (int i = 1; i < N; ++i) {
		cin >> H;
		if (tmp <= H) ++ans;
		tmp = max(tmp, H);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define maxn 10
int A[maxn];
int cnt=0;
int trace(int num[],int n)
{
	for(int i=0;i<n;i++)
	{
		if(i>0)
		cout<<" ";
		cout<<num[i];
	}
	cout<<endl<<cnt<<endl;
	return 0;
}

//冒泡排序：稳定排序(仅对相邻元素进行比较和交换) ，时间复杂度O(n^2), 
//冒泡排序中的交换次数又称逆序数或反序数，可用于体现数列的错乱程度。
 
//使用flag的冒泡排序法
 
int BubbleSort(int num[],int n)
{
	int flag=1;//存在顺序相反的相邻元素
	while(flag)
	{
		flag=0;
		for(int j=n-1;j>=1;j--)
		{
			if(num[j]<num[j-1])//改为<=算法会失去稳定性 
			{
				cnt++;
				int tt=num[j-1];
				num[j-1]=num[j];
				num[j]=tt;
				flag=1;
			}	
		}
	 } 
}
/*int BubbleSort(int num[],int n)
{
	
	for(int i=0;i<n;i++)
	{
		for(int j=n-1;j>i;j--)
		{
			if(num[j]<num[j-1])
			{
				cnt++;
				int tt=num[j-1];
				num[j-1]=num[j];
				num[j]=tt;
			}
		}
		
	}
	return 0;
}*/
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>A[i];
	}
	BubbleSort(A,n);
	trace(A,n);
	return 0;
}


Measured memory_bytes: 3072
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int calc(int R[],int n){
	int ans=(R[1]-R[0]);
	int min=R[0];

	for(int i=1;i<n;i++){
		if(ans < (R[i]-min)){
			ans=(R[i]-min);
		}
		if(R[i] < min){
			min = R[i];
		}
	}

	return ans;
}

int main(){
    int n;
	int *R;

	scanf("%d",&n);
	R=(int*)malloc(sizeof(int)*n);

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

	int ans = calc(R,n);

	printf("%d\n",ans);
	
	return 0;
}


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

struct UnionFind{
  vector<int>r;
  
  UnionFind(int x){
    r=vector<int>(x,-1);
  }
  
  int root(int x){
    if(r.at(x)<0)return x;
    else return root(r.at(x));
  }
  
  int size(int x){
    return -1*r.at(root(x));
  }
  
  bool unite(int x,int y){
    x=root(x);y=root(y);
    if(x==y)return false;
    if(r.at(x)>r.at(y))swap(x,y);
    r.at(x)+=r.at(y);
    r.at(y)=x;
    return true;
  }
};


int main(){
  int n,m;cin>>n>>m;
  int ans=0;
  UnionFind UF(n);
  int a,b;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    UF.unite(a-1,b-1);
  }
  for(int i=0;i<n;i++){
    ans=max(ans,UF.size(i));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {

		ArrayList<String> datas = new ArrayList<String>();
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		ArrayList<String> result = new ArrayList<String>();

		while (true) {
			String s1 = new String(in.readLine());
			int count = 0;

			if (s1.equals("0 0"))
				break;

			String[] data = s1.split(" ");

			int d1 = Integer.parseInt(data[0]);
			int d2 = Integer.parseInt(data[1]);

			int r1 = 0;
			int r2 = 0;

			int target = d1 * d1 + d2 * d2;
			int min = 150 * 150 * 2;
			
			for (int i = 1; i <= 150; i++) {
				for (int j = i+1; j <= 150; j++) {
					int res = i * i + j * j;
					
					if(res == target && i<= d1) break;
					
					if (target <= res && (d1 != i || d2 != j)) {
						
						if (res < min) {
							min = res;
							r1 = i;
							r2 = j;
						}else{
							break;
						}
					}
				}
			}
			
			result.add(String.valueOf(r1)+" "+String.valueOf(r2));
		}

		for (String s : result) {
			System.out.println(s);
		}
	}
}


Measured memory_bytes: 24992
import numpy as np

H, W = map(int, input().split())
S = np.array([list(input()) for i in range(H)])

ans = np.array([['0']*W for i in range(H)])
for i in range(H):
    for j in range(W):
        if S[i, j] == '#':
            ans[i, j] = '#'
        else:
            ans[i, j] = np.sum(S[max(0, i-1):min(i+2, H), max(0, j-1):min(j+2, W)] == '#')

for x in ans:
    print(''.join(list(x)))


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


int main(){
   string s;
   cin>>s;
   char j,k,l;
   j=s[0];
   k=s[1];
   l=s[2];
   if (l==k || l==j || j==k) {
       cout<<"No";
   } else {
       cout<<"Yes";
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cstdio>
using namespace std;
string a[100],b[100],c[100000];
int n,i,m;
string henkan(){
	for(int j=0;j<n;j++){
		if(c[i]==a[j]){
			c[i]=b[j];
			break;
		}
	}
	return c[i];
}
int main(){
	while(cin>>n){
		if(n==0)break;
		for(i=0;i<n;i++){
			cin>>a[i]>>b[i];
		}
		cin>>m;
		for(i=0;i<m;i++){
			cin>>c[i];
			c[i]=henkan();
		}
		for(i=0;i<m;i++){
			cout<<c[i];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
#include<atcoder/all>
#define int long long
using namespace std;
using namespace atcoder;
signed main(){
  int N,M;
  cin>>N>>M;
  vector<string> A(N);
  for(string &S:A)cin>>S;
  mf_graph<int> G(N*M+2);
  int s=N*M,t=N*M+1;
  for(int i=0;i<N;i++)
    for(int j=0;j<M;j++)
      if(A[i][j]=='.'){
        if((i+j)%2==0)G.add_edge(s,i*M+j,1);
        else G.add_edge(i*M+j,t,1);
      }
  for(int i=0;i<N;i++)
    for(int j=i%2;j<M;j+=2){
      if(j!=0 && A[i][j]=='.' && A[i][j-1]=='.')G.add_edge(i*M+j,i*M+j-1,1);
      if(i!=0 && A[i][j]=='.' && A[i-1][j]=='.')G.add_edge(i*M+j,(i-1)*M+j,1);
      if(j!=M-1 && A[i][j]=='.' && A[i][j+1]=='.')G.add_edge(i*M+j,i*M+j+1,1);
      if(i!=N-1 && A[i][j]=='.' && A[i+1][j]=='.')G.add_edge(i*M+j,(i+1)*M+j,1);
    }
  cout<<G.flow(N*M,N*M+1)<<endl;
  for(auto e:G.edges()){
    if(e.from==s || e.to==t || e.flow==0)continue;
    int x1=e.from/M,y1=e.from%M,x2=e.to/M,y2=e.to%M;
    if(x1+1==x2)A[x1][y1]='v',A[x2][y2]='^';
    if(x1-1==x2)A[x1][y1]='^',A[x2][y2]='v';
    if(y1+1==y2)A[x1][y1]='>',A[x2][y2]='<';
    if(y1-1==y2)A[x1][y1]='<',A[x2][y2]='>';
  }
  for(string S:A)cout<<S<<endl;
}

Measured memory_bytes: 6256
import java.util.*;

public class Main{

    static long gcd(long a,long b){
        if(b==0)return a;
        return gcd(b,a%b);
    }

    static long lcm(long a,long b){
        return a/gcd(a,b)*b;
    }
    public static void main(String[] srgs){
        Scanner sc=new Scanner(System.in);

        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        if(a+b+c>=22)System.out.println("bust");
        else System.out.println("win");
    }
}


Measured memory_bytes: 21588
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

int n,out=inf;
vi in,co;
int w[3];
void f(int q){
	if(q==n){
		int sum=0;
		rep(i,3){
			int c=0,s=0;
			rep(j,n)if(co[j]==i)c++,s+=in[j];
			if(c)sum+=abs(w[i]-s)+10*(c-1);
			else return;
		}
		cmin(out,sum);
	}else{
		co[q]=0;f(q+1);
		co[q]=1;f(q+1);
		co[q]=2;f(q+1);
		co[q]=3;f(q+1);
	}
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin>>n>>w[0]>>w[1]>>w[2];
	in=co=vi(n);
	rep(i,n)cin>>in[i];
	f(0);
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */

int main() {
    string S;
    cin >> S;
    if(S == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

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

		while(sc.hasNext()){
			double n = sc.nextDouble();

			if (n <= 48.0){
				System.out.println("light fly");
			}
			else if (48.0 < n && n<= 51.0){
				System.out.println("fly");
			}
			else if (51.0 < n && n<= 54.0){
				System.out.println("bantam");
			}
			else if (54.0 < n && n<= 57.0){
				System.out.println("feather");
			}
			else if (57.0 < n && n<= 60.0){
				System.out.println("light");
			}
			else if (60.0 < n && n<= 64.0){
				System.out.println("light welter");
			}
			else if (64.0 < n && n<= 69.0){
				System.out.println("welter");
			}
			else if (69.0 < n && n<= 75.0){
				System.out.println("light middle");
			}
			else if (75.0 < n && n<= 81.0){
				System.out.println("middle");
			}
			else if (81.0 < n && n<= 91.0){
				System.out.println("light heavy");
			}
			else if (91.0 < n ){
				System.out.println("heavy");
			}

		}
	}
}

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

void Makepn(vector<int>&v , int n){
	int count=0;
	int i, j;
	vector<bool> pn(n+1 , true);
	pn[0]=false;
	pn[1]=false;
	for(i=2;i<sqrt(n); i++){
		if(pn[i]){
			for(j=0 ; i*(j+2)< n ; j++){
				pn[i*(j+2)]=false;
			}	
		}
	}
	for(i=2 ; i<n ; i++){
		if(pn[i]){
			count++;
		}
	}
	v.resize(count);

	v[0]=2;
	j=1;
	for(i=3;i<=n;i+=2){
		if(pn[i]){
			v[j++]=i;
		}
	}
	return;
}

int main(){
	ios::sync_with_stdio(false);
	vector<int> pn;
	Makepn(pn , 10000);
	int n , num , ans;
	cin>>n;
	ans=n;
	for(int i=0 ; i<n ; i++){
		cin >> num;
		for(int j=0 ; j<pn.size(); j++){
			if(pn[j]*pn[j]>num) break;
			if(num%pn[j]==0){
				ans--;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    ll j;
    cin >> n >> m >> k >> j;
    if(abs(n-k)<=j){
        cout << "Yes" << Endl;
        return 0;
    }
    if(abs(n-m)<=j&&abs(m-k)<=j){
        cout << "Yes" << Endl;
        return 0;
    }
    cout << "No" << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static List<List<int>> tree = new List<List<int>>();

        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int n = sc.intarr[0];
            int[] b = sc.intarr;

            int sum = b[0];

            for(int i=1; i<n-1; i++)
            {
                if(b[i-1] >= b[i])
                {
                    sum += b[i];
                }
                else
                {
                    sum += b[i - 1];
                }
            }
            sum += b[n - 2];

            wr.wri(sum);
   
        }

        static void judge(int now, int point)
        {
            for (int i=0; i<tree.Count; i++)
            {
                if(tree[i][1] == now)
                {
                    tree[i][2] += point;
                    judge(tree[i][1], point);
                }
            }
            return;
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13268
a,b,c,d = list(map(int, input().split()))

def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

e = int(c*d/gcd(c,d))
cde = [c,d,e]

cde1 = []
for i in cde:
    a0 = 0 if a%i != 0 else 1
    a1 = b//i - a//i + a0
    cde1.append(a1)

x,y,z = cde1
print((b-a+1) - x - y + z )

Measured memory_bytes: 38384
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

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

int D[30][30];

int main() {
  int n, m; scanf("%d%d", &n, &m);
  memset(D, 0x0f, sizeof(D));
  REP(i, n) { D[i][i] = 0; }
  REP(i, m) {
    int a, b, c, d; scanf("%d,%d,%d,%d", &a, &b, &c, &d); --a; --b;
    D[a][b] = c; D[b][a] = d;
  }
  int x1, x2, y1, y2; scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2); --x1; --x2;
  REP(k, n) REP(i, n) REP(j, n) {
    D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
  }
  printf("%d\n", y1 - (y2 + D[x1][x2] + D[x2][x1]));
}

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

int N,K;
int stones[100];
int bestbypl[2][100001];

int getwinner(bool pl,int restantstones)
{
	
	if(bestbypl[pl][restantstones]!=-1)
	{
		return bestbypl[pl][restantstones] ;
	}
	for(int i = 0 ; i < N ; i++)
	{
		//cout<<"stone "<<stones[i]<<endl;
		if(restantstones-stones[i]<0)
		{
			bestbypl[pl][restantstones]=!pl;
			//cout<<"nbstones : "<<restantstones<<" and player "<<pl<<" gives "<<!pl<<endl;
			return !pl;
		}
		if(getwinner(!pl,restantstones-stones[i])==pl)
		{
			bestbypl[pl][restantstones]=pl;
			//cout<<"nbstones : "<<restantstones<<" and player "<<pl<<" gives "<<pl<<endl;
			return pl;
		}
	}
	bestbypl[pl][restantstones]=!pl;
	//cout<<"nbstones : "<<restantstones<<" and player "<<pl<<" gives "<<!pl<<endl;
	return !pl;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin>>N>>K;
	for(int i = 0 ; i < N ; i++)
	{
		cin>>stones[i];
	}
	sort(stones,stones+N);
	for(int i = 0 ; i <= K ; i++)
	{
		bestbypl[0][i]=-1;
		bestbypl[1][i]=-1;
	}
	cout<<(!getwinner(0,K) ? "First" : "Second");

}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int A,B;
	cin>>A>>B;
	A--;B--;
	
	vector<string> V(100,"");
	
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			if(i<50)V[i]+='.';
			else V[i]+='#';
		}
	}
	
	cout<<"100 100"<<endl;
	
	for(int i=0;i<100;i+=2){
		for(int j=0;j<100;j+=2){
			if(B==0)break;
			B--;
			V[i][j]='#';
		}
	}
	
	for(int i=51;i<100;i+=2){
		for(int j=0;j<100;j+=2){
			if(A==0)break;
			A--;
			V[i][j]='.';
		}
	}
	
	for(int i=0;i<100;i++)cout<<V[i]<<endl;
		
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

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

  vector<ll> dp(N+10,1);
  ll MOD = 1000000007;
  rep(i,M){
    int a; cin >> a;
    dp[a] = 0;
  }
  for (int i=1;i<=N;i++){
    if (dp[i]==0) continue;
    dp[i] = dp[i-1];
    if (i>1) dp[i] = (dp[i-1]+dp[i-2])%MOD;
  }
  cout << dp[N] << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4024
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int N=in.nextInt(),W=in.nextInt();
		
		int DP[]=new int[W+1];
		Arrays.fill(DP, 0);
		for(int i=0;i<N;i++) {
			int v=in.nextInt(),w=in.nextInt();
			for(int j=0;j<=W;j++) {
				if(j-w>=0) {
					DP[j]=Math.max(DP[j], DP[j-w]+v);
				}
			}
		}
		System.out.println(DP[W]);
	}

}



Measured memory_bytes: 27024
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>

using namespace std;

int n;
bool q[4]={};
char c;


int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%c",&c);
        q[(c=='W')+(c=='G')*2+(c=='Y')*3]=1;
    }
    cout<<(q[0]+q[1]+q[2]+q[3]-3 ? "Four":"Three")<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;


lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli d[100000] = {};

int main(void) {

	lli N;
	cin >> N;

	FOR(N) {
		cin >> d[i];
	}

	sort(d, d + N);

	COUT(d[N / 2] - d[N / 2 - 1]);

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std ; 
typedef long long int ll;
#define forn(i,e) for(ll i=0; i<e; i++)
#define fors(i , s ,e) for(ll i = s ; i < e ; i++)
#define endl "\n"
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PB push_back 
#define MP make_pair
#define F first
#define S second


int main()
{
ll a ; cin >> a; 
cout << a + (a*a) + (a*a*a) << endl ; 
}
  



Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	static int gcd(int x, int y) {
		return y == 0 ? x : gcd(y, x % y);
	}
	static int lcm(int x, int y) {
		return x / gcd(x, y) * y;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int a = sc.nextInt(), b = sc.nextInt();
			System.out.printf("%d %d\n", gcd(a, b), lcm(a, b));
		}
		sc.close();
	}
}


Measured memory_bytes: 26012
#include <stdio.h>

int main(){
    int w=0,h=0,n=0;
    scanf("%d",&n);
    scanf("%d",&h);
    scanf("%d",&w);
    
    if(h==n && w==n){
        printf("%d",1);
        } else if ((n-w)==0 ||(n-h)==0){
            printf("%d",((n-h)+1)*((n-w)+1));
        }else{
           printf("%d",((n-w)+1)*((n-h)+1));
    }
        
    }


Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

char win(char s) {
	switch (s) {
	case 'r':
		return 'p';
	case 's':
		return 'r';
	case 'p':
		return 's';
	default:
		return 'q';
	}
}

int main(void) {
	int n, k, r, s, p;
	char t[100000];
	cin >> n >> k >> r >> s >> p;
	for (int i = 0; i < n; ++i) {
		cin >> t[i];
	}
	ll score = 0;
	for (int i = 0; i < n; ++i) {
		switch (win(t[i])) {
		case 'r':
			if (i < k || t[i] != t[i - k]) {
				score += r;
			}
			else {
				t[i] = 'q';
			}
			break;
		case 's':
			if (i < k || t[i] != t[i - k]) {
				score += s;
			}
			else {
				t[i] = 'q';
			}
			break;
		case 'p':
			if (i < k || t[i] != t[i - k]) {
				score += p;
			}
			else {
				t[i] = 'q';
			}
			break;
		}
	}
	cout << score;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<String, Long> map = new HashMap<String, Long>();

    for (int i = 0; i < n; i++) {
      String in = sc.next();
      char[] chars = in.toCharArray();
      Arrays.sort(chars);
      String s = new String(chars);

      Long p = map.get(s);
      if (p == null) {
        map.put(s, 1L);
      } else {
        map.put(s, p + 1);
      }
    }

    long cnt = 0;
    for (Map.Entry<String, Long> entry : map.entrySet()) {
      long i = entry.getValue();
      if (i > 1) {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      }
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 52032
#include <bits/stdc++.h>
using namespace std;
int dp[100005];
int count(int ar[],int i,int n,int k){
	vector<int> v;
	if(dp[i]==-1){
		if(i==n-1)
			return 0;
		if(i>=n)
			return INT_MAX;
		for(int j=i+1;j<=i+k;j++){
			if(j<n)
				v.push_back(abs(ar[i]-ar[j])+count(ar,j,n,k));
		}
		dp[i]=*min_element(v.begin(),v.end());
	}
	return dp[i];
}
int main(){
	int n,k;
	cin>>n>>k;
	int ar[n];
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
		cin>>ar[i];
	cout<<count(ar,0,n,k)<<endl;
	return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };



int main() {
	const int money[] = { 10, 50, 100, 500 };
	int n;
	bool d = false;
	while ( ~scanf("%d", &n) && n ) {
		if ( d ) {
			printf( "\n" );
		}
		d = true;
		int many[ 4 ];
		for ( int i = 0; i < 4; i++ ) {
			scanf( "%d", &many[ i ] );
		}
		int use[ 4 ] = {0, 0, 0, 0};
		for ( int i = 0; i < 4; i++ ) {
			while ( many[ i ] ) {
				n -= money[ i ];
				many[ i ]--;
				use[ i ]++;
			}
		}
		if ( n < 0 ) {
			while ( abs( n ) % 50 ) {
				n += money[ 0 ];
				use[ 0 ] = max( 0, use[ 0 ] - 1 );
			}
			while ( abs( n ) % 100 ) {
				n += money[ 1 ];
				use[ 1 ] = max( 0, use[ 1 ] - 1 );
			}
			while ( abs( n ) % 500 ) {
				n += money[ 2 ];
				use[ 2 ] = max( 0, use[ 2 ] - 1 );
			}
			while ( n ) {
				n += money[ 3 ];
				use[ 3 ] = max( 0, use[ 3 ] - 1 );
			}
		}
		for ( int i = 0; i < 4; i++ ) {
			if ( use[ i ] ) {
				printf( "%d %d\n", money[ i ], use[ i ] );
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1192
import sys
import numpy as np
from numba import njit,i8


def input(): return sys.stdin.readline()

N,Q = map(int,input().split())

C=np.array(input().split(), int)

# Query取得-rightでソート
# dtypeQuery = [("index", int), ("start", int), ("end", int)]
queries=np.empty((Q,2),int)
# #rights=[[] for _ in range(N+1)]

for q in range(Q):
	l,r=map(int,input().split())
	#queries[q] = (q,l,r)
	queries[q][0] = l
	queries[q][1] = r
	#queries=np.sort(queries,order="end")

#queries=np.array(sys.stdin.buffer.read().split(),int).reshape(Q,2)

orderByR=np.argsort(queries[:,1])

# 各色の現在の一番右のindex
mostRightColorIndex = np.zeros(N+1, int)
# bit indexed tree
bitArray=np.zeros(N+1,int)

@njit(cache=True)
# @jit(返り値の型(引数1の型,引数2の型,．．．,引数nの型))
#@jit(i8[:](i8,i8,i8[:],i8[:,:],i8[:],i8[:],i8[:]))
def main(N,Q,C,queries,orderByR,mostRightColorIndex,bitArray):

	def add(itemCount, items, i, value):
		while i <= itemCount:
			items[i] += value
			i += (i & (-i))

	def sumFromStart(items, end):
		summary = 0
		i = end
		while i > 0:
			summary += items[i]
			i -= (i & (-i))
		return summary

	def sum(items, start,end):
		summary = sumFromStart(items, end) - sumFromStart(items, start-1)
		return summary

	# 答え配列
	ans=np.zeros(Q, i8)#int)
	#ans=[0]*Q
	# 左からBITと現在色の更新をしながら、クエリのrightに到達したときにBITにクエリ発行する
	qindex = 0

	for n in range(N):
		# 外側のループでは、全部の色をループ

		if Q <= qindex:
			break

		if 0 < mostRightColorIndex[C[n]]:
			# ループ中の場所の色のindexが既にある場合(=過去に、同じ色が登録されていた場合)
			# 今回で、同じ色の一番右側の要素はループ中の要素になる
			# 前登録したこの色の一番右のindexを一度BITから抜く(↓で再度登録される)
			add(N,bitArray,mostRightColorIndex[C[n]], -1 )

		# この要素の色の一番右のindexを、BITに登録
		mostRightColorIndex[C[n]] = n+1
		add(N,bitArray,n+1, 1)

		# while qindex < Q and n+1 == queries[qindex][2]:
		while qindex < Q and n+1 == queries[orderByR[qindex]][1]:
			# 今のBITが次のクエリ発行するための状態(n==query.right)だったら、クエリ発行
			tmpIndex = orderByR[qindex]
			start = queries[tmpIndex][0]
			end = queries[tmpIndex][1]
			ans[tmpIndex]=sum(bitArray,start,end)
			# print(tmpIndex,start,end,ans[tmpIndex])
			qindex += 1

	return ans

for a in main(N,Q,C,queries,orderByR,mostRightColorIndex,bitArray):
	print(a)


Measured memory_bytes: 150376
#include <cstdio>

int n, m, k;

int main()
{
    scanf("%d%d%d", &n, &m, &k);

    bool valid = false;
    for (int r = 0; r <= n; ++r) {
        for (int c = 0; c <= m; ++c)
            if (r * (m - c) + c * (n - r) == k) {
                valid = true; break;
            }
        if (valid) break;
    }

    puts(valid ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string s, t, u;
  cin >> s >> t >> u;
  cout << s[0] << t[0] << u[0] << endl;
  return 0;
}



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

int main() {
    int K, A, B; cin >> K >> A >> B;

    for(int i = A; i <= B; i++){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}

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

bool compare_pair_second(const pair<int,int>&a, const pair<int,int>&b){
    if(a.second == b.second){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}

int main(){
    int n, m;
    vector<pair<int,int> > data;

    while(cin >> n >> m){
        if(n == 0 && m == 0) break;
        for(int i=0; i<m; i++){
            data.push_back(make_pair<int,int>(i+1,0));
        }
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                int tmp;
                cin >> tmp;
                if(tmp == 1){
                    data[j].second++;
                }
            }
        }

        vector<pair<int,int> >::iterator it = data.begin();
        it = it+m;

        sort(data.begin(), it, compare_pair_second);

        for(int i=0; i<m; i++){
            printf("%d%c", data[i].first, (i==m-1)?'\n':' ');
        }
        data.clear();
    }
    return 0;
}

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

using namespace std;

int main() {
    const string player[2] = {"First", "Second"};

    string s;
    cin >> s;

    // sの長さの偶奇がベース
    int ans = s.size() % 2;
    // sの先頭と末尾が一致するかで答えが反転する
    if (s.front() != s.back()) ans = 1 - ans;

    cout << player[ans] << endl;
    return 0;
}


Measured memory_bytes: 512
import fractions

a, b, c, d = map(int,input().split())

e = c * d // fractions.gcd(c,d)
c_count = b // c - a // c
if a % c == 0:
    c_count += 1
d_count = b // d - a // d
if a % d == 0:
    d_count += 1
e_count = b // e - a // e
if a % e == 0:
    e_count += 1

ans = b - a + 1 - (c_count + d_count - e_count)

print(ans)

Measured memory_bytes: 5300
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
	    Scanner sc = new Scanner(System.in);
		    int A = sc.nextInt();
		    int B = sc.nextInt();
		    int C = sc.nextInt();
		    int D = sc.nextInt();
		    while(A>0&&C>0) {
		    C=C-B;
		    if(C<=0) {
		    	System.out.println("Yes");
		    	break;
		    }
		    A=A-D;
		    if(A<=0) {
		    	System.out.println("No");
		    	break;
		    }
		    }
		}
}


Measured memory_bytes: 35780
#include <bits/stdc++.h>
using namespace std;
//型名省略
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<long long>> vll;
typedef vector<char> vc;
typedef vector<vector<char>> vcc;
typedef vector<string> vs;
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rep2(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define all(A) A.begin(), A.end()

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

    if(s.size() <= k) cout << s << endl;
    else cout << s.substr(0,k) << "..." << endl;
}

Measured memory_bytes: 3636
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split(' ')))
    count = 0
    while True:
        A_b = [x%2 == 0 for x in A]
        if not False in A_b:
            A = list(map(lambda x: x//2, A))
            count += 1
        else:
            print(count)
            break
    

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    
    string A,B,C;
    cin >> A >>B;

    C = A + B;

    istringstream ss1;
    ll p1;
    ss1 = istringstream(C);
    ss1 >> p1;

    //cout << p1 << endl;

    bool flag = true;

    REPS(i,p1){
        double tmp = 0;
        tmp = (double)p1 / i;
        double tmp1 = i*1.0;
        
        if (tmp == tmp1)
        {
            // cout << tmp1 << endl;
            flag = false;
        }
    }

    if(flag==true){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

static int n;
static int A[20];

static bool solve(int i, int m)
{
    if (m == 0) {
        return true;
    }
    if (i >= n) {
        return false;
    }
    return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

int main()
{
    int q, M;

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

    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &M);
        if (solve(0, M)) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int a,b,m;
    cin >> a >> b >> m;
    int num_a[a],num_b[b];
    int min_a=INF,min_b=INF;
    rep(i,a){
        cin >> num_a[i];
        min_a = min(min_a,num_a[i]);
    }
    rep(i,b){
        cin >> num_b[i];
        min_b = min(min_b,num_b[i]);
    }
    int x[m],y[m],c[m];
    rep(i,m){
        int x0,y0;
        cin >> x0 >> y0 >> c[i];
        x0--; y0--;
        x[i] = x0; y[i] = y0;
    }
    int ans = min_a + min_b;
    rep(i,m){
        ans = min(ans, num_a[x[i]] + num_b[y[i]] - c[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5564
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define INF 1e9

struct P
{
	int cost, state;

	bool operator >(const P& p) const{
		return cost > p.cost;
	}
};

int main() {
	int n;
	while(cin >> n, n){
		vvi stage_times(n, vi(n + 1));
		REP(i, n){
			REP(j, n + 1){
				cin >> stage_times[i][j];
			}
		}

		vi G(1 << n, INF);

		priority_queue<P, vector<P>, greater<P>> que;
		que.push({0, (1 << n) -1});

		int res = -1;
		while(!que.empty()){
			P p = que.top(); que.pop();
			if(p.state == 0){
				res = p.cost;
				break;
			}
			 // LOG("cost %d state %d\n", p.cost, p.state);

			REP(i, n){
				if(p.state & (1 << i)){//そのステージへ行ったことがない
					//装備を使わない
					int min_cost = stage_times[i][0];

					//なにか装備を使う
					REP(j, n){
						if (p.state & (1 << j)) continue; //そのステージをクリアしてないなら装備は使えない
						// LOG("can use %d\n", j);
						min_cost = min(min_cost, stage_times[i][j + 1]);
					}

					int next_state = p.state & ~(1 << i);
					int next_cost = p.cost + min_cost;
					if (G[next_state] > next_cost){
						G[next_state] = next_cost;
						que.push({next_cost, next_state});
					}
				}
			}
		}

		cout << res << endl;
	}
}

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

void doStdOut(const char *str);

int main()
{
	int a = 0, b = 0;
	cin >> a >> b;

	if(a < b)
	{
		doStdOut("a < b");
	}
	else if(a > b)
	{
		doStdOut("a > b");
	}
	else
	{
		doStdOut("a == b");
	}
	return 0;
}

void doStdOut(const char *str){ cout << str << endl; }

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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    string s;
    cin >> s;
    map<char, Int> mp;
    rep(i, 0, n) mp[s[i]]++;
    Int res = 1;
    for (auto i : mp) {
        res *= i.se + 1;
        res %= mod;
    }
    dump(res - 1);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef pair<int,int> pairii;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main(){
  int N=100009;
 int n,m,h[N],ma[N];
 cin>>n>>m;
 for(int i=1;i<=n;i++){
 cin>>h[i];
 ma[i]=0;
 }
 for(int i=0;i<m;i++){
 int a,b;
 cin>>a>>b;
 ma[a]=max(ma[a],h[b]);
 ma[b]=max(ma[b],h[a]);
 }
 int ans=0;
 for(int i=1;i<=n;i++){
 ans+=(h[i]>ma[i]);
 }
 cout<<ans<<endl;
 }


Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> que;
  rep(i,n) {
    int a; cin >> a;
    que.push(a);
  } 
  while (m--) {
    int p = que.top(); que.pop();
    p /= 2;
    que.push(p);
  }
  ll res = 0;
  while (!que.empty()) res += que.top(), que.pop();
  cout << res << endl;
  return 0; 
}


Measured memory_bytes: 3932
import queue
n,m=map(int,input().split())
a=[[] for j in range(n)]
for i in range(0,m):
    b,c=map(int,input().split())
    a[b-1].append(c-1)
    a[c-1].append(b-1)
re=[0 for i in range(n)]
le=[0]
for i in range(0,n):
    if re[i]==0:
        ans=queue.Queue()
        ans.put(i)
        le.append(1)
        re[i]=1
        while ans.empty()==False:
            d=ans.get()
            for j in range(len(a[d])):
                if re[a[d][j]]==0:
                    ans.put(a[d][j])
                    re[a[d][j]]=1
                    le[-1]+=1
print(max(le))

Measured memory_bytes: 120436
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1e18+10;

int main(){

	string s,t;
	cin >> s >> t;
	int m = s.length();
	int n = t.length();

	int dp[m+1][n+1];
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			if(i==0||j==0)
				dp[i][j]=0;
			else if(s[i-1]==t[j-1])
				dp[i][j] = 1+dp[i-1][j-1];
			else
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int temp = dp[m][n];
	int temp2 = temp;
	//cout << temp << endl;
	char ans[temp+1];
	ans[temp]='\0';
	//temp--;
	int i=m,j=n;
	while(i>0&&j>0){
		if(s[i-1]==t[j-1]){
			ans[temp-1] = s[i-1];
			i--;
			j--;
			temp--;
			//cout << "hi" << " ";
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;
	}
	cout << ans;
	// for(int i=0;i<temp2;i++){
	// 	cout << ans[i];
	// }
	return 0;
}

Measured memory_bytes: 35456