akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i = 0; i < (n); ++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;

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

    // idea: a number is "spellable"
    // if (m-p)*t + p*(n-t) = k. , where p and t are the # of flips on two directions
    // given a p, mt + pn - 2pt = k, t = (k - pn) / (m - 2p)
    
    int n, m, k;
    cin >> n >> m >> k;
    for (int p = 0; p <= m; p++) {
        int l1 = (k - p * n) , l2 = (m - 2 * p);
        if (l2 != 0 && l1 % l2 == 0 && (l1 / l2) <= n && (l1 / l2) >= 0) {
            cout << "Yes" << endl; exit(0);
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
n = gets.to_i
line = gets.chomp

count = 0
ind = 0
rind = n - 1
front = true
n.times do
  break if ind - 1 == rind

  if front
    if line[ind] == "W"
      count += 1
      front = false
    end
    ind += 1
  else
    front = line[rind] == "R"
    rind -= 1
  end
end

count -= 1 if !front
puts count

Measured memory_bytes: 14668
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-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 main() {
    ll h,w;
    cin>>h>>w;
    if(h*w%3==0){
        cout<<0<<endl;
        return 0;
    }
    else{
        ll s1,s2,s3;
        ll MIN = 1000000000;
        for(ll i=1;i<h;i++){
            s1 = i * w;
            s2 = (h-i) * (w/2);
            s3 = h*w - s1 - s2;
            MIN=min(MIN,max(max(s1,s2),s3)-min(min(s1,s2),s3));

            s2 = (h-i)/2 * w;
            s3 = h*w - s1 - s2;
            MIN=min(MIN,max(max(s1,s2),s3)-min(min(s1,s2),s3));
        }

        for(ll i=1;i<w;i++){
            s1 = i * h;
            s2 = (w-i) * (h/2);
            s3 = h*w - s1 - s2;
            MIN=min(MIN,max(max(s1,s2),s3)-min(min(s1,s2),s3));

            s2 = (w-i)/2 * h;
            s3 = h*w - s1 - s2;
            MIN=min(MIN,max(max(s1,s2),s3)-min(min(s1,s2),s3));
        }


        cout<<MIN<<endl;
        return 0;
    }






    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        long[] a = new long[n];

        long sum = 0;
        int count = 0;
        for (int i = 0; i < n; i++) {
            int j = scanner.nextInt();
            if (j < 0)
                count++;

            sum += a[i] = Math.abs(j);
        }

        if (count % 2 == 0) {
            System.out.println(sum);
        } else {
            long min = Arrays.stream(a).min().getAsLong();
            System.out.println(sum - min * 2);
        }
    }
}

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

int main() {
  ll x, y; cin>>x>>y;
  if (x>y) swap(x, y);
  if (y-x>1) cout<<"Alice"<<endl;
  else cout<<"Brown"<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const ll INF=2e15;
const double PI=acos(-1);

vector<P> vectorCnt(vector<int> a) {
    sort(a.begin(),a.end());
    int n=a.size();
    vector<pair<int,int>> b;
    int cnt=1;
    rep(i,n-1) {
        if (a[i+1]!=a[i]) {
            b.push_back({cnt,a[i]});
            cnt=1;
        } else {
            ++cnt;
        }
    }
    b.push_back({cnt,a[n-1]});
    return b;
}

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

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end()); 
    int j=lower_bound(a.begin(),a.end(),a[n-1]/2)-a.begin();
    int ind;
    if (j==0) ind=0;
    else if (j==n-1) ind=n-2;
    else if (a[n-1]-a[j]>a[j-1]) ind=j;
    else ind=j-1;
    cout << a[n-1] << ' ' << a[ind] << endl;


    return 0;
}


Measured memory_bytes: 3972
import java.util.Scanner;

public class Main {
	int n;
	public static void main(String args[]) {
		new Main().run();
	}
	Main() {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
	}
	void run() {
		Node n1 = new Node(0,0);
		Node n2 = new Node(100,0);
		System.out.println(n1);
		koch(n1,n2,n);
		System.out.println(n2);
	}
	void koch(Node n1, Node n2,int depth) {
		if (depth == 0)
			return;
		double sx = (n1.x * 2 + n2.x) / 3;
		double sy = (n1.y * 2 + n2.y) / 3;
		Node s = new Node(sx,sy);
		double tx = (n1.x + n2.x * 2) / 3;
		double ty = (n1.y + n2.y * 2) / 3;
		Node t = new Node(tx,ty);
		double ux = (tx - sx) * Math.cos(Math.toRadians(60)) - (ty - sy) * Math.sin(Math.toRadians(60)) + s.x;
		double uy = (tx - sx) * Math.sin(Math.toRadians(60)) + (ty - sy) * Math.cos(Math.toRadians(60)) + s.y;
		Node u = new Node(ux,uy);
		koch(n1,s,depth-1);
		System.out.println(s);
		koch(s,u,depth-1);
		System.out.println(u);
		koch(u,t,depth-1);
		System.out.println(t);
		koch(t,n2,depth-1);
	}
}
class Node {
	double x,y;
	Node(double x,double y) {
		this.x = x;
		this.y = y;
	}
	public String toString() {
		return String.format("%.8f %.8f", this.x, this.y);
	}
}



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

