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

using namespace std;

const int INF=10000000;
typedef pair<int,int> P;
const int MAX_N=1000;
char maze[MAX_N][MAX_N];
int N,M;
int sx=0,sy=0;
int gx,gy;
int d[MAX_N][MAX_N];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cnt=0;

int bfs()
{
	gx=N-1,gy=M-1;
	queue<P> que;
	for(int i=0;i<N;i++)
		for(int j=0;j<M;j++)
			d[i][j]=INF;
	que.push(P(sx,sy));
	d[sx][sy]=0;

	while(que.size())
	{
		P p=que.front();
		que.pop();
		if(p.first==gx&&p.second==gy) break;
		for(int i=0;i<4;i++)
		{
			int nx=p.first+dx[i],ny=p.second+dy[i];
			if(0<=nx&&nx<N&&0<=ny&&ny<M&&maze[nx][ny]!='#'&&d[nx][ny]==INF)
			{
				que.push(P(nx,ny));
				d[nx][ny]=d[p.first][p.second]+1;
			}
		}
	}
	return d[gx][gy];
}

void solve()
{
	int res=bfs();
	int max1;
	max1=M*N-cnt-res-1;
	if(res==INF) cout<<"-1"<<endl;
	else cout<<max1<<endl;
}

int main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)
		for(int j=0;j<M;j++)
		{
			cin>>maze[i][j];
			if(maze[i][j]=='#') cnt++;
		}
	solve();
	return 0;
}

Measured memory_bytes: 2432
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

arr = []
for i in range(len(a)):
    arr.append(b[a[i]-1])
    if i > 0:
        if a[i] == a[i-1] + 1:
            arr.append(c[a[i-1]-1])
    
print(sum(arr))


Measured memory_bytes: 40716
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const int MOD=1e9+7;
const ll INF=1e18;
const ll inf=1e9;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  ll x;
  cin >> x;
  ll ans = 0;
  ans += (x/500)*1000;
  x%=500;
  ans += (x/5)*5;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main( void ){
	int i, j, n, count, minj, tmp;
	
	scanf("%d", &n );
	
	int a[n];
	
	for( i = 0; i < n; i++ ){
		scanf("%d", &a[i] );
	}
	
	count = 0;
	for( i = 0; i < n; i++ ){
		minj = i;
		for( j = i; j < n; j++ ){
			if( a[j] < a[minj] ){
				minj = j;
			}
		}
		if( i != minj ){
			tmp = a[i];
			a[i] = a[minj];
			a[minj] = tmp;
			count++;
		}
	}
	
	for( i = 0; i < n; i++ ){
		if( i != n-1 ){
			printf("%d ", a[i] );
		}
		else{
			printf("%d\n", a[i] );
		}
	}
	printf("%d\n", count );
	
	return 0;
}


Measured memory_bytes: 2096
#include <stdio.h>
#include <stdlib.h>
int main(){
	
	int n,k;
	int *a;
	int i,j;
	int sum,max;

	while(1){
		scanf("%d %d",&n,&k);
		if(n==0&&k==0)break;
		a=(int *)malloc(sizeof(int)*n);
		for(i=0;i<n;i++) scanf("%d",&a[i]);
		
		sum=0;
		for(i=0;i<k;i++)sum+=a[i];
		
		max=sum;
		
		for(j=k;j<n;j++){
			sum=sum+a[j]-a[j-k];
			if(sum>=max)max=sum;
		}
		
		printf("%d\n",max);
		free(a);
	}
	return 0;
}

Measured memory_bytes: 884
import Data.Maybe
import Data.List

main = do
  s <- getLine
  let t = s ++ "NEWS"
  putStrLn $ (\a -> if (head a == 1 && last a > 1) || (head a > 1 && last a == 1) || (a!!1 == 1 && a!!2 > 1) || (a!!1 > 1 && a!!2 == 1) then "No" else "Yes") $ map length $ group $ sort t



Measured memory_bytes: 4656
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val dict = mutableMapOf<String, Int>()
    repeat(N) {i ->
        val S = readLine()!!
        val v = dict[S] ?: 0
        dict[S] = v + 1
    }
    val max = dict.values.max()
    val ans = dict.filterValues { v -> v == max }.keys.sorted()
    println(ans.joinToString("\n"))
}

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

