akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

//aとbが同じ文字となりうるか判定
bool same(char a, char b){
    return (a == '?' || b == '?' || a == b);
}

//aのx文字目以降とbが一致するか
bool consist(string a, string b, int x){
    if(x >= a.size()) return true;
    rep(i, min(b.size(), a.size()-x)){
        if(!same(b[i], a[x+i])) return false;
    }
    return true;
}

//文字列sとsのi文字目(0-indexed)以降の最長共通接頭辞の長さを記録した配列を返す
vector<int> z_algorithm(string s){
    int n = s.size();
    vector<int> res(n);
    res[0] = n;
    int i = 1, j = 0;
    while(i < n){
        while(i+j < n && same(s[j], s[i+j])) j++;
        res[i] = j;
        if(j == 0) {i++; continue;}
        int k = 1;
        while(i+k < n && k+res[k] < j){
            res[i+k] = res[k];
            k++;
        }
        i += k, j -= k;
    }
    return res;
}

int main(){
    string s[3];
    int n[3];
    rep(i, 3) {cin >> s[i]; n[i] = s[i].size();}
    bool a[3][3][4001];
    rep(i, 3) rep(j, 3) rep(k, 4001){
        a[i][j][k] = consist(s[i], s[j], k);
    }
    int ans = inf;
    //先頭の文字がi,j,kの順番である場合を調べる
    rep(i, 3) rep(j, 3) rep(k, 3){
        if(i == j || j == k || k == i) continue;
        //j,kを始める位置をすべて調べる
        rep(p, n[i]+1) rep(q, max(n[j], n[i]-p)+1){
            if(!a[i][j][p] || !a[j][k][q] || !a[i][k][p+q]) continue;
            int tmp = n[i];
            tmp = max(tmp, p+n[j]);
            tmp = max(tmp, p+q+n[k]);
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// AOJ 2589 "North North West" (ICPC模擬地区予選 2014 Problem A)
import java.util.Scanner;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            String s = sc.next();
            if (s.equals("#")) {
                break;
            }
            
            BigDecimal degree;
            int pos = s.length() - 1;
            if (s.charAt(pos) == 't') {
                degree = new BigDecimal("90");
                pos -= 4;
            } else {
                degree = new BigDecimal("0");
                pos -= 5;
            }
            
            int n = 1;
            BigDecimal tmp = new BigDecimal("45");
            while (pos >= 0) {
                if (s.charAt(pos) == 't') {
                    degree = degree.add(tmp);
                    pos -= 4;
                } else {
                    degree = degree.subtract(tmp);
                    pos -= 5;
                }
                n++;
                tmp = tmp.divide(new BigDecimal("2"));
            }
            
            if (n > 2) {
                degree = degree.multiply(new BigDecimal(Math.pow(2, n - 2)));
            }
            System.out.print(degree.intValue());
            if (n > 2) {
                System.out.print("/" + (int)Math.pow(2, n - 2));
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 17520
using System;
using System.Collections.Generic;

namespace ABC115_B_Christmas_Eve_Eve
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			List<int> pList = new List<int>(n);
			for(int i = 0; i < n; i++)
				pList.Add(int.Parse(Console.ReadLine()));
			
			pList.Sort();
			int sum = 0;
			for (int i = 0; i < n - 1; i++)
				sum += pList[i];

			sum += pList[n - 1] / 2;
			
			Console.WriteLine(sum);
		}
	}
}

Measured memory_bytes: 11220
#include<stdio.h>
int main()
{
    int p,q;
    char c;
    scanf("%d",&p);
    scanf(" %c",&c);
    scanf("%d",&q);
    if(c=='+'){
        printf("%d\n",p+q);
    }
    else{
        printf("%d\n",p-q);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int a[50]={0,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};
	int k;	cin>>k;
	cout<<a[k]<<endl;
}

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

int n,i;
char s1[111],s2[111];

int main(){
	
	cin>>n;
	scanf("%s",s1);
	scanf("%s",s2);
	for(i=0;i<=n-1;i++){
		cout<<s1[i]<<s2[i];
	}
	
	return 0;
}

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

#define pai 3.1415926535


int main(void)
{
	char s[11];
	scanf("%s", s);
	char S[100]="";
	for (int i = 0; i < strlen(s); i++) {
		if (s[i] == '0') {
			strcat(S, "0");
		}
		else if (s[i] == '1') {
			strcat(S, "1");
		}
		else {
			if (strlen(S) != 0) {
				S[strlen(S) - 1] = '\0';
			}
		}
	}
	printf("%s", S);

	return 0;


}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a[55];

bool check(ll k) {
    ll m = 0;
    for (int i = 0; i < n; i++) {
        m += max(0LL, (a[i] + k + 1) / (n + 1));
    }
    return m <= k;
}

ll solve() {
    ll lb = -1, ub = 1e18;
    while (ub - lb > 1) {
        ll mid = (ub + lb) / 2;
        bool f = false;
        for (ll i = max(lb, mid-25); i <= min(ub-1, mid+25); i++) {
            if (check(i)) {
                ub = i;
                f = true;
                break;
            }
        }
        if (!f)
            lb = mid;
        /*
        if (check(mid)) {
            ub = mid;
        } else {
            lb = mid;
        }
        */
    }
    return ub;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
import sys
from collections import Counter
one=list(input())
#print(one)
two=list(input())
z={}
result=[]
for num,i in enumerate(one):
    if i not in z:
        z[i]=[num]
    else:
        z[i].append(num)
p={}
for num,i in enumerate(two):
    if i not in p:
        p[i]=[num]
    else:
        p[i].append(num)

#print(p)
#print(z)

w=[]
for k,v in z.items():
    if len(v)>1:
        w.append(v)
o=[]
for k,v in p.items():
    if len(v)>1:
        o.append(v)
#print(w)
#print(o)
"""
for i in w:
    if i not in o:
        print("No")
        sys.exit()
for i in o:
    if i not in w:
        print("No")
        sys.exit()
print("Yes")"""
"""


for k,v in z.items():
    if len(v)>1:
        temp=0
        for k1, v1 in p.items():
            if p[k1]==z[k]:
                temp=1
"""



w.sort()
o.sort()
print("Yes") if w==o else print("No")

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



int main(){
  int N,K;
  cin>>N>>K;
  vector<int> vec(N+1);
  for(int i=0;i<K;i++){
    int d;
    cin>>d;
    for(int i=0;i<d;i++){
      int x;
      cin>>x;
      vec.at(x)+=1;
    }
  }
  
  int sum=0;
  for(int i=1;i<=N;i++){
    if(vec.at(i)==0) sum+=1;
  }
  cout<<sum<<endl;
  
 
  
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	int P[10], Q[10];
	int R[] = { 0,1,2,3,4,5,6,7,8 };
	cin >> N;
	for (int i = 0; i < N; i++)cin >> P[i];
	for (int i = 0; i < N; i++)cin >> Q[i];
	int x = 0, y = 0;
	int cnt = 0;
	do
	{
		bool ok1 = true, ok2 = true;
		for (int i = 0; i < N; i++) {
			if (R[i] != P[i] - 1)ok1 = false;
			if (R[i] != Q[i] - 1)ok2 = false;
		}
		if (ok1) x = cnt;
		if (ok2) y = cnt;
		cnt++;
	} while (next_permutation(R, R + N));
	cout << abs(x - y) << endl;
}


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

int main(){
  int N;
  cin >> N;
  
  int A[200];
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  
  int ans = 0;
  
  while(1){
    bool jud = false;
    for(int i = 0; i < N; i++){
      if(A[i] % 2 ==1){
        jud = true;
        break;
      }
    }
    
    if(jud){
      break;
    }
    
    ans++;
      
    for(int i = 0; i < N; i++){
      A[i] /= 2;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){

  cin.tie(0); //cin高速化
  ios::sync_with_stdio(false); //cin高速化
  
  int a,b;
  cin >> a >> b;
  if((a<=8)&&(b<=8)){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
char katerute(char dasite) {
    if (dasite == 'r') {
        return 'p';
    } else if (dasite == 's') {
        return 'r';
    } else {
        return 's';
    }
}
int main()
{
    int64_t N, K;
    cin >> N >> K;
    int64_t R, S, P;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    int64_t sum_score = 0;
    vector<char>vec(N);
    for (int64_t i=0; i<N; i++) {
        char dasite = T[i];
        char katite = katerute(dasite);
        int64_t add_score = 0;
        if (katite == 'r') {
            add_score = R;
        } else if (katite == 'p') {
            add_score = P;
        } else {
            add_score = S;
        }

        if (i - K >= 0) {
            if (vec[i-K] == katite) {
                vec[i] = '-';
            } else {
                vec[i] = katite;
                sum_score += add_score;
            }
        } else {
            vec[i] = katite;
            sum_score += add_score;
        }
    }

    cout << sum_score << endl;
    return 0;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int N;
	cin >> N;
	unordered_map<string, int> A;
	for (int i = 0; i < N; i++)
	{
		string temp;
		cin >> temp;
		A[temp]++;
	}
	string arr[4] = {"AC", "WA", "TLE", "RE"};
	for (int i = 0; i < 4; i++)
	{
		cout << arr[i] << " x " << A[arr[i]] << "\n";
	}
}

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

int main() {
	int N, K, ans;
	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;

		if (x > K - x) {
			ans += 2 * (K - x);
		}
		else {
			ans += 2 * x;
		}
	}

	cout << ans << endl;
}

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

using namespace std;
int main()
{
    int i,j,k,arr[100001],n,dp[100001],temp1,temp2,temp[100];
    cin>>n>>k;
    for(i=1;i<=n;++i)
        cin>>arr[i];
    arr[0]=-1;
    dp[0]=-1;
    for(i=1;i<=k;++i)
        dp[i]=abs(arr[i]-arr[1]);


    for(i=k+1;i<=n;i++)
    {
       // temp1=dp[i-1]+abs(arr[i]-arr[i-1]);
       // temp2=dp[i-2]+abs(arr[i]-arr[i-2]);
       for(j=1;j<=k;j++)
        {
            temp[j]=dp[i-j]+abs(arr[i]-arr[i-j]);
        }
        temp1=temp[1];
        for(j=1;j<=k;j++)
        {
            if(temp1>temp[j])
                temp1=temp[j];
        }

            dp[i]=temp1;

    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main() {
    char s[4];
    int i;
    bool flag = true;

    fscanf(stdin, "%s\n", s);

    for (i=1; i<4; i++) {
        if (s[i-1] == s[i]) flag = false;
    }
    if(flag) printf("Good\n");
    else printf("Bad\n");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;
string s;

int a, b;
int main(void){
	cin >> a >> b;
	printf("%d\n", (a + b) % 24);
	return 0;
}

Measured memory_bytes: 764
//add sub easy
#include <bits/stdc++.h>
using namespace std;
long long a,b;
char r1,r2,op;
int main(){
	cin>>a>>op>>b;
	if (op=='+') cout<<a+b<<endl;
	else cout<<a-b<<endl;
	//cout<<op<<endl;
	return 0;
}

Measured memory_bytes: 3540
import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
input=sys.stdin.readline
##import numpy as np
#sys.setrecursionlimit(10**7)
mo=10**9+7
def cin():
    return map(int,sin().split())
def ain():            
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
##def power(x, y):
##    if(y == 0):return 1
##    temp = power(x, int(y / 2))%mo
##    if (y % 2 == 0):return (temp * temp)%mo 
##    else:
##        if(y > 0):return (x * temp * temp)%mo 
##        else:return ((temp * temp)//x )%mo
##
##for _ in range(inin()):
n=inin()
d=dd(int)
for i in range(n):
    s=sin().strip()
    d[s]+=1
print("AC x",d["AC"])
print("WA x",d["WA"])
print("TLE x",d["TLE"])
print("RE x",d["RE"])

    
    
    
    
    
    
    
    
        
    
    
    
    
    
    
        
        
    
    
    
    


    





##
        
    
    
    
    
    
    
        
        
    
    
    
    


    





##def msb(n):n|=n>>1;n|=n>>2;n|=n>>4;n|=n>>8;n|=n>>16;n|=n>>32;n|=n>>64;return n-(n>>1) #2 ki power
##def pref(a,n,f):             
##    pre=[0]*n
##    if(f==0):         ##from beginning
##        pre[0]=a[0]
##        for i in range(1,n):
##            pre[i]=a[i]+pre[i-1]
##    else:              ##from end
##        pre[-1]=a[-1]
##        for i in range(n-2,-1,-1):
##            pre[i]=pre[i+1]+a[i]
##    return pre
##maxint=10**24 
##def kadane(a,size): 
##    max_so_far = -maxint - 1
##    max_ending_here = 0
##       
##    for i in range(0, size): 
##        max_ending_here = max_ending_here + a[i] 
##        if (max_so_far < max_ending_here): 
##            max_so_far = max_ending_here 
##  
##        if max_ending_here < 0: 
##            max_ending_here = 0   
##    return max_so_far


Measured memory_bytes: 9476
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    L = SI()
    n = len(L)
    b = 1
    ans = 1
    for i in range(len(L)):
        if L[n-i-1] == '1':
            ans = (ans*2 + b) % MOD
        b = (b * 3) % MOD
    print((ans)%MOD)

if __name__ == '__main__':
    main()

Measured memory_bytes: 41324
// Vicfred
// https://atcoder.jp/contests/abc128/tasks/abc128_c
// bitmask, brute force, implementation
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    int n, m;
    readf("%d %d\n", &n, &m);

    int[][] bulbs = new int[][](m+1, n+1);

    foreach(i; 1..m+1)
        bulbs[i] = readln.split.map!(to!int).array[1..$];

    int[] p = 0~readln.split.map!(to!int).array;

    int ans = 0;
    for(int mask = 0; mask <= ((1 << n) - 1); mask++) {
        int[] turned = new int[m+1];
        for(int bit = 0; bit < n; bit++)
            if(mask & (1 << bit))
                for(int i = 1; i <= m; i++)
                    if(bulbs[i].count(bit + 1) > 0)
                        turned[i] += 1;

        int count = 0;
        for(int i = 1; i <= m; i++)
            if(turned[i]%2 == p[i])
                count += 1;

        if(count == m)
            ans += 1;
    }
    
    ans.writeln;
}



Measured memory_bytes: 2872
#include <bits/stdc++.h>
using namespace std;
#define LL long long

int main() {

LL  N;
cin>>N;
if((N-1)%10==0){
cout<<"pon"<<endl;
}
else if((N-2)%10==0){
  cout<<"hon"<<endl;
}
else if((N-3)%10==0){
  cout<<"bon"<<endl;
}
else if((N-4)%10==0){
  cout<<"hon"<<endl;
}
else if((N-5)%10==0){
  cout<<"hon"<<endl;
}
else if((N-6)%10==0){
  cout<<"pon"<<endl;
}
else if((N-7)%10==0){
  cout<<"hon"<<endl;
}
else if((N-8)%10==0){
  cout<<"pon"<<endl;
}
else if((N-9)%10==0){
  cout<<"hon"<<endl;
}
else if(N%10==0){
  cout<<"pon"<<endl;
}
}


Measured memory_bytes: 3632
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
N,Q=map(int,input().split())
L=[[] for _ in range(N)]
for _ in range(N-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    L[a].append(b)
    L[b].append(a)
CL=[0]*N
for _ in range(Q):
    p,x=map(int,input().split())
    CL[p-1]+=x

AL=[0]*N
ed=[0]*N
q=[(0,0)]
while len(q)!=0:
    now,val=q.pop(-1)
    ed[now] = 1
    val += CL[now]
    AL[now] = val
    for p in L[now]:
        if ed[p] == 0:
            q.append((p,val))
print(" ".join(map(str,AL)))

Measured memory_bytes: 125352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int v[][][] = new int[4][3][10];
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		for(int i = 0; i < n; i++){
			int b = scan.nextInt() - 1;
			int f = scan.nextInt() - 1;
			int r = scan.nextInt() - 1;
			v[b][f][r] += scan.nextInt();
		}
		scan.close();
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 10; k++){
					System.out.print(" " + v[i][j][k]);
				}
				System.out.println();
			}
			if(i != 3){
				System.out.println("####################");
			}
		}
	}
}

Measured memory_bytes: 30208
from collections import Counter
from functools import reduce

N, K = map(int, input().split())
A = [int(s) for s in input().split()]

count = Counter(A)

if len(count.keys()) <= K:
    print(0)
    exit()

L = sorted(list(count.items()), key=lambda x: x[1], reverse=True)
ans = sum([n[1] for n in L[K:]])
print(ans)

Measured memory_bytes: 41332
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np

N = int(input())
prev_dst = [0,0,0]

for n in range(N):
    t, x, y = map(int, input().split(" "))
    a = (t - prev_dst[0]) - (np.abs(prev_dst[1]-x) + np.abs(prev_dst[2]-y))
    if a >= 0 and a % 2 == 0:
        prev_dst = [t, x, y]
    else:
        print("No")
        exit(0)

print("Yes")



Measured memory_bytes: 12504
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include<vector>
#include<cstring>
#include<set>
#include <cstdio>
#include<queue>
#include<map>
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define endl '\n'
#define forup(i,a,n) for( int i =a; i < n; i++)
#define llforup(i,a,n) for( ll i =a; i < n; i++)
#define fordown(i,a,n) for( int i =a; i >= n; i--)
#define fornot(i,a,n) for( int i=a;!n;i++)
#define mod  (ll)(1e9+7)
#define ifempty(a)  if(!a)
using namespace std;
typedef long long ll;
inline int readnum()
{
	int p, data = 0; char ch = 0;
	while ((ch != ' - ') && ch < '0' || ch>'9') ch = getchar();//相当于正则表达式的搜索，跳过不需要的字符
	if (ch == '- ')p = -1, ch = getchar();
	else p = 1;
	while (ch >= '0' && ch <= '9') data = data * 10 + ch - '0', ch = getchar();//搜索需要的字符
	return data * p;
}
//E-mail 374656045@qq.com
#define MAX 1400
int tile[MAX][MAX + 1];
struct Rectangle { int height; int pos; };
Rectangle stack[1401];//开全局第W+1个已经自动初始化为0
class solve {
private:
	int H, W; int area; int bound; int top;
	char ch;
public:
	solve()
	{
		initial();//OK,单元测试通过
		int ans = getrectangle();//方便生成优质机器码
		printf("%d\n",ans );
	}
	inline void initial()
	{
		scanf("%d %d", &H, &W);
		forup(i, 0, H)
			forup(j, 0, W)
		{
			ch = getchar();
			while (ch == ' ' || ch == '\n')
				ch = getchar();//惯用法

			tile[i][j] = (ch == '0') ? 0 : 1;
		}
		forup(i, 0, W)tile[0][i] = (tile[0][i] == 0) ? 1 : 0;
		forup(i, 1, H)
			forup(j, 0, W)
			tile[i][j] = (tile[i][j] == 0) ? (tile[i - 1][j] + 1) : 0;//OK,
	}
	int getrectangle()
	{
		int maxv = 0;
		forup(i, 0, H)
		{//开头元素必须要特殊处理，还有++top更合适
			top = 0; stack[top].height = tile[i][0];// stack[top].pos = 0;这部分自动初始化
			forup(j, 1, W + 1)//由于开全局，每行第W+1个元素已经被初始化为0.
			{
					
					if (stack[top].height < tile[i][j]) 
					{
						stack[++top].height = tile[i][j]; stack[top].pos = j;
					}//分级防止越界
					else if(stack[top].height>tile[i][j])
					{
						while (stack[top].height > tile[i][j])
						{
							area =stack[top].height * (j - stack[top].pos);
							top--;
							if (area > maxv)
								maxv = area;
							if (top==-1)break;//麻烦，降低效率，改进否？
						}
						stack[++top].height = tile[i][j];//反应了手写数组栈的优势！
					}
				
			}
		}
	
		return	maxv;
	}
};
int main(void)
{
	//ios_base::sync_with_stdio(0); cin.tie(0);//慎用，cin和scanf混用会导致非MSC++WA
#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve solution;
#ifdef DEBUG
	fclose(stdin);//关闭文件 
	fclose(stdout);//关闭文件 
#endif
	return 0;

}




Measured memory_bytes: 10876
# 1000000000000001 15
# 素因数分解的な感じで解く 26で解く
n = int(input())
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
            'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']


def base10to(n, b):
    if n/b == 0:
        return
    n -= 1
    if (int(n//b)):
        return base10to(int(n//b), b) + alphabet[n % b]
    return alphabet[n % b]


print(base10to(n, 26))


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

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  for(ll i=0;i<s.size();i++) {
    if('z'-s[i]<k&&s[i]!='a') {
      k-='z'-s[i]+1;
      s[i]='a';
    }
  }
  s[s.size()-1]=char(s[s.size()-1]+k%26);
  cout << s << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = Integer.parseInt(sc.nextLine().trim());
		
		int[] i = new int[M];
		
		for(int j = 0; j < i.length; j++) {
			i[j] = 0;
		}
		
		for(int k = 0; k < N; k++) {
			String s = sc.nextLine();
			String[] split = s.split(" ");
			
			for(int l = 1; l < split.length; l++) {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			}
		}
		
		int res = 0;
		
		for(int n = 0; n <i.length; n++) {
			if(i[n] == N) {
				res++;
			}
		}
		System.out.println(res);
	}
}

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

int main() {

  int N, M;
  cin >> N >> M;

  vector<int> a(N+1);

  for (int i = 0; i < M; i++) {
    int i_;
    cin >> i_;
    a[i_] = 1;
  }

  vector<long> dp(N+1);

  long mod = 1000000007;
  
  dp[N] = 1;

  for (int i = N - 1; 0 <= i; i--) {
    if (a[i] == 1) {
      dp[i] = 0;
    } else {
      if (i == N - 1) {
        dp[i] = dp[N];
      } else if (N < i + 2) {
        dp[i] = (dp[i + 1] + dp[N]) % mod;
      } else {
        dp[i] = (dp[i + 1] + dp[i+2]) % mod;
      }
    }
  }

  cout << dp[0] << endl;

}

Measured memory_bytes: 1408
#include<iostream>

using namespace std;

typedef long long ll;

ll f(ll x){
  ll a = ((x + 1)/2) % 2;
  return x % 2 ? a : (a ^ x);
}

int main(void){
  ll a,b;
  cin >> a >> b;
  cout << (f(a-1)^f(b)) << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> PA;
#define int long long
#define MAXN 1003
#define MAXK 100005
#define INF 1000000009
#define pb push_back

int n, a[103], ans;


signed main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i > 0){
            if(a[i] == a[i - 1] && a[i - 1] != 0){
                ans++;
                a[i] = 0;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

int N;

int main(){
    scanf("%d", &N);
    long r, l;
    long sum = 0;
    for(int i=0; i<N; i++){
        scanf("%ld%ld", &l, &r);
        sum += r-l+1;
    }
    printf("%ld", sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int b[105];
typedef long long ll;
ll ans = 0;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n - 1; i++)
    cin >> b[i];
  for (int i = 1; i <= n - 2; i++) {
    ans += min(b[i], b[i + 1]);
  }
  ans += b[1];
  ans += b[n - 1];
  cout << ans << endl;
}

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

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1; 
    //cin >> t;
    for(int T = 0; T < t ; T++){
        int x;
        cin >> x;
        cout << 1 - x << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

int a[100];
int main(){
	int n;
	long long d[100];
	d[0] = 2;d[1] = 1;
	cin >> n;
	for(int i = 2;i <= n;i++){
		d[i] = d[i-1] + d[i-2];
	}
	cout << d[n] << endl;
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
k_keta = len(bin(k)) - 2
k_nisin = list(bin(k))
k_nisin.pop(0)
k_nisin.pop(0)
a = list(map(int,input().split()))
a_keta = len(bin(max(a))) - 2

fix = max(k_keta,a_keta)
nisin = []
for i in range(n):
    temp = list(bin(a[i]))
    temp.pop(0)
    temp.pop(0)
    for i in range(fix-len(temp)):
        temp.insert(0,"0")
    nisin.append(temp)

counter = []
for i in range(fix):
    temp = 0
    for k in range(n):
        if nisin[k][i] == "1":
            temp += 1
    counter.append(temp)

ans = [0 for i in range(k_keta)]
check = False # ans が k より小さいことが確定した場合True
for i in range(k_keta):
    if counter[-1-k_keta+1+i]*2 <= n:
        if k_nisin[i] == "1":
            ans[i] += 1
        else:
            if check:
                ans[i] += 1
    else:
        if k_nisin[i] == "1":
            check = True

ans.reverse()
x = 0 #Xに当たる
c = 1
for i in range(len(ans)):
    x += ans[i] * c
    c = c*2

out = 0
for i in range(n):
    out += x ^ a[i]
print(out)

Measured memory_bytes: 56324
w,h,n=map(int,input().split())
s=0
b=w
t=0
c=h

for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    s=max(s,x)
  elif a==2:
    b=min(b,x)
  elif a==3:
    t=max(t,y)
  else:
    c=min(c,y)
if b>s and c>t:
   print((b-s)*(c-t))
else:
  print(0)

Measured memory_bytes: 9052
n = int(input())
sss = list(map(int, input().split()))

ans = 0
for c in range(1, n // 2):
    a = n - 1 - c
    k = c
    tmp = 0
    while a > c and a != k and a + c != k:
        tmp += sss[a] + sss[k]
        ans = max(ans, tmp)
        a -= c
        k += c
print(ans)


Measured memory_bytes: 14860
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc162/tasks/abc162_d

//ポイント：
//条件が考えづらい時は
//全体 - 条件に当てはまらないもの
//という考え方をするといい時がある
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
string S;
 
LL ans = 0;
 
void solve(){
	//最初にとりあえず全パターン足して
	LL r = 0,g = 0,b = 0;
	for(int i=0;i<N;i++){
		if(S[i]=='R') r++;
		if(S[i]=='G') g++;
		if(S[i]=='B') b++;
	}
	ans += r*g*b;

	//後から条件を満たさないものを引く
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(2*j-i>=N) continue;
			if(S[i]!=S[j] && S[i]!=S[2*j-i] && S[j]!=S[2*j-i]) ans--;
		}
	}
}
 
int main(){
    cin >> N;
    cin >> S;
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
struct custom_hash 
{
    static unsigned long long splitmix64(unsigned long long x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(unsigned long long x) const 
    {
        static const unsigned long long FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
mt19937 random_generator(chrono::steady_clock::now().time_since_epoch().count());

string s;
void read()
{
	cin >> s; 
}

int dp[2019], nxt_dp[2019];
void solve()
{
	int sz = s.size();
    dp[s[0]-'0']++;
    long long ans = dp[0];
    for (int i = 2; i <= sz; i++)
    {
		memset(nxt_dp, 0, sizeof(nxt_dp)); 
		for (int j = 0; j < 2019; j++)
        nxt_dp[(j * 10 + s[i-1] - '0') % 2019] += dp[j];
        
        nxt_dp[s[i-1]-'0']++;
        for (int j = 0; j < 2019; j++)
        dp[j] = nxt_dp[j];
     
        ans += dp[0];
	}
	
	cout << ans << endl; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	read();
	solve();
}


Measured memory_bytes: 3760
# coding: utf-8
# Your code here!

while True:
   try:
      a, b, c, d, e, f = map(float, input().split())
      x = (c * e - b * f) / (a * e - b * d)
      y = (c - a * x) / b
      
      if x == 0:
         print('{:.3f}'.format(abs(x)), '{:.3f}'.format(y))
      elif y == 0:
         print('{:.3f}'.format(x), '{:.3f}'.format(abs(y)))
      else:
         print('{:.3f}'.format(x), '{:.3f}'.format(y))
   except EOFError:
      break



Measured memory_bytes: 5592
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    map<string,int> s;
    for (int i=0; i<n; i++) {
        string si; cin>>si;
        s[si];
    }

    cout << s.size() << endl;
}


Measured memory_bytes: 18820
def main():
    a,b = map(int, input().split())
    c = [0, 0, 0, 0, 0]
    ans = 0

    for n in range(a,b+1):
        for i in range(5):
            c[i] = n % 10
            n = n // 10

        if (c[0]==c[4]) and (c[1]==c[3]):
            ans = ans + 1
    return ans

print(main())

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


int N;
vector<int> a, b;
vector<int> nxt, vt, vp;


vector<int> kmp()
{
    int i, q, k;
    vector<int> res;

    nxt[0] = 0;
    for (q = 1, k = 0; q < N; ++q) {
        while (k > 0 && vp[q] != vp[k])
            k = nxt[k - 1];
        if (vp[q] == vp[k])
            k++;
        nxt[q] = k;
    }

    for (i = 0, q = 0; i < 2*N-1; ++i) {
        while (q > 0 && vp[q] != vt[i])
            q = nxt[q - 1];
        if (vp[q] == vt[i])
            q++;
        if (q == N) {
            res.push_back(i - N + 1);
            q = nxt[q - 1];
        }
    }
    return res;
}


void solve()
{
    vector<int> c(N);
    vector<int> d(N);
    vector<int> pos;
    nxt.resize(N);
    vt.resize(2*N-1);
    vp.resize(N);

    for (int i = 0; i < N - 1; i++) {
        c[i] = a[N - 1 - i] ^ a[N - 2 - i];
        d[i] = b[N - 1 - i] ^ b[N - 2 - i];
    }
    c[N - 1] = a[N - 1] ^ a[0];
    d[N - 1] = b[N - 1] ^ b[0];
    for (int i = 0; i < 2*N; i++)
        vt[i] = (i < N) ? d[i] : d[i - N];
    for (int i = 0; i < N; i++)
        vp[i] = c[i];

    pos = kmp();
    for (int k : pos) {
        int x = b[0] ^ a[k];
        cout << k << " " << x << endl;
    }
}


int main()
{
    cin >> N;
    a.resize(N);
    b.resize(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    for (int i = 0; i < N; i++)
        cin >> b[i];
    solve();
    return 0;
}


Measured memory_bytes: 10612
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

    LL a, b, c;
    cin >> a >> b >> c;
    LL ans = (a/2 + a%2) * b * c - (a/2) * b * c;
    ans = min(ans, (b/2 + b%2) * a * c - (b/2) * a * c);
    ans = min(ans, (c/2 + c%2) * b * a - (c/2) * b * a);
    cout << ans << endl; 
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   string X, Y;
   cin >> X >> Y;
   if (X > Y) cout << ">" << endl;
   else if (X < Y) cout << "<" << endl;
   else cout << "=" << endl;
   return 0;
}


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

int main(){
  long N, T;
  cin >> N >> T;
  long ans=0;
  long time=0;
  cin >> time;
  for(int i=1; i<N; i++){
    long t;
    cin >> t;
    if(t-time<=T){
      ans+=t-time;
    }
    else ans+=T;
    time=t;
  }
  cout << ans+T << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
ll dp[111][111111];
const int C=100000+300;

int main(){
  int n,w;
   cin>>n>>w;
  vector<pair<ll,ll> > v(n+1);
   for(int i=1;i<=n;i++)cin>>v[i].first>>v[i].second;
   for(int i=1;i<=C;i++)dp[0][i]=ll(1e18);
   for(int i=1;i<=n;i++)for(int j=1;j<=C;j++){
     dp[i][j]=dp[i-1][j];
     if(j-v[i].second>=0)dp[i][j]=min(dp[i][j],dp[i-1][j-v[i].second]+v[i].first);
   }
   ll ans=0;
   for(ll i=1;i<=C;i++)if(dp[n][i]<=w)ans=max(ans,i);
   cout<<ans;
   }

Measured memory_bytes: 88192
# -*- coding:utf-8 -*-
N,x = map(int,input().split())
a = list(map(int,input().split()))

cnt = 0
a.sort()

while x > 0:
    if cnt >= N:
        if x > 0:
            cnt -= 1
            break
        else:
            break
    elif a[0] > x:
        break
    else:
        tmp = a.pop(0)
        x -= tmp
        cnt+=1


print(cnt)


Measured memory_bytes: 9176
s=input()
s1=int(s[:2])
s2=int(s[2:])
if 0<s1<13 and 0<s2<13:
  print("AMBIGUOUS")
elif (12<s1 or s1==0) and 0<s2<13:
  print("YYMM")
elif (12<s2 or s2==0) and 0<s1<13:
  print("MMYY")
else:
  print("NA")

Measured memory_bytes: 3060
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n";
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

const int maxn=2000+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;
char arr[maxn][maxn];
int dpr[maxn][maxn];
int dpl[maxn][maxn];
int dpd[maxn][maxn];
int ddp[maxn][maxn];
int dpu[maxn][maxn];
int main(){
	migmig;
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>arr[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			dpl[i][j]=dpl[i][j-1]+1;
			if(arr[i][j]=='#'){
				dpl[i][j]=0;
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=m;j>=1;j--){
			dpr[i][j]=dpr[i][j+1]+1;
			if(arr[i][j]=='#'){
				dpr[i][j]=0;
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			dpu[i][j]=dpu[i-1][j]+1;
			if(arr[i][j]=='#'){
				dpu[i][j]=0;
			}
		}
	}
	for(int i=n;i>=1;i--){
		for(int j=1;j<=m;j++){
			dpd[i][j]=dpd[i+1][j]+1;
			if(arr[i][j]=='#'){
				dpd[i][j]=0;
			}
		}
	}
	int ans=-1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			ddp[i][j]=dpl[i][j]+dpr[i][j]+dpd[i][j]+dpu[i][j];
			ans=max(ans,ddp[i][j]);
		}
	}	
	cout<<ans-3;
	return 0;
}



Measured memory_bytes: 82688
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

ll gcd(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
}

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

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

    if(B%A==0){
        cout << A+B << endl;
    }else{
        cout << B-A << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Point {
	final int x;
	final int y;

	Point( final int x, final int y ) {
		this.y = y;
		this.x = x;
	}

	public boolean equals( final Point p ) {
		return x == p.x && y == p.y;
	}
}

class Main {

    public static void main( final String[] args ) {

		final Scanner stdin = new Scanner( System.in );

		while ( true ) {

			final int w = stdin.nextInt();
			final int h = stdin.nextInt();
			final int[][] map = new int[ h + 2 ][ w + 2 ];
			
			if ( w == 0 && h == 0 ) break;

			final Point start = new Point( stdin.nextInt(), stdin.nextInt() );
			final Point end = new Point( stdin.nextInt(), stdin.nextInt() );

			final int n = stdin.nextInt();
			for ( int i = 0; i < n; i++ ) {
				final int c = stdin.nextInt();
				final int d = stdin.nextInt();
				final int xs = stdin.nextInt();
				final int ys = stdin.nextInt();

				final int dx = d == 0 ? 4 : 2;
				final int dy = d == 0 ? 2 : 4;
				
				for ( int y = ys; y < ys + dy; y++ ) {
					for ( int x = xs; x < xs + dx; x++ ) {
						map[ y ][ x ] = c;
					}
				}				
			}
			if ( solve( map, start, end ) ) {
				System.out.println( "OK" );
			} else {
				System.out.println( "NG" );
			}
		}
    }

	static final int VISITED = -1;
	static final int[] dx = {-1, 0, 1, 0};
	static final int[] dy = {0, 1, 0, -1};
	
	static boolean solve( final int[][] map, final Point start, final Point end ) {
		
		final int color = map[ start.y ][ start.x ];
		final int w = map[ 0 ].length - 2;
		final int h = map.length - 2;
		
		final Queue<Point> que = new ArrayDeque<Point>();

		que.add( start );

		while ( !que.isEmpty() ){
			final Point p = que.poll();
			map[ p.y ][ p.x ] = VISITED;
			if ( p.x == end.x && p.y == end.y ) return true;

			for ( int i = 0; i < 4; i++ ) {
				final int nx = p.x + dx[ i ];
				final int ny = p.y + dy[ i ];

				if ( 1 <= nx && nx <= w && 1 <= ny && ny <= h &&
					 map[ ny ][ nx ] == color ) {

					que.offer( new Point( nx, ny ) );
				}				
			}			
		}
		return false;
	}
}

Measured memory_bytes: 86468
#include<bits/stdc++.h>
#define ll     long long int
#define mod    1000000007
#define io     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi      vector<int>
#define endl    "\n"
using namespace std;
void solve();
int main()
{
	io

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
//	/*is Single Test case?*/cin >> t;
	for (int i = 1; i <= t; i++)
	{	//cout<<"Case #"<<i<<": ";
		solve();
		cout << "\n";
	}

	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}
void solve()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({a * c, b * c, a * d, b * d});

}




Measured memory_bytes: 3784
#include<iostream>
#include<vector>
#define lli long long int
using namespace std;
int main()
{
	lli h,n,sum=0;
	cin>>h>>n;
	for(int i=0;i<n;i++)
	{  int a;
		cin>>a;
		sum+=a;
	}
	if(sum>=h)
	cout<<"Yes";
	else 
cout<<"No";

}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main( int argc, char** argv ){

	int a1,b1;
	int a2,b2;
	int a3,b3;

	cin >> a1 >> b1;
	cin >> a2 >> b2;
	cin >> a3 >> b3;

	int x1=0,x2=0,x3=0,x4=0;
	int num[6];

	num[0] = a1;
	num[1] = b1;
	num[2] = a2;
	num[3] = b2;
	num[4] = a3;
	num[5] = b3;

	for(int i = 0; i < 6; i++){
		if(num[i] == 1){
			x1++;
		}
		else if (num[i] == 2){
			x2++;
		}
		else if (num[i] == 3){
			x3++;
		}
		else if (num[i] == 4){
			x4++;
		}
	}

	if (x1 >= 3 || x2 >= 3 || x3 >= 3 || x4 >= 3 ){
		cout << "NO" << endl;
	}else{
		cout << "YES" << endl;
	}
		
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void){
    int x,a,b;
    int xa = 0,
        xb = 0;
    scanf("%d",&x);
    scanf("%d",&a);
    scanf("%d",&b);

    if(x-a<0){
        xa = a-x;
    }else{
        xa = x-a;
    }

    if(x-b<0){
        xb = b-x;
    }else{
        xb = x-b;
    }
    if(xb > xa){
        printf("A\n");
    }else{
        printf("B\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,m;
int e;
vvi data;

//DFS
vector<vector<pair<int, int>>> g;
const int N = 1e5;
int used[N];
int col[N];

int dfs(int i, int c,int num) {
  if(used[i]) return 0;
  used[i] = 1;
  
  for(auto to : g[i]) {
    if (to.first==c){
      e=1;
      data[to.second].emplace_back(num);
      break;
    }else{
      e=dfs(to.first, c,num);
      if (e==1){
        data[to.second].emplace_back(num);
        break;
      }
    }
  }

  return e;
}




int main() {
  cin>>n;
  g.resize(n);
  for(int i = 0; i < n-1; i++) {
    int a, b;
    cin >> a >> b ;
    a--; b--;
    g[a].emplace_back(b, i);
    g[b].emplace_back(a, i);
  }

  cin>>m;
  vi u(m),v(m);
  REP(i,m){
    cin>>u[i]>>v[i];
    u[i]--;
    v[i]--;
  }

  
  //
  data.resize(50*20*2);
  REP(i,m){
    e=0;
    REP(j,50){used[j]=0;}
    e=dfs(u[i], v[i],i);
  }

  /*
  cout<<endl;
  REP(i,50){
    cout<<i<<" ";
    REP(j,data[i].size()){
      cout<<data[i][j]<<" ";
    }
    cout<<endl;
      
    
  }
  */

  ll ans=0LL;
  //1乗のやつを計算
  vi numm1(20);
  vvi numm2;
  numm2.resize(50*n);

  REP(i,n-1){
    REP(j,data[i].size()){
      numm1[data[i][j]]++;
      numm2[data[i][j]].emplace_back(i);
    }
  }

  /*
  REP(i,20){
    if (numm1[i]!=0){
      ans+=1LL<<((n-1)-numm1[i]);
    }
  }
  */

  //2乗のやつを計算
  //vvi ddata(20, vi(50,-1));//mi番目の通る道


  vi tabl(n-1,0);
  REP(i,1<<m){
    vi v(m);
    ll flag=0;
    REP(j,m){
      v[j]=(i>>j)%2;
      flag+=v[j];
    }
    flag%=2;

    
    REP(j,m){
      if (v[j]==1){
        for(int k=0;k<numm2[j].size();k++){
          tabl[numm2[j][k]]=1;
        }
      }
    }
    
    int sm=0;
    for(int k=0;k<n-1;k++){
      sm+=tabl[k];
      tabl[k]=0;
    }
    ans+=(1LL<<(n-1-sm))*(flag*2LL-1LL);

  }
/*

  REP(i,50){
    REP(j,data[i].size()){
      for(int k=j+1;k<data[i].size();k++){
        tabl[data[i][j]*20+data[i][k]]++;
        tabl[data[i][k]*20+data[i][j]]++;
      }
    }
  }


  ll cnt=0;
  ll cnt1=0;
  REP(i,20){
    for(int j=i+1;j<20;j++){
      if ((numm1[i]!=0)&(numm1[j]!=0)){
        
        
        cnt=tabl[i*20+j];
        cnt1=numm1[i]+numm1[j]-cnt;
        ans-=(1LL<<(n-1-cnt1))*( (1LL<<(numm1[i]-cnt))+(1LL<<(numm1[j]-cnt)) -2LL);
      }
    }
  }
*/
  //cout<<ans<<endl;


  //ans=(1LL<<(n-1))-ans;

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

/*
3
1 2
2 3
2
1 3
2 3
*/

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
using namespace std;

int main(){
	int n, x, t;
	cin >> n >> x >> t;
	cout << (((n / x) + (n % x != 0)) * t ) << '\n';
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int i=0;
int main(int argc, char* argv[]){
  long int a=0,b=0,c=0;
  char s[7];
  scanf("%s",s);
  if (s[2]==s[3] && s[4] == s[5]) {
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}


Measured memory_bytes: 128
// Last Change: 07/09/2019 18:58:41.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;
const ll MAX = 1e5 + 5;

vector<vector<ll>> edge;
ll N, K;

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// 二項係数計算
long long comb(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<ll> kaijo(100005);

// DFSはansに相当するものを参照で渡していって、各階層で逐次更新していったほうが
// 見やすいときもあるっぽい。
void DFS(ll cur, ll prev, ll depth, ll &ans) {
  ll children = 0;
  for (auto &&e : edge[cur]) {
    if (e != prev) {
      DFS(e, cur, depth + 1, ans);
      ++children;
    }
  }
  //子の塗り分け方
  if (depth == 0) {
    ans = (ans * (comb(K - 1, children) * kaijo[children] % MOD)) % MOD;
  } else {
    ans = (ans * (comb(K - 2, children) * kaijo[children] % MOD)) % MOD;
  }
}

int main() {
  cin >> N >> K;
  edge.assign(N, vector<ll>());
  for (ll i = 0; i < N - 1; ++i) {
    ll a, b;
    cin >> a >> b;
    --a;
    --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  COMinit();

  kaijo[0] = 1;
  for (ll i = 1; i < 1e5 + 5; ++i) {
    kaijo[i] = (kaijo[i - 1] * i) % MOD;
  }

  ll ans = 1;
  DFS(0, -1, 0, ans);
  cout << (ans * K) % MOD << endl;
}


Measured memory_bytes: 14720