akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define N 8
#define Free -1
#define Notfree -2
#define False 0
#define True 1

void putQueen(int);
void printBoard(void);

int a[N][N],row[N],col[N],dpos[2*N-1],dneg[2*N-1];

int main(){
  int i,j,k,r,c;

  for(i = 0;i < N;i++){
    row[i] = Free;
    col[i] = Free;
  }
  for(i = 0;i < 2*N-1;i++){
    dpos[i] = Free;
    dneg[i] = Free;
  }

  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      a[N][N] = False;
    }
  }

  scanf("%d",&k);
  for(i = 0;i < k;i++){
    scanf("%d %d",&r,&c);
    a[r][c] = True;
  }

  putQueen(0);
  
  
  return 0;
}

void putQueen(int i){
  int j;
  if(i == N){
    printBoard();
    return;
  }
  for(j = 0;j < N;j++){
    if(col[j] == Notfree || dpos[i+j] == Notfree || dneg[i-j+N-1] == Notfree) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = Notfree;
    putQueen(i+1);
    col[j] = dpos[i+j] = dneg[i-j+N-1] = Free;
  }
}

void printBoard(void){
  int i,j;
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(a[i][j] == True){
	if(row[i] != j) return;
      }
    }
  }
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}



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

using namespace std;

long long gcd(long long a, long long b) {
   if(!b) return a;
   return gcd(b, a % b);
}
bool valid(vector<int>v) {
   int gc = v[0];
   long long s = 0;
   for(int i = 0; i < v.size(); ++i)
      gc = __gcd(v[i], gc), s += v[i];
   if(gc != 1) return 0;

   for(int i : v) {
      if(gcd(i, s - i) == 1)
         return 0;;

   }
   return 1;
}
bool vaz[200000];
int main() {
   int n;
   vector<int>v = {2, 3, 4, 9};
   vector<int>only2, only3, both;
   int L = 3e4;
   for(int i = 6; i <= L; ++i) {
      if(i == 9)
         continue;
      if(i % 6 == 0)both.push_back(i);
      else if(i % 2 == 0)only2.push_back(i);
      else if(i % 3 == 0)only3.push_back(i);
   }
   cin >> n;
   if(n == 3)
   {
       cout<<2<<' '<<5<<' '<<63;
       return 0;
   }
   n -= 4;
   if(n % 2 == 1) {
      v.push_back(both.back());
      both.pop_back();
      n--;
   }
   while(n > 0) {
      vector<int>&vec = (only2.empty() ? only3 : only2);
      if(vec.empty()) break;
      for(int j = 0; j < 2; ++j) {
         v.push_back(vec.back());
         vec.pop_back();
      }
      n -= 2;
   }
   while(n > 0) {
      v.push_back(both.back());
      both.pop_back(); n--;
   }

   for(int i = 0; i < v.size(); ++i)cout << v[i] << ' ';

}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func count(m map[int]int) (evens, odds int) {
	for _, v := range m {
		if v%2 == 1 {
			odds++
		} else {
			evens++
		}
	}
	return
}

var sc = NewScanner(os.Stdin, 1000000)

func main() {
	n := sc.ReadInt()
	a := make(map[int]int)
	for i := 0; i < n; i++ {
		a[sc.ReadInt()]++
	}
	evens, odds := count(a)
	r := evens + odds
	if evens%2 == 1 {
		r--
	}
	fmt.Println(r)
}

type Scanner struct {
	*bufio.Scanner
}

func (scn *Scanner) ReadInt() int {
	scn.Scanner.Scan()
	i, _ := strconv.Atoi(scn.Scanner.Text())
	return i
}

func NewScanner(r io.Reader, bufSize int) *Scanner {
	buf := make([]byte, bufSize)
	scn := bufio.NewScanner(r)
	scn.Buffer(buf, bufSize)
	scn.Split(bufio.ScanWords)
	return &Scanner{scn}
}

Measured memory_bytes: 7168
m,n=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))

dep = []#一個目のの到着場所
arr = []#二回目のの出発場所
for i in range(n):
    if a[i][0]==1:
        dep.append(a[i][1])
    if a[i][1]==m:
        arr.append(a[i][0])
dep=set(dep)
arr=set(arr)
ans=dep & arr

if len(ans)==0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Measured memory_bytes: 60304
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;

int f(char c){
    if(c=='R') return 1;
    if(c=='G') return 2;
    if(c=='B') return 4;
    cerr << " error" << bn;
    return 0;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    vector<int64> cnt_R(N),cnt_G(N),cnt_B(N);
    int64 ans=0;
    REP(i,N){
        if(i){
            cnt_R[i]=cnt_R[i-1];
            cnt_G[i]=cnt_G[i-1];
            cnt_B[i]=cnt_B[i-1];
        }
        if(S[i] == 'R') {
            cnt_R[i]++;
            ans += cnt_G[i]*cnt_B[i];
        }
        if(S[i] == 'G') {
            cnt_G[i]++;
            ans += cnt_R[i]*cnt_B[i];
        }
        if(S[i] == 'B') {
            cnt_B[i]++;
            ans += cnt_G[i]*cnt_R[i];
        }
    }
    REP(i,N){
        REP(k,N){
            if(i+2*k>=N)break;
            auto tmp = f(S[i]) + f(S[i+k]) + f(S[i+2*k]);
            if(tmp==7) ans--;
        }
    }


    cout << ans << endl;
}