int popcount(int x) {
  return __builtin_popcount(x);
}

int f(int x) {
  // ベースケース
  if (x == 0) {
    return 0;
  }
  // 再起ステップ
  return f(x % popcount(x)) + 1;
}


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

  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    x.at(i) = s.at(i) - '0';
  }

  // X0 の popcount
  int pc = 0;
  for (int i = 0; i < n; i++) {
    pc += x.at(i);
  }

  vector<int> ans(n, 0);
  for (int bit = 0; bit < 2; bit++) {
    int npc = pc;
    // bit = 0 の場合、0 から 1 に flip する
    // bit = 1 の場合、1 から 0 に flip する
    if (bit == 0) { npc++; } else { npc--; }

    // 例えば X0 が2進数で 10000 の場合 (10進数で16の場合)
    // pc = 1 となる。
    // 5桁目の 1 を 0 に flip すると npc = 0 となる。
    // 後続の処理で、ゼロ除算による Runtime Error が発生するケースがある。
    // そのため、ここで例外処理を行う。
    //
    // 2進数の 00000 は10進数の 0 である。
    // X0 = 10000 と仮定した場合、X1 = 00000 となる。
    // f(00000) について、0 の場合の操作回数は 0 である。
    //
    // vector を宣言した際に、各要素は 0 で初期化されているため、
    // 後続処理は行わなくてよく、ここで処理をスキップする。
    if (npc == 0) { continue; }

    // flip 後の popcount で x0 を割った余りを求める
    int r0 = 0;
    for (int i = 0; i < n; i++) {
      int sum = r0 * 2 + x.at(i);
      // 2進数を10進数に変換した後、余りを求めると、
      // int や long long 型の範囲を超えるため、都度、余りを求める
      r0 = sum % npc;
    }

    int k = 1;
    for (int i = n - 1; i >= 0; i--) {
      // bit = 0 の場合、0 から 1 に flip する
      // bit = 1 の場合、1 から 0 に flip する
      if (x.at(i) == bit) {
        int remainder = r0;
        // 0 から 1 に flip するので、余りを加算する
        // * 2進数 11011 の余りは 27 % 5 = 2
        // * 3ビット目の 0 を 1 に flip した場合、2**2 % 5 = 4 余りが増える
        // * X0 の余り (2) と flip して増加した X3 の余り (4) を合計すると 6 になる
        // * 6 は npc = 5 より大きいため、余りは 1 となる
        if (bit == 0) {
          remainder = (remainder + k) % npc;
        // 1 から 0 に flip するので、余りを減算する
        } else {
          remainder = (remainder - k + npc) % npc;
        }

        // remainder は「Xi を popcount(Xi) で割った余りに置き換える」
        // という操作を1回した結果である
        ans.at(i) = f(remainder) + 1;
      }

      // n 桁目のビットを反転させた際に、増減する余りの数
      // * 次のループで利用される
      k = (k * 2) % npc;
    }
  }

  for (int i = 0; i < n; i++) {
    cout << ans.at(i) << endl;
  }
  return 0;
}


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

s = input()
t = input()
ansstr = []

if(len(s)<len(t)):
    flg = False
for i in range(len(s)-len(t)+1)[::-1]:
    tmpstr = s[i:i+len(t)]
    flg = True
    for j in range(len(t)):
        if(tmpstr[j] == '?'):
            pass
        elif(tmpstr[j] == t[j]):
            pass
        else:
            flg = False
    if(flg):
        uset = list(range(i,i+len(t)))
        for k in range(len(s)):
            if(k in uset):
                ansstr += t[k-i]
            elif(s[k]=='?'):
                ansstr += 'a'
            else:
                ansstr += s[k]
        break
print(''.join(ansstr) if flg else 'UNRESTORABLE')     
        
        

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string k;
  ll d;
  cin>>k>>d;
  ll dp[10005][105][2];
  memset(dp,0,sizeof(dp));
  dp[0][0][0]=1;
  rep(i,sz(k)){
    rep(j,d){
      rep(z,2){
        rep(u,10){
          ll nd=k[i]-'0';
          ll ni=i+1;
          ll nj=(j+u)%d;
          ll nz=z;
          if(nz==0&&nd>u) nz=1;
          if(nz==0&&nd<u) continue;
          dp[ni][nj][nz]+=dp[i][j][z];
          dp[ni][nj][nz]%=MOD;
        }
      }
    }
  }
  ll ans=dp[sz(k)][0][1]+dp[sz(k)][0][0]-1;
  if(ans<0)ans+=MOD;
  COUT(ans%MOD);
}


Measured memory_bytes: 16640
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

int cnt[100002];