int main() {
    //使う変数を定義する
    int N;
    cin >> N ;
    
    //N個の整数をベクトルとして表す
    vector<int> vec(N) ;
    
    //ベクトルの要素に値を代入する
    for(int i=0 ; i<N ; i++){
        cin >> vec.at(i) ;
    }
    
    //2で割るループ
    int count=0 ;
    
    for(int l=0 ; l<300 ; l++){
        
        //i番目の要素が2で割ることができるならsumに1を足す
        int sum=0 ;
        
        for(int j=0 ; j<N ; j++){
        
            if(vec.at(j) % 2 == 0){
                sum++;
            }
        }
        
            //sumがNと等しければループ継続 > 全て2で割ることができる
            if(sum == N){
                count++ ;
        
                for(int m=0 ; m<N ; m++){
                    vec.at(m) = vec.at(m) / 2 ;
                }
            }
        
            //sumとNが等しくない = 2で割れていない要素がある = ループ終了
            else if ( sum != N){
                break;
            }
    }
    
    cout << count << endl;
}


Measured memory_bytes: 3604
import sys

MOD = 10 ** 9 + 7


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = sum(a) ** 2
    for e in a:
        ans -= e ** 2
    ans //= 2
    ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 29276
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

// l:距離, v:速さ, かかる時間を返す.
double f(double l, double v){
	return l / v;
}

typedef pair<double,int> P;
const int CARROT = 1;
const int SLOW = 2;
const int GOAL = 3;

int main(){
	int N, K, T, U, V, L;
	scanf("%d %d %d %d %d %d", &N, &K, &T, &U, &V, &L);
	
	vector<int> D(N);
	priority_queue<P, vector<P>, greater<P> > q;
	q.push( P(L,GOAL) );
	for(int i=0 ; i < N ; i++ ){
		scanf("%d", &D[i]);
		q.push( P(D[i],CARROT) );
	}
	
	double x=0.0, v = U, t=0.0, k=0, carrot=0;
	while( !q.empty() ){
		if( q.top().second == CARROT ){ // 次の位置がニンジンのとき
			double l = q.top().first - x; // 移動する距離
			x = q.top().first; // 次の位置
			t += f(l,v); // 時間経過
			q.pop();
			
			if( v == U ){ // 通常の速さのとき(ニンジンを食べる)
				v = V; // 速度変化
				q.push( P(x + V*T, SLOW) ); // ニンジンの効果が切れる位置
			}else{ // 速いとき
				if( k < K ){ // ニンジンを持てるとき(持つ)
					k++;
				}else{ // ニンジンを持てないとき(食べる)
					carrot++;
					q.push( P(x + V*T, SLOW) ); // ニンジンの効果が切れる位置
				}
			}
		}else if( q.top().second == SLOW ){ // ニンジンの効果が切れるとき
			double l = q.top().first - x; // 移動する距離
			x = q.top().first; // 次の位置
			t += f(l,v); // 時間経過
			q.pop();
			
			if( carrot > 0 ){ // ニンジンを効果が切れる前に食べたときは遅くならない
				carrot--;
			}else if( k > 0 ){ // ニンジンを持っているときは即座に食べる
				k--;
				q.push( P(x + V*T, SLOW) ); // ニンジンの効果が切れる位置
			}else{ // 通常の速さに戻る
				v = U;
			}
		}else if( q.top().second == GOAL ){ // ゴールのとき
			double l = q.top().first - x; // 移動する距離
			x = q.top().first; // 次の位置
			t += f(l,v); // 時間経過
			q.pop();
			break;
		}
	}
	printf("%.9f\n", t);
}

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

int main(){
  string S;
  cin >> S;
  int L = S.size();
  string ans = "AC";
  if(S[0] != 'A'){
  	ans = "WA";
  }
  int cnt = 0;
  for(int i =1 ; i < L ; ++i){
  	if(isupper(S[i])){
    	if(i==1 || i == L-1 || S[i] != 'C'){
        	ans = "WA";
        }
    	cnt++;
    }
  
  }
  if(cnt != 1){
  	ans = "WA";
  }
	cout << ans << endl;
}

Measured memory_bytes: 256
class Vector:

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def move(self, offset):
        self.x += offset[0]
        self.y += offset[1]

    def move_offset(self, offset, multiple=1):
        x = self.x + offset[0] * multiple
        y = self.y + offset[1] * multiple
        return Vector(x, y)


NOTHING = " "
EXIST = "#"
SENTINEL = "?"

MOVE = [
    [[-1, -1], [-1, +0], [-1, +1]],
    [[-1, +1], [-0, +1], [+1, +1]],
    [[+1, +1], [+1, +0], [+1, -1]],
    [[+1, -1], [+0, -1], [-1, -1]],
]


