akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//typedef long long int ll;
using namespace std;
using ll = long long;
using ld = long double;
using Vc = vector <char>;
using Vs = vector <string>;
using Vll = vector <ll>;
using Vi = vector <int>;
using Sll = set <ll>;
using Ss = set <string>;
using Sc = set <char>;
using Si = set <int>;
using MiVi = map<int,Vi>;
using MllVll = map<ll,Vll>;
using Mllll = map<ll,ll>;
using Mii = map<int,int>;
using MllSll = map<ll,Sll>;
using Mlls = map<ll,string>;
using Pllll = pair<ll,ll>;
using Pii = pair<int,int>;
 
 
#define nl cout<<endl
#define ns cout<<" "
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define forAuto(i,x) for(auto i: x)
#define forRange(i,l,h) for(int i=l;i<h;i++)
#define all(x) x.begin(),x.end()
#define append push_back
 
 
template<class T>
T gcd(T a,T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll bigmod(ll a, ll b, ll c)
{
    if(b==0) return 1;
    
    if(b%2==0)
    {
        ll x=bigmod(a,b/2,c);
        return (x*x)%c;
    }
    else return (a%c * bigmod(a,b-1,c))%c;
}
 
void vsInput()
{
    #ifndef ONLINE_JUDGE
         freopen("input.txt","r",stdin);
         freopen("output.txt","w",stdout);
    #endif // ONLINE_JUDGE
}
template<class T1,class T2>
T2 sum(T1 a,T2 ans){ans=0;forAuto(i,a)ans+=i;return ans;}
 
template<class T>
void printC(T a){forAuto(i,a)cout<<i<<" ";cout<<endl;}
 
template<class T1,class T2>
void printP(pair<T1,T2> i){cout<<"{"<<i.first<<",";cout<<i.second<<"} ";}
 
template<class T1,class T2>
void printG(map<T1,T2> a){forAuto(i,a){cout<<i.first<<" -> ";printC(i.second);}}
 
template<class T1,class T2>
void printWG(map<T1,T2> a){forAuto(i,a){cout<<i.first<<" -> ";forAuto(j,i.second)printP(j);nl;}}
 
void value() {}
template <class T1, class... T2>
void value(T1& var1, T2&... var2) { cin>>var1; value(var2...); }
 
void print() {}
template <class T1, class... T2>
constexpr void print(const T1& var1, const T2& ... var2) { cout<<var1;ns; print(var2...); }
 
 
template<class T1,class T2>
void printM(map<T1,T2> a){forAuto(i,a){cout<<i.first<<" -> ";cout<<i.second; nl;}}
 
Vll Vinput(ll n){Vll a;forRange(i,0,n){ll x;cin>>x;a.append(x);}return a;}
 
bool cmp(const ll &a, const ll &b)
{ return a<b; }
 
 
#define CPN 700007
#define M 1000000007
const int inf=1e18+5;
 
 
//----------------------------CODE----------------------------//
 
 
 
void code()
{
    ll n,k;cin>>n>>k;
    Vll height(n);
    
    forRange(i,0,n)
    cin>>height[i];
    
    
    
    ll dp[n];
    forRange(i,0,n)
    dp[i]=INT_MAX;
    
    
    dp[0]=0;
    
    forRange(i,1,n)
    {
        forRange(j,1,k+1)
        {
            if(i-j>=0)
                dp[i]=min(dp[i], dp[i-j] + abs(height[i]-height[i-j]));
        }
        
    }
    
    print(dp[n-1]);
    nl;
    
}
 
 
 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
//--------------------------------END-----------------------------//
int main()
{
    fast;
    ll t=1;
    //vsInput();
    
    
    cout << fixed << setprecision(10);
    //cin>>t;
    
    
    while(t) {
        t--;
        code();
    }
 
    return 0;
}


Measured memory_bytes: 4792
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();
        if(a < b){
            System.out.println("a < b");
        }else if(a > b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26340
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string str;
  cin>>str;
  set<char>s;
  for(int i=0;i<3;i++)
  {
    s.insert(str[i]);
  }
  if(s.size()==2)
  {
    cout<<"Yes\n";
  }
  else
  {
    cout<<"No\n";
  }
}

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

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

    int n;
    cin >> n;

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> dp;
    dp.push_back(a[0]);
    rep(i, n){
        if(a[i] > dp.back()) dp.push_back(a[i]);
        else{
            int idx = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
            dp[idx] = a[i];
        }
    }

    cout << dp.size() << endl;

    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> Pll;

int main() {
    ll K; cin >> K;
    queue<ll> q;
    for (int i = 1; i <= 9; i++) q.push(i);
    K--;
    while (K--) {
        ll x = q.front();
        q.pop();
        if (x % 10 == 0) {
            q.push(x * 10 + 0);
            q.push(x * 10 + 1);
        } else if (x % 10 == 9) {
            q.push(x * 10 + 8);
            q.push(x * 10 + 9);
        } else {
            q.push(x * 10 + x % 10 - 1);
            q.push(x * 10 + x % 10);
            q.push(x * 10 + x % 10 + 1);
        }
    }
    ll ans = q.front();
    cout << ans << endl;
}


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

int main() {
	string S;  cin >> S;
	int ret = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == '+') ret++;
		if (S[i] == '-') ret--;
	}
	cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define nl "\n"
