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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    int X;
    cin >> X;
    ll now = X;
    ll cnt = 1;
    while(now % 360 != 0){
        now %= 360;
        now += X;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3580
//code by lynmisakura.wish to be accepted!
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
    int n;cin >> n;
    vector<ll> c(n);
    ll ans = 0;
    for(int i = 0;i < n;i++){
        ll a,b;cin >> a >> b;
        ans -= b;
        c[i] = a+b;
    }
    sort(c.begin(),c.end());
    reverse(c.begin(),c.end());
    for(int i = 0;i < n;i+=2){
        ans += c[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
<?php


$input_array = explode(" ", fgets(STDIN));

$ans = array();

$a = $input_array[0];
$b = $input_array[1];
$c = $input_array[2];
$d = $input_array[3];

$x_array = array($a, $b);
if ($a < 0 and $b > 0) {
    $x_array[] = 0;
}

$y_array = array($c, $d);
if ($c < 0 and $d > 0) {
    $y_array[] = 0;
}

foreach ($x_array as $x) {
    foreach ($y_array as $y) {
        $ans_array[] = $x*$y;
    }
}

rsort($ans_array);

print_r($ans_array[0]);

?>


Measured memory_bytes: 16120
#include<stdio.h>
int main()
{
	int i,x;
	char a[10],s[10];
	scanf("%s",&a);
	scanf("%s",&s);
	x = 0;
	for(i = 0;a[i] !='\0';i++)
	{
		if(a[i] == s[i])
		{
			x++;
		}
			else
		{
			
		}
	}
	printf("%d\n",x);

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
//
// using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = int(s.size());
  vector<int> count(n+1);

  for (int i = 0; i < n; i++) {
    if(s[i] == '<'){
      count[i+1] = count[i] + 1;
    }
  }
  for (int i = n-1; i >= 0; i--) {
    if(s[i] == '>'){
      count[i] = max(count[i], count[i+1] + 1);
    }
  }

  ll res = 0;
  for(auto a : count){
    res += a;
  }
  cout << res << endl;
}


Measured memory_bytes: 2844
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	int z[n];
	for(int i = 0; i < n; i++) cin >> z[i];
	int total = 0;
	while(true){
		bool bl = true;
		for(int i = 0; i < n; i++) {bl &= z[i] % 2 == 0; z[i] /= 2;}
		if(!bl) break; 
		total++;
	}
	cout << total << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

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

    int best = 10000;

    for (char c = 'a'; c <= 'z'; ++c) {
        string t = s;
        int steps = 0;
        while (t.find_first_not_of(c) != string::npos) {
            string u(t.size() - 1, '\0');
            for (size_t i = 0; i < t.size() - 1; ++i) {
                if (t[i] == c || t[i + 1] == c)
                    u[i] = c;
                else
                    u[i] = t[i];
            }
            t.swap(u);
            ++steps;
        }
        best = min(best, steps);
    }

    cout << best << '\n';

    return 0;
}


Measured memory_bytes: 256
A, B, K = map(int, input().split()) # 横に2個

from fractions import gcd

Gcd = gcd(A, B)

c = 0
for i in range(1, Gcd+1):
	if Gcd % i == 0:
		c += 1
	if c == K:
		print(Gcd//i)
		break

Measured memory_bytes: 5048
#include <stdio.h>
#include <stdlib.h>
int h,w;
char s[50][51];
int d[4][2]={{1,0},{0,-1},{-1,0},{0,1}};

int bfs(int a,int b){
    int q[2500][3];
    memset(q,-1,sizeof(q));
    q[0][0]=a;q[0][1]=b;q[0][2]=1;
    int visit[50][50]={0};
    visit[a][b]=1;
    int l=0,m=1;
    while(q[l][0]!=-1){
        int i;
        for(i=0;i<4;i++){
            int y=q[l][0]+d[i][0];
            int x=q[l][1]+d[i][1];
            if(0<=y&&y<h&&0<=x&&x<w&&!visit[y][x]&&s[y][x]=='.'){
                //printf("%d %d\n",y,x);
                if(y==h-1&&x==w-1)return q[l][2]+1;
                visit[y][x]=1;
                q[m][0]=y;
                q[m][1]=x;
                q[m++][2]=q[l][2]+1;
            }
        }
        l++;
    }
    return -1;
}

int main(){
    scanf("%d %d",&h,&w);
    int i,j;
    int cnt=0;
    for(i=0;i<h;i++){
        scanf("%s",&s[i]);
        for(j=0;j<w;j++){
            if(s[i][j]=='.')cnt++;
        }
    }
    int dis = bfs(0,0);
    if(dis==-1){
        puts("-1");
    }else{
        printf("%d\n",cnt-dis);
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define H 500000
int key[H];

void  maxHeapify(int i,int h){
  int largest;
  int temp;
  int left =2*i;
  int right = 2*i + 1;
  if(left <= h && key[left] > key[i])largest = left;
  else largest=i;
  if(right <= h && key[right] > key[largest])largest = right;
  if(largest != i){
    temp = key[i];
    key[i] = key[largest];
    key[largest] = temp;
    maxHeapify(largest,h);
  }
}

int main() {
  int h,i;
  scanf("%d",&h);
  for(i=1;i<=h;i++)scanf("%d",&key[i]);
  for(i=h/2;i>=1;i--)maxHeapify(i,h);
  for(i=1;i<=h;i++)printf(" %d",key[i]);
  printf("\n");
  return 0;
}



Measured memory_bytes: 3672
#include<bits/stdc++.h>
    using namespace std;
    signed main(){
int n,b[55],sum=0;
      cin>>n;
     for(int i=0;i<n;i++){
       	cin>>b[i];
     }
      for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
          sum+=b[i]*b[j];
        }
      }
      cout<<sum<<'\n';
      return 0;
    }

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<utility>
#include<queue>
#define mod 1000000007
#define INF 1000000000000000
using namespace std;

int main(){
    int n,p,q,r;
    scanf("%d %d %d",&p,&q,&r);
    n=p;
    p+=q+r;
    n=max(n,q);
    n=max(n,r);
    printf("%d\n",p-n);
}

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

int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  int ans=0;
  bool flag=true;
  while(flag){
    flag=false;
    for(int i=0;i<n;++i){
      if(a[i]%2==0){
        a[i]=a[i]/2;
        flag=true;
        ++ans;
      }
    }
  }
  cout<<ans;
  return 0;
}

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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
/*
ll solve(ll x){
    ll tmp = x%10;
    ll ans = 1;
    while(x>0){
        if(tmp-(x%10)<2 && (x%10)-tmp<2){
            tmp = x%10;
            x = x/10;
        }
        else{
            ans = 0;
            break;
        }
    }
    return ans;
}

int main(){
    ll K;
    cin>>K;
    ll tmp = 1;
    while(K>0){
        if(solve(tmp)==1){
            K-=1;
        }
        tmp++;
    }
    tmp-=1;
    cout<<tmp<<endl;
}
*/
int main(){
    ll K;
    cin>>K;
    queue<ll> que;
    for(ll i=1;i<10;i++){
        que.push(i);
    }
    while(K>0){
        ll p = que.front();
        que.pop();
        ll pp = p%10;
        if(pp==0){
            que.push(p*10);
            que.push(p*10+1);
        }
        else if(pp==9){
            que.push(p*10+8);
            que.push(p*10+9);
        }
        else{
            que.push(p*10+pp-1);
            que.push(p*10+pp);
            que.push(p*10+pp+1);
        }
        K-=1;
        if(K==0){
            cout<<p<<endl;
        }
    }
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
int main()
{   char s[100001];
    scanf("%s",s);
    int n=strlen(s),ans=0,l=0,r=n-1;
    while(l<r){
        if(s[l]==s[r]){
            l++;
            r--;
            continue;
            }
        if(s[r]=='x'){
            r--;
            ans++;
            continue;
        }
        if(s[l]=='x'){
            l++;
            ans++;
            continue;
        }
        if(s[l]!=s[r]){
            printf("-1");
            return 0;
        }
    }
    printf("%d",ans);
    return 0;
}


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

const int mN = 200200;
const int shift = 0;
unordered_map<int,long long> cnt;

int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
    cin >> n;
    long long ans = 0;
	for (int i=1,a; i<=n; i++) {
    	cin >> a;
    	ans += cnt[shift+i-a];
    	//cerr << "req." << i-a << "\n";
		cnt[shift+i+a]++;
    	//cerr << "provide " << i+a << "\n";
	}
    cout << ans;
	return 0;
}


Measured memory_bytes: 18540
#include <iostream>
#include <iomanip>

#define PI 3.14159265359

int main(void)
{
	double r;
	std::cin >> r;
	std::cout
		<< std::fixed
		<< std::setprecision(6)
		<< r * r * PI << " "
		<< r * 2 * PI << std::endl;
	return 0;
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
vector<vll> S;
vector<bool> vis;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y, lli p){
    lli res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
lli solve(){
	lli x, y;
	cin>>x>>y;
	if(x == 1 && y == 1){
		cout<<1000000<<"\n";
		return 0;
	}
	if(x == 1)	x = 300000;
	else if(x == 2)	x = 200000;
	else if(x == 3)	x = 100000;
	else	x = 0;
	if(y == 1)	y = 300000;
	else if(y == 2)	y = 200000;
	else if(y == 3)	y = 100000;
	else	y = 0;
	cout<<x+y<<"\n";
	return 0;
	
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,c[507],s[507],f[507],cur=0;
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n-1;i++){
		cin>>c[i]>>s[i]>>f[i];
	}
	for(int i=1;i<=n;i++){
		cur=0;
		for(int j=i;j<n;j++){
			if(cur<s[j]) cur=s[j];
			if(cur%f[j]!=0) cur=(cur/f[j]+1)*f[j];
			cur+=c[j];
		}
		cout<<cur<<"\n";
	}
}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
xy = [0]*4

xy[0] = x2 + (y1-y2)
xy[1] = y2 + (x2-x1)
xy[2] = x1 + (y1-y2)
xy[3] = y1 + (x2-x1)

print(*xy)

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  for(int i = 0; i < N; ++i) cin >> B[i];
  vector<int> cnt(N);
  for(auto e : B)
    ++cnt[e-1];
  if(*min_element(cnt.begin(), cnt.end()) > 0){
    puts("Yes");
    return 0;
  }
  vector<int> C(N,2), D(N);
  for(int i = 0; i < N; ++i){
    D[i] = (cnt[A[i]-1] > 0) + 1;
  }
  puts("No");
  for(int i = 0; i < N; ++i)
    cout << C[i] << (i+1 < N ? " " : "\n");
  for(int i = 0; i < N; ++i)
    cout << D[i] << (i+1 < N ? " " : "\n");
}



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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

void No() {
  cout << "NO\n";
  exit(0);
}

int main() {
  string t = "AKIHABARA";
  vector<int> posA; rep(i, t.size()) if (t[i] == 'A') posA.push_back(i);

  string s; cin >> s;
  if (s.size() > t.size()) No();

  int needA = posA.size() - accumulate(s.begin(), s.end(), 0, [](int a, char x) {
    return x == 'A' ? a + 1 : a;
  });
  if (s.size() + needA != t.size()) No();

  int posAIdx = 0;
  int spos = 0;
  rep(i, t.size()) {
    if (t[i] != s[spos] && posA[posAIdx] == i) {
      // s[spos] == null もある
      needA--;
    } else if (t[i] != s[spos]) {
      No();
    } else {
      spos++;
    }
    if (t[i] == 'A') posAIdx++;
  }
  cout << "YES\n";
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(len(a)):
  if a[i]%2==0:
    b+=1
    if a[i]%3==0 or a[i]%5==0:
      c+=1
if b==c:
  print("APPROVED")
else:
  print("DENIED")
    

Measured memory_bytes: 9156
#include<iostream>
using namespace std;
template<class T>inline T sqr(T a){return a*a;}
template<class T>T pow(T a,T n)
{
	if(!n)return 1;
	if(n&1)return sqr(pow(a,n/2))*a;
	return sqr(pow(a,n/2));
}
int n,a[100];
unsigned long long go(int x,int y)
{
	if(x==n)
	{
		if(y)return (a[n]&1)+1;
		return 3;
	}
	if(y)return go(x+1,1)*(2-(a[x]&1))+go(x+1,0)*(1+(a[x]&1));
	return go(x+1,0)*3;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	cout<<go(1,1)<<endl;
	return 0;
}


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

//kieutrave ten ham(tham so)
int main(){
	int a;
	cin>>a;
	if (a%10==2 or a%10==4 or a%10==5 or a%10==7 or a%10==9){
		cout<<"hon";
	}
	if (a%10==0 or a%10==1 or a%10==6 or a%10==8){
		cout<<"pon";
	} 
	if (a%10==3){
		cout<<"bon";
	}
	return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;
public class Main {
	static void output(int[] num,int N){
		for(int j=0;j<N;j++){
			if(j==0) System.out.print(num[j]);
			else System.out.print(" "+num[j]);
		}
		System.out.println();
	}
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int key,k;
		int[] num=new int[N];
		for(int i=0;i<N;i++) num[i]=scan.nextInt();
		
		for(int i=1;i<N;i++){
			output(num,N);
			key=num[i];
			k=i-1;
			while(k>=0&&num[k]>key){
				num[k+1]=num[k];
				k--;
			}
			num[k+1]=key;
		}
		output(num,N);
		scan.close();
	}
}

Measured memory_bytes: 24272
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <iomanip>

const int MOD = 1000000007;


ll POWER(ll x,ll y)
{
	ll ret=1;
	ll p=x;
	for (ll i=y;i>0;i/=2)
	{
		if (i%2) ret=(ret*p)%MOD;
		p=(p*p)%MOD;
	}
	return ret;
}
ll gcm(ll a, ll b)
{
	if (b>a) {ll c=a; a=b; b=c;}
	while (b>0)
	{
		ll r=a%b;
		a=b;
		b=r;
	}
	return a;
}


int main(int argc, char *argv[])
{
	ll x;
	cin>>x;
	ll m=100;
	int ret=0;
	do
	{
		m=m+(m/100);
		ret++;
	} while (m<x);
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int N=2e5+10;
int q[N],a[N],f[N],g[N],p[N],sum[N];
int main()
{
	int n,k,i,tail,ans,head;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	tail=0;
	head=1;
	for(i=1;i<=k;i++)
	{
		while(head<=tail&&a[q[tail]]<a[i])
			tail--;
		q[++tail]=i;
	}
	for(i=k+1;i<=n;i++)
	{
		while(head<=tail&&q[head]<=i-k)
			head++;
		while(head<=tail&&a[q[tail]]<a[i])
			tail--;
		if(head>tail)
			f[i]=1;
		q[++tail]=i;
	//	for(int j=head;j<=tail;j++)
	//		printf("%d ",q[j]);
	//	printf("\n");
	}
	head=1;
	tail=0;
	for(i=n;i>n-k;i--)
	{
		while(head<=tail&&a[q[tail]]>a[i])
			tail--;
		q[++tail]=i;
	}
	for(i=n-k;i>0;i--)
	{
		while(head<=tail&&q[head]>=i+k)
			head++;
		while(head<=tail&&a[q[tail]]>a[i])
			tail--;
		if(head>tail)
			g[i]=1;
		q[++tail]=i;
	}
	head=1;
	tail=0;
    for(i=1;i<k;i++)
	{
		while(head<=tail&&a[q[tail]]>a[i])
			tail--;
		q[++tail]=i;
	}
	for(i=k;i<=n;i++)
	{
		while(head<=tail&&q[head]<=i-k)
			head++;
		while(head<=tail&&a[q[tail]]>a[i])
			tail--;
		q[++tail]=i;
		if(tail-head+1==k)
			p[i]=1;
		sum[i]=sum[i-1]+p[i];
		//for(int j=head;j<=tail;j++)
		//	printf("%d ",q[j]);
		//printf("\n");
	}
	ans=1;
	for(i=k+1;i<=n;i++)
	{
		ans++;
		if(f[i]&&g[i-k])
			ans--;
		else
			if(p[i]&&sum[i-k])
				ans--;
	}
	/*for(i=1;i<=n;i++)
		printf("%d ",f[i]);
	printf("\n");
	for(i=1;i<=n;i++)
		printf("%d ",g[i]);
	printf("\n");
	for(i=1;i<=n;i++)
		printf("%d ",p[i]);
	printf("\n");
	for(i=1;i<=n;i++)
		printf("%d ",sum[i]);
	printf("\n");*/
	printf("%d",ans);
	return 0;
}

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

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

int main() {
 while(true) {
  int n;
  scanf("%d", &n);
  if (!n) break;
  int m=0x7fffffff;
  int M=-0x7fffffff;
  int sum=0;
  rep(i, n) {
   int t;
   scanf("%d",&t);
   sum+=t;
   if(m>t)m=t;
   if(M<t)M=t;
  }
  sum-=m;
  sum-=M;
  printf("%d\n",sum/(n-2));
 }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
//typedef long long int ll;
typedef pair <int,int> P;

int h,w,n;
int sr,sc;
int a,b,p,q;
int l,r,u,d,ll,rr,uu,dd;
string S,T;

int main(){
  cin >> h >> w >> n;
  cin >> sr >> sc;
  cin >> S >> T;
  a = p = sr;
  b = q = sc;
  ll = sc-1;
  rr = w-sc;
  uu = sr-1;
  dd = h-sr;
  bool X = true;
  rep(i,0,n){
    
    if(S[i] == 'L'){
      rr++;
      b--;
      if(b<=0){
        if(r==0){
          X = false;
          break;
        }else{
          r--;
          b++;
        }
      }
    }else if(S[i]=='R'){
      ll++;
      q++;
      if(q>w){
        if(l==0){
          X = false;
          break;
        }else{
          l--;
          q--;
        }
      }
    }else if(S[i]=='U'){
      dd++;
      a--;
      if(a<=0){
        if(d==0){
          X = false;
          break;
        }else{
          d--;
          a++;
        }
      }
    }else if(S[i]=='D'){
      uu++;
      p++;
      if(p>h){
        if(u==0){
          X = false;
          break;
        }else{
          u--;
          p--;
        }
      }
    }

    if(T[i]=='L'){if(ll>l)l++;}
    else if(T[i]=='R'){if(rr>r)r++;}
    else if(T[i]=='U'){if(uu>u)u++;}
    else {if(dd>d)d++;};
  }
  cout << (X?"YES":"NO") << endl;
    
  return 0;
}


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

int main()
{
	string X,Y,A = "ABCDEF";

	cin >> X >> Y;

	for (int i = 0; i < 6; i++) {
		if (X[0] == A[i]&&Y[0] == A[i]) {
			cout << "=";
			break;
		}
		if (X[0] == A[i]) {
			cout << "<";
			break;
		}
		if (Y[0] == A[i]) {
			cout << ">";
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
    int a, b, c, x, i, j, k, cnt=0;
    scanf("%d%d%d%d", &a, &b, &c, &x);
    for (i=0; i <= a && 500*i<=x; i++)
    {
        for (j=0; j <= b && 100*j+500*i<=x; j++)
        {
            for (k=0; k <= c && 50*k+100*j+500*i<=x; k++)
            {
                if (500*i+100*j+50*k==x)
                {
                    cnt++;
                }
            }
        }
    }

    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch ManyRequirements | diff ManyRequirements.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address ManyRequirements.cpp && ./a.out

/*

 7/10/2020

 22:44-

 */

const int MAX_Q=50+1;
int A[MAX_Q][4];
int N,M,Q;

int res=0;
void dfs(int p, VI &cur) {
  //dump(p);
  if(p==N) {
    int ans=0;
    REP(i,Q) if(cur[A[i][1]-1]-cur[A[i][0]-1]==A[i][2]) ans+=A[i][3];
    SMAX(res,ans);
    return;
  }
  int lb=1;
  if(SZ(cur)) lb=cur.back();
  FORE(x,lb,M) {
    cur.push_back(x);
    dfs(p+1,cur);
    cur.pop_back();
  }
}

void solve() {
  VI cur;
  dfs(0,cur);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>M>>Q;
  REP(i,Q)REP(j,4) cin>>A[i][j];
  solve();

  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

ll n, m;

int main() {
    cin >> n >> m;
    
    vector<P> ab(n);
    rep(i, n) cin >> ab[i].first >> ab[i].second;

    sort(all(ab));

    ll cnt = 0, ret = 0;
    ll index = 0;
    while(cnt < m) {
        ll t = min(m - cnt, ab[index].second);
        ret += ab[index].first * t;
        cnt += t;
        index++;
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

/**
 * Created by nakatsukatakahiro on 2017/06/10.
 */
class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int N = Integer.parseInt(scanner.next());

        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            int tmp = Integer.parseInt(scanner.next());
            if (tmp > max) {
                max = tmp;
            }
            if (tmp < min) {
                min = tmp;
            }
        }
        System.out.println(max - min);
    }
}


Measured memory_bytes: 21844
n, m = list(map(int, input().split()))
hl = list(map(int, input().split()))
ansl = [1]*n
for i in range(m):
    a, b = list(map(int, input().split()))
    if hl[a-1] == hl[b-1]:
        ansl[a-1] = 0
        ansl[b-1] = 0
    elif hl[a-1] > hl[b-1]:
        ansl[b-1] = 0
    else:
        ansl[a-1] = 0
print(sum(ansl))


Measured memory_bytes: 84880
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int dp[1 << 13];

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);

    int N, M; cin >> N >> M;
    fill(dp, dp+(1<<13), INTINF);
    dp[0] = 0;
    int maxN = 1 << (N+1) -1;
    rep(_, M){
        int a, b; cin >> a >> b;
        int mask = 0;
        rep(j, b){
            int c; cin >> c;
            mask += 1 << (c-1);
        }
        for(int i=maxN; i>=0; i--){
            // max ~ 0
            // print(i | mask);
            if(dp[i] != INTINF && ((i | mask) < maxN)){
                // dp[(i|mask)] = dp[i] + a;
                dp[(i|mask)] = min(dp[(i|mask)], dp[i] + a);
            }
        }
        // break;
    }

    // rep(i, maxN){
    //     print(dp[i]);
    // }

    if(dp[maxN-1] != INTINF){
        print(dp[maxN-1]);
    }
    else{
        print(-1);
    }
    
    
    return 0;
}


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

int main() {
  int A, B;
  string op;
  cin >> A >> op >> B;
  
  if (op == "+") {
    cout << A + B << endl;
  }
  
  else {
    cout << A - B << endl;
  }
  
  cin >> A >> op >> B;
}


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

int main(){
    long long int n,i,j,a[100001],b[100001];
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i];
        b[a[i]]=i;
    }
    for(i=1;i<=n;i++){
        cout<<b[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
////////////////////////////////////////////////
int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    int ans = 0;

    while (n > 0)
    {
        n -= x;
        ans += t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3480
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a[] = new int[n];
		int b[] = new int[n];

		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		Arrays.sort(a);
		Arrays.sort(b);

		double medA, medB;
		if(n % 2 == 1){
			medA = a[n/2];
			medB = b[n/2];

			System.out.println((int)(medB - medA + 1));
		}
		else {
			medA = (a[n/2 - 1] + a[n/2])/2.0;
			medB = (b[n/2 - 1] + b[n/2])/2.0;
			System.out.println((int)((medB - medA)*2 + 1));
		}
	}

}


Measured memory_bytes: 51872
#include <stdio.h> 
 
 
 int main(){ 
     int h, w; 
     int i, j; 
     while(1){ 
         scanf("%d %d ", &h, &w); 
         if(h==0&&w==0)break; 
         for(i=0;i<h;i++){ 
             for(j=0;j<w;j++){ 
                 printf("#"); 
             } 
             printf("\n"); 
         } 
         printf("\n"); 
     } 
 
 
     return 0; 
 } 



Measured memory_bytes: 2108
# -*- coding: utf-8 -*-
import io, sys
import bisect


def main():
    N = int( sys.stdin.readline() )
    x1y1x2y2_list = [ list(map(int, sys.stdin.readline().split())) for _ in range(N) ]
    
    X1 = [a for a,b,c,d in x1y1x2y2_list]
    X2 = [c for a,b,c,d in x1y1x2y2_list]
    Y1 = [b for a,b,c,d in x1y1x2y2_list]
    Y2 = [d for a,b,c,d in x1y1x2y2_list]

    all_X = compress(X1,X2)
    all_Y = compress(Y1,Y2)

    matrix =[ [0]*len(all_X) for _ in range(len(all_Y)) ]

    for i in range(N):
        matrix[ Y1[i] ][ X1[i] ] += 1
        matrix[ Y2[i] ][ X2[i] ] += 1
        matrix[ Y2[i] ][ X1[i] ] -= 1
        matrix[ Y1[i] ][ X2[i] ] -= 1

    for row in range(len(matrix)):
        for col in range(1, len(matrix[0])):
            matrix[row][col] += matrix[row][col-1]
    
    for row in range(1, len(matrix)):
        for col in range(len(matrix[0])):
            matrix[row][col] += matrix[row-1][col]

    ans = 0

    for row in range(len(matrix)):
        for col in range(len(matrix[0])):
            if matrix[row][col] > 0:
                area = (all_X[col+1] - all_X[col]) * (all_Y[row+1] - all_Y[row])
                ans += area

    print(ans)


def compress(A1 :list, A2 :list):
    all_A = []
    #delta = [-1, 0, 1]
    delta = [0]

    for a in (A1 + A2):
        for d in delta:
            all_A.append(a + d)
    
    all_A = sorted(set(all_A))

    for i in range(len(A1)):
        A1[i] = bisect.bisect_left(all_A, A1[i])
        A2[i] = bisect.bisect_left(all_A, A2[i])
    
    return all_A


if __name__ == "__main__":
    main()



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

typedef long long ll;
typedef pair<int,int> ii;

string fmt(int x, int len) {
	stringstream ss; ss<<x;
	string ret=ss.str();
	while(ret.size()<len)
		ret='0'+ret;
	return ret;
}

string eval(int x, int y) {
	return fmt(x,6)+fmt(y,6);
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m; cin>>n>>m;
	map<int, ii> mp;
	map<int, set<int>> order;
	for (int i=0; i<m; i++) {
		int p,y; cin>>p>>y;
		ii cur={p,y};
		mp[i]=cur;
		order[p].insert(y);
	}
	map<ii, string> id;
	for (auto it : order) {
		int ord=0;
		for (auto it2 : it.second)
			id[{it.first, it2}]=eval(it.first, ++ord);
	}
	for (auto it : mp)
		cout << id[it.second] << endl;
	return 0;
}


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

int main() {
  int N,ans=0;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(int i=0;i<N;i++){
    if(i%2){
      ans-=a[i];
    }
    else{
      ans+=a[i];
    }
  }
  cout<<ans;
  
       
  
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long double util(vector<vector<long double>> & dp, long double p[],int n,int a)
{
    if(n==0  )
    
    
    return 1;
    
    if(dp[a][n]!=-1)
    return dp[a][n];
    
    if(a==0)
    dp[a][n]=util(dp,p,n-1,a)*p[n-1];
    
    else
    dp[a][n]=(util(dp,p,n-1,a)*p[n-1])+(util(dp,p,n-1,a-1)*(1.0-p[n-1]));
    
    return dp[a][n];
}

int main() {
        int n;
        cin>>n;
     long double p[n];
      for(int i=0;i<n;i++)
      cin>>p[i];
       int a = n%2==0?n/2-1:n/2;
      
       vector<vector<long double>> dp(a+1,vector<long double>(n+1,-1));
       
      long  double ans=util(dp,p,n,a);
      	cout<<fixed<<setprecision(10);
      cout<<ans<<endl;
     
        
	return 0;
}

Measured memory_bytes: 71040
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  ve<int> a(N);
  rep(i, N){
    ci(a.at(i));
  }
  sort all(a);
  co(a.at(N - 1) - a.at(0));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

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

int main(){
  ll k;
  cin >>k;
  int n=50;
  vector<ll> a(n, n-1+k/n);
  int kpn=k%n;
  /*
  a[0]+=(k%n)*n;
  repo(i, n-1){
    a[i]-=(k%n);
  }
  */
  rep(i, kpn){
    a[i]+=n;
    rep(j, n){
      if(j==i)continue;
      a[j]-=1;
    }
  }
  cout << n << endl;
  rep(i, n){
    cout << a[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	vector<int> x(n), y(n);
	for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
	vector<int> idx(n);
	for (int i = 0; i < n; i++) idx[i] = i;
	double m = 0;
	do {
		for (int i = 0; i < n - 1; i++) {
			m += hypot(x[idx[i]] - x[idx[i + 1]], y[idx[i]] - y[idx[i + 1]]);
		}
	} while (next_permutation(idx.begin(), idx.end()));
	for (int i = 1; i <= n; i++) m /= i;
	printf("%.10f\n", m);
	return 0;
}


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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
// #define endl '\n'
#define Matrix vector<vector<int>>
#define mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v));

const int MAXN = 2e5 + 3;
int anc[MAXN][63];

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, m, k;

  cin >> n >> k;

  for (int i = 0; i < n; i++) {
    cin >> anc[i][0];
    anc[i][0]--;
  }

  for (int j = 1; j < 63; j++) {
    for (int i = 0; i < n; i++) {
      anc[i][j] = anc[anc[i][j - 1]][j - 1];
    }
  }

  m = 1;
  while (m--) {
    int u, mov;

    u = 0, mov = k;
    int pos = 0;
    while (mov) {
      if (mov & 1)
        u = anc[u][pos];

      pos++;
      mov >>= 1;
    }

    cout << ++u << endl;
  }
}

Measured memory_bytes: 102080
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;
    cin>>n;
    vector<int> s(n);
    int Sum=0;
    bool all10=true;
    rep(i,n){
        cin>>s.at(i);
        Sum+=s.at(i);
        if(s.at(i)%10!=0) all10=false;
    }
    if(Sum%10!=0) cout<<Sum<<endl;
    else if(!all10){
        sort(s.begin(),s.end());
        rep(i,n){
            if(s.at(i)%10!=0){
                Sum-=s.at(i);
                cout<<Sum<<endl;
                break;
            }
        }
    }
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<string>
#include<vector>
#include<math.h>
#include<time.h>
#include<utility>
#include<cstdlib>
#include<sstream>
#include<cstring>
#include<stdio.h>
#include<iomanip>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	cout<<"ABC"<<n;
	return 0;
}

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as U
import Data.List
import Debug.Trace


main :: IO ()
main = do
    n <- fmap read getLine
    ps <- fmap (map read . words) getLine
    let v0 = U.singleton 1.0
    let vn :: U.Vector Double
        vn = foldl' step v0 ps
        step tbl pi = U.generate (l + 1) gen
            where
            l = U.length tbl 
            gen i = q1 + q2 
                where
                    q1 = if i >= 1 then pi * tbl U.! (i - 1) else 0
                    q2 = if i < l  then (1 - pi) * tbl U.! i else 0
    print (U.sum $ U.drop (n `div` 2 + 1) vn)


Measured memory_bytes: 1660
import sys

chklist = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
           'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

word = ''
for i in sys.stdin:
    word += i

for n in chklist:
    cnt = 0
    for w in word:
        if n.upper() == w.upper():
            cnt += 1
    print(str.format('{} : {}', n, cnt))


Measured memory_bytes: 5560
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 5;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
ll po(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

int n;
ll val[maxn], ans[maxn];

ll ans1()
{
	ll res = 0;
	repp(i, 2, n)
	{
		ll t = min(val[i], val[i - 1]);
		val[i] -= t;
		val[i - 1] -= t;
		res += t;
	}
	repp(i, 1, n)
	{
		res += val[i] / 2LL;
	}
	return res;
}

ll ans2()
{
	ll res = 0;
	for (int i = n - 1; i >= 1; i--)
	{
		ll t = min(val[i], val[i + 1]);
		val[i] -= t;
		val[i + 1] -= t;
		res += t;
	}
	repp(i, 1, n)
	{
		res += val[i] / 2LL;
	}
	return res;
}

void solve()
{
	sa(n);
	ll res = 0;
	repp(i, 1, n)
	{
		scanf("%lld", &ans[i]);
	}

	repp(i, 1, n)
	{
		if (ans[i] & 1)
		{
			if (ans[i + 1])
			{
				ans[i + 1]--;
				res++;
			}
		}
		res += ans[i] / 2;
	}

	printf("%lld", res);
}

int main()
{

	solve();
	return 0;
}


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


int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());

    vector<int> ans(N);
    ans[N/2] = A[0];
    int l = 1, r = N-1;
    int lcur = N/2-1, rcur = N/2+1;
    int turn = 0;

    rep(i, N-1) {
        if (turn%2 == 0) {
            if (r-l+1 >= 2) {
                ans[lcur--] = A[r--];
                ans[rcur++] = A[r--];
            }
            else if (r == l) {
                ans[lcur--] = A[r--];
            }
            turn++;
        }
        else {
            if (r-l+1 >= 2) {
                ans[lcur--] = A[l++];
                ans[rcur++] = A[l++];
            }
            else if (r == l){
                ans[lcur--] = A[l++];
            }
            turn++;
        }
    }

    // cout << endl;
    // rep(i, N) cout << ans[i] << endl;


    vector<ll> ans2(N);
    sort(A.rbegin(), A.rend());
    ans2[N/2] = A[0];
    l = 1, r = N-1;
    lcur = N/2-1, rcur = N/2+1;
    turn = 0;
    rep(i, N-1) {
        if (turn%2 == 0) {
            if (r-l+1 >= 2) {
                ans2[lcur--] = A[r--];
                ans2[rcur++] = A[r--];
            }
            else if (r == l) {
                ans2[lcur--] = A[r--];
            }
            turn++;
        }
        else {
            if (r-l+1 >= 2) {
                ans2[lcur--] = A[l++];
                ans2[rcur++] = A[l++];
            }
            else if (r == l){
                ans2[lcur--] = A[l++];
            }
            turn++;
        }
    }
    //
    // rep(i,N) {
    //     cout << ans2[i] << " ";
    // }
    // cout << endl;

    ll ret1 = 0, ret2 = 0;
    rep(i, N-1) {
        ret1 += llabs(ans[i]-ans[i+1]);
        ret2 += llabs(ans2[i]-ans2[i+1]);
    }
    cout << max(ret1, ret2) << endl;
}

Measured memory_bytes: 2176
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define N 2*10e5
#define precise cout<<fixed<<setprecision(10)
#pragma GCC optimize("O0")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#define rep(i,a,b) for(int i=a;i<b;i++)
#define min3(a,b,c) min(a,min(b,c))
#define nl cout<<"\n";
#define all(v) v.begin(),v.end()
#define F first
#define S second
typedef long long ll;
typedef vector<long long> vl;
typedef vector<pair<long,long>> vp;
void get(ll arr[],ll n){for(ll i=0;i<n;i++) cin>>arr[i];}
ll gcd(ll a,ll b);
ll binpow(ll a,ll b);
void solve()
{
	 char c;
	 cin>>c;
	 if(c-'A'<=26)cout<<"A";
	 else cout<<"a";
}
int main()
{
 	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
	 	solve();
	}
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}
ll binpow(ll a, ll b) {
   ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


Measured memory_bytes: 3608
import collections
import fractions
from functools import reduce
import sys
input = sys.stdin.readline


def main():
    n, y = input_list()
    for x_1000 in range(n+1):
        for x_5000 in range(n+1):
            x_10000 = n - (x_1000+x_5000)
            if x_10000 < 0:
                continue
            yen_1000 = x_1000 * 1000
            yen_5000 = x_5000 * 5000
            yen_10000 = x_10000 * 10000
            if (yen_1000 + yen_5000 + yen_10000) == y:
                print(x_10000, x_5000, x_1000)
                exit(0)
    print(-1, -1, -1)


def input_list():
    return list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

if __name__ == "__main__":
    main()


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

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i) << ", ";
  }
  cout << "]" << endl;
}

int main()
{
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;

  int ans = 0;
  if (a < 0)
  {
    ans += -a * c;
    ans += d;
    a = 0;
  }

  ans += (b - a) * e;

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



Measured memory_bytes: 3212
MOD = 10 **9 + 7
INF = 10 ** 10
import numpy as np
from  scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

def main():
    n,m,l = map(int,input().split())
    dist = [[INF] * n for _ in range(n)]  
    for _ in range(m):
        a,b,c = map(int,input().split())
        a -= 1
        b -= 1
        dist[a][b] = c
        dist[b][a] = c

    csr = csr_matrix(dist)
    dist1 = floyd_warshall(csr)
    dist1 = np.where(dist1 <= l,1,INF)
    cnt = floyd_warshall(dist1)
    q = int(input())
    for _ in range(q):
        s,t = map(int,input().split())
        s -= 1
        t -= 1
        print(-1 if cnt[s][t] == INF  else int(cnt[s][t]) - 1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 19880
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
const long long INF = 10e9 + 7;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	ll n;
	cin >> n;
	map<ll, ll>a;
	ll temp = 0;
	ll ans = 0;
	rep0(i, n) {
		cin >> temp;
		a[temp]++;
	}
	for (auto& j : a) {
		if (j.second % 2 != 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6528