def create_area(size):
    area = [[SENTINEL] * 2 + [NOTHING] * size + [SENTINEL] * 2 for _ in range(size)]
    tmp = [[SENTINEL] * size + [SENTINEL] * 2 * 2]
    area = tmp * 2 + area + tmp * 2
    return area


def even_spiral_pattern(area, point):
    move_index = 0
    area[point.x][point.y] = EXIST

    while True:

        left, center, right = MOVE[move_index]
        end1, end2 = point.move_offset(left), point.move_offset(right)
        offset, offset2 = point.move_offset(center), point.move_offset(center, 2)

        if area[end1.x][end1.y] == EXIST or area[end2.x][end2.y] == EXIST:
            return area
        elif area[offset.x][offset.y] == NOTHING and area[offset2.x][offset2.y] != EXIST:
            point.move(center)
            area[point.x][point.y] = EXIST
        else:
            move_index += 1
            move_index %= 4


def odd_spiral_pattern(area, point):
    move_index = 0
    is_end = False
    area[point.x][point.y] = EXIST

    while True:

        left, center, right = MOVE[move_index]
        offset, offset2 = point.move_offset(center), point.move_offset(center, 2)

        if area[offset.x][offset.y] == NOTHING and area[offset2.x][offset2.y] != EXIST:
            point.move(center)
            area[point.x][point.y] = EXIST
            is_end = False
        else:
            if is_end:
                return area
            else:
                is_end = True

            move_index += 1
            move_index %= 4


def formater(area):
    output = ["".join(item).replace(SENTINEL, "") for item in result[2:-2]]
    output = "\n".join(output)
    return output


output = []

for _ in range(int(input())):
    size = int(input())

    area = create_area(size)
    point = Vector(size - 1 + 2, 2)

    if size % 2 == 0:
        result = even_spiral_pattern(area, point)
    else:
        result = odd_spiral_pattern(area, point)

    output.append(formater(result))

print("\n\n".join(output))



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


int main() {
  int A, B;
  cin >> A >> B;
  string ans;
  if (A <= 8 && B <= 8) {
    ans = "Yay!";
  } else {
    ans = ":(";
  }
  cout << ans << endl;
  return 0;
}








Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int N=cin.nextInt();
        string ans="Christmas";
        for(int i=0;i<(25-N);i++)
        {
          ans+=" Eve";
        }
        Console.WriteLine(ans);
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

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

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

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

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

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


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}



Measured memory_bytes: 11092
def read_values():
    return map(int, input().split())


def read_list():
    return list(map(int, input().split()))


def f():
    a, b = read_values()
    if 1 <= a <= 9 and 1 <= b <= 9:
        print(a * b)
    else:
        print(-1)


if __name__ == '__main__':
    f()


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

int main(){
  int N;
  cin >>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  
  int ans=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      ans+=a[i]*a[j];
    }
  }
  
  cout << ans <<endl;
}


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

using namespace std;

int main(int argv,char* argc[])
{
    vector<pair<string,int> >ar;
    int n;
    cin>>n;
    string s; int t;
    for(int i=0;i<n;++i)
     {
         cin>>s>>t;
         ar.push_back(make_pair(s,t));
     }
     string x;
     cin>>x;
     int sum=0;
     for(int i=n-1;i>=0;--i)
     {
         if(ar[i].first!=x)
            sum+=ar[i].second;
         else break;
     }
     cout<<sum;
    return 0;
}


Measured memory_bytes: 256
//人正是因为度过了一段阴暗岁月，才会更渴求黎明的曙光
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <memory.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

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

const int MAXN = 0;
int N;
void dfs(string s, char now) {
	if (s.size() == N) {
		cout << s << endl;
		return;
	}
	for (char i='a'; i<now; i++) dfs(s + i, now);
	dfs(s + now, now + 1);
}
int main() {
	cin >> N;
	dfs("", 'a');
	return 0;
}



Measured memory_bytes: 1536
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

constexpr int MOD = 1000000007;

int main(){
    ll N, K;
    read(N, K);
    N++;
    ll ans = 0;
    for(int i = K; i <= N; i++){
        ans += (i * (N - i) + 1) % MOD;
        ans %= MOD;
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

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



int main(){
    ll n;
    cin >> n;
    ll res=0;
    for(ll i=1;i*i<n;i++){
        ll ans=(n-i)/i;
        if((n-i)%i==0&&ans>i) res+=ans;
    }
    cout << res << endl;
    return 0;
}  


Measured memory_bytes: 3588
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().ToCharArray();
            for (int i = 0; i < line.Length; i++)
            {
                if (char.IsUpper(line[i]))
                {
                    line[i] = char.ToLower(line[i]);
                } else if (char.IsLower(line[i]))
                {
                    line[i] = char.ToUpper(line[i]);
                }
            }

            Console.WriteLine(new string(line));
        }
    }
}