using namespace std;
#define f(i, a, b) for(ll i = a; i<b;i++)
#define ll long long
int main()
{
    string a, b,c,s;
    cin>>a>>b;
    ll la,lb;
    la = a.size();
    lb = b.size();
    if(lb-la!=1)
{
        cout<<"No"<<nl;
        return 0;}

        s = b.substr(0, la);
        if(s==a)
            cout<<"Yes"<<nl;
        else cout<<"No"<<nl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl ;
typedef pair<ll,ll> pl;
 
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define rep(i,N) for(int i=0; i < (N); i++)
#define all(v) (v).begin(),(v).end()

int main(){
	int K, N;
	cin >> K >> N;
	vl A(N);
	rep(i,N) cin >> A[i];
	sort(A.begin(), A.end());
	ll m = 0;
	rep(i,N-1){
		m = max(m, A[i+1]-A[i]);
	} 
	m = max(K-A[N-1]+A[0], m);
	cout << K-m << endl;
}

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

public class Main {
	
	int inf = 1_000_000_007;

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

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int h = fs.nextInt();
		int n = fs.nextInt();
		
		int[] dp = new int[h+1];
		
		for(int i = 1; i <= h; i++) {
			dp[i] = inf;
		}
		Magic[] magicArr = new Magic[n];
		for(int i = 0; i < n; i++) {
			int atk = fs.nextInt();
			int cost = fs.nextInt();
			magicArr[i] = new Magic(atk,cost);
		}
		
		for(int i = 1; i <= h; i++) {
			for(Magic magic : magicArr) {
				int atk = magic.atk;
				int cost = magic.cost;
				
				if(atk > i) {
					dp[i] = Math.min(cost, dp[i]);
				}else {
					dp[i] = Math.min(cost + dp[i-atk], dp[i]);
				}
			}
		}
		
		System.out.println(dp[h]);
	}
	
	class Magic {
		int atk;
		int cost;
		
		Magic(int atk, int cost){
			this.atk = atk;
			this.cost = cost;
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

   if(a<=b) rep(i, b) cout<<a;
   else rep(i, a) cout<<b;
   cout<<endl;
   return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>

int main(void){
    int a,b;
    
    while(1){
        scanf("%d %d",&a,&b);
        if(a==0 && b==0) break;
        if(a<b){
            printf("%d %d\n",a,b);
        }else{
            printf("%d %d\n",b,a);
        }
    }
}


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

int main(){
    int n[5];
    cin>>n[0]>>n[1]>>n[2]>>n[3]>>n[4];
    sort(n,n+5);
    cout<<n[4]<<" "<<n[3]<<" "<<n[2]<<" "<<n[1]<<" "<<n[0]<<endl;
    return 0;
}

Measured memory_bytes: 3144
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    vi v(3,0); rep(i,3)cin>>v[i];
    if(max(v[1],v[2])-min(v[1],v[2])-v[0]>=0)cout<<max(v[1],v[2])-min(v[1],v[2])-v[0]<<endl;
    else cout<<0<<endl;
                                    
}

Measured memory_bytes: 256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 200000+7;
int a[MX];
int n;

template<class T>
vector<T> calc_divisor(T n) {
    vector<T> res;
    for (T i = 1; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            T j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end()); //大きい順
    return res;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> n;
    map<int, int> mp;
    FOR(i,0,n-1) {
        cin >> a[i];
        mp[a[i]]++;
    }
     
    int ans = 0;
    for(int i = 0; i <= n-1; i++) {
        if(mp[a[i]] > 1) continue;
        bool ok = true;
        for(auto e: calc_divisor(a[i])) {
            if(e == a[i]) continue;
            if(mp[e] > 0) ok = false;
        }
        if(ok) ans++;
    }

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


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  string s; cin >> s;
  if(s == "keyence") {
    cout << "YES" << endl;
    return 0;
  }
  int n = SZ(s);
  REP(i, n) {
    FOR(j, i, n) {
      if(s.substr(0, i) + s.substr(j, n-j+1) == "keyence") {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
	ll n,m;
	cin >> n >> m;
	const ll mod = 1e9 + 7;
	vector<ll> st(n+1);
	ll a;
	for (int i=0; i < m; i++) {
		cin >> a;
		st[a] = 1; //壊れてたら1
	}
	vector<ll> dp(n+1);
	//1,2壊れてない
	dp[1] = 1;
	dp[2] = 2;
	if (st[1] == 1) {
		dp[1] = 0;
		dp[2] = 1;
	}
	if (st[2] == 1) {
		dp[2] = 0;
	}
	for (int i = 3; i < n + 1; i++) {
		if (st[i] == 0) {
			dp[i] = dp[i - 1]%mod + dp[i - 2]%mod;
		}else{
        dp[i] == 0;
        }
	}
	cout << dp[n]%mod << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}
  // assign: 総とっかえ
  void init(int n) { par.assign(n, -1); }

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

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

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;

    // xにyをmerge
    if (par[x] > par[y]) swap(x, y);  // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }

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

int main(){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.merge(a, b);
    }
    int res=0;
    rep(i, n){
        res = max(res, uf.size(i));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4048
N, M = map(int, input().split())
H = list(map(int, input().split()))
graph = [[] for _ in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)
ans = [1] * N
for j in range(N):
  for t in graph[j]:
    if(H[j] <= H[t]):
      ans[j] = 0
print(sum(ans))

Measured memory_bytes: 93448
#include <stdio.h>
#include <string.h>

int main(void) {
	// your code goes here
	char d[200000];
	scanf("%s",d);
	int i,j;
	for(i = 0;d[i] != 'A';	i++);
	for(j = strlen(d);d[j] != 'Z';j--);
	printf("%d",j-i+1);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
	long long r, d, x;
	long long  i;

	scanf("%lld %lld %lld", &r, &d, &x);

	for (i = 0; i < 10; i++) {
		x = r*x - d;
		printf("%lld\n", x);
	}


	return 0;
}

Measured memory_bytes: 128
s=list(input())

if s[0]=='A':
    if s.count('C')==1 and s[1]!='C' and s[len(s)-1]!='C':
        s.remove('A')
        s.remove('C')
        s=''.join(s)
        if s.islower()==True:
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')



Measured memory_bytes: 3060
//ITP1_11_A

#include <stdio.h>

int main(){

	int dice[6];
	int swap;				//????????¨
	char c;
	
	int i;
	
	for(i=0;i<6;i++){
		scanf("%d",&dice[i]);
	}
	
	while(scanf("%c",&c)!=EOF){
	
		if(c=='E'){
			swap=dice[0];
			dice[0]=dice[3];
			dice[3]=dice[5];
			dice[5]=dice[2];
			dice[2]=swap;
		}
		if(c=='W'){
			swap=dice[0];
			dice[0]=dice[2];
			dice[2]=dice[5];
			dice[5]=dice[3];
			dice[3]=swap;
		}
		if(c=='S'){
			swap=dice[0];
			dice[0]=dice[4];
			dice[4]=dice[5];
			dice[5]=dice[1];
			dice[1]=swap;
		}	
		if(c=='N'){
			swap=dice[0];
			dice[0]=dice[1];
			dice[1]=dice[5];
			dice[5]=dice[4];
			dice[4]=swap;
		}
	}
	
	printf("%d\n",dice[0]);
	
	return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
    cin >> s;
    int slen = s.length();
    int cnt = 0;
    if(slen % 2 == 0) {
        for(int i = 0; i < slen/2; ++i) {
            if(s.at(i) != s.at(slen-1-i)) cnt++;
        }
    }else {
        for(int i = 0; i <= slen/2; ++i) {
            if(s.at(i) != s.at(slen-1-i)) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

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

	if (A == B) {
		cout << C;
	}
	else if (B == C) {
		cout << A;
	}
	else if (C == A) {
		cout << B;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  var ans
  input = input.trim().split("\n");
	const [X] = input[0].split(" ").map((n) => parseInt(n));
	ans = Math.floor(X / 500) * 1000
	var am = X % 500 - X % 5
	var ans = ans + am




  //出力
  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require("fs").readFileSync("./input.txt", "utf-8"));


Measured memory_bytes: 29572
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX 2050

int N;
char t[MAX][MAX];
bool T[MAX][MAX];
int a[MAX][MAX];
int b[MAX][MAX];

map < P , vector<P> > G;

bool inField(int y,int x){
  return (0<=y&&y<N&&0<=x&&x<N);
}

bool inField(P p){
  return inField(p.first,p.second);
}

bool inField(int ay,int ax,int by,int bx,P p){
  int y=p.first;
  int x=p.second;
  return (ay<y&&y<by&&ax<x&&x<bx);
}

map< P , P > mem[4];

P search(P p,int dir){
  if(mem[dir].count(p))return mem[dir][p];
  int Dy[]={-1,-1,1,1};
  int Dx[]={-1,1,1,-1};
  int dy=Dy[dir];
  int dx=Dx[dir];
  int y=p.first+dy;
  int x=p.second+dx;
  while(inField(y+dy,x)&&t[y+dy][x]=='o')y+=dy;
  while(inField(y,x+dx)&&t[y][x+dx]=='o')x+=dx;
  return mem[dir][p]=P(y+dy,x+dx);
}

void put(P p,int dir){
  int y=p.first;
  int x=p.second;
  int dy[]={-1,0,1,0};
  int dx[]={0,1,0,-1};
  T[y][x]=false;
  while(inField(y,x)&&!T[y][x]){
    T[y][x]=true;
    y+=dy[dir];
    x+=dx[dir];
  }
}


set< P > st;

P solve(int ay,int ax,int by,int bx){
  P sp=P(-1,-1);
  P tmp=P(ay,ax);
  while(1){
    if(mem[2].count(tmp))break;
    tmp=search(tmp,2);
    if(!inField(ay,ax,by,bx,tmp))break;
    if(st.count(tmp)){
      sp=tmp;
    }
    st.insert(tmp);
  }
  tmp=P(by,ax);
  while(1){
    if(mem[1].count(tmp))break;
    tmp=search(tmp,1);
    if(!inField(ay,ax,by,bx,tmp))break;
    if(st.count(tmp)){
      sp=tmp;
    }
    st.insert(tmp);
  }
  if(sp.first==-1)return P(-1,-1);
  if(sp.first<=ay || sp.second<=ax)return P(-1,-1);
  if(sp.first>=by || sp.second>=bx)return P(-1,-1);
  P LU=solve(ay,ax,sp.first,sp.second);
  P LD=solve(sp.first,ax,by,sp.second);
  P RU=solve(ay,sp.second,sp.first,bx);
  P RD=solve(sp.first,sp.second,by,bx);
  if(LU.first!=-1)G[ sp ].push_back(LU);
  if(LD.first!=-1)G[ sp ].push_back(LD);
  if(RU.first!=-1)G[ sp ].push_back(RU);
  if(RD.first!=-1)G[ sp ].push_back(RD);
  return sp;
}

int main(){
  

  scanf("%d",&N);
  bool flag=false;
  for(int i=0;i<N;i++){
    scanf("%s",t[i]);
    for(int j=0;j<N;j++)
      if(t[i][j]=='x')flag=true;
  }
  if(!flag){
    cout<<0<<endl;
    return 0;
  }
  
  P sp=solve(-1,-1,N,N);

  map<P,bool> flg;
  priority_queue< P , vector<P> , greater<P> > Q;
  flg[ sp ]=true;
  Q.push( sp );
  
  vector<P> ans;
  while(!Q.empty()){
    P p=Q.top();

    Q.pop();
    ans.push_back(p);

    if(T[p.first][p.second]){
      printf("-1\n");
      return 0;
    }
    
    for(int i=0;i<4;i++){
      put(p,i);
    }
        
    for(int i=0;i<(int)G[p].size();i++){
      P to=G[p][i];
      if(to==P(-1,-1))continue;
      if(flg[to])continue;
      if(!inField(to))continue;
      flg[to]=true;
      Q.push(to);
    }
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if( (t[i][j]=='x') != T[i][j] ){
        printf("-1\n");
        return 0;
      }
    }
  }

  printf("%d\n",(int)ans.size());
  for(int i=0;i<(int)ans.size();i++){
    printf("%d\n",ans[i].first+1);
    printf("%d\n",ans[i].second+1);
  }
  return 0;
}

Measured memory_bytes: 214416
import numpy as np
N = int(input())
xy = []
for i in range(N):
    tmp1, tmp2 = map(int,input().split())
    xy.append((tmp1,tmp2))
#print(xy)
d = np.zeros((N,N))
for i in range(N):
    for j in range(N):
        d[i][j] = np.sqrt((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)
print(np.sum(d)/N)


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

int main() {
  int d, g;
  cin >> d >> g;
  vector<int> p(10), c(10);
  for (int i = 0; i < 10; i++) {
    cin >> p.at(i) >> c.at(i);
  }
  
  int ans = 1e9;
  for (int mask = 0; mask < (1 << d); mask++) {
    int s = 0, num = 0, rest_max = -1;
    for (int i = 0; i < d; i++) {
      if (mask >> i & 1) {
        s += 100 * (i + 1) * p.at(i) + c.at(i);
        num += p.at(i);
      } else {
        rest_max = i;
      }
    }
    if (s < g) {
      int s1 = 100 * (rest_max + 1);
      int need = (g - s + s1 - 1) / s1;
      if (need >= p.at(rest_max)) {
        continue;
      }
      num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a==b) cout << 2*a << endl;
    else cout << 2*max(a,b)-1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String a = scan.next();
        String b = scan.next();
        
        Integer ll = a.length();
        Integer ans = 0;
        
        for (int i=0;i<ll;i++) {
            if (!a.substring(i,i+1).equals(b.substring(i,i+1))) {
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 55596
use std::io;
fn main() {
    let mut l1 = String::new();
    let stdin = io::stdin();
    stdin.read_line(&mut l1).unwrap();
    let trimed = l1.trim_right();
    let mut itr = trimed.split_ascii_whitespace();
    let r = itr.next().unwrap().parse::<f64>().unwrap();
    println!("{}", 2_f64 * std::f64::consts::PI * r);
}


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

int main(){
	long long s;
	cin>>s;
	
	const int v=1000000000;
	
	int x=(v-s%v)%v;
	int y=(s+x)/v;
	
	cout<<"0 0 1000000000 1 "<<x<<" "<<y<<endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define MOD 998244353
using namespace std;
typedef long long ll;
int n, cnt, X[210], Y[210], P[210] = { 1 };
bool done[210][210];
int norm(int x) {
	return (x + MOD) % MOD;
}
bool linear(int a, int b, int c) {
	return (X[a] - X[c])*(Y[b] - Y[c]) - (Y[a] - Y[c])*(X[b] - X[c]) == 0;
}
int subset(int x) {
	return norm(P[x] - x - 1);
}
void count(int v, int u) {
	if (done[v][u]) return;
	vector<int> V;
	for (int i = 1; i <= n; i++)
		if (linear(u, v, i))
			V.push_back(i);
	int m = V.size();
	for (int i = 0; i<m; i++)
		for (int j = 0; j<m; j++)
			done[V[i]][V[j]] = true;
	cnt = (cnt + subset(m)) % MOD;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		P[i] = (P[i - 1] * 2) % MOD;
	for (int i = 1; i <= n; i++)
		scanf("%d%d", X + i, Y + i);
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			count(i, j);
	int ans = subset(n);
	printf("%d", norm(ans - cnt));
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict

N = int(input())
P = [int(input()) for _ in range(N)]
idx = defaultdict(int)

for i in range(N):
    idx[P[i]] = i
    
dp = [0]*N

for i in range(N):
    if P[i]==1:
        dp[i] = 1
    else:
        dp[i] = dp[idx[P[i]-1]]+1
    
print(N-max(dp))

Measured memory_bytes: 76252
import java.util.BitSet;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n){return REPS(n).map(i->getInt());}
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		while(true){
			int n=getInt();
			if(n==0)return;
			BitSet[]f=new BitSet[n];
			for(int i=0;i<n;++i)f[i]=new BitSet();
			for(int i=getInt();i>0;--i) {
				int a=getInt()-1,b=getInt()-1;
				f[a].set(b);
				f[b].set(a);
			}

			BitSet r=(BitSet)f[0].clone();
			r.set(0);
			for(int i=f[0].nextSetBit(0);i!=-1;i=f[0].nextSetBit(i+1))
				r.or(f[i]);
			System.out.println(r.cardinality()-1);
		}
	}
}

Measured memory_bytes: 45568
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 1e5 + 500;

int A[N], n, st = 0, k;

int main(){
	scanf("%d%d", &n, &k);
	for(int i = 0;i < n;i++){
		scanf("%d", A + i);
	}	
	while(st < n && A[st] < 0) st++;
	int ret = 1e9;
	for(int i = st;i <= n;i++){
		if((i - st) <= k && st >= k - (i - st)){
			int R = (i == st ? 0 : A[i - 1]);
			int L = -((i - st) == k ? 0 : A[st - (k - (i - st))]);
			ret = min(ret, L + R + min(L, R));
		}
	}
	printf("%d\n",  ret);
	return 0;
}

Measured memory_bytes: 2116
n = int(input())
h = list(map(int,input().split()))
b = [0]*(n-1)
for i in range(n-1):
    if h[i]-h[i+1]>=0:
        b[i]=1


c = (''.join(map(str, b))).split("0")
#print(c)
d = set(c)
#print(d)
print(len(max(d)))


Measured memory_bytes: 20948
#include <stdio.h>
 
int main()
{
  int n, a, i, j, x;
  int y[8] = {0,0,0,0,0,0,0,0};
  int z = 0;
  int min = 0;
  int max = 0;
 
  scanf("%d", &n);
  for(i = 0; i < n; i++)
  {
    scanf("%d", &a);
    x = a / 400;
    if(x < 8)
    {
      y[x]++;
    }
    else if(x >= 8)
    {
      z++;
    }
  }
  for(j = 0; j < 8; j++)
  {
    if(y[j] > 0)
    {
      min++;
    }
  }
  max = min + z;
  if(min == 0)
  {
    min = 1;
  }
  printf("%d %d", min, max);
  return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
int main(){
  int k;
  int64_t s=0;
  cin >> k;
  for(int i=1; i<=k; i++)
    for(int j=1; j<=k; j++)
      for(int l=1; l<=k; l++)
	s += gcd(i, gcd(j, l));
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#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>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

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


int main(void) {

	lli N;
	cin >> N;

	lli a[] = { 105,135,165,189,195,201 };

	for (int i = 0; i < 6; i++) {
		if (N < a[i]) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

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

#define min(a, b) a < b ? a : b
#define max(a, b) a > b ? a : b

int main(void)
{
	long long x, ans;

	scanf("%lld", &x);
	
	if (x % 11 == 0) {
		ans = 2 * (x / 11);
	} else if (x % 11 <= 6){
		ans = 2 * (x / 11) + 1;
	} else {
		ans = 2 * (x / 11) + 2;
	}

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

	return (0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,l;
    cin>>n>>l;
    int sum=0,mn=1e9,c=0;
    for (int i=1;i<=n;i++){
        int cost = i+l-1;
        if (abs(cost)<mn)mn=abs(cost),c=cost;
        sum+=cost;
    }
    cout<<sum-c<<endl;
}

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

INF = 10 ** 15
WF = [[INF for _ in range(N + 1)] for _ in range(N + 1)]

for a, b, c in ABC:
  WF[a][b] = c
  WF[b][a] = c
for k in range(1, N + 1):
  for i in range(1, N + 1):
    for j in range(1, N + 1):
      WF[i][j] = min(WF[i][j], WF[i][k] + WF[k][j])

answer = 0
for a, b, c in ABC:
  if WF[a][b] < c:
    answer += 1
print(answer)

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

int main(){
  using edge= pair<int, int>;
  using Graph= vector<set<edge>>;
  constexpr int TBC= -1;

  int L;
  cin >> L;
  
  Graph gph;
  vector<int> pow3;
  pow3.emplace_back(0); // 番兵
  pow3.emplace_back(1);
  while(pow3.back()* 3 < L){
    gph.emplace_back(set<edge>());
    gph.back().insert(make_pair(TBC, 0* pow3.back()));
    gph.back().insert(make_pair(TBC, 1* pow3.back()));
    gph.back().insert(make_pair(TBC, 2* pow3.back()));

    pow3.emplace_back(pow3.back()* 3);
  }

  int Mhead= L/pow3.back();
  if(Mhead > 1){
    gph.emplace_back(set<edge>());
    for(int j=0; j<Mhead; j++){
      gph.back().insert(make_pair(TBC, j* pow3.back()));
    }
  }
  gph.emplace_back(set<edge>());
  reverse(gph.begin(), gph.end());

  size_t N= gph.size();
  int offset= Mhead* pow3.back();
  for(size_t to=2; to<=N; to++){
    while(offset+ pow3.at(N- (to- 1)) <= L){
      gph.at(1).insert(make_pair(to, offset));
      offset+= pow3.at(N- (to- 1));
    }
  }

  size_t M= 0;
  for(size_t from=1; from<N; from++){
    M+= gph.at(from).size();
  }

  cout << N <<" "<< M << endl;
  for(size_t from=1; from<N; from++){
    for(auto [to, w]:gph.at(from)){
      if(to==TBC){ to= from+ 1; }
      cout << from <<" "<< to <<" "<< w << endl;
    }
  }
}

Measured memory_bytes: 3608
#include<stdio.h>
#define M 10000
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}Tree;
 
Tree t[M];
int n;
 
void preParse(int);
void inParse(int);
void postParse(int);
void print(void);
 
int main(){
  int i,v,l,r;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    t[i].parent =NIL;
  }
  for(i = 0;i < n; i++){
    scanf("%d %d %d",&v,&l,&r);
    t[v].left = l;
    t[v].right = r;
    if(l != NIL)t[l].parent = v;
    if(r != NIL)t[r].parent = v;
  }
  print();
  return 0;
}
 
void preParse(int u){
 
  if(u == NIL)return;
  printf(" %d",u);
  preParse(t[u].left);
  preParse(t[u].right);
}
 
void inParse(int u){
 
  if(u == NIL)return;
  inParse(t[u].left);
  printf( " %d",u);
  inParse(t[u].right);
}
 
void postParse(int u){
 
  if(u == NIL)return;
  postParse(t[u].left);
  postParse(t[u].right);
  printf(" %d",u);
}
 
void print(){
  int i,r;
  for(i = 0; i < n; i++){
    if(t[i].parent == NIL)r = i;
  }
 
  printf("Preorder\n");
  preParse(r);
  printf("\n");
  
  printf("Inorder\n");
  inParse(r);
  printf("\n");
   
  printf("Postorder\n");
  postParse(r);
  printf("\n");
 
}



Measured memory_bytes: 2056
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<char> L = new List<char>();
		for(int i=0;i<S.Length;i+=M){
			L.Add(S[i]);
		}
		Console.WriteLine(new String(L.ToArray()));
	}
	String S;
	int M;
	public Sol(){
		S = rs();
		M = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long lli;
lli n,m;
string s;
vector<lli> rightend;
vector<vector<lli> > dp;
vector<lli> sum;
int main(){
    cin >> n >> m;
    cin >> s;
    rightend = vector<lli> (n+1);
    for(lli i = 1;i <= n;i++) rightend[i] = i;
    for(lli i = 0;i < m;i++){
        lli l,r;
        cin >> l >> r;
        rightend[l] = max(rightend[l],r);
    }
    sum = vector<lli> (n+1);
    for(lli i = 1;i <= n;i++) sum[i] = s[i-1] - '0';
    for(lli i = 0;i < n;i++) sum[i+1] += sum[i];
    for(lli i = 0;i < n;i++) rightend[i+1] = max(rightend[i+1],rightend[i]);
    dp = vector<vector<lli> > (n+2,vector<lli>(n+2));
    dp[0][0] = 1;
    for(lli i = 0;i < n;i++){
        lli b,e;
        b = max(0ll,i - (rightend[i] - sum[rightend[i]]));
        e = min(i,sum[rightend[i]]);
        for(lli j = b;j <= e;j++){
            dp[i+1][j] += dp[i][j];dp[i+1][j] %= 1000000007;
            dp[i+1][j+1] += dp[i][j];dp[i+1][j] %= 1000000007;
        }
    }
    cout << dp[n][sum[n]] << endl;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  int A, B, C, D;
  A = (int)(s[0]-'0');
  B = (int)(s[1]-'0');
  C = (int)(s[2]-'0');
  D = (int)(s[3]-'0');
  if (A+B+C+D == 7) {
    cout << A << '+' << B << '+' << C << '+' << D << "=7" << endl;
  }
  else if (A+B+C-D == 7) {
    cout << A << '+' << B << '+' << C << '-' << D << "=7" << endl;
  }
  else if (A+B-C+D == 7) {
    cout << A << '+' << B << '-' << C << '+' << D << "=7" << endl;
  }
  else if (A+B-C-D == 7) {
    cout << A << '+' << B << '-' << C << '-' << D << "=7" << endl;
  }
  else if (A-B+C+D == 7) {
    cout << A << '-' << B << '+' << C << '+' << D << "=7"  << endl;
  }
  else if (A-B+C-D == 7) {
    cout << A << '-' << B << '+' << C << '-' << D << "=7" << endl;
  }
  else if (A-B-C+D == 7) {
    cout << A << '-' << B << '-' << C << '+' << D << "=7" << endl;
  }
  else if (A-B-C-D == 7) {
    cout << A << '-' << B << '-' << C << '-' << D << "=7" << endl;
  }
}

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

int main(){
  int n;
  cin >> n;
  string w[n];
  for (int i=0;i<n;i++) cin >> w[i];
  for (int i=1;i<n;i++){
    for(int j=0;j<i;j++) if(w[j]==w[i]) {
      cout << "No" << endl;
      return 0;
    }
    if (w[i-1].back() != w[i].front()) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
int main(){
    int n;
    cin >> n;
    string s;
    map<string, int> ans;
    ans["AC"] = 0;
    ans["WA"] = 0;
    ans["TLE"] = 0;
    ans["RE"] = 0;

    rep(i,n){
        cin >> s;
        ans[s]++;
    }

    cout << "AC x " << ans["AC"] << endl;
    cout << "WA x " << ans["WA"] << endl;
    cout << "TLE x " << ans["TLE"] << endl;
    cout << "RE x " << ans["RE"] << endl;

    return 0;
}

Measured memory_bytes: 3628
h,n=map(int,input().split())
A,B=[],[]
maA=0
for i in range(n):
   a,b=map(int,input().split())
   A.append(a)
   B.append(b)
   maA=max(maA,a)
inf=float("inf")
dp=[inf]*(h+maA+1)
dp[0]=0
for i in range(h):
   for j in range(n):
      dp[i+A[j]]=min(dp[i+A[j]],dp[i]+B[j])
print(min(dp[h:]))

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

int main() {
	string s;
	cin >> s;
	vector<char> v;
	for (char c: s) {
		if (c == 'B') {
			if (!v.empty()) v.pop_back();
		} else {
			v.push_back(c);
		}
	}
	for (char c: v) {
		cout << c;
	}
	cout << endl;
	return 0;
}


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

    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        long b =1;
        for (int i =1;i<=a;i++){
            b=b*i;
        }
        System.out.println(b);
    }
}

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

int main() {
  int n,buf,fn=0;
  cin >> n;
  buf=n;
  while (true) {
    if (buf<1) break;
    fn += buf%10;
    buf -= buf%10;
    buf /= 10;
  }
  string ans;
  if (n % fn == 0) ans="Yes";
  else ans="No";
  cout << ans << endl;
}

Measured memory_bytes: 256
s=list(input().split())


num1=1
tmp1=0
for i in range(len(s)):
    if tmp1>num1:                                       #出現頻度が高い
        #print("tmp1",tmp1)
        num1=tmp1
        list1=s[i-1]
    tmp1=0
    for m in range(len(s)):
        if s[i]==s[m]:
            tmp1+=1

for l in range(len(s)-1):                               #単語が一番長い
    if len(s[l])>len(s[l+1]):
        tmp2=s[l+1]
        s[l+1]=s[l]
        s[l]=tmp2

print(list1,s[len(s)-1])
        




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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum+=a[i];
    }
    int cnt = 0;
    int d = sum/(4*m);
    if(sum%(4*m) != 0){
        d++;
    }
    for(int i = 0; i < n; i++){
        if(a[i]>=d){
            cnt++;
        }
    }
    if(cnt >= m){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}


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

int main(){
    int a[10];
    for(int i = 0; i < 10; i++) a[i] = 0;
    for(int i = 0; i < 4; i++){
        int n; cin >> n;
        a[n]++;
    }
    if(a[1] == 1 && a[9] == 1 && a[7] == 1 && a[4] == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1000000007;
void files(){
 freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);

}
void fast(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

}

int main(){
 fast();
 int n,ans=0;
 cin>>n;
 vector<int> d1(n),d2(n);
 for(int i=0; i<n; i++){
    cin>>d1[i]>>d2[i];
    if(i>1&&ans==0){
        if(d1[i]==d2[i]&&d1[i-1]==d2[i-1]&&d1[i-2]==d2[i-2]){ans=1;}
    }
 }
 if(ans){cout<<"Yes";}
 else{cout<<"No";}

    return 0;
}

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

#define float double
#define debug(x) (cerr << #x << ": " << (x) << endl)

typedef long long ll;

using namespace std;

int32_t main() {
    int n;
    int x;
    cin >> n >> x;

    ll total = 0;
    ll minMoto = (int) 1e6;

    for(int i = 0; i < n; i++){
        ll mi;
        cin >> mi;

        x -= mi;
        total += 1;
        minMoto = min(minMoto, mi);

    }

    total += (x / minMoto);
    cout << total << endl;


}


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

int main(){
    int k, x;
    cin >> k >> x;
    vector<int> a(2000001, 0);

    int pl = 0;
    int pr = 0;
    
    if(k == 0){
        cout << x << endl;
        return 0;
    }

    pl = x - (k - 1);
    pr = x + (k - 1);
    for(int i = pl; i < pr+1; i++){
        cout << i << ' ';
    }
    cout << endl;
    

    



}

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

int main() {
  string s;
  int count=0;
  while(cin >> s) {
    int i;
    for(i=0; i<=s.size()/2; i++) {
      if(s[i]!=s[s.size()-1-i]) break;
    }
    if(i==s.size()/2+1) count++;
  }
  cout << count << endl;
  return 0;
}


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

#define MAXN 5000005
#define ll long long int

int main(){
    int n;
    cin>>n;
    if(n%1000==0)cout<<"0\n";
    else 
        cout<<(1+(n/1000))*1000-n<<"\n";
    return 0;
}


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

namespace AOJ.Volume1
{
    public class RewardForCarpenter
    {
        private static int n;
        private static int[,] cost;

        private class Town
        {
            public int Cost { get; set; }
            public bool Confirm { get; set; }
        }

        public static int Main()
        {
            n = int.Parse(Console.ReadLine());
            // ??????????????????????????????
            // ???????????????????????¢???????????§n+1?????§??¨?????????
            // cost[1,2]???1??????2???????????????
            cost = new int[n + 1, n + 1];
            // ??????????????????????????¨???????????´??????-1
            for(int i = 0; i <= n; i++)
            {
                for(int j = 0; j <= n; j++) { cost[i, j] = -1; }
            }

            int m = int.Parse(Console.ReadLine());
            for(int i = 0; i < m; i++)
            {
                var input = Console.ReadLine().Split(',');
                int a = int.Parse(input[0]);
                int b = int.Parse(input[1]);
                int c = int.Parse(input[2]);
                int d = int.Parse(input[3]);
                cost[a, b] = c;
                cost[b, a] = d;
            }

            var data = Console.ReadLine().Split(',');
            int start = int.Parse(data[0]);
            int goal = int.Parse(data[1]);
            int capital = int.Parse(data[2]);
            int material = int.Parse(data[3]);

            // ???????????????????????§????????¢?´¢
            // ??????
            int c_go = Calc(start, goal);
            // ????????????????????????????????????
            capital = capital - c_go - material;

            // ??????
            int c_ret = Calc(goal, start);

            // ??±??¬????±????
            capital -= c_ret;

            Console.WriteLine(capital);
            return 0;
        }

        // ???????????????????????§??????????¨??????????
        private static int Calc(int s, int g)
        {

            var t = new Town[n + 1];
            for (int i = 1; i <= n; i++)
            {
                t[i] = new Town();
                t[i].Cost = int.MaxValue;
                t[i].Confirm = false;
            }

            t[s].Cost = 0;
            t[s].Confirm = true;
            int no = s;
            while (true)
            {
                int min = int.MaxValue;
                for(int i = 1; i <= n; i++)
                {
                    if (cost[no, i] >= 0)
                    {
                        if (!t[i].Confirm) { t[i].Cost = Math.Min(t[i].Cost, t[no].Cost + cost[no, i]); }
                    }
                    if (!t[i].Confirm) { min = Math.Min(min, t[i].Cost); }
                }

                for(int i = 1; i <= n; i++)
                {
                    if(!t[i].Confirm && t[i].Cost == min) { no = i;break; }
                }
                t[no].Confirm = true;
                if(no == g) { break; }
            }

            return t[g].Cost;
        }
    }
}

Measured memory_bytes: 9104
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()




int main() {

	ll N;
	cin >> N;
	vll a(N);
	rep(i, N) cin >> a[i];
	sort(all(a), greater<ll>());

	ll ans = 0;
	rep(i, N) {
		if (i % 2 == 0) ans += a[i];
		else ans -= a[i];
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 256
/*  Bismillahir Rahmanir Rahim  */

#include <bits/stdc++.h>

using namespace std;

const int N = 305;

int n, m, a[N][N];
int act[N], tot[N];

bool OK(int can){
	memset(tot, 0, sizeof(tot));
	memset(act, 0, sizeof(act));
	for(int i = 1; i <= m; ++i) act[i] = 1;
	for(int i = 1; i <= n; ++i) ++tot[a[i][1]];
	int left = m;
	while(left){
		bool ok = true;
		left = 0;
		for(int i = 1; i <= m; ++i){
			if(act[i] == 0) continue;
			if(tot[i] > can){
				ok = false;
				act[i] = 0;
			}
			left += act[i];
		}
		if(ok == true) return true;
		memset(tot, 0, sizeof(tot));
		for(int i = 1; i <= n; ++i){
			for(int j = 1; j <= m; ++j){
				if(act[a[i][j]]){
					++tot[a[i][j]];
					break;
				}
			}
		}
	}
	return false;
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			scanf("%d", &a[i][j]);
		}
	}
	int lo = 1, hi = n, ans = n;
	while(lo <= hi){
		int mid = (lo + hi) / 2;
		if(OK(mid)) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		string s1,s2;
		cin >> s1 >> s2;
		vector<int> ans;
		int k=0;
		for(int j=0;j<1000;j++)
		{
			int num=0;
			int a=s1.size()-1-j,b=s2.size()-1-j;
			if(a<0&&b<0&&k==0)break;
			if(a>=0)num+=s1[a]-'0';
			if(b>=0)num+=s2[b]-'0';
			ans.pb((num+k)%10);
			if(num+k>=10)k=1;
			else k=0;
		}
		if(ans.size()>80)
		{
			printf("overflow\n");
			continue;
		}
		for(int j=ans.size()-1;j>=0;j--)
		{
			cout << ans[j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1240