akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;
const long long N = 3010;
const long long S = 3010;
const long long mod = 998244353;
long long n, s;
long long a[N];
long long dp[S];
long long ans;
int main() {
	scanf("%lld%lld", &n, &s);
	for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
	for (long long i = 1; i <= n; i++) {
		if (s == a[i]) {
			ans += i * (n - i + 1) % mod;
			ans %= mod;
		} else if (s > a[i]) {
			ans += dp[s - a[i]] * (n - i + 1) % mod;
			ans %= mod;
		}
		for (long long j = s; j >= a[i]; j--) {
			dp[j] += (dp[j - a[i]] + (j == a[i] ? i : 0)) % mod;
			dp[j] %= mod;
		}
	} 
	printf("%lld", ans);
	return 0;
}

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

using namespace std;

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

struct node {
    int p, q, r, b;
};

vector<node> sticks;
int par[105];

int n;

int gcd(int a, int b)
{
    int tmp;
    while (b != 0) {
        tmp = b;
        b = a % b;
        a = tmp;
    }

    return a;
}

int lcm(int a, int b)
{
    return a / gcd(a, b) * b;
}

int dfs(int cur)
{
    node& s = sticks[cur];

    if (s.r == -1 && s.b == -1) {
        int g = gcd(s.p, s.q);
        return s.p / g + s.q / g;
    }

    if (s.r == -1) {
        int bch = dfs(s.b);
        int a = lcm(s.p, bch * s.q);
        return a / s.p + bch * (a / (bch * s.q));
    }

    if (s.b == -1) {
        int rch = dfs(s.r);
        int a = lcm(rch * s.p, s.q);
        return rch * (a / (rch * s.p)) + a / s.q;
    }

    int rch = dfs(s.r), bch = dfs(s.b);
    int a = lcm(rch * s.p, bch * s.q);

    return rch * (a / (rch * s.p)) + bch * (a / (bch * s.q));
}

signed main()
{
    while (cin >> n, n) {
        sticks.resize(n);
        memset(par, -1, sizeof(par));

        rep(i, n) {
            int p, q, r, b;
            cin >> p >> q >> r >> b;
            r--, b--;
            sticks[i] = node{p, q, r, b};

            if (r >= 0) par[r] = i;
            if (b >= 0) par[b] = i;
        }

        int root;

        {
            int cur = 0;
            do {
                root = cur;
                cur = par[cur];
            } while (cur != -1);
        }

        cout << dfs(root) << endl;
    }
}

Measured memory_bytes: 3040
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
string s,t;
bool comp(char& a,char& b){
  return a>b;
}
int main(){
  scan(s);scan(t);
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),comp);
  if(s<t)prin("Yes");
  else prin("No");
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,c,d,e;
  scanf("%d",&a);
  b=a/3600;
  c=a%3600;
  d=c/60;
  e=c%60;
  printf("%d:%d:%d\n",b,d,e);
  return 0;
}




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

int main(void)
{
  char str[1000];
  int i=0;

  gets(str);

  while(str[i] != '\0'){
    str[i] = toupper(str[i]);
    printf("%c", str[i]);
    i++;
  }
  putchar('\n');

  return 0;
}

Measured memory_bytes: 524
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner scan = new Scanner(System.in);
		
		while(true)
		{
			int n = scan.nextInt();
			if(n == 0) {break;}
			PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
			
			for(int i = 0; i < n; i++)
			{
				pq.add(scan.nextInt());
			}
			
			int ans = 9000000;
			int prev = -999;
			int now = 0;
			
			while(pq.size() > 0)
			{
				now = pq.poll();
				
				if(prev != -999)
				{
					ans = Math.min(ans, Math.abs(prev - now));
				}
				
				prev = now;
			}
			
			System.out.println(ans);
		}
		
	}

}



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

string s;
bool flag=false;

