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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

//5,6の繰り返し

int main(){
    ll A,B;
    cin>>A;
    B=A%11;
    A-=B;
    A=A/11*2;
    if(B!=0){
    if(B<=6){
        A++;
    }else{
        A+=2;
    }
    }
    cout<<A<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    string S, T;
    int N;
    cin >> N >> S >> T;

    rep(i, N) {
        cout << S[i] << T[i];
    }
    cout << endl;

    return 0;
}


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

int main(){
  ll n,a,b;
  cin >>n >> a >> b;
  ll cnt;
  if((n<2 && a!=b) || a>b) cout << 0 <<endl;
  else{
  cnt=(n-1)*(b-a)+(a-b)+1;
  cout << cnt << endl;
  }
}

Measured memory_bytes: 256
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cout<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
vll a(n);
vll b(n);
read(a);
read(b);
int index=0;
ll needsum=0;
ll havesum=0;
priority_queue<ll> pq;
fo(i,0,n)
if(a[i]==b[i])
continue;
else if(a[i]>b[i])
{havesum+=a[i]-b[i];pq.push(a[i]-b[i]);}
else 
{needsum+=b[i]-a[i];index++;}
if(needsum>havesum)
{cout<<-1;return ;}
else
{
    while(needsum>0)
    {
        needsum-=pq.top();
        pq.pop();
        index++;
    }
}
cout<<index;






return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

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

int main(void){
    int A,B,C;
    cin >> A >> B>> C;
    for(int i = 0 ; i < B ;i++){
        if((A*i)%B==C){
            cout << "YES"<<endl;
            return 0;
        }
    }
    cout <<"NO"<<endl;
    return 0;
    
}



Measured memory_bytes: 256
#include<stdio.h>
int A[100][100];
int visit[100];
void MinimumSpanningTree(int);

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

void MinimumSpanningTree(int n){
  int i, j, k=1, X[100], minCost, min, sum=0;
  
  X[0] = 0;
  visit[0] = 1;
  for(i = 1; i < n; i++){
    visit[i] = 0;
  }
  while(1){
    minCost = 2001;
    for(i = 0; i < k; i++){
      for(j = 0; j < n; j++){
	if(A[X[i]][j] < minCost && A[X[i]][j] != -1 && visit[j] != 1){
	  minCost = A[X[i]][j];
	  min = j;
	}
      }
    }
    if(k != n){
      X[k] = min;
      visit[min] = 1;
      sum += minCost;
      k++;
    }
    else break;
  }
  printf("%d\n", sum);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n,k;
ll a[2*MAX];
int main(){FAST;
cin>>k>>n;
for(ll i=0;i<n;++i)cin>>a[i];
ll ans = k-1;
for(ll i=0;i<n;++i){
  ll x = a[(i+1)%n];
  ll y = a[(i-1+n)%n];
  ll dist1 = (a[i]-x+k)%k;
  ll dist2 = (a[i]-y+k)%k;
  dist1 = max(dist1,k-dist1);
  dist2 = max(dist2,k-dist2);
  ans = min({ans,dist1,dist2});
}  
cout<<ans;
return 0;
}

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

ll inf=1ll<<60,mod=1e9+7;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	string a,b,c;
	int t;
	cin>>a>>b>>c;
	t=a[0]-'0';
	cout<<(char)(t+16);
	t=b[0]-'0';
	cout<<(char)(t+16);
	t=c[0]-'0';
	cout<<(char)(t+16);
	return 0;
}

Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


A, B, C, K = list(map(int, sys.stdin.buffer.readline().split()))

if K %2 == 1:
    print(B - A)
else:
    print(A - B)


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

int main(){
  ll n,a,b;
  cin >> n>> a >> b;
  ll block = n/(a+b);
  ll leftover = n%(a+b);
  if(leftover>a){
    cout << (block+1)*a <<endl;
  }
  else cout << block*a+leftover << endl;
  return 0;
}


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

int main()
{
    int n;
    double y = 0;
    cin >> n;
    double x;
    string u;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> u;
        if (u == "JPY")
            y += x;
        else if (u == "BTC")
            y += (x * 380000.0);
    }
    cout << fixed << setprecision(9);
    cout << y << endl;
    return 0;
}