Measured memory_bytes: 15796
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, k = Is()
X = LI()
ans = INF
for l in range(n):
    r = l + k - 1
    if l < 0 or n <= l or r < 0 or n <= r:
        continue
    else:
        ans = min(ans, abs(X[l])+abs(X[r]-X[l]), abs(X[r])+abs(X[l]-X[r]))
print(ans)


Measured memory_bytes: 87532
n = int(input())
a = [1]
i = 6
while i <= n:
  a.append(i)
  i *= 6
i = 9
while i <= n:
  a.append(i)
  i *= 9
t = [float("inf")] * (n + 1)
t[0] = 0
for i in range(n):
  for j in a:
    if i + j <= n and t[i + j] > t[i] + 1:
      t[i + j] = t[i] + 1
print(t[n])

Measured memory_bytes: 3828
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

  int N;
  cin >> N;
  vector<ll> a(3 * N);
  rep(i, 3 * N) cin >> a[i];

  sort(all(a));

  ll ans = 0;
  int k = 3 * N - 2;
  rep(i, N) {
    ans += a[k];
    k -= 2;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2560
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		String s = in.next();
		if ("#".equals(s)) return false;

		int pos = s.length(), cnt = 0;
		double d = -1;
		while (pos >= 0) {
			while (s.charAt(--pos) != 'w' && s.charAt(pos) != 'n');
			if (s.charAt(pos) == 'n') {
				if (cnt == 0) d = 0;
				else d -= 90.0 / (1<<cnt);
			} else {
				if (cnt == 0) d = 90;
				else d += 90.0 / (1<<cnt);
			}
			cnt++;
			pos--;
		}

		int div = 1;
		while ((int)d != d) {
			d *= 2;
			div *= 2;
		}

		int ans = (int)d;

		out.println(ans + (div == 1 ? "" : ("/"+div)));

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    String st;
	    while((st=sc.readLine())!=null){
		String[] sp = st.split(" ");
		double[] map = new double[8];
		for(int i=0; i<8; i++)
		    map[i] = Double.valueOf(sp[i]);
		if(map[0] == map[2])
		    if(map[5] == map[7])
			System.out.println("YES");
		    else
			System.out.println("NO");
		else if(map[4] == map[6])
		    if(map[1] == map[3])
			System.out.println("YES");
		    else
			System.out.println("NO");
		else{
		    if((map[3]-map[1])/(map[2]-map[0])*(map[7]-map[5])/(map[6]-map[4]) == -1)
			System.out.println("YES");
		    else
			System.out.println("NO");
		}
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 9584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod=1e9+7;
const int N=2e5+100;
ll a[N];
int f[5];
bool cmp(int x,int y)
{
    return abs(x)<abs(y);
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        if(a[i]>=0) f[1]++;
        else f[2]++;
    }
    int l=1,r=n;
    ll ans=1;
     if(!f[1]&&m%2==1){
        sort(a+1,a+1+n,cmp);
        for(int i=1;i<=m;i++){
            ans=a[i]*ans%mod;
        }
    }
    else {
        sort(a+1,a+1+n,greater<int>());
    while(m>0){
        if(m%2) ans=ans*a[l]%mod,l++,m--;
        else if(m>=2){
           if(a[l]*a[l+1]>=a[r]*a[r-1]){
              ans=ans*a[l]%mod*a[l+1]%mod;
              l+=2;
              m-=2;
           }
           else{
            ans=ans*a[r-1]%mod*a[r]%mod;
            r-=2;
            m-=2;
           }
        }
    }
    }
    cout<<(ans%mod+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 5128
N = int(input())
l = [tuple(map(int, input().split())) for _ in range(N)]

l.sort(key=lambda x:(x[1],-x[0]))
c = 0

for i,j in l:
    if c+i <= j:
        c += i
    else:
        print("No")
        break
else:
    print("Yes")

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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair
#define X first
#define Y second
const int MAXN = 100005;
bool can[MAXN];
int cnt[MAXN];

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

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int n, m;
    cin >> n >> m;
    for (int i=1;i<=n;i++)
    {
        cnt[i] = 1;
        can[i] = false;
    }
    can[1] = true;
    for (int i=0;i<m;i++)
    {
        int x, y;
        cin >> x >> y;
        if (!can[x])
        {
            cnt[x]--;
            cnt[y]++;
        }
        else
        {
            if (cnt[x] == 1)
            {
                can[x] = false;
            }
            cnt[x]--;
            can[y] = true;
            cnt[y]++;
        }
    }
    int ans = 0;
    for (int i=1;i<=n;i++)
    {
        if (can[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m;
char r[600][600],b[600][600],a[600][600];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i+=2)
        for(int j=1;j<=m;j++)
            r[i][j]='#';
    for(int i=2;i<=n;i+=2)
        for(int j=1;j<=m;j++)
        {
            r[i][j]='.';
        }
    for(int i=2;i<=n;i+=2)
        for(int j=1;j<=m;j++)
            b[i][j]='#';
    for(int i=1;i<=n;i+=2)
        for(int j=1;j<=m;j++)
        {
            b[i][j]='.';
        }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            char cur;
            cin>>cur;
            if(cur=='#')
            {
                r[i][j]='#';
                b[i][j]='#';
            }
        }
    }
    for(int i=1;i<=n;i++)
        r[i][1]='#',b[i][1]='.';
    for(int i=1;i<=n;i++)
        r[i][m]='.',b[i][m]='#';
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
          cout<<r[i][j];
        cout<<endl;
    }
    cout<<endl;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
          cout<<b[i][j];
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 1280
import math
a, b, x = map(int, input().split())
n = a * b
x /= a
if x / n < 0.5:
    d = 2 * x / b
    atan = math.degrees(math.atan(d / b))
    ans = 90 - atan
else:
    y = n - x
    d = 2 * y / a
    ans = math.degrees(math.atan(d / a))

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#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 ln(a) cout << (a) << endl
#define debug(a, n) rep(hoge, n) printf("%lld%c", a[hoge], hoge == (n) - 1? '\n' : ' ');
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define EPS 0.00000001

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

signed main() {
    int h, n;
    cin >> h >> n;
    int* a = new int[n];
    int* b = new int[n];
    rep(i, n) cin >> a[i] >> b[i];

    ll* dp = new ll[h + 1];
    fill(dp + 1, dp + h + 1, LINF);
    dp[0] = 0;
    rep(i, n) {
        rep(j, h + 1) {
            dp[j] = min(dp[j], dp[max(0, j - a[i])] + b[i]);
        }
    }

    ln(dp[h]);
}


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


int main() {
    int h, n;
    cin >> h >> n;
    int a[n];
    int sum = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        sum += a[i];
    }
    string judge = "Yes";
    if (sum < h) judge = "No";
    cout << judge << endl;
}

Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct edge {
	int a, b, cost;
};
vector<int> par;
int root(int x) {
	if (x == par[x]) return x;
	return par[x] = root(par[x]);
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, M, K;
	cin >> N >> M >> K;
	vector<int> c(N);
	for (int i = 0; i < N; ++i) {
		cin >> c[i]; --c[i];
	}
	vector<edge> edges;
	for (int i = 0; i < M; ++i) {
		int a, b, w;
		cin >> a >> b >> w; --a, --b;
		edges.push_back(edge{ c[a] != -1 ? c[a] + N : a, c[b] != -1 ? c[b] + N : b, w });
	}
	sort(edges.begin(), edges.end(), [](edge e1, edge e2) { return e1.cost < e2.cost; });
	par.resize(N + K);
	for (int i = 0; i < N + K; ++i) par[i] = i;
	int comps = 0;
	long long ans = 0;
	for (edge e : edges) {
		if (root(e.a) != root(e.b)) {
			par[root(e.a)] = root(e.b);
			ans += e.cost;
			++comps;
			if (comps == K - 1) break;
		}
	}
	cout << (comps == K - 1 ? ans : -1) << '\n';
	return 0;
}

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

using namespace std;

template <class T> inline bool chmax(T &a, T b) { /* {{{ */
  if (a < b) {
    a = b;
    return true;
  }
  return false;
} /* }}} */

int main() {
  int N;
  cin >> N;
  vector<pair<long long, int>> A(N);
  for (int i = 0; i < N; i++) {
    long long a;
    cin >> a;
    A[i] = {a, i};
  }
  sort(A.rbegin(), A.rend());
  vector<vector<long long>> dp(N + 5, vector<long long>(N + 5));
  for (int i = 0; i < N; i++) {
    long long a = A[i].first;
    int idx = A[i].second;
    for (int j = 0; j <= i; j++) {
      chmax(dp[i + 1][j + 1], dp[i][j] + a * abs(idx - j));
      chmax(dp[i + 1][j], dp[i][j] + a * abs(idx - (N - 1 - i + j)));
    }
  }
  long long ans = 0;
  for (int i = 0; i <= N; i++) {
    chmax(ans, dp[N][i]);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 34676
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define nl '\n'
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define dcit cin.sync_with_stdio(0);cin.tie(0);
#define frp(x, y) freopen(x, "r", stdin);freopen(y, "w", stdout);
typedef pair<int, int> pii;
typedef long long ll;

#ifdef LOCAL_PROJECT

#define gc getchar()
#define pc(x) putchar(x)

#endif
#ifndef LOCAL_PROJECT

#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)

#endif

template<typename T> void scani(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printi(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
string nextstring() { string r; register char c=gc;while(c==32||c==10) c = gc;while(!(c==32||c==10)) { r += c;c = gc; }return r; }
char nextgetchar(){ register char c = gc; while(c==32 || c==10) c = gc; return c;}

void prints(string k){ for (int i = 0; i < k.length(); i++)pc(k[i]); }
void scani() {}

template<typename First, typename ... Ints>
void scani(First &arg, Ints&... rest) { scani(arg);scani(rest...); }

int N, K, a[102], dp[100002];
int main(){
    scani(N, K);
    for (int i = 0; i < N; i++)scani(a[i]);
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j < N; j++) {
            if(a[j]<=i && !dp[i-a[j]]) dp[i]=true;
        }
    }
    prints(dp[K] ? "First": "Second");
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

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

		String[] str = S.split("");
		int N = str.length;

		String S_two = S.substring(0, (N-1)/2  );
		String S_three = S.substring((N+3)/2 -1, N );

		StringBuffer b_str = new StringBuffer(S);
		StringBuffer b_str_two = new StringBuffer(S_two);
		StringBuffer b_str_three = new StringBuffer(S_three);

        String ReS = b_str.reverse().toString();
        String ReS_two = b_str_two.reverse().toString();
        String ReS_three = b_str_three.reverse().toString();


		boolean one = false;
		boolean two = false;
		boolean three = false;

		if (S.equals(ReS)){
			one = true;
		}
		if (S_two.equals(ReS_two)){
			two = true;
		}
		if (S_three.equals(ReS_three)){
			three = true;
		}


		if (one && two && three){
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 22996
#include<stdio.h>
int main(void)
{
	int a[5];
	int i,j,box;
	for(i=0;i<=4;i++){
		scanf("%d",&a[i]);
	}
	box=0;
	for(i=0;i<=3;i++){
		for(j=i+1;j<=4;j++){
			if(a[i]<=a[j]){
				box=a[i];
				a[i]=a[j];
				a[j]=box;
			}
		}
	}
	printf("%d",a[0]);
	for(i=1;i<5;i++){
		printf(" %d",a[i]);
	}
	printf("\n");
	return 0;
}



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

class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int x = sc.nextInt();
        boolean isPrime = false;
        if(x==2) {
            System.out.println(2);
            return;
        }
        if(x==3) {
            System.out.println(3);
            return;
        }
        for (int i = 5; i <= 10000000; i += 2) {
            // 素数判定対象(i)は素数判定対象(j)の平方根以下で除算する
            for (int j = 2; j * j <= i; j++) {
                // 除算できた場合は素数ではないため判定から抜ける
                if (i % j == 0) {
                    isPrime = false;
                    break;
                }
                isPrime = true;
            }
            if (isPrime) {
                if(i>=x) {
                    System.out.println(i);
                    return;
                }
            }
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22740
tmp = [int(i) for i in input().split()]
M, D = tmp[0], tmp[1]
if D < 22 or M < 4:
  print(0)
else:
  days = [(str(i)[0], str(i)[1]) for i in range(22,  D+1) if int(str(i)[0])>1 and int(str(i)[1])>1]
  n = 0
  print(sum([1 for m in range(4, M+1) for d in days if m == int(d[0])*int(d[1])]))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<cassert>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<30
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;

int main(){
  int Q;
  string s;
  cin >> Q;
  while(Q-- > 0){
    cin >> s;
    int index = 0;
    int Mex = 0;
    
    while(true){
      if(s.length() == 1){
	cout << index << endl;
	break;
      }
      Mex = 0;
      rep(j,s.length()-1){
      int A,B;
      A = B = 0;
      int st = 0;
      if(s[st] == '0'){
	for(int i=0;s[i] == '0' && i<j;i++){
	  st++;
	}
      }
      assert(j-st+1 >= 0);
           if(st < s.length())A = (atoi)(s.substr(st,j-st+1).c_str());
	   //cout << "A = " << A << endl;
      st = j+1;
      if(s[st] == '0'){
	for(int i=j+1;s[i] == '0' && i<s.length()-1;i++){
	  st++;
	}
      }     
     
      assert(s.length()-st >= 0);
            if(st < s.length())B = (atoi)(s.substr(st,s.length()-st).c_str());
	    //cout << "B = " << B << endl; 
     Mex = max(Mex,A*B);

      }
      //cout << "mex = " << Mex << endl;
      stringstream ss;
      ss << Mex;
      ss >> s;
      //cout <<"new s = " << s << endl;

      index++; 
    }
  }
  return 0;
}

Measured memory_bytes: 1236
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define debuga(a) cout << "debug " << a << endl;
#define debugab(a,b) cout << "debug1 " << a <<" debug2 " << b << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	ll n,k;
	cin>>n>>k;
	cout<<n*k<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)

int h, w;
vector<vector<char> > G;
vector<int> mx = {0, 0, -1, 1}, my = {1, -1, 0, 0};

void solve(){
    int L[h][w], R[h][w], U[h][w], D[h][w];
    rep(i, 0, h){
        rep(j, 0, w){
            if (G[i][j]=='#') L[i][j] = 0;
            else{
                L[i][j] = 1;
                if (j != 0) L[i][j] += L[i][j-1];
            }
            if (G[i][w-j-1]=='#') R[i][w-j-1] = 0;
            else{
                R[i][w-j-1] = 1;
                if (j != 0) R[i][w-j-1] += R[i][w-j];
            }
        }
    }
    rep(i, 0, w){
        rep(j, 0, h){
            if (G[j][i]=='#') U[j][i] = 0;
            else{
                U[j][i] = 1;
                if (j != 0) U[j][i] += U[j-1][i];
            }
            if (G[h-j-1][i]=='#') D[h-j-1][i] = 0;
            else{
                D[h-j-1][i] = 1;
                if (j != 0) D[h-j-1][i] += D[h-j][i];
            }
        }
    }
    int ans = 0;
    rep(i, 0, h){
        rep(j, 0, w){
            if (G[i][j]=='#') continue;
            ans = max(ans, R[i][j]+L[i][j]+U[i][j]+D[i][j]-3);
        }
    }
    cout << ans << endl;
}

int main(){
    sc(h), sc(w);
    G.resize(h);
    rep(i,0,h) G[i].resize(w);
    rep(i,0,h){
        rep(j,0,w) cin >> G[i][j];
    }
    solve();
    return 0;
}

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


ll int A,B;


void input(){

cin>>A>>B;


}

void solve(){

    input();

    for(int i=1;i<=B;i++){
        if((A*i)%B==0){

        cout<<A*i<<endl;

        break;
    }

    }





}


int main()
{

    solve();


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  int x;cin>>x;
  vector<int> a;

  repi(i,x) repi(j,x) {
    int y = pow(i,j+1);
    if (y > x) continue;
    a.push_back(y);
  }
  sort(ALL(a));
  int ans = a[a.size()-1];
  cout << ans << endl;
}


Measured memory_bytes: 6128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void solve() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    VI b(n);
    REP(i,0,32) {
        int cnt = 0;
        REP(j,0,n) if (a[j] & (1<<i)) ++cnt;
        bool inv = cnt % 2;
        REP(j,0,n) {
            if (inv && (a[j] & (1<<i)) == 0) b[j] += (1<<i);
            if (!inv && (a[j] & (1<<i)) != 0) b[j] += (1<<i);
        }
    }
    REP(i,0,n) cout << b[i] << " ";
    cout << endl;
}

signed main() {
    solve();
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=-10000000000;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	string s1,s2,s3; cin>>s1>>s2>>s3;
	ll d='A'-'a';
	cout<<(char)(s1[0]+d)<<(char)(s2[0]+d)<<(char)(s3[0]+d);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
int type[1005]={0};
vector<int> son[1005];
int par[1005]={0};
int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    string s;
    cin>>s;
    if(s=="E") type[i]=0;
    else if(s=="E?") type[i]=3;
    else if(s=="A") type[i]=1;
    else if(s=="A?") type[i]=4;
    else if(s=="R") type[i]=2;
    else type[i]=5;
  }
  for(int i=0;i<n-1;i++){
    int s,t;
    cin>>s>>t;
    son[s].push_back(t);
    par[t]=s;
  }
  vector<int> vec;
  queue<int> que;
  que.push(1);
  while(!que.empty()){
    int pos=que.front();
    que.pop();
    vec.push_back(pos);
    for(int i=0;i<son[pos].size();i++) que.push(son[pos][i]);
  }
  ll dp[1005]={0};
  for(int i=n-1;i>=0;i--){
    int pos=vec[i];
    if(son[pos].size()==0){
      if(type[pos]==0) dp[pos]=1;
      else dp[pos]=2;
    }
    else{
      if(type[pos]%3==0){
        dp[pos]=1;
        for(int j=0;j<son[pos].size();j++){
          dp[pos]*=dp[son[pos][j]];
          dp[pos]%=mod;
        }
        if(type[pos]>=3) dp[pos]++;
      }
      else if(type[pos]%3==1){
        for(int j=0;j<son[pos].size();j++){
          dp[pos]+=dp[son[pos][j]];
        }
        if(type[pos]>=3) dp[pos]++;
      }
      else{
        int siz=son[pos].size();
        for(int j=0;j<(1<<siz);j++){
          ll ksum=1;
          for(int k=0;k<siz;k++){
            int snum=son[pos][k];
            if(((j>>k)&1)==1){
              ksum*=dp[snum];
              ksum%=mod;
            }
          }
          dp[pos]+=ksum;
          dp[pos]%=mod;
        }
        if(type[pos]==2) dp[pos]--;
      }
    }
    dp[pos]%=mod;
  }
  cout<<dp[1]<<endl;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H,vector<char>(W));
  int t=0;
  
  for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
     	cin>>a.at(i).at(j);
    }
  }
  
  for(int i=0;i<H;i++){
   	for(int j=0;j<W;j++){
     	if(a.at(i).at(j)=='.'){
          if(j==W-1){
           	for(int k=0;k<W;k++){
             	a.at(i).at(k)=' ';
            }
          }
          else
         	continue; 
        }
      	else{
         	break; 
        }
    }
  }
  
   for(int j=0;j<W;j++){
   	for(int i=0;i<H;i++){
     	if(a.at(i).at(j)=='.'||a.at(i).at(j)==' '){
          if(i==H-1){
           	for(int k=0;k<H;k++){
             	a.at(k).at(j)=' ';
            }
          }
          else
         	continue; 
        }
      	else{
         	break; 
        }
    }
  }
  
  
   for(int i=0;i<H;i++){
     t=0;
   	for(int j=0;j<W;j++){
        if(a.at(i).at(j)!=' '){
     		cout<<a.at(i).at(j);
      		t=1;
        }
    }
     if(t==1){
      	cout<<endl;
     }
     else{
     }	
  }
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<pair<i64, i64>> ap(A + B + C);
  for (i64 i = 0; i < A; i++)
  {
    cin >> ap[i].first;
    ap[i].second = 0;
  }
  for (i64 i = A; i < A + B; i++)
  {
    cin >> ap[i].first;
    ap[i].second = 1;
  }
  for (i64 i = A + B; i < A + B + C; i++)
  {
    cin >> ap[i].first;
    ap[i].second = 2;
  }
  sort(ap.rbegin(), ap.rend());
  i64 ans = 0;
  i64 e[3] = {};
  for (i64 i = 0; i < A + B + C; i++)
  {
    if (ap[i].second == 0 && e[0] < X)
    {
      ans += ap[i].first;
      e[0]++;
    }
    if (ap[i].second == 1 && e[1] < Y)
    {
      ans += ap[i].first;
      e[1]++;
    }
    if (ap[i].second == 2)
    {
      ans += ap[i].first;
      e[2]++;
    }
    if (e[0] + e[1] + e[2] == X + Y)
      break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll n;
    cin>>n;
    vl countt(n+1, 0);
    forr1(x, 100)
    {
        forr1(y, 100)
        {
            forr1(z, 100)
            {
                if(x*x+y*y+z*z+x*y+x*z+y*z<=n)
                countt[x*x+y*y+z*z+x*y+x*z+y*z]++;
            }
        }
    }
    forr1(i, countt.size()-1)
    cout<<countt[i]<<endl;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
}

Measured memory_bytes: 3636