int main()
{
#ifdef LOCAL_JUDGE
    freopen("B.in", "r", stdin);
#endif
    int n;
    while (scanf("%d", &n) == 1) {
        int result = 0, cnt = 0;
        for (int i = 0, p; i < n; ++ i) {
            scanf("%d", &p);
            p --;
            if (p == i) {
                cnt ++;
            } else {
                result += cnt + 1 >> 1;
                cnt = 0;
            }
        }
        result += cnt + 1 >> 1;
        printf("%d\n", result);
    }
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if(a + b > c + d){
    cout << "Left\n";
  }else if(a + b < c + d){
    cout << "Right\n";
  }else{
    cout << "Balanced\n";
  }
  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
namespace alds18a
{
    class node{
        public int key;
        public node parent;
        public node left;
        public node right;

        public node(int key)
        {
            this.key = key;
        }
        public void writein()
        {
            if (left != null) left.writein();
            Console.Write(" ");
            Console.Write(key);
            if (right != null) right.writein();
        }
        public void writepre()
        {
            Console.Write(" ");
            Console.Write(key);
            if (left != null) left.writepre();
            if (right != null) right.writepre();
        }


    }
    class main
    {
        static void Main()
        {
            node root = null; ;
            int no = int.Parse(Console.ReadLine());
            for (int i = 0; i < no; i++)
            {
                string[] oder = Console.ReadLine().Split(' ');
                if (oder[0] == "insert")
                {
                    node x = root;
                    node y = null;
                    node z = new node(int.Parse(oder[1]));
                    while (x != null)
                    {
                        y = x;
                        if (z.key < x.key)
                            x = x.left;
                        else x = x.right;
                    }
                    z.parent = y;
                    if (y == null)
                    {
                        root = z;
                    }
                    else
                    {
                        if (z.key < y.key) y.left = z;
                        else y.right = z;
                    }
                }
                else
                {
                    root.writein();
                    Console.WriteLine();
                    root.writepre();
                    Console.WriteLine();
                }
            }
        }
    }
}

Measured memory_bytes: 43448
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define maxn 100005
LL m,s[maxn*2];
int a[maxn],b[maxn*2],n;
bool check(int x){
	LL sum=0;
	for(int i=0;i<n;i++){
		if(a[i]<=x)sum+=b[x-a[i]];
		else sum+=n;
	}
	return sum>=m;
}
int main(){
	scanf("%d%lld",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		b[a[i]]++,s[a[i]]+=a[i];
	}
	for(int i=99999;~i;i--)b[i]+=b[i+1],s[i]+=s[i+1];
	int l=0,r=2e5,mid;
	LL ans=0;
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid))l=mid+1;
		else r=mid-1;
	}
	for(int i=0;i<n;i++){
		if(a[i]>l)m-=n,ans+=1ll*a[i]*n+s[0];
		else m-=b[l-a[i]],ans+=1ll*a[i]*b[l-a[i]]+s[l-a[i]];
	}
	ans+=m*(l-1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m, x = MAP()
c = []
a = []
for i in range(n):
    A = LIST()
    c.append(A[0])
    a.append(A[1:])
ans = inf
for y in product([0,1], repeat=n):
    b = [0]*m
    tmp = 0
    for i in range(n):
        if y[i] == 1:
            tmp += c[i]
            for j in range(m):
                b[j] += a[i][j]
            if all(b[k]>=x for k in range(m)):
                ans = min(ans, tmp)
if ans == inf:
    ans = -1
print(ans)

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

#include <algorithm>
#include <array>
#include <chrono>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)

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

  if (N % 2 == 0) {
    cout << N << endl;
  } else {
    cout << 2 * N << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int solve(int a[], int size, int p, int m)
{
  if(m == 0){
    return(0);
  }

  if((size <= p) || (m < 0)){
    return(1);
  }else{
	  if(solve(a, size, p + 1, m - a[p]) == 0){
		  return(0);
	  }else if(solve(a, size, p + 1, m) == 0){
		  return(0);
	  }
  }
  return(1);
}

void intAryScan(int b[], int size)
{
  int i;
  for(i = 0; i < size; i++){
    scanf("%d", &b[i]);
  }
  return;
}

int main()
{
  int n, q, i;
  int A[20], M[200];

  scanf("%d", &n);
  intAryScan(A, n);
  scanf("%d", &q);
  intAryScan(M, q);

  for(i = 0; i < q; i++){
	  if(solve(A, n, 0, M[i]) == 0){
		  printf("yes\n");
	  }else{
		  printf("no\n");
	  }
  }

  return(0);
}

Measured memory_bytes: 580
require 'set'

class Graph
	def add_node(label = nil)
		Node.new(label)
	end

	def add_edge(u, v)
		e = Edge.new(u, v)
		u.outgoings << e
		v.incomings << e
		e
	end
	
	def del_edge(e)
		u, v = e.from, e.to
		u.outgoings.delete(e)
		v.incomings.delete(e)
		e
	end

	class Node
		def initialize(label)
			@label = label
			@outgoings = Set.new
			@incomings = Set.new
		end
		
		def to_s
			@label
		end

		attr_accessor :incomings, :outgoings
		attr_reader :label
	end

	class Edge
		def initialize(u, v)
			@from = u	
			@to = v
		end

		attr_reader :from, :to
	end

	def Graph::get_path_dfs(s, t, reached = Set.new)
		reached << s	
		s.outgoings.each{|e|
			v = e.to
			next if reached.include?(v)
			return [e] if v == t
			
			path = get_path_dfs(v, t, reached) 
			return [e] + path if path
		}
		nil
	end
end

class Forest < Graph
	def add_node(label = nil)
		Node.new(label)
	end

	def add_edge(u, v)
		raise "multiple in-edge" unless v.incomings.empty?
		e = Edge.new(u, v)
		u.outgoings << e
		v.incomings << e
		e
	end

	class Node < Graph::Node
		def parent
			a = incomings.to_a.map(&:from)
			a.empty? ? nil : a[0]
		end
	end

	class Edge < Graph::Edge
	end
end

loop {
	n, m = gets.split(" ").map(&:to_i)
	break if n == 0

	g = Forest.new
	stack = []
	name_to_node = {}

	n.times {
		gets =~ /^(\s*)(\w+)$/
		stack.pop until stack.size <= $1.size
		v = g.add_node($2)
		g.add_edge(stack.last, v) unless stack.empty?
		stack << v
		name_to_node[v.label] = v
	}

	m.times {
		gets =~ /^(\w+) is \w+ (\w+) of (\w+)\.$/
		u = name_to_node[$1]
		relation = $2
		v = name_to_node[$3]
		
		bool = false
		case relation
		when "descendant"
			bool = Graph::get_path_dfs(v, u)
		when "ancestor"
			bool = Graph::get_path_dfs(u, v)
		when "child"
			bool = u.parent == v
		when "parent"
			bool = v.parent == u
		when "sibling"
			bool = u.parent == v.parent
		end
		puts bool ? "True" : "False"
	}

	puts
}

Measured memory_bytes: 8064
using System;

namespace ABC122A
{
    class Program
    {
        static void Main(string[] args)
        {
            string b;
            b = Console.ReadLine();

            if (b == "A")
                Console.WriteLine("T");
            else if (b == "C")
                Console.WriteLine("G");
            else if (b == "G")
                Console.WriteLine("C");
            else
                Console.WriteLine("A");
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
import java.util.*;
public class Main{
  public static void main(String[] args){
  	Scanner sc=new Scanner(System.in);
    int N = sc.nextInt();
    int a[] = new int[N];
    for(int i=0;i<N;i++){
      a[i]=sc.nextInt();
    }
    
    
    int counter=0;
    for(int i=0;i<N;i++){
      if(i%2==0&&a[i]%2==1) counter++;
    }
    System.out.print(counter);
  }
}

Measured memory_bytes: 35856
#include<stdio.h>
#include<stdlib.h>
#define N 100

void push(int);
int pop(void);

int stack[N];
int top = 0;

int main(){
  char data;
  int num, status, i, j, k, count = 0;

  while(1)
    {
      status = scanf("%c",&data);
      
      if(status != 1) break;
      
      if(data == ' ')
	{
	  count = 0;
	  continue;
	}
      
      if(data <= '9' && data >= '0')
	{
	  num = data - 48;
	  count++;
	  
	  if(count >= 2)num = pop()*10 + num;
	  
	  push(num);
	}
      
      if(data == '+' || data == '-' || data == '*')
	{
	  count = 0;
	  i = pop();
	  j = pop();
	  
	  if(data == '+') k = j + i;
	  if(data == '-') k = j - i;
	  if(data == '*') k = j * i;

	  push(k);
	}
    }
  printf("%d\n",stack[0]);
  return 0;
}

void push(int data)
{
  if(top == N) exit(2);
  stack[top] = data;
  top++;
}

int pop(void)
{
  if(top == 0) exit(3);
  top--;
  return stack[top];
}













/*
#include<stdio.h>
#include<stdlib.h>
#define N 100

int n_array[N], tail = 0 , i = 0, cnt;;
char c_array[10000];
void calculator(int, int, char);
void number();

int main(){
  
  int num1, num2, j, flag;

  scanf("%s",&c_array);

  while(1)
    {
      number();

    }
  
  printf("%d",n_array[0]);
  
  return 0;
}

void calculator(int a, int b, char sym){

  if(sym == '+')n_array[tail - 1] = a + b;
  if(sym == '-')n_array[tail - 1] = a - b;
  if(sym == '*')n_array[tail - 1] = a * b;
  
  tail--;
}
*/



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

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

struct node *tree = NULL;

void insert(struct node **root, struct node *node)
{
  struct node *parent = NULL;
  struct node *current = *root;

  while (current != NULL) {
    parent = current;
    if (node->key < current->key) {
      current = current->left;
    } else {
      current = current->right;
    }   
  }
    
  node->parent = parent;
    
  if (parent == NULL) {
    *root = node;
  } else if (node->key < parent->key) {
    parent->left = node;
  } else {
    parent->right = node;
  }
}

int find_tree(struct node* node, int key)
{
  if (node != NULL) {
    if (node->key > key) {
      return find_tree(node->left, key);
    } else if (node->key < key) {
      return find_tree(node->right, key);
    } else {
      return 1;
    }
  }
  return 0;
}

void preorder_traverse(struct node* node)
{
  if (node != NULL) {
    printf(" %d", node->key);
    preorder_traverse(node->left);
    preorder_traverse(node->right);
  }
}

void inorder_traverse(struct node *node)
{
  if (node != NULL) {
    inorder_traverse(node->left);
    printf(" %d", node->key);
    inorder_traverse(node->right);
  }
}

void tree_destroy(struct node* node)
{
  if (node != NULL) {
    tree_destroy(node->left);
    tree_destroy(node->right);
    free(node);
  }
}

int main (int argc, char** argv)
{
  int i, num;
  char str[32] = {0};
  fgets(str, 32, stdin);
  num = atoi(str);
  for (i = 0; i < num; i++) {
    fgets(str, 32, stdin);
    if (str[0] == 'i') {
      struct node *node = (struct node *)malloc(sizeof(struct node));
      node->key = atoi(&str[7]);
      node->left = NULL;
      node->right = NULL;
      insert(&tree, node);
    } else if (str[0] == 'f') {
      int key = atoi(&str[4]);
      printf("%s\n", find_tree(tree, key) ? "yes" : "no");
    } else if (str[0] == 'p') {
      inorder_traverse(tree);
      printf("\n");
      preorder_traverse(tree);
      printf("\n");
    }
  }
  tree_destroy(tree);
  return 0;
}

Measured memory_bytes: 19320
n, x, y = map(int, input().split())

ls = [0] * n
for i in range(1, n):
    for j in range(i+1, n+1):
        leng = min(abs(i - j), abs(x - i) + 1 + abs(y - j))
        ls[leng] += 1

for i in ls[1:n]:
    print(i)

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

int main() {
	int N, M;

	cin >> N >> M;
	vector<vector<int>> s( M );
	for( int i = 0; i < M; i++ ) {
		int k;

		cin >> k;
		for( int j = 0; j < k; j++ ) {
			int S;
		
			cin >> S;
			s[i].push_back( S );
		}
	}
	vector<int> p( M );
	for( int i = 0; i < M; i++ ) {
		cin >> p[i];
	}

	vector<int> bit( M );
	for( int i = 0; i < M; i++ ) {
		for( int j = 0; j < s[i].size(); j++ ) {
			bit[i] |= 1 << ( s[i][j] - 1 );
		}
	}
	long long ans = 0;
	for( int i = 0; i < 1 << N; i++ ) {
		int flag = 0;
		for( int j = 0; j < M; j++ ) {
			int b = bit[j] & i;
			if( __builtin_popcount( b ) % 2 != p[j] ) {
				flag = 1;
				break;
			}
		}
		if( flag == 0 ) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
H1, M1, H2, M2, K = map(int,input().split())
import math

time1=H1*60+M1
time2=H2*60+M2
a=time2-K
if a<=0:
    print(0)
    exit()

if time1<=a:
    print(a-time1)
else:
    print(0)

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

using namespace std;

typedef long long ll;

const int MAX = (int) 1e5 + 5;

vector<int> g[MAX];
vector<int> dp(MAX);

void dfs(int u) {
	if (dp[u] != -1) {
		return;
	} else {
		dp[u] = 0;
		for (int v : g[u]) {
			dfs(v);	
			dp[u] = max(dp[u], dp[v] + 1);
		}
		return;
	}
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		--x, --y;
		g[x].push_back(y);
	}
	dp.assign(n + 1, -1);
	for (int i = 0; i < n; i++) {
		dfs(i);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 11132
#include<bits/stdc++.h>
using namespace std;
/* Notations
 * 1) 'v' stands for vertex
 * 2) 'low[v]' and 'high[v]' represents the interval the vertex 'v' is controlling
 * 3) 'left' and 'right' represents the interval that we are dealing with
 * 4) Always pass 'v' as the last argument to enable function overloading 
 */
const long long m_inf = -1e16;
class SegTree
{
	vector<int> low, high;
	vector<long long> tree;
public:
	SegTree(int n);
	void init(int left, int right, int v);
	void build(vector<long long> &a, int v);
	void update(int ind, long long new_val, int v);
	long long query(int left, int right, int v);
};

SegTree :: SegTree(int n)
{
	low.resize(4*n + 1);
	high.resize(4*n + 1);
	tree.resize(4*n + 1);
	init(0, n - 1, 1);
}

void SegTree :: init(int left, int right, int v = 1)
{
	low[v] = left;
	high[v] = right;

	if(left == right)
		return;

	int mid = (left + right)/2;

	init(left, mid, 2*v);
	init(mid + 1, right, 2*v + 1);
}

void SegTree :: build(vector<long long> &a, int v = 1)
{
	if(low[v] == high[v])
	{
		tree[v] = a[low[v]];
		return;
	}

	build(a, 2*v);
	build(a, 2*v + 1);

	tree[v] = max(tree[2*v] , tree[2*v + 1]);
}

void SegTree :: update(int ind, long long new_val, int v = 1)
{
	if(ind < low[v] or ind > high[v])
		return;

	if(low[v] == high[v])
	{
		tree[v] = new_val;
		return;
	}

	update(ind, new_val, 2*v);
	update(ind, new_val, 2*v + 1);

	tree[v] = max(tree[2*v], tree[2*v + 1]);
}

long long SegTree :: query(int left, int right, int v = 1)
{
	/* Completely Disjoint */
	if(right < low[v] or left > high[v])
		return m_inf;

	/* Vertex is completely contained in the interval */
	/* Also handles leaf nodes */
	if(low[v] >= left and high[v] <= right)
		return tree[v];

	/* Partial Overlap */
	auto left_res = query(left, right, 2*v);
	auto right_res = query(left, right, 2*v + 1);

	return max(left_res, right_res);
}

void Flowers(vector<long long> &a, vector<int> &h)
{
	int n = a.size();

	vector<long long> dp(n, 0);

	SegTree segtree(n);
	segtree.build(dp);

	/* dp[height] represents the maximum beauty of a subsequence which ends with height 'height' */
	for(int i = 0; i < n; i++)
	{
		int curr_height = h[i];

		// Always update the seg tree parallely
		dp[curr_height] = a[i];
		segtree.update(curr_height, dp[curr_height]);

		long long prefix_max = 0;

		/*
		for(int j = 0; j < curr_height; j++)
			prefix_max = max(prefix_max, dp[j]);
		*/
		
		if( curr_height == 0)
			continue;
		
		prefix_max = segtree.query(0, curr_height - 1);

		dp[curr_height] += prefix_max;
		segtree.update(curr_height, dp[curr_height]);
	}

	cout << *max_element(dp.begin(), dp.end()) << endl;
}

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

	vector<int> h(n);
	for(auto &ele : h)
	{
		cin >> ele;
		ele--;
	}
	
	vector<long long> a(n);
	for(auto &ele : a)
		cin >> ele;

	Flowers(a, h);
	return 0;
}



Measured memory_bytes: 18688
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            long H = in.nextLong();
            long n = 0;
            while (Math.pow(2, n) <= H) {
                n++;
            }
            out.println((long) (Math.pow(2, n - 1) * 2 - 1));
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 23380
# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
edge=[[] for _ in range(N)]
for _ in range(N-1):
    a,b=map(int1,input().split())
    edge[a].append(b)
    edge[b].append(a)
C=list(map(int,input().split()))
C.sort()
print(sum(C)-C[-1])
que=deque([0])
ans=[-1]*N
while que:
    v=que.popleft()
    ans[v]=C.pop()
    for nv in edge[v]:
        if ans[nv]==-1:
            que.append(nv)
print(*ans)

Measured memory_bytes: 46320
H, W, K = map(int, input().split())
C = [[(c=="#") for c in input()] for _ in range(H)]
cnt0 = sum(sum(c) for c in C)
ans = 0
for sy in range(1<<H):
    for sx in range(1<<W):
        D = [c.copy() for c in C]
        cnt = cnt0
        for y in range(H):
            for x in range(W):
                if sy>>y&1 | sx>>x&1:
                    cnt -= D[y][x]
                    D[y][x] = False
        if cnt == K:
            ans += 1
print(ans)


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

int main() {
  long long N;
  cin >> N;
  long long A[N+10];
  long long B[N+10];
  for (long long i = 0; i < N+1; i++) {
    cin >> A[i];
  }
  for (long long i = 0; i < N; i++) {
    cin >> B[i];
  }
  long long sum = 0;
  for (long long i = 0; i < N ; i++) {
    sum += min(A[i],B[i]);
    if (A[i] < B[i]) {
      if (A[i + 1] > (B[i] - A[i])){
         sum += B[i] - A[i];
         A[i+1] = A[i+1] - (B[i] - A[i]);
      }
      else {
        sum += A[i+1];
        A[i + 1] = 0;
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 1920
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
mmod(x) = x%1000000007<0?x%1000000007+1000000007:x%1000000007

function main()
	n,m = readline() |> split |> parseMap
	s = readline() |> split |> parseMap
	t = readline() |> split |> parseMap
	dp = zeros(Int,n+1,m+1)
	dp[1,:] = 1
	dp[:,1] = 1
	for i in 1:n
		dp[i+1,:] = dp[i,:]
		for j in 1:m
			if s[i] == t[j]
				dp[i+1,j+1] = mmod(dp[i,j+1]+dp[i+1,j])
			else
				dp[i+1,j+1] = mmod(dp[i,j+1]+dp[i+1,j]-dp[i,j])
			end
		end
	end
	println(dp[n+1,m+1])
end

main()

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

const int MaxN = 100000;
int S[ MaxN + 10 ];

void SCNF( int &x )
{
char C;

	while( true )
	{
		C = fgetc( stdin );
		if( C >= '0' && C <= '9' ) break;
	}

	x = C - '0';

	while( true )
	{
		C = fgetc( stdin );
		if( C < '0' || C > '9' ) break;

		x = x * 10 + ( C - '0' );
	}
}

int main()
{
int i;
int N;
int M;
int A;
long long x;
long long iCnt;
int iSum;

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

	iSum = 0;
	iCnt = 0;
	for( i = 1; i <= N; i++ )
	{
		SCNF( A );

		iSum += A;
		iSum %= M;
		S[ i ] = iSum;
	}

	sort( S, S + ( N + 1 ) );

	x = 0;
	for( i = 1; i <= N; i++ )
	{
		if( S[ i - 1 ] == S[ i ] )
			x++;
		else
		{
			iCnt += ( x + 1 ) * x / 2;
			x = 0;
		}
	}

	if( x > 0 ) iCnt += ( x + 1 ) * x / 2;

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

	return 0;
}






Measured memory_bytes: 640
#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;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

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

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)



void solve() 
{
    string s;
    cin>>s;
    int sum = 0;
    for(char x : s)
    {
        sum += x-48;
    }
    if(sum%9 == 0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int tc = 1; 
    //cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}


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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(a>b)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream&os, const pair<t,u>&p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream&operator <<(ostream&os,const vc<t>&v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

template<class t>
void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

const int inf=LLONG_MAX/3;

template<class t>
t sq(t x){return x*x;}

using ld=long double;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n,k;cin>>n>>k;
	vc<pi> xy(n);
	rep(i,n)cin>>xy[i].a>>xy[i].b;
	
	const ld v=1000;
	const int itr=80;
	
	ld ans=inf;
	
	auto waf=[&](ld y){
		ld cur=inf;
		auto relka=[&](ld x){
			vc<ld> ds(n);
			rep(i,n)
				ds[i]=sqrt(sq(xy[i].a-x)+sq(xy[i].b-y));
			sort(all(ds));
			ld res=0;
			rng(i,n-k,n)res+=ds[i];
			chmin(cur,res);
			return res;
		};
		ld lw=-v,up=v;
		rep(_,itr){
			ld m1=(lw+lw+up)/3,m2=(lw+up+up)/3;
			if(relka(m1)<relka(m2))
				up=m2;
			else
				lw=m1;
		}
		chmin(ans,cur);
		return cur;
	};
	
	ld lw=-v,up=v;
	rep(_,itr){
		ld m1=(lw+lw+up)/3,m2=(lw+up+up)/3;
		if(waf(m1)<waf(m2))
			up=m2;
		else
			lw=m1;
	}
	
	cout<<ans<<endl;
}



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<bool>> G(N, vector<bool>(N));
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a][b] = true;
        G[b][a] = true;
    }

    vector<int> per(N);
    rep(i, N) per[i] = i;
    int ans = 0;
    do {
        if (per[0] != 0)
            break;
        bool flag = true;
        rep(i, N - 1) {
            if (!G[per[i]][per[i + 1]])
                flag = false;
        }
        if (flag)
            ans++;
    } while (next_permutation(per.begin(), per.end()));

    cout << ans << endl;

    return 0;
}

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double R,G;
  cin >> R >> G;
  cout << G*2. - R << endl;  
  return 0;
    

}


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

using namespace std;
int main() {
    const int MAX = 100001;
    vector<bool> is_prime(MAX);
    for (int i = 2; i < MAX; ++i) {
        is_prime[i] = true;
    }

    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = false;
    }

    vector<int> a(MAX);
    for (int i = 0; i < MAX; ++i) {
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }

    vector<int> s(MAX+1, 0);
    for (int i = 0; i < MAX; ++i) s[i+1] = s[i] + a[i];

    int q; cin >> q;
    for(int i = 0; i < q; ++i){
        int l, r; cin >> l >> r;
        cout << s[r+1] - s[l] << endl;
    }
    return 0;

}

Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[100005], b[100005], c[100005];
ll dp[1005][100005];
int main() {
	int n, W;
	cin >> n >> W;
	ll w[104];
	ll v[104];
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
			
	}
	for (int j = 0; j <= W; j++) {
		dp[0][j] = 0;
	}
	for (int i = 0; i <n; i++) {
		for (int j = 0; j <= W; j++) {
			if (w[i] <= j) {
				dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
			else {
				dp[i+1][j] = dp[i][j];
			}
		}
	}
	cout << dp[n][W] << endl;
	return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k,tmp,ans=0;
    cin >> n >> k;
    vector<int> a(n+1,0);
    for(int i=0;i<n;i++){
        cin >> tmp;
        a.at(tmp)++;
    }
    sort(a.rbegin(),a.rend());
    for(int i=0;i<n-k;i++){
        ans+=a.at(i+k);
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    int n, c;
    cin >> n >> c;
 
    int disc[30][30];
    rep(i, c)rep(j, c)cin >> disc[i][j];
 
    int grid[3][30] = {0};
    rep(i, n)rep(j, n){
        int g;
        cin >> g;
        grid[(i+j)%3][g-1]++;
    }
 
    ll ans = 10000000000;
    rep(i, c){
        rep(j, c){
            if(j == i)continue;
            rep(k, c){
                if(k == i || k == j)continue;
                ll score = 0;
                rep(l, c)score += disc[l][i]*grid[0][l];
                rep(l, c)score += disc[l][j]*grid[1][l];
                rep(l, c)score += disc[l][k]*grid[2][l];
                ans = min(ans, score);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;
typedef long long ll;

int main() {
  int N,X,T;
  int L;
  cin >> N >> X >> T;
  if (N % X != 0) L = N / X + 1;
  else L = N / X;
  cout << (int)(L * T) << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#define FALSE 0
#define TRUE 1
int solve(int , int);

int n, A[2000];

int main(){
  int q, M, i=0;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
for(i=0; i<q; i++){

    scanf("%d", &M);
    if(solve(0, M)) printf("yes\n");
    else printf("no\n");
  }
  return 0;

}

int solve(int i, int m){
  int res = 0;

  if(m==0) return TRUE;
  if(i>=n) return FALSE;

res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;

}

Measured memory_bytes: 580
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class ACC_2D:
    """
    二次元累積わ
    """

    def __init__(self, W, H):
        """
        W:幅
        H:高さ
        """

        self.W = W
        self.H = H
        self.mat = [[0]*(W+1) for _ in range(H+1)]

    def add(self, row, col, val):
        """
        matの値を変更する(初期化)
        row:たて(0<=row<H)
        col:横(0<=col<W)
        val:mat[row][col]を初期化する値
        """
        self.mat[row+1][col+1] += val

    def build(self):
        """
        累積和を計算する
        """
        for row in range(1, self.H+1):
            for col in range(1, self.W+1):
                self.mat[row][col] += self.mat[row][col-1] + \
                    self.mat[row-1][col] - self.mat[row-1][col-1]

    def get_val(self, g_row, g_col, s_row, s_col):
        """
        ２点で囲まれる長方形の、累積和を求める
        gx,gyは含まれない
        """
        return self.mat[g_row][g_col] - self.mat[s_row][g_col] - self.mat[g_row][s_col] + self.mat[s_row][s_col]


def solve():
    N, K = map(int, input().split())
    K2 = 2*K

    ACC = ACC_2D(K2, K2)

    # handle input
    # 全てを2K*2Kに圧縮する
    for _ in range(N):
        x, y, s = input().split()
        # 2K * 2Kに収める
        x = int(x)
        y = int(y)
        if s == "W":
            y += K
        x %= K2
        y %= K2

        ACC.add(x, y, 1)

    # 累積和をとる
    ACC.build()

    ans = 0
    # 黒としてチェックする
    # dは希望に沿っている数
    # ほんとは0~2Kで探さないといけないけど、N-dをついでにチェックすることで、半分でよくなる
    for row in range(K + 1):
        for col in range(K + 1):
            # 区間に入っている点の数
            d = ACC.get_val(row+K, col, row, 0)
            d += ACC.get_val(row, col+K, 0, col)
            d += ACC.get_val(K2, col+K, row+K, col)
            d += ACC.get_val(row+K, K2, row, col+K)
            ans = max(ans, d, N-d)
    print(ans)


solve()


Measured memory_bytes: 74844
#include <stdio.h>

int main(){
  int f=1,i,j,k,l,n,m=0,a,b[2005];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&b[i]);
  }
  i=1;
  while(f==1){
    f=0;
    for(j=0;j<n-i;j++){
      if(b[j]>b[j+1]){
        a=b[j];
        b[j]=b[j+1];
        b[j+1]=a;
        f=1;
      }
    }
    i++;
  }
  for(i=n-1;i>=2;i--){
    for(j=i-1;j>=1;j--){
      l=b[i]-b[j];
      for(k=j-1;k>=0;k--){
        if(b[k]<=l){
          break;
        }else{
          m++;
        }
      }
    }
  }
  printf("%d",m);
  return(0);
}

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

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
	string a,b,c;
	cin>>a>>b;
	if(a.size()<b.size())swap(a,b);
	int as=a.size(),bs=b.size();
	for(int i=0;i<as-bs;i++)b="0"+b;
	c=a;
	bool kuri=false;
	int sum=0;
	for(int i=a.size()-1;i>=0;i--){
		 sum=a[i]-'0';
		char now;
		sum=sum+b[i]-'0';
		if(kuri)sum++;
		if(sum>=10){
			kuri=true;
				sum-=10;
				//cout<<"a";
		}
		else{
			kuri=false;
		}
		now=sum+'0';
		//cout<<sum;
		c[i]=now;
	}
	if(kuri)c="1"+c;
	
	if(c.size()>80)cout<<"overflow"<<endl;
	else cout<<c<<endl;
	c.clear();
	}
	return 0;
}

Measured memory_bytes: 1216
import sys

N, M = map(int, sys.stdin.readline().strip().split())
A = set()
for _ in range(M):
    A.add(int(sys.stdin.readline()))

# i段目の階段への到達方法の数
dp = [0 for _ in range(N+1)]
dp[0] = 1
dp[1] = 0 if 1 in A else 1

for i in range(2, N+1):
    if i in A:
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= 1000000007

print(dp[N])

Measured memory_bytes: 52312
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int n, m; cin >> n >> m;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int s = 0;
	rep(i, n) s += a[i];
	int count = 0;
	double x = 0.25 * s / m;
	rep(i, n) if (a[i] >= x) count++;
	if (count >= m) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N, M; cin>>N>>M;
  map<int,int> dict; // kind, love
  for(int i=0; i<N; i++) {
    int K; cin>>K;
    for(int j=0; j<K; j++) {
      int a; cin>>a;
      dict[a]++;
    }
  }

  int ans = 0;
  for(auto p: dict) {
    if(p.second == N) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define l long int 
#define ll long long int 
vector<int>adj[1000001];
int vis[1000001];
int n=2005;
int dp[2005];
int fact[1000001];
#define mod 1000000007 
//int dp[n];
ll sequence_sum(int a)
{
    if(a==0)
     return 1ll;
    else if(a==1 || a==2)
        return 0ll;
    else if(a==3 || a==4 || a==5)
        return 1ll;
    else if(dp[a]!=-1)
            return dp[a];
    else
    {
        ll total=0;
        for(int i=3;i<=a;i++)
        {
            if((a-i)>=0)
            {
                total=(total+sequence_sum(a-i))%mod; 
            }
        }
    return dp[a]=total;
    }
}
int main()
{
    int s;
    cin>>s;
    for(int i=0;i<=n;i++)
    {
        dp[i]=-1;
    }
    dp[0]=0;
    // sequence_sum(s);
    cout<<sequence_sum(s)<<"\n";
    
    return 0;
}

Measured memory_bytes: 27080