Measured memory_bytes: 3716
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
bool chmax(int &a, int b) { if (a < b) { a = b; return 1; } return 0; }
void chmin(int &a, int b) { if (a > b) { a = b; } }
const int INF = 1e9;

int main() {
    int N, M;
    cin >> N >> M;
    queue<int> data[N];
    vector<int> user(M, 0);
    vector<bool> is_open(M, true);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            int a; cin >> a; a--;
            data[i].emplace(a);
        }
    }
    
    auto now_max = [&]()->pair<int, int> {
        // return { amount, index }
        int p = 0, idx = -1;
        for (int i = 0; i < M; i++) {
            if (chmax(p, user[i])) idx = i;
        }
        return make_pair(p, idx);
    };
    
    auto count_participant = [&]() {
        fill(user.begin(), user.end(), 0);
        for (int i = 0; i < N; i++) user[data[i].front()]++;
    };
    
    count_participant();
    int ans = now_max().first;
    for (int _ = 0; _ < M-1; _++) {
        count_participant();
        int mx, id; tie(mx, id) = now_max();
        chmin(ans, mx);
        is_open[id] = false;
        for (int i = 0; i < N; i++) {
            while (!is_open[data[i].front()]) data[i].pop();
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)

const ll MOD = (1LL<<50);
const ll B = 29;	//Base

ll power(ll a,ll b,ll mod){
	ll ret=1;
	if(b>0){
		ret = power(a,b/2,mod);
		if(b%2==0)ret = (ret*ret)%mod;
		else ret = (((ret*ret)%mod)*a)%mod;
	}
	return ret;
}

int main(){
	int n,m;
	string s;
	cin>>n>>m>>s;
	
	int l=0,r=0;
	static set<ll> st[300003];
	static ll hash[300003];
	hash[0]=0;
	for(int i=1;i<=n;i++){
		hash[i] = ( hash[i-1]*29 + s[i-1]-'a'+1 )%MOD;
	}
	rep(i,m){
		string q;
		cin>>q;
		
		if(q=="R++")		r++;
		else if(q=="R--")	r--;
		else if(q=="L++")	l++;
		else if(q=="L--")	l--;
		
//		cout<<l<<" "<<r<<" "<<hash[r+1]<<" "<<hash[l]*power(29,r-l+1,MOD)<<endl;
		st[r-l].insert((MOD + hash[r+1]-(hash[l]*power(29,r-l+1,MOD))%MOD)%MOD);
	}
	
	int ans = 0;
	rep(i,300003)ans+=st[i].size();
	cout<<ans<<endl;
}

Measured memory_bytes: 33632
def e_divisible_substring():
    # 参考: https://atcoder.jp/contests/abc158/submissions/10611866
    from collections import Counter
    N, P = [int(i) for i in input().split()]
    S = [int(ch) for ch in input()]  # 数字を桁ごとにバラす

    def solve_specific(S, p):
        """p -> 2 または 5 のときは、連続部分文字列が p の倍数かどうかは
        1の位だけ見ればよい。つまり左から k 番目に 2 か 5 の倍数がある場合、
        k 個の連続部分文字列が p の倍数となる。"""
        return sum(k for k, s in enumerate(S, 1) if s % p == 0)

    if P in (2, 5):
        return solve_specific(S, P)

    s = S[::-1]  # 下の桁から見ていく
    # editorial の U_i mod P の計算
    u = [0] * N
    u[0] = s[0] % P
    power = 1
    for i in range(1, N):
        power *= 10
        power %= P  # S の桁数は最大 20万 なので、この処理は必要
        u[i] = u[i - 1] + power * s[i]
        u[i] %= P
    # 配列 u における、値が等しいインデックス 2 つを選ぶと、そのインデックスが表す
    # 2 つの整数の差は P の倍数になる
    # 値が 0 のインデックスについては、それ単体が P の倍数である
    counter = Counter(u)
    return sum(x * (x - 1) // 2 for x in counter.values()) + counter[0]

print(e_divisible_substring())

Measured memory_bytes: 14936
#include <cstdio>

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

int main(){
    int n;
    scanf("%d", &n);
    int ans = 0, sum = 0;
    REP(i, n){
        int d;
        scanf("%d", &d);
        ans += sum * d;
        sum += d;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1000000007;


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

    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    bool ok = A[0] == 0;
    for(int i=1;ok&&i<N;i++){
        if(A[i] - A[i - 1] > 1){
            ok = false;
        }
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;
    int x = 0;
    for(int i=N-1;i>=0;i--){
        if(x != A[i]){
            ans += A[i];
            x = A[i];
        }
        x = max(x - 1, 0);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import math
from itertools import accumulate

n = int(input())
a = list(map(int, input().split()))

fromleft = list(accumulate(a, math.gcd))
fromright = list(accumulate(a[::-1], math.gcd))[::-1]

gcd = []

gcd.append(fromright[1])
for i in range(1, n-1):
    gcd.append(math.gcd(fromleft[i-1], fromright[i+1]))
gcd.append(fromleft[n-2])

print(max(gcd))

Measured memory_bytes: 24976
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;
		String c[] = new String[N];

		for(int i = 0; i < N; i++) {
			c[i] = sc.next();
			if(c[i].equals("AC")) {
				AC++;
			}else if(c[i].equals("WA")) {
				WA++;
			}else if(c[i].equals("TLE")) {
				TLE++;
			}else if(c[i].equals("RE")) {
				RE++;
			}
		}
		System.out.println("AC x " + AC);
		System.out.println("WA x " + WA);
		System.out.println("TLE x " + TLE);
		System.out.println("RE x " + RE);

	}

}

Measured memory_bytes: 64804
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,x[101],m,a,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x[i]);
	}
	x[n+1]=2020;
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d",&a);
		if(x[a]+1!=x[a+1]){
			x[a]++;
		}
	}
	for(i=1;i<=n;i++){
		printf("%d\n",x[i]);
	}
	return 0;
}


Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
int gcd(long long int a,long long int b){
    if(a==0) return b;
    else return gcd(b%a,a);
}
int main(){
   long long  int a,b;
    cin>>a>>b;
    cout<<(a*b)/gcd(a,b)<<endl;
return 0;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> l(n);
    rep(i, 0, n) cin >> l[i];

    sort(l.begin(), l.end(), greater<ll>());
    ll ans = 0;
    rep(i, 0, k) ans += l[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;

#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(4);
    cin >> a[0] >> a[1] >> a[2] >>a[3];
    SORT(a);
    if(a[0]-1==0&&a[1]-4==0&&a[2]-7==0&&a[3]-9==0){
        cout << "YES" <<endl;
    }else{
        cout << "NO" <<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
var
  a:array[0..51,0..51] of longint;
  n,m,i,j,s:longint;
  ch:char;
begin
  readln(n,m);
  for i:=1 to n do
    begin
      for j:=1 to m do
        begin
          read(ch);
          if ch='#' then a[i,j]:=1;
        end;
      readln;
    end;
  for i:=1 to n do
    begin
      for j:=1 to m do
        if a[i,j]<>0 then write('#')
          else
            begin
              s:=a[i-1,j-1]+a[i,j-1]+a[i+1,j-1]+a[i-1,j]+a[i+1,j]+a[i-1,j+1]+a[i,j+1]+a[i+1,j+1];
              write(s);
            end;
      writeln;
    end;
end.

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main(void) {
    string s, ss;
    cin >> s >> ss;
    int l = s.size();
    int k = ss.size();
    int ind = -1;
    for (int i = 0; i <= l - k; ++i) {
        int f = 0;
        for (int j = i; j < i + k; ++j) {
            if (s[j] == '?') continue;
            if (s[j] != ss[j - i]) {
                f = -1;
                break;
            }
        }
        if (f == 0) {
            ind = i;
        }
    }
    if (ind == -1) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for (int i = ind; i < ind + k; ++i) {
        s[i] = ss[i - ind];
    }
    for (int i = 0; i < l; ++i) {
        if (s[i] == '?') {
            cout << 'a';
        }else {
            printf("%c", s[i]);
        }
    }
    cout << endl;
    return 0;
}












Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC111B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;

            int ans = 0;
            for (int i = 1; i <= 9; i++)
            {
                int cand = 100 * i + 10 * i + i;
                if (cand >= N)
                {
                    ans = cand;
                    break;
                }
            }

            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13268
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


h = I()



ret = 0
cnt = 1
while h:
    ret += cnt
    cnt *= 2
    h //= 2


print(ret)




Measured memory_bytes: 39664
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const ll inf = int(1e18);
const int mod = 256;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);
 
void solve()
{
	int a, b;
	cin >> a >> b;
	if(a % 2 != b % 2){
		cout << "IMPOSSIBLE";
	}else 
	cout << (a + b) / 2;
}
int main()
{
	Red;
	solve();
	return 0;
}

Measured memory_bytes: 256
K=int(input())
s=0

import math
# 全部同じパターン
for i in range(1, K+1):
  # print("{} {} {}".format(i,i,i))
  s += i

# 2つ同じパターン
for i in range(1, K+1):
  for j in range(1,K+1):
    if i==j:
      continue
    # print("{} {} {}".format(i,i,j))
    s += math.gcd(i,j)*3

from itertools import combinations
# 全部違うパターン
for i in combinations(range(1,K+1), 3):
  # print("{} {} {}".format(i[0], i[1], i[2]))
  s += math.gcd(math.gcd(i[0], i[1]),i[2])*3*2

print(s)



Measured memory_bytes: 9200
def main():
	N = int(input())
	is_able = False

	for i in range(26):
		for j in range(15):
			if 4 * i + 7 * j == N:
				is_able = True
				break

	if is_able:
		print("Yes")
	else:
		print("No")

  
if __name__ == "__main__":
  	main()

Measured memory_bytes: 9112
#include<iostream>
#include<algorithm>

using namespace std;


int a[10], b[10];

int main(){
	for(int i = 0;i < 10;i++){
		cin >> a[i];
	}
	sort(a, a + 10);
	for(int i = 0;i < 10;i++){
		cin >> b[i];
	}
	sort(b, b + 10);

	cout << a[9] + a[8] + a[7] << " " << b[9] + b[8] + b[7] << endl;
	return 0;
}

Measured memory_bytes: 3116
a,b,c,d,e,f = gets.split.map(&:to_i)
sw = Array.new(31){Array.new(3000,-1)}
sw[0][0] = 0
max = [0,a*100,0]


31.times do |i|
	sw[i][0] = sw[i-a][0] + a*e if (i-a) >= 0 && sw[i-a][0] >=0
	sw[i][0] = sw[i-b][0] + b*e if (i-b) >= 0 && sw[i-b][0] >=0
end
31.times do |i|
	3001.times do |j|
		sw[i][j] = sw[i][j-c] - c if (j-c) >= 0
		if sw[i][j] >= 0 && (100*j/(100*i+j).to_f) > max[0] && (100*i+j) <= f
			max[0] = (100*j/(100*i+j).to_f)
			max[1] = 100*i+j
			max[2] = j
		end
	end
	3001.times do |j|
		sw[i][j] = [sw[i][j-d] - d,sw[i][j] ].max if (j-d) >= 0
		if sw[i][j] >= 0 && (100*j/(100*i+j).to_f) > max[0] && (100*i+j) <= f
			max[0] = (100*j/(100*i+j).to_f)
			max[1] = 100*i+j
			max[2] = j
		end
	end
end

print "#{max[1]} #{max[2]}"

Measured memory_bytes: 2812
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>

using namespace std;
using ull = unsigned long long;

int N;
vector<ull> a;
priority_queue<ull> q;
map<ull, int> m;
int main(void) {
  cin >> N;
  a = vector<ull>(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (m.count(a[i]) == 0) m[a[i]] = 1;
    else m[a[i]]++;
    if (m[a[i]] == 2) {
      q.push(a[i]);
      m[a[i]] -= 2;
    }
  }
  if (q.size() < 2) cout << 0 << endl;
  else {
    ull a1 = q.top(); q.pop();
    ull a2 = q.top();
    cout << a1 * a2 << endl;
  }
}


Measured memory_bytes: 7296
S = str(input())
N = len(S)
ans = 0
dis = 0
for i in range(N):
  if S[i] == "T":
    if dis == 0:
      ans +=1
    else:
      dis -= 1
  else: #Sのとき
    dis += 1
ans += dis
print(ans)
  

Measured memory_bytes: 9200
#include<cstdio>
#include<algorithm>

using namespace std;

int x[100005], dx[100005];
int main() {
    int n, m;

    scanf("%d%d", &n, &m);

    for (int i = 0; i < m; i++) scanf("%d", &x[i]);

    int ans = 0;

    if (n < m) {
        sort(x, x + m);
        for (int i = 0; i < m - 1; i++) dx[i] = x[i + 1] - x[i];
        sort(dx, dx + m - 1);

        for (int i = 0; i < m - n; i++) ans += dx[i];

    }

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

    return 0;
}


Measured memory_bytes: 896
n=int(input())
*a, =map(int,input().split())
dp=[[0]*(n+1) for _ in range(n+1)]

for length in range(1, n+1):
    for l in range(n-length+1):
        r=l+length
        if (n-length)%2==0:
            dp[l][r]=max(dp[l+1][r]+a[l] ,dp[l][r-1]+a[r-1])
        else:
            dp[l][r]=min(dp[l+1][r]-a[l] ,dp[l][r-1]-a[r-1])
print(dp[0][-1])

Measured memory_bytes: 144864
#include <stdio.h>

int main(void) {  

int n ,ai ,i ,max ,min;          

long int sum = 0;    

scanf("%d" ,&n);    

for(i=0;i<n;i++){      

scanf("%d" ,&ai);      

sum += ai;      

if(i==0){        

max = ai;                        

min = ai;

}      

else if(ai>max){        

max = ai;      

}      

else if(ai<min){        

min = ai;       

}

          } 
   
printf("%d %d %ld\n" ,min ,max ,sum);
      
return 0;     

}     

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#define MN 5000
#define mod 1000000007
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,head[MN+5],cnt=0,flag,rt,mn=1e9,ans,size[MN+5],mx[MN+5],p[MN+5],inv[MN+5],f[MN+5],g[MN+5];
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
	e[++cnt]=(edge){t,head[f]};head[f]=cnt;
	e[++cnt]=(edge){f,head[t]};head[t]=cnt;	
}
void dfs(int x,int fa)
{
	size[x]=1;mx[x]=0;
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=fa)
		{
			dfs(e[i].to,x);
			size[x]+=size[e[i].to];mx[x]=max(mx[x],size[e[i].to]);
			if(size[e[i].to]*2==n) flag=1;	
		}
	if(max(n-size[x],mx[x])<mn) mn=max(n-size[x],mx[x]),rt=x;
}
inline int C(int n,int m){return 1LL*p[n]*inv[m]%mod*inv[n-m]%mod;}
inline void R(int&x,int y){x+=y;x>=mod?x-=mod:0;}
int main()
{
	n=read();p[0]=p[1]=inv[0]=inv[1]=f[0]=1;
	for(int i=2;i<=n;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=n;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod; 
	for(int i=1;i<n;++i) ins(read(),read());
	dfs(1,0);if(flag) return 0*printf("%d",1LL*p[n/2]*p[n/2]%mod);
	for(int i=head[rt];i;i=e[i].next)
	{
		int sz=size[e[i].to]>size[rt]?n-size[rt]:size[e[i].to];
		for(int j=0;j<=n;++j) if(f[j])
			for(int k=0;k<=sz;++k)
				R(g[j+k],1LL*f[j]*C(sz,k)%mod*C(sz,k)%mod*p[k]%mod);
		for(int j=0;j<=n;++j) f[j]=g[j],g[j]=0;
	}
	for(int i=0;i<=n;++i) R(ans,1LL*f[i]*((i&1)?mod-1:1)%mod*p[n-i]%mod); 
	cout<<ans;
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <utility>

using namespace std;
using P = pair<double,double>;
constexpr int n = 10;

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

int main(){
  string str;
  while(getline(cin,str)){
    double tmp[8];
    P p[4];
    string tmpstr;
    istringstream stream(str);
    for(int i=0;getline(stream,tmpstr,',')&&i<8;++i){
      tmp[i] = stof(tmpstr);
    }
    for(int i=0;i<4;++i){
      p[i].first = tmp[(i+1)%4*2]-tmp[i*2];
      p[i].second = tmp[(i+1)%4*2+1]-tmp[i*2+1];
      // cout << p[i].first << "," << p[i].second << endl;
    }
    
    bool allpos = true ,allneg = true;
    for(int i=0;i<4;++i){
      double val = cross(p[i],p[(i+1)%4]);
      // cout << val << endl;
      allpos = allpos && val>0;
      allneg = allneg && val<0;
    }

    bool isconvex = allneg||allpos;
    if(isconvex){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 3128
#include <iostream>
#include <queue>
#include <map>
using namespace std;
int maper[102][102],pushed[102][102];
int main() {
	int W,H,draw=0;
	cin >> W >> H;
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++)
			cin >> maper[j][i];
	queue<pair<int,int> > qoo;
	qoo.push( pair<int,int>(0,0) );
	pushed[0][0]=1;
	int x,y,dx[6]={1,-1,1,1,0,0},dy[6]={0,0,1,-1,1,-1},dxB[6]={1,-1,0,0,-1,-1};
	while(!qoo.empty()){
		x=qoo.front().first;
		y=qoo.front().second;
		qoo.pop();
	
		for(int i=0;i<6;i++){
			int xx=dxB[i],yy=dy[i];
			if(y%2)
				xx=dx[i];
			if(x+xx>=0 && x+xx<=W+1 && y+yy>=0 && y+yy <= H+1 && pushed[x+xx][y+yy] ==0){
				if(maper[x+xx][y+yy]==0){
				qoo.push(pair<int,int>(x+xx,y+yy));
					pushed[x+xx][y+yy]=1;
				}
				else{
				draw++;
				}
			}
		}
	}
	cout << draw << endl;
			
	return 0;
}

Measured memory_bytes: 1300
n, m = map(int, input().split())
h = list(map(int, input().split()))

good = [1] * len(h)

for i in range(m):
    a1, a2 = list(map(int, input().split()))
    if h[a1-1] == h[a2-1]:
        good[a1-1] = 0
        good[a2-1] = 0
    elif h[a1-1] > h[a2-1]:
        good[a2-1] = 0
    else:
        good[a1-1] = 0

print(good.count(1))

Measured memory_bytes: 20148
#include <bits/stdc++.h> 
#define inf 4294967295
#define N 500000
#define LL long long
#define pi acos(-1)
#define MO 1000000007

using namespace std; 

LL ans;
int ot[N],ne[N],g[N],e,n,k;
LL fac[N]; 

void add(int x,int y){
	ot[++e]=y,ne[e]=g[x],g[x]=e;
	ot[++e]=x,ne[e]=g[y],g[y]=e;	
}

void dfs(int x,int fa){
	int son = 0;
	for (int p = g[x]; p; p = ne[p]){
		int y = ot[p];
		if (y != fa){
			son++;
			dfs(y,x);
		}
	}
	if (son){
		if (fa == -1){
			if (son <= k - 1) ans = ans * (k-1) % MO * fac[k-son] % MO;
			else ans = 0;
		}	else {
			if (son <= k - 2) ans = ans * fac[k-1-son] % MO;
			else ans = 0;
		}
	}
}

int main(){
	scanf("%d%d",&n,&k);
	fac[k]=fac[k-1]=1;
	fac[k-2]=k-2;
	for (int i = k-3; i >= 1; --i) fac[i] = (fac[i+1] * i) % MO;
	for (int i = 1; i < n; ++i) {
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);	
	}
	ans = k;
	dfs(1,-1);
	cout << ans << endl;
	return 0;
}

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

int main(){
    int ptaro=0;
    int phanako=0;
    int num;//カードの数
    string ctaro;
    string chanako;

    cin >> num;

    for(int i=0; i<num; i++){
        cin >> ctaro >> chanako;
        if(ctaro > chanako){
            ptaro += 3;
        } else if(ctaro < chanako){
            phanako += 3;
        } else{
            ptaro++;
            phanako++;
        }
    }
    cout << ptaro << " " << phanako << endl;

    return 0;
    
}


Measured memory_bytes: 3140
# B - Judge Status Summary

n = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(n):
    j =input()
    if j == 'AC':
        AC += 1
    elif j == 'WA':
        WA += 1
    elif j == 'TLE':
        TLE += 1
    elif j == 'RE':
        RE += 1
print('''
AC x {}
WA x {}
TLE x {}
RE x {}
'''.format(AC,WA,TLE,RE))



Measured memory_bytes: 9164
/*
    Created by Tejas Chaudhari
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef double lf;
typedef bool bl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<lf> vd;
typedef vector<bl> vb;
typedef string st;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

#define INF (LONG_LONG_MAX / 4)
#define Mod % 1000000007
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

void re_curse() {
    ll n, d;
    cin>>n>>d;
    d = d * d;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll x, y;
        cin>>x>>y;
        ll t = (x*x) + (y*y);
        if (t <= d) {
            ++ans;
        }
    }
    cout<<ans<<endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    for (int i = 1; i <= t; ++i) {
        re_curse();
    }
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        if(line.equals("----"))
        System.out.println(-4);
        if(line.equals("-+--")||line.equals("+---")||line.equals("--+-")||line.equals("---+"))
        System.out.println(-2);
        if(line.equals("++--")||line.equals("+-+-")||line.equals("+--+")||line.equals("-++-")||line.equals("-+-+")||line.equals("--++"))
        System.out.println(0);
        if(line.equals("++++"))
        System.out.println(4);
        if(line.equals("+++-")||line.equals("++-+")||line.equals("+-++")||line.equals("-+++"))
        System.out.println(2);
    }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
using namespace std;
int n,k;
int main()
{
    while (~scanf("%d %d",&n,&k)) {
        int mx = (n-1)*(n-2)/2;
        vector<pair<int,int>> out;
        if (k>mx) {
            puts("-1");
            continue;
        }


        REP(i,2,n) out.push_back( make_pair(1,i) );
        REP(i,2,n)REP(j,i+1,n) if(mx>k) {
            out.push_back( make_pair(i,j) );
            mx--;
        }
        printf("%d\n", (int)out.size());
        for (auto i:out) printf("%d %d\n",i.first,i.second);
    }

    return 0;
}


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

#define f first
#define s second
#define ins insert
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (int) (c).size()
#define trav(x,c) for (auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rll(c) (c).rbegin(), (c).rend()
#define db(x) cout << #x << ": " << x << endl;
#define _db(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios_base::sync_with_stdio(0); cin.tie(0);

int main() { 
	godspeed;
	
	char c; cin >> c;

	if (islower(c)) cout << "a";
	else cout << "A";
}

Measured memory_bytes: 3608
#include<iostream>
 
using namespace std;
 
int main() {
	int A, B;
	double T;
	int sum;
	int i;
 
	cin >> A >> B >> T;
 
	i = (T+0.5) / A;
	
	sum = i * B;
 
	cout << sum;
 
	return 0;
}

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

namespace AOJ1_8_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "";
            while (true)
            {
                string strAdd = Console.ReadLine();
                if (strAdd == null) break;
                else
                {
                    str = str + strAdd;
                }
            }
            int[] Spell = new int[26];
            for (int i = 0; i < Spell.Length; i++)
            {
                Spell[i] = 0;
            }

            for (int i = 0; i < str.Length; i++)
            {
                for (int j = 97; j < 97 + 26; j++)
                {
                    string a = str.Substring(i, 1);
                    char jj = (char)j;
                    if (a == jj.ToString() || a == jj.ToString().ToUpper())
                    {
                        Spell[j - 97] += 1;
                        break;
                    }
                }
            }
            for (int i = 0; i < 26; i++)
            {
                Console.WriteLine((char)(i + 97) + " : " + Spell[i]);
            }

        }

    }
}




Measured memory_bytes: 17800
x,n=map(int,input().split())
p=list(map(int,input().split()))
p1=list(range(-150,150))
l= set(p) ^ set(p1)

for i in range(150-x):
    if x-i in l:
        print(x-i)
        exit()
    if x+i in l:
        print(x+i)
        exit()

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

typedef long long int ll;

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n;
    cin>>n;

    ll arr[n+1];

    for(ll i=1;i<=n;i++){
        cin>>arr[i];
    }

    ll ans[n+1];
    memset(ans,0,sizeof(ans));
    ll z = 0;
    for(ll i=n;i>=1;i--){
        ll c = 0;ll d = 0;
        for(ll j=i;j<=n;j+=i){
            if(ans[j]==1)
            {
                //cout<<j<<" * "<<i<<endl;
                c++;
            }
            d++;
        }
        //cout<<i<<" "<<c<<endl;
        if(c%2==arr[i]){

        }
        else{

            z++;
            ans[i] = 1;
        }

    }

    cout<<z<<endl;
    for(ll i=1;i<=n;i++){
        if(ans[i]==1){
            cout<<i<<" ";
        }
    }cout<<endl;



}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
int n,p;
int a[10],b[10];
int main()
{
    scanf("%d%d",&n,&p);
    for(int i=0;i<n;i++)
        scanf("%d%d",&a[i],&b[i]);
    int ans=1e9;
    int t=1<<n;
    for(int i=0;i<t;i++)
    {
        int sum=0,res=0;
        for(int j=0;j<n;j++)
            if((1<<j)&i)
            {
                res+=a[j];
                sum+=(j+1)*100*a[j]+b[j];
            }
        for(int j=n-1;j>=0&&sum<p;j--)
        {
            if((1<<j)&i) continue;
            for(int k=1;k<=a[j]&&sum<p;k++)
            {
                res++;
                sum+=100*(j+1);
                if(k==a[j]) sum+=b[j];
                if(sum>=p) break;
            }
            if(sum>=p) break;
        }
        if(sum>=p)
            ans=min(ans,res);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 1e9 + 7;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	if(N < 1000)cout << "ABC" << endl;
	else cout << "ABD" << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

mi = lambda: map(int, input().split())

R, G, B, N = mi()

count = 0
for i in range(N//R + 1):
    for j in range((N-i*R)//G + 1):
        if (N - i*R - j*G) % B == 0:
            count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define Would
#define you
#define please

long long N, K, A[59], dp[59][5009][2], mod = 1000000007;

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

	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	int x[100], y[100];
	rep(i, N) cin >> x[i];
	rep(i, M) cin >> y[i];
	sort(x, x + N);
	sort(y, y + M);

	if (x[N-1] < y[0] && x[N - 1] < Y && X < y[0]) co("No War");
	else co("War");

	Would you please return 0;

}

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

// NOTE : use H with larger N
/// --- Modulo Factorial {{{ ///
#include <cassert>
#include <cstddef>
template < std::size_t N, int mod = static_cast< int >(1e9 + 7) >
struct Factorial {
  using integer = long long;
  constexpr integer extgcd(integer a, integer b, integer &x, integer &y) {
    integer d = 0;
    return b == 0 ? (x = a < 0 ? -1 : 1, y = 0, a < 0 ? -a : a)
      : (d = extgcd(b, a % b, y, x), y -= a / b * x, d);
  }
  constexpr integer modinv(integer a) {
    integer x = 0, y = 0;
    extgcd(a, mod, x, y);
    if(x < 0)
      x += mod;
    else if(x == mod)
      x = 0;
    return x;
  }
  int arr[N + 1], inv[N + 1];
  integer operator[](int i) const { return arr[i]; }
  Factorial() : arr(), inv() {
    arr[0] = 1;
    for(std::size_t i = 1; i <= N; i++) {
      arr[i] = (integer) i * arr[i - 1] % mod;
    }
    inv[N] = modinv(arr[N]);
    for(int i = N - 1; i >= 0; i--) {
      inv[i] = (integer)(i + 1) * inv[i + 1] % mod;
    }
  }
  integer C(int n, int r) const {
    if(n < 0 || r < 0 || n < r) return 0;
    assert(n <= N);
    return (integer) arr[n] * inv[r] % mod * inv[n - r] % mod;
  }
  integer H(int n, int r) const { return C(n + r - 1, r); }
};
/// }}}--- ///

constexpr int mod = 1e9 + 7;
const int N = 2e5 + 10;
Factorial< N * 2, mod > fact;

ll sum[212345];

int inv2 = 500000004;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  if(n > m) swap(n, m);
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) for(int k = 0; k < m; k++) {
      sum[abs(i - j)]++;
      sum[abs(i - j) + 1]++;
      sum[abs(i - j) + k + 1]--;
      sum[abs(i - j) + (m - 1 - k) + 1]--;
    }
  }

  ll ans = 0;
  for(int i = 1; i <= n + m; i++) {
    sum[i] += sum[i-1];
    sum[i] %= mod;

    ans += i * sum[i] % mod;
  }
  ans %= mod;
  ans = ans * inv2 % mod;

  ans = ans * fact.C(n * m - 2, k - 2) % mod;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
//Volume0-0082
import java.util.Scanner;

public class Main {

	private static final int S = 8;

	public static void main(String[] args) {

		//declare
		String[] s;
		int      i,j,m,msum,mmin,maxi;
		int[]    p = new int[S];
		int[][]  c = {{1,2,1,2,1,4,1,4}, //ascending order
				      {1,2,1,4,1,4,1,2},
                      {1,4,1,2,1,2,1,4},
                      {1,4,1,4,1,2,1,2},
                      {2,1,2,1,4,1,4,1},
                      {2,1,4,1,4,1,2,1},
                      {4,1,2,1,2,1,4,1},
			          {4,1,4,1,2,1,2,1}};

        //input
        Scanner sc = new Scanner(System.in);
        while((sc.hasNext())){
        	s = sc.nextLine().split("\\s");
        	for(i=0;i<S;i++){p[i] = Integer.parseInt(s[i]);}

        	//calculate
        	mmin = Integer.MAX_VALUE;
        	maxi = 0;
        	for(i=0;i<S;i++){
            	msum = 0;
        		for(j=0;j<S;j++){
        			m = p[j] - c[i][j];
        			if(m>0){msum += m;}
        		}
        		if(mmin > msum){
        			mmin = msum;
        			maxi = i;
        		}
        	}

        	//output
        	for(i=0;i<S;i++){
        		System.out.print(c[maxi][i]);
        		if(i<S-1){
        			System.out.print(" ");
        		} else {
        			System.out.println();
        		}
        	}
        }
	}
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
string w="WA";
string a="AC";

bool check(string s){

    rep(i,2){
        if(s[i]!=a[i]){
            return false;
        }
    }
    return true;

}

int main(){
    long long N,M;
    cin>>N>>M;
    bool collect[N]={};
    int wa[N]={};
    rep(i,M){
        int p;
        string s;
        cin>>p>>s;
        if(check(s)){
        collect[p-1]=true;
        }
        else if(!collect[p-1]){
        wa[p-1]++;
        }
    }
    int c_cnt=0,w_cnt=0;
    rep(i,N){
        if(collect[i]){
        c_cnt++;
        w_cnt+=wa[i];
        }
    }
    cout<<c_cnt<<" "<<w_cnt<<endl;

    return 0;

}
/*


*/


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
vector<vector<int> > d; 
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return (power((a*a)%mod,n/2))%mod;
  else
    return (a*(power((a*a)%mod,n/2))%mod)%mod;    
}
double sqrt1(double a){
    double l=0;
    double h=a;
    double m;
    double ans;
    while((h-l)>=1e-8){
       m=(h+l)/2;
       if((m*m)<a){
             ans=m;
             l=m;
       }
       else if(m*m==a){
             ans=m;
             break;
       }
       else{
          h=m;
       }
    }
    return ans;
}
int main(){
FASTIO
ll a,b;
cin>>a>>b;
ll ans=-1;
ll x1=(a*100)/8;
ll x2=((a+1)*100)/8;
for(ll i=x1;i<x2;i++){
  if((((i*8)/100)==a)&&(((i)/10)==b))
    { ans=i;
      break;
    }
}
x1=b*10;
x2=(b+1)*10;
for(ll i=x1;i<x2;i++){
  if((((i*8)/100)==a)&&(((i)/10)==b))
    { ans=min(ans,i);
      break;
    }
}
cout<<ans;
return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

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

	for(int i=0;i<n;i++){
		double xa, ya, ra, xb, yb, rb;
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		/*
		double d = (xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
		if(d>ra*ra+rb*rb){
			cout << 0 << endl;
		}else if(d+rb*rb<ra*ra){
			cout << 2 << endl;
		}else if(d+ra*ra<rb*rb){
			cout << -2 << endl;
		}else{
			cout << 1 << endl;
		}
		*/
		double d = sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
		if(d>ra+rb){
			cout << 0 << endl;
		}else if(d+rb<ra){
			cout << 2 << endl;
		}else if(d+ra<rb){
			cout << -2 << endl;
		}else{
			cout << 1 << endl;
		}
	}

	return 0;
}

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

using namespace std;

int main(){
	while(true){
		vector<int> size(3);
		cin >> size[0] >> size[1] >> size[2];
		if(size[0] == 0 && size[1] == 0 && size[2] == 0){ break; }
		sort(size.begin(), size.end());
		int n;
		cin >> n;
		while(n--){
			int r;
			cin >> r;
			if(4 * r * r > size[0] * size[0] + size[1] * size[1]){
				cout << "OK" << endl;
			}else{
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto N = readln.split.to!(ulong[]);

  string solve() {
    if (N[0] == N[1] && N[0] == N[2]) return "No";
    if (N[0] != N[1] && N[1] != N[2] && N[0] != N[2]) return "No";
    return "Yes";
  }

  solve().writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 1000000
#define MOD 998244353
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
inline int fxp(int s, int n=MOD-2){int a=1; for(; n; n&1 ? a = 1ll*a*s%MOD : 0, s = 1ll*s*s%MOD, n >>= 1); return a;}
int N, M, U, Ans, fac[MAXN+5], efac[MAXN+5]; inline int C(int n, int k){return 1ll*fac[n]*efac[k]%MOD*efac[n-k]%MOD;}
int main()
{
	N = read(), M = read(), N<M?N^=M^=N^=M:0, U = N+M;
	for(rint i = fac[0] = 1; i <= U; fac[i] = 1ll*i*fac[i-1]%MOD, i++); efac[U] = fxp(fac[U]); for(rint i = U; i; efac[i-1] = 1ll*i*efac[i]%MOD, i--);
	for(rint i = 1; i <= M; Ans = (Ans+1ll*C(i<<1,i)*C(N+M-(i<<1),M-i))%MOD, i++); printf("%d\n",(499122177ll*Ans%MOD*fxp(C(N+M,M))+N)%MOD); return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(void){
	int N,A,i=0,ANS=0;
	cin>>N;
	for(int j=0;j<N;j++){
		cin>>A;
		if(A==1){
			i++;
		}
		else{
			i=0;
		}
		if(ANS<i){
				ANS=i;
			}
	}
	cout<<ANS+1<<endl;
	return 0;
}


Measured memory_bytes: 3096
#include<iostream>
using namespace std;
int main(){
	long long a,b,x;
	cin>>a>>b>>x;
	long long ans;
	 if(a==0){
    	  ans=1+(b/x);
}
else
  ans=(b/x)-((a-1)/x);
	 cout<< ans;
	
	
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int cnt[100100][3];

int main(void){
	int n,i,a,m,ans;
	std::cin >> n >> m;
	for(i=0; i<n; ++i){
		std::cin >> a;
		++cnt[a][0];
		++cnt[a%m][1];
	}
	for(i=1; i<=100000; ++i){
		cnt[i%m][2] += cnt[i][0]/2;
	}
	ans = cnt[0][1]/2;
	for(i=1; i<m; ++i){
		if(cnt[i][1]<cnt[m-i][1]){
			continue;
		}
		if(i==m-i){
			ans += cnt[i][1]/2;
			continue;
		}
		if(cnt[i][1]==cnt[m-i][1] && i>m-i){
			continue;
		}
		ans += cnt[m-i][1]+std::min((cnt[i][1]-cnt[m-i][1])/2,cnt[i][2]);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
char s[101010];
int main(){
    scanf("%s",s);
    n=strlen(s);
    for(int i=0;i<n;i++){
        if(i%2){
            if(s[i]=='1') a++;
            else b++;
        }else{
            if(s[i]=='1') b++;
            else a++;
        }
    }
    printf("%d",min(a,b));
}


Measured memory_bytes: 384