Measured memory_bytes: 256
import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
As = list(set(A))
As.sort(reverse=True)
h1 = 0
h2 = 0
for i in range(len(As)):
    if c[As[i]] >= 4:
        if h1 == 0:
            h1 = As[i]
        h2 = As[i]
    elif c[As[i]] >= 2:
        if h1 == 0:
            h1 = As[i]
        else: h2 = As[i]
    if h1*h2 > 0:
        break
print(h1*h2)

Measured memory_bytes: 20772
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n;cin>>n;
    ll k;cin>>k;
    ll h[n];
    ll ans=0;
    for(ll i=0;i<n;i++){
        cin>>h[i];
        if(h[i]>=k){
            ans++;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a,b;
string n;
int main()
{
	cin>>a>>b;
	for(int s=0;s<b+2;s++)cout<<"#";
	cout<<endl;
	for(int s=0;s<a;s++)
	{
		cout<<"#";
		cin>>n;
		cout<<n<<"#"<<endl;
	}
	for(int s=0;s<b+2;s++)cout<<"#";
	cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define pii pair<int, int>
#define all(s) s.begin(), s.end()
#define prev myrza4321
#define y1 myrza1234
#define OK() puts("OK")
using namespace std;

const int N = (int)1e5 + 5;
const int INF = (int)1e9 + 7;

deque <char> dq;
string s;
bool ok = 1;
int Q;

main() {
  cin >> s;
  for (auto c : s) {
    dq.push_back(c);
  }
  cin >> Q;
  while (Q--) {
    int tp;
    scanf("%d", &tp);
    if (tp == 1) {
      ok ^= 1;
    } else {
      int tp2;
      char ch;
      cin >> tp2 >> ch;
      if (!ok) {
        tp2 = (tp2 == 1 ? 2 : 1);
      }
      if (tp2 == 1) {
        dq.push_front(ch);
      } else {
        dq.push_back(ch);
      }
    }
  }
  string ans = "";
  for (char c : dq) {
    ans += c;
  }
  if (!ok) {
    reverse(all(ans));
  }
  cout << ans;
}


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

int main() {
  string x, y; cin >> x >> y;
  if (x > y) {
    cout << ">" << endl;
  }
  else if (x < y) {
    cout << "<" << endl;
  }
  else if (x == y) {
    cout << "=" << endl;
  }
}

Measured memory_bytes: 256
d={}
N=int(input())
for _ in range(N):
    s=input()
    if not s in d:
        d[s]=1
    else:
        d[s]+=1
M=int(input())
for _ in range(M):
    s=input()
    if not s in d:
        d[s]=-1
    else:
        d[s]-=1
print(max(0,max(d.values())))


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

int main(void) {
  int n; cin >> n;
  vector<int> s(n);
  for (int i=0; i<n; i++) cin >> s.at(i);
  sort(s.begin(), s.end());
  
  int ans = 0;
  for (int i=0; i<(n-1); i++) {
    ans += s[i];
  }
  
  ans += s[n-1] / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>

using namespace std;
const int MX = 50+10;
int mp[MX][MX];
int vis[MX];

int main()
{
    int n, m;
    int ans = 0;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; ++i)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        vis[a]++; vis[b]++;
        mp[a][b] = mp[b][a] = 1;
    }
    while(true)
    {
        int pos;
        bool flag = true;
        for(int i = 1; i <= n; ++i)
        {
            if(vis[i] == 1)
            {
                ans++;
                flag = false;
                pos = i;
                vis[i]--;
                break;
            }
        }
        if(flag) break;
        for(int i = 1; i <= n; ++i)
        {
            if(mp[pos][i] == 1)
                vis[i]--;
        }
    }
    printf("%d\n", ans);
}


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 k = sc.nextInt();
        int ans = 0;
        for(int i = 0; i < n; i++) {
          int value = sc.nextInt();
          ans += 2 * Math.min(value, Math.abs(k - value));
        }

		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 23888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long result = 0;
            long keep = 0;
            for(int i = 0; i < N; i++)
            {
                long P = long.Parse(Console.ReadLine());
                if (keep <= P)
                {
                    result += keep;
                    keep = P;
                }
                else 
                {
                    result += P;
                }
            }
            Console.WriteLine(result + keep/2);

        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 27468
import math

a, b, x = input().split(' ')
a, b, x = float(a), float(b), float(x)

full = a ** 2 * b
ratio = x / full
# print('ratio', ratio)

# 容積の半分以下
if ratio <= 0.5:
    # 底面積
    s = (x / a)

    c = s * 2 / b
    # print('c=',c)
    # print('b=',b)

    print(
        90 - math.atan(c/b) * 180 / math.pi
    )
else:
    # 低面積
    s = a*b - (x/a)
    c = s * 2 / a

    # print('c=',c)
    # print('a=',a)

    print(
        math.atan(c / a) * 180 / math.pi
    )

# print(c)
#
# print(
# math.atan(0.5)
# )


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

int main() {
	
	const int inf=100000000;
	int n,m;
	cin>>n>>m;
	int a[1005],b[1005],c[1005];
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i]>>c[i];
		a[i]--;
		b[i]--;
	}
	
	int dist[1005][1005];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j)dist[i][j]=0;
			else dist[i][j]=inf;
		}
	}
	
	for(int i=0;i<m;i++){
		
		dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
		dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
		
	}
	
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	
	int ans=m;
	for(int i=0;i<m;i++){
		bool shortest=false;
		for(int j=0;j<n;j++){
			if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
			
		}
		if(shortest==true){
			ans=ans-1;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2688
//#pragma GCC optimize("03", "unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,n) for(i=0;i<n;i++)
#define FORn(i,j,n) for(i=j;i<n;i++)
#define pb push_back
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define vli vector<lli>
#define vi vector<int>
#define vs vector<string>
#define vprint(v) for(auto t:v)cout<<t<<" "
#define endl "\n"

typedef long long int lli;
typedef long int li;

const lli mod=1000000007;
const lli limit=1000000;

using namespace std;

void fc(lli &x)
    {
        bool neg=false;
        register char c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    fast()
    lli n,q,t;
    lli temp,temp1,temp2,temp3;
    lli i,j,k;
    string arr[100005],str;
    temp1=1;
    cin>>n;
    FOR(i,10)arr[i]=i+'0';
    for(i=10;i<=n+1;i++){
        temp=arr[temp1][arr[temp1].length()-1]-'0';
        if(temp!=0){
            str=(temp-1)+'0';
            arr[i++]=arr[temp1]+str;
        }
        str=temp+'0';
        arr[i++]=arr[temp1]+str;
        str=(temp+1)+'0';
        if(temp!=9) arr[i]=arr[temp1]+str;
        else i--;
        temp1++;
    }
    //FOR(i,n+1)cout<<arr[i]<<endl;
    cout<<arr[n]<<endl;
 
}

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

using namespace std;

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


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

  int N = s.length(), i;

  int a = 0, b = 0;
  REP(i,N) {
    if (s[i] == '0') a++;
    else b++;
  }
  int c = a - b;

  cout << N - (c < 0 ? -c : c) << endl;

  return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
# coding: utf-8


import sys
import math
from pprint import pprint
import numpy as np


text =input()
N=int(text.split()[0])
sentounoaji=int(text.split()[1])


saigonoaji=sentounoaji+N-1

goukei = int((sentounoaji*N) + (saigonoaji-sentounoaji)*N/2)

if sentounoaji<=0 and 0<=saigonoaji : #0をまたいでいるので何も引かなくてOK。
    print(goukei)
elif 0<sentounoaji :
    print(goukei-sentounoaji)
else :
    print(goukei-saigonoaji)



Measured memory_bytes: 18488
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[M];
		int[] B = new int[M];
		Vertice[] vs = new Vertice[N];
		for (int i = 0; i < N; ++i) {
			vs[i] = new Vertice(i);
		}
		for (int i = 0; i < M; ++i) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			--A[i];
			--B[i];
			addEdge(vs[A[i]], vs[B[i]]);
		}
		vs[0].dfs(null);
		if (vs[0].deg == 1) {
			System.out.println(-1);
		} else {
			for (int i = 0; i < N; ++i) {
				for (Edge e : vs[i].outgo) {
					if (e.direction == 1) {
						System.out.println((i + 1) + " " + (e.dst.id + 1));
					}
				}
			}
		}
	}

	void addEdge(Vertice a, Vertice b) {
		Edge ab = new Edge();
		Edge ba = new Edge();
		ab.dst = b;
		ba.dst = a;
		ab.rev = ba;
		ba.rev = ab;
		a.outgo.add(ab);
		b.outgo.add(ba);
	}

	class Vertice {
		int id;
		int deg = 0;
		ArrayList<Edge> outgo = new ArrayList<>();
		boolean visited = false;

		public Vertice(int id_) {
			id = id_;
		}

		void dfs(Edge toParent) {
			visited = true;
			for (Edge e : outgo) {
				if (e == toParent) {
					continue;
				}
				if (!e.dst.visited) {
					e.dst.dfs(e.rev);
				} else if (e.direction < 0) {
					e.direction = 1;
					e.rev.direction = 0;
				}
				deg ^= e.direction;
			}
			if (toParent == null)
				return;
			toParent.direction = deg;
			toParent.rev.direction = 1 ^ deg;
			deg = 0;
		}
	}

	class Edge {
		Vertice dst;
		Edge rev;
		int direction = -1;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 119716
#include <bits/stdc++.h>
#define SIZE 200005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int to[SIZE];
int L[SIZE],R[SIZE];
int main()
{
	int n,m;
	scanf("%d",&n);
  scanf("%d",&m);

  if(n == m) printf("Yes\n");
  else printf("No\n");
}


Measured memory_bytes: 256
def median(arr)
  n = arr.size
  n.odd? ? arr[n/2] : (arr[n/2 - 1] + arr[n/2])/2.0
end

n = gets.to_i
args = readlines(chomp: true)
ab = args.map{|arr| arr.split(" ").map(&:to_i)}.transpose

result = []

ab.each do |range|
  result << median(range.sort)
end

result = result[-1] - result[0]

result = n.odd? ? result + 1 : result * 2 + 1

p result.to_i


Measured memory_bytes: 46832
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d %d",&A,&B);
    if(A==1&&B==2||B==1&&A==2)
        printf("3");
    else if(A==2&&B==3||B==2&&A==3)
    printf("1");
    else
        printf("2");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;
const int maxn = 405;

int n,m;
string s[maxn];
int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int nb, nw;
bool f[maxn][maxn];

void bfs(int x, int y) {
  nb = nw = 0;
  queue<int>qx,qy;
  qx.push(x);
  qy.push(y);
  f[x][y] = 1;
  while(!qx.empty()) {
    int x = qx.front();
    qx.pop();
    int y = qy.front();
    qy.pop();
    if(s[x][y]=='#')nb++;
    else nw++;
    for(int i =0;i<4;i++){
      int nx = x+dir[i][0];
      int ny = y+dir[i][1];
      if(nx<0||nx>=n||ny<0||ny>=m)continue;
      if(f[nx][ny])continue;
      if(s[nx][ny]!=s[x][y]){
        f[nx][ny]=1;
        qx.push(nx);
        qy.push(ny);
      }
    }
  }
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>s[i];
  ll ret = 0;
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
      if(s[i][j]=='#'&&f[i][j]==0){
        bfs(i,j);
        ret += nb * (ll)nw;
      }
    }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  i64 N, M;
  std::cin >> N >> M;
  std::vector<i64> A;
  tools::read(A, N);

  std::nth_element(A.begin(), A.begin() + (M - 1), A.end(), std::greater<i64>());
  std::cout << (A[M - 1] >= tools::ceil(std::accumulate(A.begin(), A.end(), static_cast<i64>(0)), 4 * M) ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main()
{
	string n;
	cin >> n;
	
	string a[4];

	a[0] = n.front();
	a[1] = n.substr(1, 1);
	a[2] = n.substr(2, 1);
	a[3] = n.back();

	if ((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3])) {
		printf("Yes");
	}
	else {
		printf("No");
	}


		

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_E
#define M_E 2.71828182845904523536
#endif

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x)
#endif

#define pln(x) cout << (x) << endl
#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);}
template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}


