akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

class Main{

  public static void main(String[] args)throws IOException{
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int id;
    int r;
    int l;
    int root = 0;
    Nodes nodes = new Nodes();
    Node[] node = new Node[n];
    nodes.nodes = node;

    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

    for(int i=0 ; i<n ; i++){
      node[i] = new Node(i);
    }

    for(int i=0 ; i<n ; i++){
      /*StringTokenizer S = new StringTokenizer(bf.readLine());
      id = Integer.parseInt(S.nextToken());
      l = Integer.parseInt(S.nextToken());
      r = Integer.parseInt(S.nextToken());*/

      /*String[] s = bf.readLine().split(" ");
      id = Integer.parseInt(s[0]);
      l = Integer.parseInt(s[1]);
      r = Integer.parseInt(s[2]);*/
      id = scan.nextInt();
      l = scan.nextInt();
      r = scan.nextInt();
      if( l!=-1 ){
        node[id].l = l;
        node[l].parent = id;
      }
      if( r!=-1){
        node[id].r = r;
        node[r].parent = id;
      }
    }

    while(node[root].parent != -1){
      root = node[root].parent;
    }
    System.out.println("Preorder");
    nodes.Preord(root);
    System.out.println("\r\nInorder");
    nodes.Inord(root);
    System.out.println("\r\nPostorder");
    nodes.Postord(root);
    System.out.println();

  }
}

class Node{
  int id;
  int parent = -1;
  int r = -1;
  int l = -1;

  public Node(int id){
    this.id = id;
  }
}

class Nodes{
  Node[] nodes;

  public void Preord(int id){
    if( id==-1){
      return ;
    }
    System.out.print(" " + id);
    Preord(nodes[id].l);
    Preord(nodes[id].r);
    }

  public void Inord(int id){
    if( id==-1 ){
      return ;
    }
    Inord(nodes[id].l);
    System.out.print(" " + id);
    Inord(nodes[id].r);
  }

  public void Postord(int id){
    if( id==-1 ){
        return ;
    }
    Postord(nodes[id].l);
    Postord(nodes[id].r);
    System.out.print(" " + id);
  }
}



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

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

  for (int i = 0; i < N; i++) {
    string x;
    cin >> x;
    if (x == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if (i == N-1)
      cout << "Three" << endl;
  }

}


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

int main()
{
     int a, b, c;
  cin >> a >> b >> c;
  if(a==b && b==c) {cout<< 1 ;}
  else if(a!=b && b==c) {cout<<2 ;}
  else if(b!=c && c==a) {cout<<2;}
  else if(c!=a && a==b) {cout<<2 ;}
  else{cout<<3 ;}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,x,y,st,md,ed,p=0,q=0;
long long gcd(long long l,long long r)
{
	if(r==0)
	{
		return l;
	}
	return gcd(r,l%r);
}
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a,&b);
		x=a/gcd(a,b);
		y=b/gcd(a,b);
		st=1;
		ed=1e18/max(x,y);
		while(ed>=st)
		{
			md=(st+ed)/2;
			if(x*md>=p&&y*md>=q)
			{
				ed=md-1;
			}else
			{
				st=md+1;
			}
		}
		//printf("%d %d %d\n",st,md,ed);
		p=(st*x);
		q=(st*y);
		//printf("%d %d\n",p,q);
	}
	printf("%lld\n",p+q);
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  vl a(n);
  vll x(20, vl(20));
  vll y(20, vl(20));
  rep(i,n){
    cin >> a[i];
    rep(j,a[i]){
      cin >> x[i][j] >> y[i][j];
    }
  }
  ll max = 0;
  for (int tmp = 0; tmp < (1 << n); tmp++){
    bitset<15> s(tmp);
    bool OK = true;
    ll count = 0;
    rep(i,n){
      if (s[i]){
        rep(j,a[i]){
          if(y[i][j]!=s[x[i][j]-1]){
            OK = false;
          }
        }
        count++;
      }
    }
    if(OK){
      chmax(max, count);
    }
  }
  print(max);
}