int main()
{
	cin>>s;
	int len=s.length();
	for(int i=0;i<len;i++)
	{
		if(!flag)
		{
			if(s[i]=='C')flag=true;
		}
		else
		{
			if(s[i]=='F')
			{
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}

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

using namespace std;

int main()
{
  string S = "";
  int K = 0;
  int ret = 0;
  int last_index = -1;

  cin >> S >> K;
  for( int i = 0; i < S.length(); ++i ){
    if( S[i] == '1' ){
        last_index = i;
    }
    else{
        ret = S[i] - '0';
        break;
    }
  }

  if( last_index != -1 && last_index + 1 >= K ) ret = 1;
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(1e6) + 17;

int n, m;

bool read() {
    if (!(cin >> n >> m))
        return false;

    return true;
}

void solve() {
    cout << n * m - (n + m - 1) << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N,D;
  cin >> N >> D;
  int ans = N / ( 2 * D + 1 );
  ans += N % ( 2 * D + 1 ) == 0 ? 0 : 1;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int[][] x = new int[n][d];
        int ans = 0;

        for (int i = 0; i < n; i++)
            for (int j = 0; j < d; j++)
                x[i][j] = sc.nextInt();
            
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                int distance = 0;
                for (int k = 0; k < d; k++) {
                    distance += Math.pow(x[j][k]-x[i][k], 2);
                }
                if (Math.sqrt(distance) - (int)Math.sqrt(distance) == 0)
                    ans ++;
            }
        }
        System.out.println(ans);
    }
}


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

int main(){
    int N;
    cin >> N;
    bool can = false;

    for (int i = 1; i < 10; ++i){
        for (int j = 1; j < 10; ++j){
            if (i * j == N) can = true;
        }
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

      cin>>n>>a;


      cnt=0;
     for(i=a; cnt<n; i++,cnt++)
     {
         sum+=i;
     }

     cnt=0;

     ll mi=1e18;

     for(i=a; cnt<n; i++,cnt++)
     {
         b=sum-i;

         if(mi>abs(sum-b))
         {
             mi=abs(sum-b);

             ans=b;
         }




     }

     cout<<ans<<endl;












}



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

const int inf = 1e9;
const ll linf = 1e18;

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

    int a, b; cin >> a >> b;
    string s; cin >> s;
    
    bool flag = true;
    for (int i = 0; i < a + b + 1; i++) {
        if (i == a && s[i] != '-') flag = false;
        if (i != a && (s[i] < '0' || s[i] > '9')) flag = false; 
    }
    cout << ((flag) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const long long mod=1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return a%b?gcd(b,a%b):b;}
ll lcm(ll c,ll d){return c*d/gcd(c,d);}
struct perm {
private:
	int sz;
	vector<long long> p, invp;
public:
	perm(int n) {
		sz = n + 1;
		p.resize(sz), invp.resize(sz);
		p[0] = 1;
		for(int i=1;i<=sz - 1;i++) {
			p[i] = p[i - 1] * i%mod;
		}
		invp[sz - 1] = 1;
		ll cop = mod - 2, x = p[sz - 1];
		while (cop) {
			if (cop % 2)invp[sz - 1] = invp[sz - 1] * x%mod;
			cop >>= 1; x = x * x % mod;
		}
		for(int i=sz-2;i>=0;i--) {
			invp[i] = invp[i + 1] * (i + 1) % mod;
		}
	}
	ll comb(ll x, ll y) {
		if (x < y || y < 0)return 0;
		ll ret = p[x];
		(ret *= invp[y]) %= mod;
		(ret *= invp[x - y]) %= mod;
		return ret;
	}
	ll combP(ll x, ll y) {
		if (x < y || y < 0)return 0;
		return p[x] * invp[x - y] % mod;
	}
};
perm p(1 << 18);
int main(){
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=k;i++){
    ll ans=0;
    for(int j=0;j<=n-k-i+1;j++){
      ans+=p.comb(k-1,i-1)%mod*p.comb(n-k-j,i-1)%mod;
    }
    cout<<ans%mod<<endl;
  }

}


Measured memory_bytes: 4352
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int k,x;
int main(){
    scanf("%d%d",&k,&x);
    k*=500;
    if(k>=x)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
import sys
from bisect import bisect_left

def solve():
    input = sys.stdin.readline
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    Ans = [0] * Q
    for i in range(Q):
        x = int(input())
        si, ti = bisect_left(S, x), bisect_left(T, x)
        shortest_path = 10 ** 20
        if si < A and ti < B: shortest_path = min(shortest_path, max(S[si], T[ti]) - x)
        if si > 0 and ti > 0: shortest_path = min(shortest_path, x - min(S[si-1], T[ti-1]))
        if si > 0 and ti < B: shortest_path = min(shortest_path, T[ti] - S[si-1] + min(T[ti] - x, x - S[si-1]))
        if ti > 0 and si < A: shortest_path = min(shortest_path, S[si] - T[ti - 1] + min(S[si] - x, x - T[ti-1]))
        Ans[i] = shortest_path
    print("\n".join(map(str, Ans)))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 23488
/**
 * Created by hiramekun at 20:53 on 2020-05-02.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll x;
    cin >> x;
    ll now = 100;
    ll ans = 0;
    while (now < x) {
        now += ll(double(now) * 0.01);
        ans++;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 3676
#include <stdio.h>

int main(void)
{
	char s[200000];
	scanf("%s", s);

	int i, a, z, count =0;
	for(i = 0; s[i] != '\0'; i++) {
		if(s[i] == 'A' && count == 0) {
			a = i;
			count++;
		}
		else if(s[i] == 'Z') {
			z = i;
		}
	}

	printf("%d", z - a + 1);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main()
{
	int i,n,m,t,p,k;
	char a[100];
	char b[100];
	scanf("%s",&a);
	n=0; m=0;
	for(i=0;i<strlen(a);i++)
	{
			if(a[i]=='C')
	        n++;
	        if(a[i]=='F')
	        m++;
			}
	t=0;p=0;		
	for(i=0;i<strlen(a);i++)
	{
		if(a[i]=='C')
		{
		t=i;
		for(k=i+1;k<strlen(a);k++)
		if(a[k]=='F')
		p=k;	
		}
		if(t<p)
		break;
	}
	if(t<p)
	printf("Yes\n");
	else
	printf("No\n");}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll n;cin >> n;
    vl v(n+2);rep(i,n)cin >> v[i+1];
    v[0]=0;v[n+1]=0;
    ll sum=0;
    rep(i,n+1){
        sum+=abs(v[i+1]-v[i]);
    }
    rep(i,n){
        ll t=abs(v[i+1]-v[i])+abs(v[i+2]-v[i+1]);
        cout << sum-t+abs(v[i+2]-v[i]) <<endl;
    }
} 

Measured memory_bytes: 2048
N = int(input())
A = list(map(int,input().split()))
 
ans = set()
 
for i in range(N-1,-1,-1):
    a = A[i]
    for j in range(i+1,N+1,i+1):
        if j in ans:
            a += 1
    if a%2:
        ans.add(i+1)
 
print(len(ans))
print(*ans)

Measured memory_bytes: 15760
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		System.out.print(min(n*a, b));
	}
	
	public static int min(int a, int b) {
		if(a<b)
			return a;
		else
			return b;
	}

}

Measured memory_bytes: 21972
#include"bits/stdc++.h"
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    if(A >= 13){
        cout << B << endl;
    }else if(A >= 6){
        cout << B/2 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define N 1000001
#define mod 1e9+7
using namespace std;
typedef long long ll;
ll n;
ll s[4];
double dp[301][301][301];
double pro(ll a,ll b,ll c){
    if(a+b+c==0)return 0.0;
    if(dp[a][b][c]>-0.5)return dp[a][b][c];
    double ks=(double)n/(a+b+c);
    double res=0;
    if(a){
        res+=(pro(a-1,b,c)+ks)*a/(a+b+c);
    }
    if(b){
        res+=(pro(a+1,b-1,c)+ks)*b/(a+b+c);
    }
    if(c){
        res+=(pro(a,b+1,c-1)+ks)*c/(a+b+c);
    }
    return dp[a][b][c]=res;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(ll i=0;i<n;i++){
	    ll t;
	    cin>>t;
	    s[t]++;
	}
	for(ll i=0;i<=n;i++){
	    for(ll j=0;j<=n;j++){
	        for(ll k=0;k<=n;k++){
	            dp[i][j][k]=-1;
	        }
	    }
	}
	double res;
	res=pro(s[1],s[2],s[3]);
	printf("%.12f",res);
	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i<b+1; i++){
        string j = to_string(i);
        if (j[0] == j[4] && j[1] == j[3]){
            ans ++;
        }
    }
    cout << ans << endl;
}


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


typedef struct{
    char name[11];
    int time;
}queue_s;

class queue{
private:
    int head,tail;
    queue_s _q[100000];
public:
    queue(){
        head = tail = 0;
    }
    void enqueue(queue_s q){
        _q[tail++] = q;
        tail = tail%100000;
    }
    queue_s dequeue(){
        head = (head+1)%100000;
        return _q[head-1 < 0 ? 100000-1 : head-1];
    }

    bool isEmpty(){
        return head == tail;
    }
};

int main(){
    int n, qtime;
    unsigned long long time = 0;
    queue q;
    cin >> n >> qtime;

    for(int i=0; i<n; ++i){
        queue_s data;
        cin >> data.name >> data.time;
        q.enqueue(data);
    }

    while(!q.isEmpty()){
        queue_s data;
        data = q.dequeue();
        if(data.time - qtime > 0){
            data.time -= qtime;
            q.enqueue(data);
        time += qtime;
        }else{
            time += data.time;
            cout << data.name << " " << time << endl;
        }
    }
}


Measured memory_bytes: 4548
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL)
    x = x->left;

  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;

  return x;
}

Node treeSearch(Node x, int k){
  if(x == NIL && k == x->key)
    return x;
  if(k < x->key)
    return treeSearch(x->left,k);
  else
    return treeSearch(x->right,k);

}

Node treeSuccessor(Node x){
  Node y;

  if(x->right != NIL)
    return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }

  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if(y->left != NIL)
    x = y->right;
  else
    x = y->right;

  if(x != NIL)
    x->parent = y->parent;

  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else
    y->parent->right = x;

  if(y != z)
    z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y = x;
    if(z->key < x->key)
      x=x->left;
    else
      x=x->right;
  }

  z->parent = y;

  if(y==NIL)
    root=z;
  else
    if(z->key < y->key)
      y->left=z;
    else
      y->right=z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } 
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}


Measured memory_bytes: 25220
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int a, b;
    cin >> a >> b;
    printAns((a + b - 1) / 2 + 1);
}


Measured memory_bytes: 384
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ") //ブランクで区切られている場合

let x = split[0]
//String -> Intの型変換はnilが返る可能性があるので、ラップされたOptional<Int>型が返るので強制アンラップ
let y = split[1]

let z = split[2]

print("A" + y.prefix(1) + "C")   // B




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

int main(){
  int n,h;
  cin>>n>>h;
  vector<int> a(n),b(n);
  int ma=0;
  rep(i,n){
    cin>>a[i]>>b[i];
    ma=max(ma,a[i]);
  }

  sort(b.begin(),b.end(),greater<int>());
  int res=n;
  rep(i,n){
    if(b[i]<ma){
      res=i;
      break;
    }
    h-=b[i];
    if(h<=0){
      cout<<i+1;
      return 0;
    }
  }
  
  int ans = min(res,n);
  ans += (h-1)/ma;
  cout << ans+1 << endl;
}

Measured memory_bytes: 1024
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<u32>();
    let (x, y, z) = (line[0], line[1], line[2]);
    println!("{} {} {}", z, x, y);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

const int MAX_N = 300 + 2;
double dp[MAX_N][MAX_N][MAX_N];
int N;

double dfs(int i, int j, int k) {

  if (dp[i][j][k] >= 0) return dp[i][j][k];

  if (i == 0 && j == 0 && k == 0) return 0.0;

  double res = 0.0;
  if (i > 0) res += dfs(i - 1, j,     k    ) * i;
  if (j > 0) res += dfs(i + 1, j - 1, k    ) * j;
  if (k > 0) res += dfs(i,     j + 1, k - 1) * k;
  res += N;
  res *= 1.0 / (double)(i + j + k);
  dp[i][j][k] = res;
  
  return dp[i][j][k];

}


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

  cin >> N;

  int a, n1, n2, n3;
  n1 = n2 = n3 = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> a;
    if (a == 1) n1++;
    else if (a == 2) n2++;
    else if (a == 3) n3++;
  }

  memset(dp, -1.0, sizeof(dp));
  dp[0][0][0] = 0.0;

  double ans = dfs(n1, n2, n3);
  printf("%0.12lf\n", ans);
  
  return 0;
}



Measured memory_bytes: 218428
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
using pa = pair<int, int>;
typedef long long ll;
const int MOD = 1e9 + 7;
ll p[N][2];

ll cal(int n) {
    ll ans = 0;
    for (int s = 0; s < 4; s++) {
        ll mx = -1e18, mn = 1e18;
        for (int i = 0; i < n; i++) {
            ll tmp = 0;
            for (int j = 0; j < 2; j++)
                tmp += (s & (1 << j)) ? p[i][j] : -p[i][j];
            mx = max(mx, tmp), mn = min(mn, tmp);
        }
        ans = max(ans, mx - mn);
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> p[i][0] >> p[i][1];
    cout << cal(n) << endl;
}


Measured memory_bytes: 6748
//g++ main.cpp -I /usr/local/include/ac-library
#include<cmath>
//#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
//using namespace atcoder;
stack<int> st;
queue<int> qu;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define pb push_back
#define sz(x) (int)(x).size()
#define mod 1000000007
//#define mint=modint1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    string s;
    cin >> s;
    int n=sz(s);
    if((n%2==0&&s[0]==s[n-1])||(n%2==1&&s[0]!=s[n-1])){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3756
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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

int a[200][3];
int b[200][3];

int main(){

	int n;
	cin >> n;
	rep(i,n){
		rep(j,3){
			cin >> a[i][j]; b[i][j]=a[i][j];
		}
	}

	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			for(int k=0;k<3;k++){
			   if(a[i][k]==a[j][k]){
				  b[i][k]=0; b[j][k]=0;
			}
		  }
		}
	 }

	rep(i,n) cout << b[i][0]+b[i][1]+b[i][2] << endl;

	return 0;
}

Measured memory_bytes: 1164
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();

    let mut candidates = vec![n];
    for k in 2.. {
        if k * k > n {
            break;
        }
        if n % k == 0 {
            candidates.push(k);
            candidates.push(n / k);
        }
        if (n - 1) % k == 0 {
            candidates.push(k);
            candidates.push((n - 1) / k);
        }
    }

    if n - 1 > 1 {
        candidates.push(n - 1);
    }
    candidates.sort();
    candidates.dedup();
    let mut ans = 0;
    for k in candidates.into_iter() {
        let mut cur = n;
        while cur >= k {
            if cur % k == 0 {
                cur /= k;
            } else {
                cur %= k;
            }
        }
        if cur == 1 {
            // println!("{}", k);
            ans += 1;
        }
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
while True:
  n,x=map(int,input().split())
  if(n==0 and x==0):
    break
  count=0
  for i in range(1,n+1):
    for j in range(i+1,n+1):
      for k in range(j+1,n+1):
        if(i+j+k==x):
          count += 1
  print(count)
  


Measured memory_bytes: 5596
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
// #define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N 			1e5+5
#define PRIME           998244353
#define MAX         1000000
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j,k;


void Anon_mouS(){
    string s;
    cin>>s;
    if(s=="ARC")cout<<"ABC"<<endl;
    else if(s=="ABC")cout<<"ARC"<<endl;
}

int32_t main(){
    fastio;
    int q=1;
    // cin>>q;
    while(q--){
        Anon_mouS();
    }
    return 0;
}


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

struct Edge {
	int d, x, y;
};

bool operator <(const Edge &a, const Edge &b) {
	return a.d < b.d;
}

bool operator >(const Edge &a, const Edge &b) {
	return a.d > b.d;
}

const int INF = 1e8;

int main() {
	int h, w;
	cin >> h >> w;
	
	int ch, cw, dh, dw;
	cin >> ch >> cw >> dh >> dw;
	ch--, cw--, dh--, dw--;
	
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	
	priority_queue<Edge, vector<Edge>, greater<Edge>> q;
	q.push(Edge{0, cw, ch});
	
	vector<vector<int>> d(h, vector<int>(w, INF)); 
	d[ch][cw] = 0;
	
	while (!q.empty()) {
		Edge e = q.top();
		q.pop();
		
		if (d[e.y][e.x] < e.d) continue;
		
		vector<int> dx = {1, 0, -1, 0};
		vector<int> dy = {0, 1, 0, -1};
		
		rep(i, 4) {
			int nx = e.x + dx[i];
			int ny = e.y + dy[i];
			if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
			if (s[ny][nx] == '#') continue;
			if (d[ny][nx] > e.d) {
				d[ny][nx] = e.d;
				q.push(Edge{d[ny][nx], nx, ny});
			}
		}
		
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				int nx = e.x + j;
				int ny = e.y + i;
				if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
				if (s[ny][nx] == '#') continue;
				if (d[ny][nx] > e.d + 1) {
					d[ny][nx] = e.d + 1;
					q.push(Edge{d[ny][nx], nx, ny});
				}
			}
		}
	}
	
	if (d[dh][dw] < INF) cout << d[dh][dw] << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 9496
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#define mod 1000000009
typedef long long ll;
using namespace std;
int main(){
  int N; cin >> N;
  string s; cin >> s;
  if(N%2!=0){
    cout << "No" << endl;
    return 0;
  }
  string t1[100],t2[100];
  for(int i=0;i<=N/2-1;i++){
    t1[i] = s[i];
  }
  for(int i=N/2;i<N;i++){
    t2[i-N/2] = s[i];
  }
  for(int i=0;i<=N/2-1;i++){
    if(t1[i]!=t2[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

int main()
{
    string s, t, s1 ;
    cin>>s>>t;
   long long n=t.size();

    s1=t.substr(0,n-1);


    if(s==s1)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
    return 0;
}


Measured memory_bytes: 3592
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

map< vector<int>, int > rec;

int N, c[10][10];
signed main() {
    cin >> N;
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            cin >> c[i][j];
        }
    }

    using State = pair< int, vector<int> >;
    priority_queue< State, vector<State>, greater<> > que;
    vector<int> init(N);
    iota(init.begin(), init.end(), 0LL);
    rec[init] = 0;
    que.push(make_pair(0, init));

    int ans = 0;
    while(que.size()) {
        int cost; vector<int> vec; tie(cost, vec) = que.top(); que.pop();

        if(rec[vec] < cost) continue;
        for(int i=0; i<N; i++) {
            for(int j=i+1; j<N; j++) {
                swap(vec[i], vec[j]);

                if(!rec.count(vec) or rec[vec] > cost + c[i][j]) {
                    rec[vec] = cost + c[i][j];
                    que.emplace(cost + c[i][j], vec);
                }
                
                swap(vec[i], vec[j]);
            }
        }
    }
    for(auto e : rec) ans = max(ans, e.second);
    cout << ans << endl;
    return 0;
}



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

int n;
string s;

int main(){
  cin >> n >> s;
  int cnt_left = 0, num_right = 0;
  rep(i, n){
    char c = s.at(i);
    if(c == '('){
      num_right++;
    }else if(num_right){
      num_right--;
    }else{
      cnt_left++;
    }
  }
  //cerr << cnt_left << endl;
  
  int cnt_right = 0, num_left = 0;
  for(int i = n - 1; i >= 0; i--){
    char c = s.at(i);
    if(c == ')'){
      num_left++;
    }else if(num_left){
      num_left--;
    }else{
      cnt_right++;
    }
  }
  //cerr << cnt_right << endl;
  
  rep(i, num_left) cout << '(';
  cout << s;
  rep(i, num_right) cout << ')';
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int x,a;cin>>x>>a;
  if(x<a)cout << 0 << endl;
  else cout << 10 << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	n, _ := strconv.Atoi(readLine())
	var v []int
	for i := 0; i < 5; i++ {
		in, _ := strconv.Atoi(readLine())
		v = append(v, in)
	}
	sort.Ints(v)
	if n%v[0] == 0 {
		fmt.Println(n/v[0] + 4)
	} else {
		fmt.Println((n/v[0] + 1) + 4)
	}
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int ss=s.size(),tt=t.size();
  for(int i=ss-tt;i>=0;i--){
    bool f=true;
    for(int j=0;j<tt;j++){
      if(s[i+j]!='?'&&s[i+j]!=t[j]){
        f=false;
      }
    }
    if(f){
      for(int j=0;j<i;j++){
        if(s[j]=='?')
          cout<<'a';
        else
          cout<<s[j];
      }
      cout<<t;
      for(int j=i+tt;j<ss;j++){
        if(s[j]=='?')
          cout<<'a';
        else
          cout<<s[j];
      }
      cout<<endl;
      return 0;
    }
  }
  cout<<"UNRESTORABLE"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    int a=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            a++;
        }
    }
    cout<<a<<'\n';
    return 0;

}

//      *   *  *****  *   *  *   *   ****  ****    ****     **  ***
//     *   *  *      **  *  *   *  *      *   *  *        * *  *  *
//    *****  *****  * * *  *   *  *      ****   *       *  *    *
//   *   *      *  *  **  *   *  *      *  *   *       *****  *
//  *   *  *****  *   *   ***    ****  *   *    ****     *   ****

//     ****  *   *  *   *   ***   *   *  *****  *   *
//    *     *   *  *   *  *   *  *   *  *      *   *
//    ***  *****  *   *  *****  * * *  ****   *   *
//      *   *    *   *  *   *  * * *  *      *   *
//  ****   *     ***   *   *   * *   *****   ***



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

int main(){
    string S;
    cin >> S;

    int ans = 0;
    int count = 0;
    for(char c : S){
        if ( c == 'A' || c == 'C' || c == 'G' || c == 'T'){
            count += 1;
        }else{
            if(ans < count){
                ans = count;
            }
            count = 0;
        }
    }

    if(ans < count){ans = count;}

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
n = input()
x = sorted([map(int,raw_input().split()) for i in range(n)], key=lambda _:-_[1])
y = sorted([map(int,raw_input().split()) for i in range(n)])
used = [False] * n
for i in range(n):
    c, d = y[i]
    for j in range(n):
        a, b = x[j]
        if not used[j] and (a < c) and (b < d):
            used[j] = True
            break
print sum(used)

Measured memory_bytes: 2692
a, b = map(int, input().split())
if a < 0 and b < 0:
    if (max(a, b) - min(a, b) + 1) % 2:
        print('Negative')
    else:
        print('Positive')
else:
    if a * b <= 0:
        print("Zero")
    else:
        print('Positive')


Measured memory_bytes: 3316
import Control.Monad
import Data.List
import Text.Printf
c n r = product [n-r+1..n] `div` product [1..r]
main = do
  [n,a,b] <- map read . words <$> getLine
  vs <- map read . words <$> getLine
  let (xs,ys) = splitAt (fromInteger a) $ reverse $ sort vs
  let p = genericLength $ filter (== last xs) xs
  let q = genericLength $ filter (== last xs) ys
  printf "%f\n" (fromInteger (sum xs) / fromInteger a :: Double)
  print $ if p == a 
    then sum $ map ((p+q) `c`) [p..(p+q)`min`b]
    else (p+q) `c` p

Measured memory_bytes: 1020
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s, t;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s >> t;
  rep(i, Size(s)) {
    cout << s[i];
    if (i <= Size(t) - 1) cout << t[i];
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

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

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");

        int n = Integer.valueOf(arr01[0]);

        int mindata = Integer.MAX_VALUE;

        for (int p = 0; p <= 100; p++) {

            int mysum = 0;

            for (int j = 0; j < n; j++) {

                int temp = Integer.valueOf(arr02[j]);

                mysum += Math.pow((temp - p), 2);

                //                System.out.println(p + " " + temp + " " + mysum);

            }

            mindata = Math.min(mindata, mysum);

        }
        System.out.println(mindata);

    }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  int A[n][m] = {0};
  int B[m] = {0};
  for (int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      int r;
      cin >> r;
      A[i][j] = r;
    }
  }

  for(int j = 0; j < m; j++) {
    int r;
    cin >> r;
    B[j] = r;
  }

  for (int i = 0; i < n; i++) {
    int r = 0;
    for(int j = 0; j < m; j++) {
      r += A[i][j] * B[j];
    }
    cout << r << endl;
  }

}

Measured memory_bytes: 3116
/*input
3 1 1 1
*/
#include <bits/stdc++.h>
using namespace std;
#define TEMPLATE

#ifdef TEMPLATE
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }
#endif

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll W, H, x, y;
	cin >> W >> H >> x >> y;

	cout << (ld)(W * H) / 2.0L << " " << (x * 2 == W and y * 2 == H ? 1 : 0) << '\n';
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
x = list()
y = list()
for i in range(h):
    if "#" in a[i]:
        x.append(i)
for j in range(w):
    cnt = 0
    for k in range(h):
        if a[k][j] == "#":
            y.append(j)
            break
for p in x:
    z = ""
    for q in y:
        z += a[p][q]
    print(z)

Measured memory_bytes: 9184