LLI f(vector<LLI> &s, LLI x){
  auto itr = lower_bound(ALL(s), x);
	
  if(x > s.back()){
    return x - s.back();
  }else if(x < s.front()){
    return s.front() - x;
  }else{
    return min(abs((*itr)-x), abs((*(itr-1)-x)));
  }
}

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

  int A,B,Q;
  while(cin >> A >> B >> Q){
    vector<LLI> s(A), t(B); cin >> s >> t;

    REP(i,Q){
      LLI x; cin >> x;

      LLI ans = 1e18;

      {
	auto itr = lower_bound(ALL(s), x);
	LLI temp = 0;
	
	if(x > s.back()){
	  temp = x - s.back() + f(t, s.back());
	}else if(x <= s.front()){
	  temp = s.front() - x + f(t, s.front());
	}else{
	  temp = min(abs((*itr)-x)+f(t,*itr), abs((*(itr-1))-x)+f(t,*(itr-1)));
	}
	chmin(ans, temp);
      }
      
      {
	auto itr = lower_bound(ALL(t), x);
	LLI temp = 0;
	
	if(x > t.back()){
	  temp = x - t.back() + f(s, t.back());
	}else if(x <= t.front()){
	  temp = t.front() - x + f(s, t.front());
	}else{
	  temp = min(abs((*itr)-x)+f(s,*itr), abs((*(itr-1))-x)+f(s,*(itr-1)));
	}
	chmin(ans, temp);
      }


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


Measured memory_bytes: 2944
#define lop(i, n) for (int i = n-1; i >= 0; i--)
#define loop(i, x) for (int i = 0; i < x; i++)
#define loopf(i, x, n) for (int i = x; i < n; i++)
#define loopr(i, x, n) for (int i = x - 1; i >= n; i--)
#define ain(arr, n) for (int i = 0; i < n; i++) cin>>arr[i]
#define aout(arr, n) for (int i = 0; i < n; i++) cout<<arr[i]<<" "
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)

#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fe first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef complex<int> ci;

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	set<int> fd;
	loop(i, n)
	{
		int a;cin>>a;
		fd.insert(a);
	}
	cout<<fd.size()<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
typedef long long ll;
#define CMAX 1010
int noinit = 1;ll memo[CMAX][CMAX];
ll aCb(ll a, ll b) {
    if (noinit) {
        rep(i, 0, CMAX) rep(j, 0, CMAX) memo[i][j] = -1;
        noinit = 0;
    }
    if (b == 0 || a == b) return 1;
    if (0 <= memo[a][b]) return memo[a][b];
    return memo[a][b] = aCb(a - 1, b - 1) + aCb(a - 1, b);
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
 
int N, P, A[101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> P;
    rep(i, 0, N) cin >> A[i];
 
    int odd = 0, even = 0;
    rep(i, 0, N) {
        if (A[i] % 2 == 1) odd++;
        else even++;
    }
 
    ll ans = 0;
    int c = P;
    while (c <= odd) ans += aCb(odd, c), c += 2;
    rep(i, 0, even) ans *= 2;
    printf("%lld\n", ans);
}

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

int main(){
	int n,nn,s=0;
	cin>>n;
	nn=n;
	while(n!=0){
		s+=n%10;
		n/=10;
	}
	if(nn%s==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

using namespace std ;
int n , m ;
string s ;
const int N = 1e5 + 10 ;
int a[N] , q[N] , pre[N] , f[N] ;
int ans[N] ;
signed main() {
  ios :: sync_with_stdio(false) ;
  cin.tie(nullptr) ; cout.tie(nullptr) ;
  cin >> n >> m ;
  cin >> s ;
  int h , t ; q[h = t = 0] = 0 ;
  for(int i = 0 ; i <= n ; i ++) a[i] = s[i] & 15 ;
  for(int i = 0 ; i <= n ; i ++) {
    if(a[i]) continue ;
    while(h <= t && q[h] + m < i) ++ h ;
    if(h > t) { cout << -1 << '\n' ; return 0 ; }
    pre[i] = q[h] ; f[i] = f[q[h]] + 1 ;
    while(h <= t && f[q[t]] > f[i]) t -- ;
    q[++ t] = i ;
  }
  int now = n ;
  int top = 0 ;
  ans[++ top] = n ;
  while(now) { ans[++ top] = pre[now] ; now = pre[now] ; }
  top -- ;
  int last = 0 ;
  while(top) {
    cout << ans[top] - last << ' ' ;
    last = ans[top --] ;
  }
  return 0 ;
}


Measured memory_bytes: 2640
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        // 楽をしましたすみません
        static void Main(string[] args)
        {
            var firstInputLine = Console.In.ReadLine();
            var firstInputs = firstInputLine.Split(new char[] { ' ', '\t', '　' });

            var nrow = int.Parse(firstInputs[0]);
            var ncol = int.Parse(firstInputs[1]);

            var spreadSheet = new int[nrow, ncol];

            for (int irow = 0; irow < nrow; ++irow)
            {
                var inputLine = Console.In.ReadLine();
                var inputs = inputLine.Split(new char[] { ' ', '\t', '　' });
                if (inputs.Length != ncol)
                {
                    return;
                }

                for (int icol = 0; icol < ncol; ++icol)
                {
                    var value = int.Parse(inputs[icol]);
                    spreadSheet[irow, icol] = value;
                }
            }

            var rowSums = new int[nrow];
            for (int irow = 0; irow < nrow; ++irow)
            {
                var sum = 0;
                for (int icol = 0; icol < ncol; ++icol)
                {
                    sum += spreadSheet[irow, icol];
                }
                rowSums[irow] = sum;
            }

            var colSums = new int[ncol];
            for (int icol = 0; icol < ncol; ++icol)
            {
                var sum = 0;
                for (int irow = 0; irow < nrow; ++irow)
                {
                    sum += spreadSheet[irow, icol];
                }
                colSums[icol] = sum;
            }

            int totalSum = 0;
            foreach (var val in spreadSheet)
            {
                totalSum += val;
            }

            for (int irow = 0; irow < nrow; ++irow)
            {
                for (int icol = 0; icol < ncol; ++icol)
                {
                    Console.Write("{0} ", spreadSheet[irow, icol]);
                }
                Console.WriteLine(rowSums[irow]);
            }
            for (int icol = 0; icol < ncol; ++icol)
            {
                Console.Write("{0} ", colSums[icol]);
            }
            Console.WriteLine(totalSum);
        }
    }
}



Measured memory_bytes: 18008
import collections
n = int(input())
d = [0] * n
for i in range(2, n + 1):
    ti = i
    for j in range(2, n + 1):
        while True:
            if ti % j == 0:
                d[j-1] += 1
                ti //= j
            else:
                break
t = 1
for i in d:
    t = t * (i + 1) % (10 ** 9 + 7)
print(t)


Measured memory_bytes: 3316
import bisect
n, q = map(int, input().split())
s = input()
ac=[]
for i in range(n):
  if s[i:i+2] == "AC":
    ac.append(i)

for i in range(q):
  l, r = map(int, input().split())
  acl=bisect.bisect_left(ac,l-1)
  acr=bisect.bisect_left(ac,r-1)
  print(acr-acl)

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

// 数字の各桁の和を返す
int sumDigits (int n) {
    int s;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

// 最大公約数を返す
int gcd (int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main () {
  int N; cin >> N;
  
  int f = sumDigits(N);
  if (N % f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
  char bd[100][100];
  int A,B;
  cin >> A >> B;
  for(int i=0;i<50;i++){
    for(int j=0;j<100;j++)
      bd[i][j]='.';
  }
  for(int i=50;i<100;i++){
    for(int j=0;j<100;j++)
      bd[i][j]='#';
  }
  for(int wh=1;wh<A;wh++)
    bd[99-wh/50*2][wh%50*2]='.';
  for(int bl=1;bl<B;bl++)
    bd[bl/50*2][bl%50*2]='#';
  
  cout << "100 100" << endl;
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      cout << bd[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<assert.h>
#include<stdlib.h>
#include<stack>
using namespace std;
/*********************Contest Template***********************/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<int,int> Cord;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(0);
struct S{
    int a,b; S(){}S(int _a,int _b){
        a=_a;
        b=_b;
    }
    const bool operator<(const S &o) const{
        return a<o.a;
    }
};
priority_queue<int,vector<int>,greater<int>> mpq;
#define SPACE 0
#define NL 1
inline void showAll(vector<int> &v,int NL_or_space){ 
    //0 is space, 1 is NL
    for(int &here:v){
        printf("%d",here);
        printf("%c",(NL_or_space)?'\n':' ');
    }
}
/*********************Contest Template***********************/
// const int SIZE=



int main(){
	int a,b;	scanf("%d %d",&a,&b);

	printf("%d\n",max(a+b,max(2*a-1,2*b-1)));

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;

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

    int max_able = b / a;
    if (max_able < c){
        cout << max_able << endl;
    }
    else{
        cout << c << endl;
    }
}

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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll N;
vector<ll> g[100100];

// 頂点 cur
// 0: 白 
// 1: 黒
ll dp[100100][2];

void dfs(int cur, int par = -1) {
    dp[cur][0] = 1;
    dp[cur][1] = 1;
    for (int i = 0; i < g[cur].size(); i++) {
        ll to = g[cur][i];
        if (to == par) continue;

        dfs(to, cur);

        // cout << "to: " << to << " <- cur: " << cur << endl;
        // 戻りがけになんかする
        dp[cur][0] *= (dp[to][0] + dp[to][1]); 
        dp[cur][0] %= MOD; 

        dp[cur][1] *= dp[to][0];
        dp[cur][1] %= MOD; 
    }
}
int main() {
    cin >> N;
    rep(i, N - 1) {
        ll x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    dfs(0);
    // cout << dp[0][0] << " " << dp[0][1] << endl;

    ll ans = dp[0][0];
    ans += dp[0][1];
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 17420
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;

double GetLen(double x1,double y1,double x2,double y2){
  return sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
}
double GetAn1(double x1,double y1,double x2,double y2){
  return atan((y2-y1)/(x2-x1));
}
double GetAn2(double a,double b,double c){
  return  acos((b*b+c*c-a*a)/(2*b*c));
}
main(){
  double x1,y1,x2,y2,x3,y3,xp,yp; 
  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
    double S,S2;
    double a,b,c,an;
    double cl1,cl2,cl3,anc;

    if( (xp==x1 && yp==y1) || (xp==x2 && yp==y2) || (xp==x3 && yp==y3)){
      printf("YES\n");
      continue;
    }

    a=GetLen(x1,y1,x2,y2);
    b=GetLen(x2,y2,x3,y3);
    c=GetLen(x3,y3,x1,y1);
    an=GetAn2(a,b,c);
    S=0.5*b*c*sin(an);

    cl1=GetLen(x1,y1,xp,yp);
    cl2=GetLen(x2,y2,xp,yp);
    cl3=GetLen(x3,y3,xp,yp);

    anc=GetAn2(a,cl1,cl2);
    S2=0.5*cl1*cl2*sin(anc);

    anc=GetAn2(b,cl2,cl3);
    S2+=0.5*cl2*cl3*sin(anc);

    anc=GetAn2(c,cl3,cl1);
    S2+=0.5*cl3*cl1*sin(anc);
    long long int Si,Si2;
    Si=S*10000000;
    Si2=S2*10000000;
    //  printf("%f %f %f %f %f %f",a,b,c,an*(180/M_PI),S,S2);
    if(Si2<=Si)
      printf("YES\n");
    else printf("NO\n");
  }
}

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

int n;
int x[100];
long long int dp[101][21];

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

  for(int i = 0; i < n; i++){
    for(int j = 0; j <= 20; j++){
      dp[i][j] = 0;
    }
  }
  dp[1][x[0]] = 1;

  for(int i = 1; i < n - 1; i++){
    for(int j = 0; j <= 20; j++){
      int minus = j - x[i];
      int plus = j + x[i];
      if (minus >= 0){
        dp[i + 1][j] += dp[i][minus];
      }
      if (plus <= 20){
        dp[i + 1][j] += dp[i][plus];
      }
    }
  }

  cout << dp[n - 1][x[n - 1]] << endl;
  return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#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 ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
double pi = 3.141592653589793238;
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
int D;
void calculate(vector<int> c, vector<vector<int>> s, int contest,int day, vector<int> &t, ll &score){
    ll p=0;
    int a[26];
    rep(i, 26){
        a[i]=0;
    }
    rep(i, D){
        rep(j, 26){
            p-=c[j]*(i+1-a[j]);
        }
        if(i!=day){
            p+=s[i].at(t[i])+c[t[i]]*(i+1-a[t[i]]);
            a[t[i]]=i+1;
        }else{
            p+=s[day].at(contest)+c[contest]*(day+1-a[contest]);
            a[contest]=i+1;
        }
        
    }
    if(score<p){
        score=p;
        t[day]=contest;
    }
}

int main(){
cin>>D;
vector<int> c(26);
rep(i, 26){
    cin>>c[i];
}
vector<vector<int>> s(D);
int r;
rep(i, D){
    rep(j, 26){
        cin>>r;
        s[i].push_back(r);
    }
}
int M[26];
rep(i, 26){
    M[i]=0;
}
vector<vector<int>> m(D);
rep(i, D){
    rep(j, 26){
        m[i].push_back(0);
    }
}
vector<int> a(26);

rep(i, 26){
    a[i]=0;
}
rep(i, D){
}
vector<int> t(D);
ll score=0;
rep(i, D){
    rep(j, 26){
        M[j]=0;
    }
    rep(j, 26){
        score-=c[j]*(i+1-a[j]);
        rep(k, j+1){
            if(s[i].at(j)+c[j]*(i+1-a[j])>M[k]){
                rep(l, j-k){
                    M[j-l]=M[j-l-1];
                    m[i].at(j-l)=m[i].at(j-l-1);
                }
                M[k]=s[i].at(j)+c[j]*(i+1-a[j]);
                m[i].at(k)=j;
            }
        }
    }
    score+=M[0];
    a[m[i].at(0)]=i+1;
    t[i]=m[i].at(0);
}
rep(j, 20){
    rep(i, j+1){
        rep(k, D){
            calculate(c, s, m[k].at(i),k, t, score);
        }
    }
}
rep(i, D){
    cout<<t[i]+1<<endl;
}
}


Measured memory_bytes: 3804
A,B,C,X,Y = map(int,input().split())

#abset==ab num *2
anss = []
for abset in range(max(X,Y)+1):
	anss.append(abset*2*C+max(0,X-abset)*A+max(0,Y-abset)*B)
				
print(min(anss))

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int k;
    cin >> k;
    for (auto&& c : s) {
        if (c == 'a') continue;
        if (('z' + 1) - c <= k) {
            k -= ('z' + 1) - c;
            c = 'a';
        }
    }
    char& c = *(s.end() - 1);
    c += k % 26;
    if (c > 'z') c -= 'a';
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
using ll = long long; using ld = long double; const char nl = '\n';
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */
 
#include <bits/extc++.h>
namespace pbds =  __gnu_pbds;
template <typename key, typename val=pbds::null_type, typename comp=less<key>>
using ostree=pbds::tree<key,val,comp,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
using vi = vector< int >; using vll = vector< ll >;
#define all(x) std::begin(x), std::end(x)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&);
string to_string(string const&s){return '"'+s+'"';}
string to_string(char const &c) {return to_string(string(1,c));}
string to_string(char const *c) {return to_string(string(c));}
string to_string(bool const &b) {return (b ? "T" : "F");}
template<typename... Args> string to_string(pair<Args...> const&p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&S)
{string s = "{"; for(auto const& e: S)s+=" "+to_string(e);s+=" }"; return s;}
template<typename Tail> void debug_out(Tail t) {cerr<<" "<<to_string(t)<<" ]"<<endl;}
template<typename Head, typename... Tail> void debug_out(Head h, Tail... t)
{cerr << " " << to_string(h) << ","; debug_out(t...);}
#define pr(...) cerr<<"["<<(#__VA_ARGS__)<<"] : [", debug_out(__VA_ARGS__)
template <typename T> void dbr(T lb, T ub)
{cerr<<'{';for(auto it=lb; it!=ub; it++)cerr<<' '<<to_string(*it); cerr<<" }"<<endl;}
template<typename T, typename Comp=less<T>> bool smin(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(v, mem) ? mem = v, true : false;}
template<typename T, typename Comp=less<T>> bool smax(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(mem, v) ? mem = v, true : false;}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

int const N = 1010;
int n;
vi a[N];

int const V = 1000100;
vector< int > g[V];
int vis[V];
int dp[V];

void dfs(int u) {
  vis[u] = 2;
  dp[u] = 0;
  for(int v: g[u]) {
    if( vis[v] != 0 ) {
      if( vis[v] == 2 ) {
	cout << -1 << endl;
	exit(0);
      } else {
	smax(dp[u], dp[v]+1);
      }
    } else {
      dfs(v);
      smax(dp[u], dp[v]+1);
    }
  }
  vis[u] = 1;
}

inline void add_edge(int x, int y, int p, int q) {
  if( x > y ) swap(x, y);
  int u = n * x - n + y;
  if( p > q ) swap(p, q);
  int v = n * p - n + q;
  g[u].emplace_back(v);
}

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

  cin >> n;
  for(int i=1; i<=n; i++) {
    a[i].resize(n-1);
    for(int& v: a[i]) cin >> v;
  }

  for(int i=1; i<=n; i++) {
    for(int j=1; j<(int)a[i].size(); j++) {
      add_edge(i, a[i][j-1], i, a[i][j]);
    }
  }

  fill(vis, vis+V, 0);  
  fill(dp, dp+V, 0);
  for(int i=1; i<=n*n; i++) {
    if( vis[i] == 0 ) dfs(i);
  }

  cout << 1+*max_element(dp+1, dp+1+n*n) << endl;  

}


Measured memory_bytes: 51200
//
// Created by yamunaku on 2020/03/28.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n, x, y;
    cin >> n >> x >> y;
    x--, y--;
    vi ans(n, 0);
    rep(i, n){
        repl(j, i + 1, n){
            int d = j - i;
            d = min(d, abs(x - i) + abs(y - j) + 1);
            ans[d]++;
        }
    }
    repl(i, 1, n)cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256