Measured memory_bytes: 3580
S = input()
S1 = S[0:(len(S)-1)//2]
S2 = S[(len(S)-1)//2+1:len(S)]

def discrimination(S):
    N = len(S)
    if N%2==0:
        return all(S[i]==S[N-1-i] for i in range(N//2))
    else:
        return all(S[i]==S[N-1-i] for i in range((N-1)//2))

if discrimination(S) and discrimination(S1) and discrimination(S2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
while True:
    h, w = map(int, input().split())
    if w == 0 and h == 0:
        break
    for i in range(1, h+1):
        if i == 1 or i == h:
            print("#"*w)
        else:
            print('#'+'.'*(w-2)+'#')
    print()



Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    string S;
    cin >> N >> S;
    // 0 = 狼　1 = 羊
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 2; j++) {
            vector<int>ans(N);
            ans[0] = i;
            ans[1] = j;
            for(int k = 2; k < N; k++) {
                if((S[k-1] == 'o' && ans[k-1] == 1) || (S[k-1] == 'x' && ans[k-1] == 0)) {
                    ans[k] = ans[k-2];
                }
                else {
                    ans[k] = (ans[k-2]^1);
                }
            }
            if(((S[0] == 'o' && ans[0] == 1) || (S[0] == 'x' && ans[0] == 0)) && ans[1] != ans[N-1]) {
                continue;
            }
            if(((S[0] == 'x' && ans[0] == 1) || (S[0] == 'o' && ans[0] == 0)) && ans[1] == ans[N-1]) {
                continue;
            }
            if(((S[N-1] == 'o' && ans[N-1] == 1) || (S[N-1] == 'x' && ans[N-1] == 0)) && ans[0] != ans[N-2]) {
                continue;
            }
            if(((S[N-1] == 'x' && ans[N-1] == 1) || (S[N-1] == 'o' && ans[N-1] == 0)) && ans[0] == ans[N-2]) {
                continue;
            }
            for(int i = 0; i < N; i++) {
                if(ans[i]) {
                    cout << "S";
                }
                else {
                    cout << "W";
                }
            }
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 4448
#include <stdio.h>

int main(void)
{
  int n;
  int a, b, c;
  scanf("%d", &n);
  c = n % 10;
  n /= 10;
  b = n % 10;
  n /= 10;
  a = n % 10;
  if (a == 1)
    a = 9;
  else
    a = 1;
  if (b == 1)
    b = 9;
  else
    b = 1;
  if (c == 1)
    c = 9;
  else
    c = 1;
  printf("%d", a * 100 + b * 10 + c);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    vint a(N,0);
    REP(i,N){
        int t; cin>>t;
        a[t-1]++;
    }
    sort(ALL(a),greater<int>());

    int ans=0;
    REP(i,K){
        ans+=a[i];
    }
    ans=N-ans;

    cout<<ans<<endl;
}


Measured memory_bytes: 1792
n = int(input())
a_list = [0] + list(map(int, input().split()))
b_list = [0] + list(map(int, input().split()))
c_list = [0] + list(map(int, input().split()))

sum = sum(b_list)

for i in range(1, n):
    if a_list[i] + 1 == a_list[i+1]:
        sum += c_list[a_list[i]]

print(sum)

Measured memory_bytes: 9092
#include<bits/stdc++.h>
#define IO cin.tie(0),ios::sync_with_stdio(0);
#define ff first
#define ss second
#define eb emplace_back
#define iter(v) v.begin() ,v.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define print(v) for(auto x: v) cout<<x<<' ';
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vec;

int main()
{
    int h,a;
    cin>>h>>a;
    cout<<ceil(h/(double)a);
    return 0;
}


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

int modPow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}

int main() {
  ll ans;
  ll xa = 1; 
  ll ya = 1; 
  ll xb = 1; 
  ll yb = 1;
  ll n,a,b;
  cin >> n >> a >> b;
  const ll p = 1e9 + 7;
  rep(i,a) {
    xa = (xa*(n-i%p))%p ;
    ya = (ya*modPow(i+1, p-2, p))%p;
  }
  rep(i,b) {
    xb = (xb*(n-i%p))%p ;
    yb = (yb*modPow(i+1, p-2, p))%p;
  }
  ans = modPow(2, n, p)-1;
  ll nCa = (xa*ya)%p ;
  ll nCb = (xb*yb)%p ;
  ans = ans - nCa -nCb;
  while(ans < 0) ans = ans + p;
  cout << ans << endl;
}

Measured memory_bytes: 256
import Control.Monad

main :: IO ()
main = do
  ra <- getLine
  if ra == "0 0"
    then return ()
    else do
      putStrLn $ solve ra
      main

solve :: String -> String
solve rs = toStr (check (words rs))
  where
    toStr :: (Int,Int) -> String
    toStr (a,b) = (show a) ++ " " ++ (show b)
    
    check :: [String] -> (Int,Int)
    check [r,a] = check' [r,a] r (0,0)
      where
        check' :: [String] -> String -> (Int,Int) -> (Int,Int)
        check' _ [] (a,b) = (a,b)
        check' [xs, (y:ys)] (z:zs) (a,b)
          | y == z = check' [xs,ys] zs (a+1,b)
          | elem y xs = check' [xs,ys] zs (a,b+1)
          | otherwise = check' [xs,ys] zs (a,b)

Measured memory_bytes: 4004
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int n = sc.nextInt();

        ArrayList<Integer> arr = new ArrayList<>();
        int ans = 0;
        for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            arr.add(a);
        }
        for (int i = 1; i<(n-1); i++){
            if (arr.get(i) > arr.get(i-1) && (arr.get(i) < arr.get(i+1))){
                ans++;
            }
            else if (arr.get(i) < arr.get(i-1) && (arr.get(i) > arr.get(i+1))){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

#ifdef OJ
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#else
#define debug(x)
#define debugv(x)
#endif

#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 2e5+3;
const int INF = 1e9;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    vector<int> a(n);
    set<int> s;
    map<int,int> cnt;
    fori(i,n) {
        cin >> a[i];
        s.insert(a[i]);
        cnt[a[i]]++;
    }
    vector<int> b(1e6+1);
    for(int x: s) {
        for(int p = x*2; p <= 1e6; p += x) 
            b[p] = 1;
    }

    int ans = 0;
    fori(i,n) {
        if(b[a[i]] || cnt[a[i]] > 1)  ans++;
    }
    cout << n-ans;

    //int ntest; cin >> ntest; while(ntest--) 
    //{
    //}
    cout << '\n';
    return 0;
}


Measured memory_bytes: 26668
#include<iostream>
#include<string>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;

typedef tuple<int, string, int> mytuple;


bool compare(const mytuple &lhs, const mytuple &rhs){
    if(get<1>(lhs) != get<1>(rhs)) return get<1>(lhs)<get<1>(rhs);
    return get<2>(lhs)>get<2>(rhs);
}

int main(){
    int N; cin >> N;
    string S;
    int P;
    vector<mytuple> SP(N);
    
    for(int i=0; i<N; i++){
      cin >> S >> P;
      SP[i] = make_tuple(i+1, S, P);
    }

    sort(SP.begin(), SP.end(), compare);

    for(int i=0; i<N; i++){
        cout << get<0>(SP[i]) << endl;
    }



}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc= new Scanner(System.in);
		
		int R= sc.nextInt();
		
		sc.close();
		
		double ans= 2* R *Math.PI;
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 36008
n,m = map(int,input().split())
ab = []
for i in range(n):
	a,b = map(int,input().split())
	ab.append((a,b))
ab.sort()

ans = 0
for i in ab:
	if m <= i[1]:ans+=m * i[0]
	else:ans+=i[0] * i[1]
	m-=i[1]
	if m < 0:break

print(ans)

Measured memory_bytes: 16892
n=int(input())
a=list(map(int,input().split()))

def gcd(a,b):
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)

ans=gcd(a[0],a[1])
if n>2:
  for i in range(2,n):
    ans=gcd(ans,a[i])
print(ans)

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N =1e5+100;

int main()
{
    ll n;
    while(~scanf("%lld",&n))
    {
        ll A[N],B[N];
        for(int i=1;i<=n+1;i++)
            scanf("%lld",&A[i]);
        for(int i=1;i<=n;i++)
            scanf("%lld",&B[i]);
        ll sum =0;
        for(int i=1;i<=n;i++)
        {
            if(B[i]<A[i])
                sum +=B[i];
            else
            {
                sum +=A[i];
                B[i] -=A[i];
                if(B[i]<A[i+1])
                    sum +=B[i],A[i+1] -=B[i];
                else
                    sum +=A[i+1],A[i+1] =0;
            }
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 1792
import math
a, b, c, d = map(int, input().split())
e = c * d //math.gcd(c, d)
ans = b - a + 1
cnt_of_c = (b // c) - ((a - 1) // c)
cnt_of_d = (b // d) - ((a - 1) // d)
cnt_of_e = (b // e) - ((a - 1) // e)
ans -= cnt_of_c + cnt_of_d - cnt_of_e
#print(cnt_of_c, cnt_of_d, cnt_of_e)
print(ans)

Measured memory_bytes: 62116
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define N 1001
#define rep(i,n) for (int i=0; i < int(n); i++)
using namespace std;


struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }

  int count(){
    vector<int> p = par;
    sort(p.begin(),p.end());
    return unique(p.begin(),p.end())-p.begin();
  }
};


int fibo(int n)
{
  if(n<=0){
    return 1;
  }
  //printf(" %d",n);
  return fibo(n-1)+fibo(n-2);
}


int main()
{
  int v,d;

  while(true){
    if(scanf("%d %d",&v,&d)!=2)return 0;
  

    int a[v];
  
    a[0]=2;
    a[1]=3;
    for(int i=2;i<v;i++){
      a[i]=(a[i-1]+a[i-2])%N;
    }
  
    //for(int i=0;i<v;i++)printf("a[%d]:%d\n",i,a[i]);
    //printf("1");

    UnionFind uf(v);
  
  
    for(int i=0;i<v;i++){
      for(int j=0;j<v;j++){
	int m = a[i] - a[j];
	if((m>0 && m<d) || (m<0 && -m<d) || m==0){
	  uf.unite(i,j);
	}
      }
    }
  
  
    cout << uf.count() << endl;
  }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

struct mint{
    static const long long MOD = 2019;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};


int main(){
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    array<ll, 2019> dp[2];
    fill(dp[0].begin(), dp[0].end(), 0);
    fill(dp[1].begin(), dp[1].end(), 0);

    ll ans = 0;
    REP(i, s.size()){
        const ll cur = (i + 1) % 2;
        const ll prev = i % 2;
        const ll d = s.at(i) - '0';
        REP(v, dp[prev].size()){
            dp[cur].at(mint(10 * v + d).v) = dp[prev].at(v);
        }
        dp[cur].at(d) += 1;
        ans += dp[cur].at(0);
    }
    cout << ans << endl;
    return 0;
}


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

#include <iostream>

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int main()
{
 lint x;
  cin >> x;
  cout << (x/500)*1000 + (x%500)/5*5;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  char s[6];
  
  scanf("%s", s);
  if( s[2] == s[3] ){
    if( s[4] == s[5] ){
      printf("Yes\n");
      return 0;
    }
  }
  
  printf("No\n");
      return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  if(c =='a'||c =='e'||c=='i'||c=='o'||c=='u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" <<endl;
  }

}

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

int solveProblem(int n , int a ,int b){
	int cost = n*a;
  	return min(cost,b);
}

int main(){
 	int n,a,b;
  	cin>>n>>a>>b;
  	int ans = solveProblem(n,a,b);
  	cout<<ans;
}

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

using namespace std;

int main()
{
  int n;
  cin>>n;
  int a[4][3][10]={{{}}};
  int b,f,r,v;
  for(int i=0;i<n;i++){
    cin>>b>>f>>r>>v;
    a[b-1][f-1][r-1]= a[b-1][f-1][r-1]+v;
  }
  
  for(int i=0;i<4;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++){    
	cout<<" "<<a[i][j][k];
      }
      cout<<endl;
    }
    if(i!=3)cout<<"####################"<<endl;
  }
  return 0;
}





Measured memory_bytes: 3116
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/

const int maxn = 55;
char a[maxn][maxn], b[maxn][maxn];

int main()
{
	int n, m, ans = 0;
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++){
		scanf("%s", a[i]);
	}
	for (int i = 0; i < m; i++){
		scanf("%s", b[i]);
	}
	for (int i = 0; i <= n - m; i++){
		for (int k = 0; k <= n - m; k++){
			int fg = 1;
			for (int j = 0; j < m; j++){
				if (strncmp(b[j], a[i + j] + k, m) != 0){
					fg = 0;
					break;
				}
			}
			if (fg){
				ans = 1;
				break;
			}
		}
		if (ans){
			break;
		}
	}
	puts(ans ? "Yes" : "No");
}

Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,i,j,cc=0,v=0;
    cin>>n;
    ll ara[n];
    for(i=0;i<n;i++)cin>>ara[i];
    map<ll,ll>check;
    ll mx=0;
    for(i=0;i<n;i+=2){
        check[ara[i]]++;
        if(mx<check[ara[i]]){
            mx=check[ara[i]];
            v=ara[i];
        }
    }
    ll x=(n/2)-mx;
    //cout<<v<<endl;
    mx=0;
    check.clear();
    for(i=1;i<n;i+=2){
        check[ara[i]]++;
        if(mx<check[ara[i]] && ara[i] != v){
            mx=check[ara[i]];
        }
    }
    x+=(n/2)-mx;//cout<<mx<<endl;
    mx=0;
    v=0;
    check.clear();
    for(i=1;i<n;i+=2){
        check[ara[i]]++;
        if(mx<check[ara[i]]){
            mx=check[ara[i]];
            v=ara[i];
        }
    }
     ll y=(n/2)-mx;
    mx=0;
    check.clear();
        for(i=0;i<n;i+=2){
        check[ara[i]]++;
        if(mx<check[ara[i]] && v != ara[i]){
            mx=check[ara[i]];
        }
    }
    y+=(n/2)-mx;
    cout<<min(x,y)<<endl;
return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll A[40];

int main(){
    ll N,M;
    cin >> N >> M;
    rep(i,N){
        ll K;cin >> K;
        rep(j,K){
            ll a;
            cin >> a;
            A[a]++;
        }
    }
    ll ans = 0;
    rep(i,M+1){
        if(A[i] == N)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int SIZE = 1e6+5;
char str[SIZE];
ll l[SIZE];
ll r[SIZE];
ll rsum[SIZE];
ll rr[SIZE];
int main(){
    int n;scanf("%d",&n);
    scanf("%s",str+1);
    int q;scanf("%d",&q);
    for(int i = 1;i <= n;i++){
        if(str[i]=='D'){
            l[i] = l[i-1]+1;
            r[i] = r[i-1];
            rsum[i] = rsum[i-1];
            rr[i] = rr[i-1];
        }
        else if(str[i]=='M'){
            l[i] = l[i-1];
            r[i] = l[i-1];
            rsum[i] = rsum[i-1]+r[i];
            rr[i] = rr[i-1]+1;
        }
        else{
            l[i] = l[i-1];
            r[i] = r[i-1];
            rsum[i] = rsum[i-1];
            rr[i] = rr[i-1];
        }
    }


    while(q--){
        int k;scanf("%d",&k);
        ll res = 0;
        for(int i=1;i<=n;i++){
            if(str[i]=='C'){
                if(i>k)res += rsum[i]-rsum[i-k]-l[i-k]*(rr[i]-rr[i-k]);
                else res += rsum[i];
            }
        }
        printf("%lld\n",res);




    }
}

/*

#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;
ll a[1010];
ll ass[1010];
ll as[500050];
int bit[65];
int main()
{
    //cout<<(((1<<(4-1))&8))<<endl;
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        ass[i]=a[i]+ass[i-1];
    }
    int tot=0;
    ll maxn=-1;
    for(int i=0;i<=n-1;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            as[++tot]=ass[j]-ass[i],maxn=max(maxn,as[tot]);
           // cout<<as[tot]<<endl;
        }

    }
    //cout<<"maxn="<<maxn<<endl;
    n=tot;
    int st=0,x=maxn;
    for(int i=0;i<64;i++)
    {
        if(x<pow(2,i)) break;
       // if(((1<<(i−1))&x)>0)
       // {
        //    st=i;
        //}
        if((((1ll*1)<<(i))&x)>0)
            st=i;
    }
    //cout<<"st="<<st<<endl;
    ll asum=0;
    for(ll i=40;i>=0;i--)
    {

        int tsum=0;
        for(int j=1;j<=n;j++)
        {
            if(as[j]==-1) continue;
            if(((1ll*1)<<i)>as[j]) continue;
            if((((1ll*1)<<(i))&as[j])>0)
            {
                tsum++;
            }
        }
        if(tsum>=k)
        {
             for(int j=1;j<=n;j++)
             {
                if(as[j]==-1) continue;
                if((((1ll*1)<<(i))&as[j])<=0)
                {
                    as[j]=-1;
                }
               // else cout<<pow(2,i)<<" "<<as[j]<<endl;
             }
             asum+=1<<i;
            // cout<<i<<" "<<tsum<< " "<<pow(2,i)<<endl<<endl;
        }

    }
    printf("%lld\n",asum);
}


*/


Measured memory_bytes: 32512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	long long x, y, z;
	long long s, ans;
	scanf("%lld", &x);
	ans = 0;
	for (long long i = 1; i < 1000010; i++) {
		if (x%i == 0) {
			y = x / i;
			y--;
			if (i < y)ans+=y;
		}
	}


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


	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define lli long long int
#define pb push_back
#define pob pop_back
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define repv(a,b) for(int i=a;i>=b;i--)
#define itr vector<lli> :: iterator
#define maximum(a,b,c)  max(a,max(b,c))
#define minimum(a,b,c) min(a,min(b,c))
#define tim clock_t
#define db double
inline void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}


void solve(lli n)
{
	
}
	
int main()
{
	fast();
	
	lli t,n;
	string s;
	cin>>n;
	db a[n],x,sum=0,y;
	rep(i,0,n)
	{
		cin>>x;
		y=(1/x);
		sum+=y;
	}
	x=1/sum;
	printf("%.15lf",x);

	return 0;
}



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

int main(void){

    int N, X;

    scanf("%d%d", &N, &X);

    int min = 100000;

    int m[N];
    int sum = 0;

    for(int i = 0; i < N; i++){
        scanf("%d", &m[i]);
        if(m[i] < min){
            min = m[i];
        }
        sum += m[i];
    }

    int ans = N;

    ans += (X - sum) / min;

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

    return 0;
}

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

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

    int digit = 6;
    double r;
    cin >> r;
    cout << fixed << setprecision(digit) << (M_PI * r * r) << " ";
    cout << fixed << setprecision(digit) << (2 * M_PI * r) << endl;
}


Measured memory_bytes: 3256
from heapq import heappop, heappush, heapify
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
heap = list(map(int, input().split()))
heapify(heap)

BC = []
for _ in range(M):
    B, C = map(int, input().split())
    BC.append([B, C])
BC.sort(key=lambda x: -x[1])

for B, C in BC:
    for _ in range(B):
        tmp = heappop(heap)
        if tmp < C:
            heappush(heap, C)
        else:
            heappush(heap, tmp)
            break
print(sum(heap))

Measured memory_bytes: 88884
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

constexpr int P = 1000000007;

int inv(int n) {
    int m = P, y = 0, v = 1;
    while (1) {
        int q = m / n;
        int r = m % n;
        if (r == 0) return v < 0 ? v + P : v;
        y -= v * q;
        swap(y, v);
        m = n;
        n = r;
    }
}

int64_t dd, ans;

struct Graph {
    struct Edge {
        bool operator<(const Edge& o) const {
            return c > o.c; // 逆
        }
        int i;
        int64_t c;
    };
    Graph(int n) : a(n), e(n) {
        for (int i = 0; i < 4; i++) {
            vv[i] = vector<int64_t>(n);
        }
    }
    void add_edge(int i, int j, int c) {
        e[i].push_back({ j, c });
    }
    void dijkstra(int i, int idx) {
        priority_queue<Edge> q;
        auto& v = vv[idx];
        auto& u = vv[idx + 2];
        fill(v.begin(), v.end(), (int64_t)1 << 60);
        q.push({ i, v[i] = 0 });
        while (!q.empty()) {
            auto p = q.top(); q.pop();
            if (p.c > v[p.i]) continue;
            for (const auto& o : e[p.i]) {
                int64_t c = p.c + o.c;
                if (c < v[o.i]) q.push({ o.i, v[o.i] = c });

                if (v[o.i] == p.c - o.c) u[p.i] += u[o.i];
            }
            u[p.i] %= P;
        }
    }
    void dfs(int i, int idx) {
        auto& v = vv[idx];
        int64_t c = v[i];
        //cout << c << ' ' << vv[2][i] << ' ' << vv[3][i] << endl;
        if (a[i]) return; else a[i] = 1;

        if (c * 2 == dd) {
            int64_t t = vv[2][i] * vv[3][i] % P;
            ans += t * t;
            ans %= P;
        }

        for (Edge& o : e[i]) {
            if (v[o.i] != c + o.c || vv[idx ^ 1][o.i] != dd - (c + o.c)) continue;

            if (c * 2 < dd && v[o.i] * 2 > dd) {
                int64_t t = vv[2][i] * vv[3][o.i] % P;
                ans += t * t;
                ans %= P;
            }

            dfs(o.i, idx);
        }
    }
    vector<int64_t> vv[4];
    vector<int> a;
    vector<vector<Edge>> e;
};

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

    int n, m;
    cin >> n >> m;

    int s[2];
    cin >> s[0] >> s[1];
    s[0]--; s[1]--;

    Graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;

        g.add_edge(a, b, c);
        g.add_edge(b, a, c);
    }

    for (int i = 0; i < 2; i++) {
        g.vv[i + 2][s[i]] = 1;
        g.dijkstra(s[i], i);
    }
    dd = g.vv[0][s[1]];
    g.dfs(s[0], 0);

    int64_t t = g.vv[2][s[1]];
    ans = t * t - ans;
    ans %= P;
    if (ans < 0) ans += P;

    cout << ans << endl;

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(v) cout<<v<<"\n"

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

  int m[9]; fill(m, m+9, 0);
  rep(i, N) {
    int a; scanf("%d", &a);
    ++m[min(8, a / 400)];
  }
  int ans = 0;
  rep(i, 8)
    if (m[i] > 0) ++ans;
  if (ans == 0)
    printf("1 %d\n", m[8]);
  else
    printf("%d %d\n", ans, ans + m[8]);

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())

l = [0 for i in range(100)]
l[0] = 2
l[1] = 1

if(n==1):
    print(1)
else:
    for i in range(2,n+1):
        l[i] = l[i-1]+l[i-2]
    print(l[n])

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)

{

int a,b;

 scanf("%d %d",&a,&b);

if(a > b){

  printf ("a > b\n");

}else if (a < b){

  printf ("a < b\n");

}else if(a == b){

  printf ("a == b\n");

}

return 0;

}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int h,r;cin>>h>>r;
    if(h==-r){
        cout<<0<<endl;
    }else if(h>-r){
        cout<<1<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}



Measured memory_bytes: 3096
<?php
function pat($a, $s = '')
{
  $r = array();
  if (count($a) && is_array($a)) {
    //第1引数に文字の配列を渡されたらループして処理
    foreach ($a as $k => $v) {
      //文字の配列から1文字もらってこちらにくっつけて
      $_s = $s . $v;
      //もらった1文字を除いた文字の配列を作って
      $_a = $a;
      unset($_a[$k]);
      //再帰呼び出し
      $_r = pat($_a, $_s);
      //返り値にする変数に結果を追加
      $r = array_merge($r, $_r);
    }
  } else {
    //第1引数が空っぽの配列だったら、再帰呼び出しはここでストップ
    //返り値はこれだけ
    $r[] = $s;
  }
  return $r;
}

$a = array('1', '2', '3', '4', '5', '6', '7', '8');
fscanf(STDIN, "%d", $N);
$P = explode(" ", trim(fgets(STDIN)));
$Q = explode(" ", trim(fgets(STDIN)));

if ($P == $Q){
    echo 0;
    die();
}
$input = array_slice($a, 0, $N);
foreach(pat($input) as $key => $value){
    if ($value == implode($P)){
        $minimum = $key;
    } elseif ($value == implode($Q)){
        $maximum = $key;
    }
}
echo abs($minimum - $maximum);

Measured memory_bytes: 15196
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define fa(a,c) for(auto &a:c)
#define yes "YES"
#define no "NO"




int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin>>s;
int ans;
if(s=="SUN")ans=7;
if(s=="MON")ans=6;
if(s=="TUE")ans=5;
if(s=="WED")ans=4;
if(s=="THU")ans=3;
if(s=="FRI")ans=2;
if(s=="SAT")ans=1;

cout<<ans<<endl;


	return 0;
}


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

ll dp[n];
dp[0]=0;
for(int i=1;i<n;i++){
    dp[i]=1ll<<31;
    for(int j=i-1;j>=max(i-k,0);j--)dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
}
cout<<dp[n-1]<<endl;
return 0;

}

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

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

	int n, x, y;
	cin >> n >> x >> y;
	vector<int> results(n);
	for (int i = 1; i <= n-1; i++) {
		for (int j = i + 1; j <= n; j++) {
			int first = abs(j-i);
			int second = abs(x-i) + 1 + abs(j-y);
			int distanceIndex = min(first, second);
			results[distanceIndex -1]++;
		}
	}
	rep(i, n-1) cout << results[i] << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define resort(v) sort((v).rbegin(), (v).rend())
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
int modpow(int a, int n, int mod) {
    int hi = 1;
    while (n > 0) {
        if (n & 1) hi = hi * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return hi;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
ll ans;
/*signed*/int main(void) {
    ll n;
    cin >> n;
    vector<ll> vec(n);
    vector<ll> ruiseki(n);
    rep(i, n) {
        cin >> vec[i];
        if (i == 0) ruiseki[i] = vec[i];
        else ruiseki[i] = ruiseki[i - 1] + vec[i];
        if (i != 0) {
            ans += vec[i] * (ruiseki[i - 1]%MOD);
        }
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6356
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    string input_str;
    cin >> input_str;
    if (input_str == "A")
    {
        cout << "T";
    }
    else if (input_str == "T")
    {
        cout << "A";
    }
    else if (input_str == "G")
    {
        cout << "C";
    }
    else if (input_str == "C")
    {
        cout << "G";
    }
    return 0;
}

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

int main()
{
	string s;
	int day = 0;;

	cin >> s;
	
	if (s == "SUN") day = 0;
	else if (s == "MON") day = 1;
	else if (s == "TUE") day = 2;
	else if (s == "WED") day = 3;
	else if (s == "THU") day = 4;
	else if (s == "FRI") day = 5;
	else if (s == "SAT") day = 6;
	
	printf("%d\n", 7 - day);
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int A, B, Q;

std::vector<uint64_t> s;
std::vector<uint64_t> t;

uint64_t dist(uint64_t x)
{
    uint64_t dist = 0;

    auto it_s = std::lower_bound(s.begin(), s.end(), x);
    auto it_t = std::lower_bound(t.begin(), t.end(), x);

    uint64_t s_right = 0;
    uint64_t s_left  = 0;
    uint64_t t_right = 0;
    uint64_t t_left  = 0;

    if (it_s == s.begin()) {
        s_left = 1000000000000;
    } else {
        s_left = x - *(it_s - 1);
    }

    if (it_s == s.end()) {
        s_right = 1000000000000;
    } else {
        s_right = *(it_s) - x;
    }

    if (it_t == t.begin()) {
        t_left = 1000000000000;
    } else {
        t_left = x - *(it_t - 1);
    }

    if (it_t == t.end()) {
        t_right = 1000000000000;
    } else {
        t_right = *(it_t) - x;
    }

    return std::min({std::max(s_left, t_left), std::max(s_right, t_right), s_right * 2 + t_left, s_left * 2 + t_right, t_right * 2 + s_left, t_left * 2 + s_right});
}

int main()
{
    std::cin >> A >> B >> Q;

    uint64_t buf;
    for (int i = 0; i < A; ++i) {
        std::cin >> buf;
        s.push_back(buf);
    }

    for (int i = 0; i < B; ++i) {
        std::cin >> buf;
        t.push_back(buf);
    }

    uint64_t x;
    for (int i = 0; i < Q; ++i) {
        std::cin >> x;
        std::cout << dist(x) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<set>
using namespace std;

const long long inf=1e18;
const int maxn=3e5+5;

multiset <int> s;
multiset <int,greater<int> > t;
long long a[maxn],b[maxn],c[maxn],n,now,ans;

int main()
{
	ans=-inf;
    cin>>n;
    for(long long i=1;i<=n*3;i++)
    {
        scanf("%lld",&a[i]);
        s.insert(a[i]);
        now=now+a[i];
        if(s.size()>n)
        {
            now-=*s.begin();
            s.erase(s.begin());
        }
        b[i]=now;
    }
    now=0;
    for(long long i=n*3;i>=1;i--)
    {
        t.insert(a[i]);
        now=now+a[i];
        if(t.size()>n)
        {
            now-=*t.begin();
            t.erase(t.begin());
        }
        c[i]=now;
    }
    for(long long i=n;i<=n*2;i++)
    {
        ans=max(ans,b[i]-c[i+1]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 16640
#include<iostream>
#include<queue>
#include<map>
#include<vector>
#include<stdlib.h>
using namespace std;
typedef pair<int,int> P;
main(){
  int h,w,n,count=0;
  P zahyou[10];
  queue<P> haba,syokika;
  char maps[1001][1001];
  int min_cost[1001][1001];
  P start,now;
  P kiokua;
  int dx[4]={0,1,0,-1};
  int dy[4]={1,0,-1,0};
  cin>>h>>w>>n;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>maps[i][j];
      min_cost[i][j]=-1;
      if(maps[i][j]=='S'){
	start.first=i;
	start.second=j;
	min_cost[i][j]=0;
      }
      else if(maps[i][j]!='.'&&maps[i][j]!='X'&&maps[i][j]!='S'){
	int a;
	for(int k=1;k<=9;k++){
	  if(maps[i][j]=='0'+k){
	    a=k;
	    break;
	  }
	}
	zahyou[a].first=i;
	zahyou[a].second=j;
      }
    }
  }
  haba.push(start);
  syokika.push(start);
  for(int i=1;i<=n;i++){
    while(!haba.empty()){
      if(haba.front().first==zahyou[i].first&&haba.front().second==zahyou[i].second){
	count=count+min_cost[haba.front().first][haba.front().second];
	while(!syokika.empty()){
	  min_cost[syokika.front().first][syokika.front().second]=-1;
	  syokika.pop();
	}
	min_cost[haba.front().first][haba.front().second]=0;
	kiokua=haba.front();
	while(!haba.empty()){
	  haba.pop();
	}
      }
      else{
	for(int j=0;j<4;j++){
	  int nx,ny;
	  nx=haba.front().first+dx[j];
	  ny=haba.front().second+dy[j];
	  if(nx>=0&&h>nx&&ny>=0&&w>ny&&min_cost[nx][ny]==-1&&maps[nx][ny]!='X'){
	    min_cost[nx][ny]=min_cost[haba.front().first][haba.front().second]+1;
	    P a;
	    a.first=nx;
	    a.second=ny;
	    haba.push(a);
	    syokika.push(a);
	  }
	}
	haba.pop();
      }
    }
    haba.push(kiokua);
    syokika.push(kiokua);
  }
  cout<<count<<endl;
}
      
	  

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
int N, sum;
  cin >> N;
  sum = 0;
  
  for(int i = 0;i < N;i++){
  int l, r;
    cin >> l >> r;
    sum += r - l + 1;
    
  }
  
  cout << sum << endl;
  
return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
using namespace std;
int main(){
	int n;
	cin >> n;
	cout << a[n - 1] << endl;
	return 0;
} 

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

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++)
	{
		cout << r * x - d << endl;
		x = r * x - d;
	}
	return 0;
}

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

int main(void){
  char s[101];
  scanf("%s", s);
  int a[26] = {0};
  
  for(int i = 0; i < strlen(s); i++){
    a[s[i] - 'a']++;
  }
  
  for(int i = 0; i < 26; i++){
    if(a[i] % 2 != 0){
      printf("No\n");
      return 0;
    }
  }
  
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 128