akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(int i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;cin>>s>>t;
  ll sl=s.length(),tl=t.length();
  vector<vector<ll>>dp(sl+1,vector<ll>(tl+1));
  vector<vector<pair<ll,ll>>>par(sl+1,vector<pair<ll,ll>>(tl+1,{-1,-1}));
  repi(i,1,sl+1)repi(j,1,1+tl){
    if(chmax(dp[i][j],dp[i-1][j]))par[i][j]=par[i-1][j];
    if(chmax(dp[i][j],dp[i][j-1]))par[i][j]=par[i][j-1];
    if(s[i-1]==t[j-1])if(chmax(dp[i][j],dp[i-1][j-1]+1))par[i][j]={i-1,j-1};
  }
  pair<ll,ll> tp={sl,tl};
  tp=par[tp.first][tp.second];

  string res;
  while(tp!=(pair<ll,ll>){-1,-1}){
    res=s[tp.first]+res;
    tp=par[tp.first][tp.second];
  }
  cout<<res<<endl;


  return 0;

}


Measured memory_bytes: 211584
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

int main(){
    int n, u;
    while(cin >> n >> u, n+u){
        vector<int> c(n), p(n);
        for(int i = 0; i < n; i++){
            cin >> c[i];
            int k;  cin >> k;
            while(k-- > 0){
                int r;  cin >> r;
                p[i] |= (1<<r);
            }
        }
        
        auto popcnt = [](int x)->int{
            int ret = 0;
            while(x > 0){
                ret += x&1;
                x >>= 1;
            }
            return ret;
        };

        int ans = 21;
        queue<pair<int,int>> q;
        vector<bool> visit(1<<n, 0);
        q.push({0, 0});
        while(!q.empty()){
            pair<int,int> x = q.front();    q.pop();
            int bit = x.first, score = x.second;
            if(visit[bit])  continue;
            visit[bit] = true;
            if(score >= u){
                ans = min(ans, popcnt(bit));
                continue;
            }
            for(int i = 0; i < n; i++){
                if( ((bit>>i)&1) == 1 || (p[i]&bit) != p[i] || visit[bit|(1<<i)])    continue;
                q.push({bit|(1<<i), score+c[i]});
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 19444
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-09-26 20:00:49
 * @LastEditTime: 2020-09-26 20:01:29
 * @FilePath: \VSC\C++\Practice\AC ACLBC A.cpp
 */
#include <bits/stdc++.h>
using namespace std;

int k;
signed main()
{
    scanf("%d", &k);
    for (register int i = 1; i <= k; ++i)
        printf("ACL");
    puts("");
    return 0;
}

Measured memory_bytes: 3724
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int slime=0;
    char S[100000];
    cin>> N;
    for(int i=0;i<N;i++)
    {
        cin >> S[i];
        slime++;
        if(i==0)
        {
            
            continue;
        }
        if(S[i-1]==S[i])
        {
            slime--;
        }
    }
    cout <<slime;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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; }

// auto mod int
// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  vector<mint> q(s+1);
  mint ans = 0;
  REP(i, n) {
    q[0] += 1;

    vector<mint> q2(s+1);
    REP(j, s+1) {
      q2[j] += q[j];
      if (j+a[i] <= s) q2[j+a[i]] += q[j];
    }
    q = q2;

    ans += q[s];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
line = gets.chomp.split(" ").map(&:to_i)
# line = [6, 20 , 7]

l = line[0]
# l = 6
r = line[1]
# r = 20
d = line[2]


d_count = 0

(l..r).each do |num|
  if num % d === 0
    d_count += 1
  end
end

puts d_count



Measured memory_bytes: 14276
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N = In.int()
L = In.ints()
ans = 0

for i in range(len(L)-2):
    for j in range(i+1, len(L)-1):
        for k in range(j+1, len(L)):
            if L[i]!=L[j] and L[i]!=L[k] and L[j]!=L[k]:
                if L[k]<L[i]+L[j] and L[j]<L[k]+L[i] and L[i]<L[k]+L[j]:
                    ans+=1

Out.int(ans)


######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 69292
N,M=map(int,input().split())
a=[]
for i in range(N):
    a.append(list(map(int,input().split())))
mod=998244353

B=[]
for i in range(M):
    b=0
    for j in range(N):
        b+=a[j][i]*2**j
    B.append(b)

base=[]
for i in range(M):
    t=B[i]
    for b in base:
        t=min(t,t^b)
    if t!=0:
        base.append(t)

res=M-len(base)
ans=pow(2,N-1,mod)*(pow(2,M,mod)-pow(2,res,mod))
print(ans%mod)

Measured memory_bytes: 42716
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

li table[9][1001][101];

li minsum(li n, li from){
	li res=0;
	repp(i,from,n+from)res+=i;
	return res;
}

li maxsum(li n){
	li res=0;
	for(li i=9; i>9-n; i--)res+=i;
	return res;
}

li solve(li n, li s, li from){
	//p3(n,s,from);
	if(n==1){
		if(s>=from && s<=9)return 1;
		else return 0;
	}
	li res=0;
	repp(i,from,10){
		if(minsum(n-1, i+1)>s-i)res+=0;
		else if(maxsum(n-1)<s-i)res+=0;
		else if(i<10 && table[n-2][s-i][i+1]>0) res+=table[n-2][s-i][i+1];
		else res+=solve(n-1,s-i,i+1);
	}
	table[n-1][s][from]=res;
	return res;
}

int main(){
	li n,s;
	while(1){
		cin>>n>>s;
		if(n==s && n==0)break;
		
		rep(i,n){
			rep(j,s+1){
				rep(k,10)table[i][j][k]=-1;
			}
		}
		
		li res=solve(n,s,0);
		cout<<res<<endl;
	}
	
	return 0;
}

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

bool stg(int x)
{
    for (int i = 2; i * i <= x; ++i)
    {
        if (x % i == 0)
            return false;
    }
    return true;
}

int main()
{
    int x;
    cin >> x;
    while (!stg(x))
        ++x;
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int K = cin.nextInt();
        long[] DP = new long[N];
        var h = cin.arrayLong();

        DP[0] = 0;
        for (int i=1; i<N; i++) {
            DP[i] = 10000000000;
        }
        for (int i=0; i<N; i++) {
            for (int j=1; j<=K; j++) {
                if (i+j < N) {
                    DP[i+j] = Math.Min(DP[i+j], DP[i]+Math.Abs(h[i]-h[i+j]));
                }
            }
        }
        Console.WriteLine(DP[N-1]);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}



Measured memory_bytes: 19680
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
long long n,v[100001],k,fact[100001],inv[100001],ans;
ll logp(ll a)
{
    ll b=mod-2;
    ll rez=1;
    while(b)
    {
        if(b%2==1)
            rez=(rez*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return rez;
}
ll combi(ll a,ll b)
{
    if(a<b)
        return 0;
    ll x=fact[a];
    x=(x*inv[b])%mod;
    x=(x*inv[a-b])%mod;
    return x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    fact[0]=1;
    inv[0]=logp(1);
    for(int i=1;i<=100000;i++)
        {
            fact[i]=(fact[i-1]*i)%mod;
            inv[i]=(logp(fact[i]))%mod;
        }
    for(int i=1;i<=n;i++)
    {
        ans=(ans+(combi(i-1,k-1)*v[i])%mod)%mod;
        ans=(ans-(combi(n-i,k-1)*v[i])%mod)%mod;
        if(ans<0)
            ans+=mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

signed main(){
    string S;
    cin >> S;
    for(int bit=0; bit<8; ++bit){
        int sum = S[0] - '0';
        vector<char> opl(3);
        for(int i=0; i<3; ++i){
            if(bit & (1<<i)){
                sum += S[i+1] - '0';
                opl[i] = '+';
            } 
            else{
                sum -= S[i+1] - '0';
                opl[i] = '-';
            }
        }
        if(sum == 7){
            for(int i=0; i<3; ++i) cout << S[i] << opl[i];
            cout << S[3] << "=7" << endl;
            return 0;
        }
    }

    return 0;
}

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

int main() {
  int N;
  cin >> N;
	int a=N/1000, b=(N%1000)/100, c=(N%100)/10, d=N%10;
  if ((a==b && b==c) || (b==c && c==d)) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
    
}

Measured memory_bytes: 256
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
B = [[0,0,0],[0,0,0],[0,0,0]]

ans = 'No'
for i, row in enumerate(A):
    for j, value in enumerate(row):
        if value in b:
            B[i][j] = 1
#print(B)
if B[0][0]==B[0][1]==B[0][2]==1 or B[1][0]==B[1][1]==B[1][2]==1 or B[2][0]==B[2][1]==B[2][2]==1:
    ans = 'Yes'
elif B[0][0]==B[1][0]==B[2][0]==1 or B[0][1]==B[1][1]==B[2][1]==1 or B[0][2]==B[1][2]==B[2][2]==1:
    ans = 'Yes'
elif B[0][0]==B[1][1]==B[2][2]==1 or B[0][2]==B[1][1]==B[2][0]==1:
    ans = 'Yes'
print(ans)

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = sc.nextInt();
        }
        System.out.println(calc(N,a));
    }

    public static int calc(int N, int[] a) {
        int allice = 0;
        int bob = 0;
        Arrays.sort(a);
        for (int i=N-1; i>=0; i-=2) {
            allice += a[i];
            if (i>=1) bob += a[i-1];
        }
        return allice - bob;
    }
}


Measured memory_bytes: 36016
#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()


signed main(){
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  int ans=0;
  V<int> red(a);
  fo(i,a){
    cin>>red[i];
  }
  Sort(red);
  rev(red);
  V<int> blue(b);
  fo(i,b){
    cin>>blue[i];
  }
  Sort(blue);
  rev(blue);
  V<int> mu(c);
  fo(i,c){
    cin>>mu[i];
  }
  Sort(mu);
  V<int> d(x+y);

  fo(i,x){
    d.pb(red[i]);
  }
  fo(i,y){
    d.pb(blue[i]);
  }

  fo(i,c){
    d.pb(mu[i]);
  }
  Sort(d);
  rev(d);
  fo(i,x+y){
    ans+=d[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 10112
#include <vector>
#include <iostream>
#include <cmath>

using namespace std;

const int INF = (1 << 30);

int main(){
	int N;
	cin >> N;
	vector<int> h(N, 0), dp(N, INF);
	dp[0] = 0;
	for(int i =0 ; i < N; i ++){
		cin >> h[i];
	}

	for(int i = 1; i < N ; i++){
		dp[i] = min(
			(i-1 >= 0? dp[i-1] + abs(h[i] - h[i-1]) : dp[i]) ,
			(i-2 >= 0? dp[i-2] + abs(h[i] - h[i-2]) : dp[i])
		);
	}

	cout << (N == 1? 0 : dp[N-1]) << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int d;
int q;

typedef struct {
  char name[100];
  int t;
}Process;

Process Q[10000000];
int n;
int head=0, tail=0;


void enqueue(Process x){
  Q[head]=x;
  head++;
}

Process dequeue(){
  tail++;
  return Q[tail-1];
}

int main(void){
  int i,j;
  int count;
  int time=0;
  Process x;
  scanf("%d %d", &n, &q);
  
  for ( i = 0; i < n; i++){
    scanf("%s", x.name);
    scanf("%d", &x.t);
    enqueue(x);
  }
  
  while(1){
    x=dequeue();
    if(x.t<=q){
      time+=x.t;
      printf("%s %d\n", x.name, time);
    }
    else{
      x.t-=q;
      time+=q;
      enqueue(x);
    }
    if(head-tail==0)break;
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,n-1):
    if p[i] != min([p[i-1], p[i], p[i+1]]) and p[i] != max([p[i-1], p[i], p[i+1]]):
        count += 1
print(count)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

bool calc(int x) {
    int cnt = 0;
    for (int i = 1; i * i <= x; ++i) {
        if (x % i == 0) {
            if (i * i == x) cnt++;
            else cnt += 2;
        }
    }
    return cnt == 8;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    int res = 0;
    rep (i, n + 1) {
        if (i % 2 == 0) continue;
        if (calc(i)) res++;
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	int A, B;
	in >> A >> B;

	int ans = 0;
	for (LL i = A; i <= B; ++i)
	{
		std::string S = std::to_string(i);
		bool flag = true;
		rep(i, S.length() / 2)
		{
			if (S[i] != S[S.length() - 1 - i])
			{
				flag = false;
				break;
			}
		}
		if (flag) ++ans;
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using lint = long long int;
using Graph = std::vector<std::vector<lint>>;

int main(int argc,char *argv[])
{
	int a,b;
	std::cin >> a >> b;

	if(a < 1 || a > 9 || b < 1 || b > 9) std::cout << -1 << std::endl;
	else std::cout << a*b << std::endl;

	return 0;
}


Measured memory_bytes: 256
a = input()
b = input()
c = input()

turn = "a"
win = ""
while True:
    if turn == "a":
        if len(a) == 0:
            win = "A"
            break
        else:
            turn = a[0]
            a = a[1::]
    elif turn == "b":
        if len(b) == 0:
            win = "B"
            break
        else:
            turn = b[0]
            b = b[1::]
    else:
        if len(c) == 0:
            win = "C"
            break
        else:
            turn = c[0]
            c = c[1::]
print(win)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 02:00:50 2019

@author: yuta
"""

def judge(r,g,b):
    ans = 100*r + 10*g + b
    if ans % 4 == 0:
        print("YES")
    else:
        print("NO")
        
x = input().split()
judge(int(x[0]),int(x[1]),int(x[2]))

Measured memory_bytes: 2940
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String S = in.next();
        int X  = S.length()/2;
        int Y  = S.length();
        int count = 0;
        for(int i = 0; i<X; i++)
        {
            Y--;
            if(S.charAt(i)!=S.charAt(Y))
            {
                count++;
            }

        }
            System.out.println(count);



    }

}















Measured memory_bytes: 35548
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

import math
N=int(input())
INF = 3000000
# rootを求める
# 二分探索すればいいのか！！！
ans = INF
pairs = make_divisors(N)
keta = lambda x: len(str(x))
for pair in pairs:
  tmp_ans = max(keta(pair), keta(int(N/pair)))
  ans = min(ans,tmp_ans)

print(ans)

# root_n = int(math.sqrt(N))
# up_n = root_n
# up_ans = 0

# while up_n <= N:
#   if N % up_n == 0:
#     pair = int(N/up_n)
#     # 桁数を求める
    
#     break
#   else:
#     up_n+=1

# print(up_ans)



Measured memory_bytes: 3188
def main():
    n = int(input())
    L = []
    for i in range(n):
        s, p = input().split()
        L.append([i, s, int(p)])

    L = sorted(L, key=lambda x: x[2], reverse=True)
    L = sorted(L, key=lambda x: x[1])
    for i in range(n):
        print(L[i][0]+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

def solve():
  k,x = (int(i) for i in input().split())
  query = []
  for i in range(k):
    query.append(x-i)
  for i in range(k-1):
    query.append(x+i+1)
  query.sort()
  print(*query)
solve()
  
  

Measured memory_bytes: 3060
//l
#include<stdio.h>

int n, a[200005], b[200005]={0}, c[200005], idx=0;

int main()
{
	scanf("%d", &n);
	for(int i=1; i<=n; i++)
	{
		scanf("%d", a+i);
	}
	for(int i=n; i>0; i--)
	{
		int tmp=0;
		for(int j=2; j*i<=n; j++) tmp+=b[i*j], tmp&=1;
		b[i]=tmp^a[i];
		if(b[i]) c[idx++]=i;
	}
	printf("%d\n", idx);
	if(idx)
	{
		printf("%d", c[0]);
		for(int i=1; i<idx; i++) printf(" %d", c[i]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define int long long
int sum,now,num[500005];
inline int read() {
	int x=0,neg=1;char ch=getchar();
	while(!isdigit(ch)) {
		if (ch=='-') neg=-1;
		ch=getchar();
	} 
	while(isdigit(ch)) {
		x=x*10+(ch-'0');
		ch=getchar();
	}
	return x*neg;
}
struct node{
	int x,v;
}p[500005];
bool cmp(node a,node b) {
	if (a.v!=b.v) return a.v>b.v;
	else return a.x>b.x;
}
signed main() {
	int n=read(),m=read();
	for (int i=1;i<=n;++i) {
		num[i]=read();
	}
	for (int i=1;i<=m;++i) {p[i].x=read(),p[i].v=read();}
	sort(p+1,p+m+1,cmp);
	sort(num+1,num+n+1);
	now=1;
	bool flag=false;
	for (int i=1;i<=m;++i) {
		for (int j=1;j<=p[i].x;++j) {
			if (now>n||num[now]>=p[i].v) {
				flag=true;
				break;
			}
			num[now++]=p[i].v;
		}
		if (flag||now>n) break;
	}
	for (int i=1;i<=n;++i) {
		sum+=num[i];
	}
	cout<<sum<<'\n';
	return 0;
} 

Measured memory_bytes: 5888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define FFOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>

int a[3*MAXN];

signed main(){
	
	int n;cin >>n;
	
	int ans = 0;
	int cnt = 0;
	int pret = 0;
	
	rep(i,3*n) cin>>a[i];
	sort(a,a+3*n);
	reverse(a,a+3*n);
	
	rep(i,n) ans += a[1+2*i];
	
	
	
	cout << ans << endl;
		
	
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++)
  {
    if(i % k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  
  return 0;
}

Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {

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

		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();

		if(a<b)
			if(b<c)	System.out.println("Yes");
			else System.out.println("No");
		else System.out.println("No");
			}
}

Measured memory_bytes: 26136
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int n,a[100005],dp[100005];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	    scanf("%d",&a[i]);
	if(n==1)
	{
		cout<<0;
		return 0;
	}
	dp[0]=0,dp[1]=abs(a[0]-a[1]);
	for(int i=2;i<n;i++)
	    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b[33]={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};
	cin>>a;
	cout<<b[a-1]<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)

int main() {

    int n,a;
    bool hit = false;
    int cnt = 0;

    while(1){
        scanf("%d", &n);
        if( n == 0 ) break;
        hit = false;
        cnt = 1;
        Rep(i,n){
            scanf("%d", &a);
            if( a > 1 ) hit = true;
            if( a > 0 ) cnt++;
        }
        if( hit ) printf ("%d\n", cnt);
        else printf ("NA\n");
    }

    return 0;
}




Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF LONG_MAX/1000
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

signed main() {
  vector<int> Jinjya;
  vector<int> Tera;
  
  Jinjya.push_back(-INF);
  Tera.push_back(-INF);
  
  int A, B, Q; cin >> A >> B >> Q;
  for (int i = 0; i < A; i++) {
    int a; cin >> a;
    Jinjya.push_back(a);
  }
  for (int i = 0; i < B; i++) {
    int a; cin >> a;
    Tera.push_back(a);
  }

  Jinjya.push_back(INF);
  Tera.push_back(INF);

  for (int i = 0; i < Q; i++) {
    cin >> Input[i];
  }

  vector<int> Output;
  for (int i = 0; i < Q; i++) {
    auto x = lower_bound(Jinjya.begin(), Jinjya.end(), Input[i]);
    auto prevx = prev(x, 1);

    auto y = lower_bound(Tera.begin(), Tera.end(), Input[i]);
    auto prevy = prev(y, 1);

    // cout << "i: " << i << " Input[i]: " << Input[i] << endl;
    // cout << "x: " << *prevx << " " << *x << endl;
    // cout << "y: " << *prevy << " " << *y << endl;

    int jr = *x - Input[i];
    int jl = *prevx - Input[i];
    int tr = *y - Input[i];
    int tl = *prevy - Input[i];

    // cout << jr << " " << jl << " " << tr << " " << tl << endl;

    int ans1 = abs(jr) + min(abs(tr - jr), abs(tl - jr));
    int ans2 = abs(jl) + min(abs(tr - jl), abs(tl - jl));
    int ans3 = abs(tr) + min(abs(jr - tr), abs(jl - tr));
    int ans4 = abs(tl) + min(abs(jr - tl), abs(jl - tl));

    // cout << ans1 << " " << ans2 << " " << ans3 << " " << ans4 << endl;

    Output.push_back(min(min(ans1, ans2), min(ans3, ans4)));
  }

  for (int i = 0; i < Q; i++) {
    cout << Output[i] << endl;
  }
}


Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
#define LL long long
 
const int maxn=5e5+10;
 
int n,L,H,T;
 
struct Point{
	LL x;
	double y;
	Point() {}
	Point(LL x,double y):x(x),y(y) {}
	Point operator + (const Point &p) const {return Point(x+p.x,y+p.y);}
	Point operator - (const Point &p) const {return Point(x-p.x,y-p.y);}
};
 
double Cross(Point A,Point B) {return A.x*B.y-A.y*B.x;}
 
Point P[maxn];
 
Point GetPoint(Point A,Point B,LL x)
{
	double t=((double)x-A.x)/(B.x-A.x);
	return Point(x,A.y+t*(B.y-A.y));
}
 
int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	scanf("%d%d",&n,&L);
	H=T=1;
	P[1]=Point(0,0);
	while (n--)
	{
		Point p;
		scanf("%lf%lld",&p.y,&p.x);
		p.y*=p.x;
		T++;
		P[T]=P[T-1]-p;
		while (H!=T&&P[H+1].x-P[T].x>=L) H++;
		if (P[H].x-P[T].x>L)
			P[H]=GetPoint(P[H],P[H+1],P[T].x+L);
		while (H+1<T&&Cross(P[T-1]-P[T],P[T-2]-P[T])>=0) P[T-1]=P[T],T--;
		printf("%.10lf\n",((double)P[H].y-P[T].y)/L);
	}
}

Measured memory_bytes: 18304
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int INF = (int)1e9;

        while(true){

            int n = sc.nextInt();
            if(n==0) break;

            int[] p = new int[n];
            int[] t = new int[n];
            for(int i=0; i<n; i++){
                p[i] = sc.nextInt();
                t[i] = sc.nextInt();
            }

            int[][] dp = new int[n][4];
            for(int i=0; i<n; i++) Arrays.fill(dp[i], INF);

            int NG = -1;
            if(p[0]<=t[0]) dp[0][1] = p[0];
            else NG = 1;

            for(int i=1; i<n; i++){
                if(NG!=-1) break;
                int time = t[i] - t[i-1];
                if(dp[i-1][3]!=INF && p[i-1]*4+p[i]<=time){
                    dp[i][1] = dp[i-1][3] + p[i-1] + p[i];
                }
                if(dp[i-1][2]!=INF && p[i-1]*3+p[i]<=time){
                    dp[i][1] = Math.min(dp[i][1], dp[i-1][2] + p[i-1] + p[i]);
                }
                if(dp[i-1][1]!=INF && p[i-1]*2+p[i]<=time){
                    dp[i][1] = Math.min(dp[i][1], dp[i-1][1] + p[i-1] + p[i]);
                }                
                if(dp[i-1][1]!=INF && Math.abs(p[i-1]-p[i])*2<=time){
                    dp[i][2] = dp[i-1][1] + Math.abs(p[i-1]-p[i]);
                }
                if(dp[i-1][2]!=INF && Math.abs(p[i-1]-p[i])*3<=time){
                    dp[i][3] = dp[i-1][2] + Math.abs(p[i-1]-p[i]);
                }
                dp[i][0] = Math.min(dp[i][1] ,Math.min(dp[i][2], dp[i][3])) + p[i];
                if(dp[i][1]==INF && dp[i][2]==INF && dp[i][3]==INF){
                    NG = i+1;
                    break;
                }
            }


            if(NG!=-1) System.out.println("NG " + NG);
            else System.out.println("OK " + (Math.min(dp[n-1][1] ,Math.min(dp[n-1][2], dp[n-1][3]))+p[n-1]));
            //System.out.println("OK " + dp[n-1][0]);
        }
    }

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

Measured memory_bytes: 23588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }



void solve() {
    string n;
    cin >> n;
    rep(i, sz(n)) {
        if (n[i] == '1') n[i] = '9';
        else if (n[i] == '9') n[i] = '1';
    }
    cout << n << endl;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}




Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
	int count = 0 , k=1 ;
	int z ;
	cin >> z;
	int N[z];
	for (int i = 0; i < z; i++)
	{
		cin >> N[i];
		if (k% 2 != 0 && N[i] % 2 != 0)
		{
			count++;
			
		}
		k++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long double  ld;
typedef long long ll;

vector<ld> a;
ll ans;
int main() {
  ll n;
  cin >> n;

  for(ld i = 1; i * i <= n; i++) {
    ld tmp = n / i;
    a.push_back(i);
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());

  for(ll i = 1; i < a.size(); i++) {
    ld r = n / a[i-1];
    ld l = n / a[i];
    if((n-i) % i != 0ll) continue;
    ld x = (n - i) / i;
    
    //  cout << l <<"   "<<r<<"   "<<x<<endl;
      if(l < x && x < r) ans += x;
  }

  cout << ans << endl;
}
  


Measured memory_bytes: 35172
from collections import defaultdict
n, m = map(int, input().split())

a = [list(map(int, input().split())) +[i, None] for i in range(m)]
a.sort(key=lambda x: x[1])
d = defaultdict(int)
for i in range(m):
    p,y = a[i][0], a[i][1]
    d[p] += 1
    code = "{0:06d}{1:06d}".format(p, d[p])
    a[i][3] = code
a.sort(key=lambda x: x[2])
for i in a:
    print(i[3])

Measured memory_bytes: 44256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		try {
			int lim = Integer.parseInt(in.readLine());
			
			for (int i = 0; i < lim; i++) {
				String[] values = in.readLine().split(" ");
				int a = Integer.parseInt(values[0]);
				int b = Integer.parseInt(values[1]);
				int c = Integer.parseInt(values[2]);

				int x = a * a;
				int y = b * b;
				int z = c * c;
				if (((x + y) == z) || ((y + z) == x) || ((z + x) == y)) System.out.println("YES");
				else System.out.println("NO");
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 26356
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long
#define pb push_back 
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<ll>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl;
#define cno cout << "No" << endl;
#define mod 1000000007
#define mod2 998244353
#define INT_MAX1 900000000
//////////////////////////////////////////////////////////////////////////////////////////////

int n;
int a[100001],b[100001],c[100001];
int dp[100001][3];
bool v[100001][3];

int s1(int i, int s)
{
    if(i==n)
        return 0;
    if(v[i][s])
        return dp[i][s];
    v[i][s] = 1;
    


    for(int k=0; k<=2; k++)
    {
        if(k==s)
            continue;
        dp[i][s] = max(dp[i][s],s1(i+1,k));
    }


    if(s==0)
        dp[i][s] += a[i];
    else if(s==1)
        dp[i][s] += b[i];
    else
        dp[i][s] += c[i];
    return dp[i][s];
}

void solve()
{
    cin >> n;
    rep(i,0,n-1)
        cin >> a[i]>>b[i]>>c[i];
    cout << max({s1(0,0),s1(0,1),s1(0,2)});
}
 
int32_t main()
{
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 9984
A,B,M = map(int,input().split())
A_list = list(map(int,input().split()))
B_list = list(map(int,input().split()))
C_list = []
for x in range(M):
    C_list.append(list(map(int,input().split())))

ans = min(A_list) + min(B_list)
#print(ans)

for x in C_list:
    tmp = A_list[x[0]-1] + B_list[x[1]-1] - x[2]
#    print("tmp",tmp)
    if(ans > tmp):
        ans = tmp
print(ans)

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

int main() {
    string str;
    getline(cin, str);

    for (int i = 0; i < str.length(); i++) {
        if (str[i] >= 'a' && str[i] <= 'z') {
            str[i] += 'A' - 'a';
        } else if (str[i] >= 'A' && str[i] <= 'Z') {
            str[i] += 'a' - 'A';
        }
    }

    cout << str << endl;
    return 0;
}



Measured memory_bytes: 3128
def bomb(x,y):
    s=M[y]
    if s[x]=="0":return
    M[y]=s[:x]+"0"+s[x+1:]
    R=[-3,-2,-1,1,2,3]
    for e in R:
        bomb(x+e,y)
        bomb(x,y+e)
    return

A=range(14)
B=range(3,11)
M=["00000000000000" for i in A]
z="000"
n=input()
for i in range(n):
    s=raw_input()
    for j in B:
        M[j]=z+raw_input()+z
    x=input()+2
    y=input()+2
    bomb(x,y)
    print "Data %d:" %(i+1)
    for j in B:
        print M[j][3:-3]

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T1, typename T2>
istream& operator>>(istream& is, pair<T1,T2>& p) {
	is >> p.first >> p.second;
	return is;
}
template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

P operator-(const P& p1, const P& p2) {
	return P(p1.first - p2.first, p1.second - p2.second);
}

ll cross(P p1, P p2) {
	return p1.first * p2.second - p1.second * p2.first;
}

struct Polygon {
	vector<int> len;
	vector<bool> isRight;
	Polygon(vector<P> v) {
		int n = v.size();
		len.resize(n-1);
		isRight.resize(n-2);
		REP(i, n-2) {
			P p1 = v[i+1]-v[i], p2 = v[i+2]-v[i+1];
			isRight[i] = cross(p1, p2) < 0;
		}
		REP(i, n-1) {
			P p = v[i+1]-v[i];
			len[i] = abs(p.first+p.second);
		}
	}
	Polygon(vector<int> len, vector<bool> isRight) : len(len), isRight(isRight) {}
	Polygon rev() {
		vector<int> l = len;
		vector<bool> ir = isRight;
		reverse(ALL(l));
		reverse(ALL(ir));
		REP(i,ir.size()) ir[i] = !ir[i];
		return (Polygon){l, ir};
	}
	bool operator==(const Polygon& pol) {
		if (pol.len.size() != len.size()) {
			return false;
		}
		REP(i,len.size()) {
			if (pol.len[i] != len[i]) return false;
		}
		REP(i,isRight.size()) {
			if (pol.isRight[i] != isRight[i]) return false;
		}
		return true;
	}
};

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	while (cin >> N, N) {
		++N;
		vector<Polygon> pol;
		REP(i, N) {
			int M; cin >> M;
			vector<P> v(M); cin >> v;
			pol.pb( Polygon(v) );
		}
//		cout << pol[1].len << endl;
//		cout << pol[1].isRight << endl;
		FOR(i, 1, N) {
			if (pol[0] == pol[i] || pol[0] == pol[i].rev()) {
				cout << i << endl;
			}
		}
		cout << "+++++" << endl;
	}
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
long long a[101],f[101][100001],s[100001];
int main()
{
        long long i,j,n,k,l,a1;
        scanf("%lld %lld",&n,&k);
        for(i=1;i<=n;i++)
        {
                scanf("%lld",&a[i]);
        }
        f[0][0]=1;
        for(i=1;i<=n;i++)
        {
                s[0]=1;
                for(a1=1;a1<=k;a1++)
                {
                        s[a1]=s[a1-1]+f[i-1][a1];
                }
                for(j=0;j<=k;j++)
                {
                        if(j-a[i]>0)
                                f[i][j]=(s[j]-s[j-a[i]-1])%1000000007;
                        else
                                f[i][j]=s[j]%1000000007;
                }
        }
        printf("%lld",f[n][k]%1000000007);
        return 0;
}


Measured memory_bytes: 79104
#include <stdio.h>

#define SIZE 2000000

int main() {
  int A[SIZE];
  int H=0;
  int i, l, largest, tmp, n;
  char com[21], buf[20];
  buf[19]='\n';
  char *p,*c1,*c2;
  c1 = com+1;
  c2 = com+2;
  do {
    fgets(com, 20, stdin);
    if (*com == 'i') {
      n = 0;
      p = com+7;
      while (*p!='\n') {
        n = n*10+*p-'0';
        p++;
      }
      A[++H] = n;
      for (i=H; i>1 && A[i>>1]<A[i];i>>=1) {
        tmp = A[i>>1];
        A[i>>1] = A[i];
        A[i] = tmp;
      }

    } else if (*c1=='x') { // extract
      n = A[1];
      for (i=18; n>0; n/=10) buf[i--]=(n%10)+'0';
      fputs(buf+i+1, stdout);
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i<<1;
        if (l < H && A[l] > A[i])        largest = l;
        else         largest = i;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    }
  } while (*c2!='d');
  return 0;
}


Measured memory_bytes: 5500
n,k=map(int,input().split())
 
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

x10=n
x2=Base_10_to_n(x10, k)
print(len(x2))

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

using namespace std;
typedef pair<long long, long long> ii;
static vector<int> adj[105];
static bool vis[105];

int main(){
	//freopen("i.txt","r",stdin);
	ii ans = ii(10238293213LL,23213213213LL);
	vector<ii> edges;
	
	int n; cin >> n;
	for(int i = 0;i < n - 1;i++){
		int u, v; cin >> u >> v; u--; v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
		edges.push_back(ii(u,v));
	}
	
	
	vector<long long> nodes;
	long long img = 0;
	for(int R = 0;R < n;R++){
		fill(vis,vis+n,false);
		long long depth = 1;
		img = 0;
		vis[R] = true;
		nodes.clear();
		nodes.push_back(R);
		while(true){
			vector<long long> newNodes;
			long long maxSz = 0;
			for(int u : nodes){
				for(int v : adj[u]){
					if(vis[v]) continue;
					newNodes.push_back(v);
				}
				maxSz = max(maxSz, (long long) adj[u].size() - 1);
			}
			
			if((int) newNodes.size() == 0) break;
			
			
			
			img *= maxSz;
			
			for(int u : nodes){
				long long newImg = maxSz - (adj[u].size() - 1);
				img += newImg;
				vis[u] = true;
			}
			
			
			
			
			swap(nodes, newNodes); newNodes.clear();
			depth++;
		}
		
		long long leaf = img + nodes.size();
		//cout << R << " " << depth << " " << leaf << "\n";
		ans = min(ans, ii(depth, leaf));
	}
	
	
	for(ii e : edges){
		fill(vis,vis+n,false);
		long long depth = 1;
		img = 0;
		vis[e.first] = true;
		vis[e.second] = true;
		nodes.clear();
		nodes.push_back(e.first);
		nodes.push_back(e.second);
		while(true){
			vector<long long> newNodes;
			long long maxSz = 0;
			for(int u : nodes){
				for(int v : adj[u]){
					if(vis[v]) continue;
					newNodes.push_back(v);
				}
				maxSz = max(maxSz, (long long) adj[u].size() - 1);
			}
			
			if((int) newNodes.size() == 0) break;
			
			img *= maxSz;
			
			for(int u : nodes){
				long long newImg = maxSz - (adj[u].size() - 1);
				img += newImg;
				vis[u] = true;
			}
			
			//if(e.first == 1 && e.second == 2){
			//	cout << depth << " " << img << "\n";
			//}
			
			
			swap(nodes, newNodes); newNodes.clear();
			depth++;
		}
		
		long long leaf = img + nodes.size();
		
		ans = min(ans, ii(depth, leaf));
		
		//cout << e.first << " " << e.second << " " << depth << " " << leaf << "\n";

	}
	
	cout << ans.first << " " << ans.second << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int W,H,N;

  cin >> W>>H>>N;

  int xmi=0,ymi=0;
  int xma=W,yma=H;

  rep(i,N){
    int x,y,a;
    cin >> x>>y>>a;
    if(a==1){
      xmi=max(xmi,x);
    }
    else if(a==2){
      xma=min(xma,x);
    }
    else if(a==3){
      ymi=max(ymi,y);
    }
    else{
      yma=min(yma,y);
    }
  }
  cout << max(0,xma-xmi)*max(0,yma-ymi) <<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256