akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace V0100{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            int n;
            while((n = sr.Next<int>()) != 0){
                var result = sr.Next<long>(n, 3)
                    .GroupBy(x => x[0])
                    .Where(g => g.Sum(x => x[1] * x[2]) >= 1000000)
                    .ToArray();
                if(result.Any()){
                    result
                        .Select(g => g.Key)
                        .ToList()
                        .ForEach(Console.WriteLine);
                } else{
                    Console.WriteLine("NA");
                }
            }
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var result = new T[x];
            for(var i = 0; i < x; ++i) result[i] = Next<T>();
            return result;
        }

        public T[][] Next<T>(int y, int x){
            var result = new T[y][];
            for(var i = 0; i < y; ++i) result[i] = Next<T>(x);
            return result;
        }
    }
}

Measured memory_bytes: 11020
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
    int n  , sum = 0 , m;
    scanf("%d",&n);
    m = n / 15;
    sum = n * 800 - m * 200;
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
import Control.Monad
import Data.List

toFloat = fromRational . toRational

distance :: [Int] -> [Int] -> Int
distance [] [] = 0
distance (x:xs) (y:ys) = ((x - y)^2) + (distance xs ys)

solveSub :: [[Int]] -> Int
solveSub [_] = 0
solveSub (x:y:z) = (if toFloat (floor sq) == sq then 1 else 0) + solveSub (x:z)
                where
                    sq = sqrt (toFloat (distance x y))

solve :: [[Int]] -> Int
solve [_] = 0
solve xz@(x:z) = solveSub xz + solve z

main = do
    [n,d] <- map read . words <$> getLine :: IO [Int]
    xnd <- replicateM n (map read . words <$> getLine) :: IO [[Int]]
    print $ solve xnd


Measured memory_bytes: 4388
import sys
sys.setrecursionlimit(300000)
from bisect import bisect_left

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


# 区間updateと要素クエリ
class SegmentTree(object):

    def __init__(self, A, e, fn):
        self.fn = fn
        self.length = 2 ** (len(A) - 1).bit_length()
        self.data = [e] * (self.length * 2)
        for i in range(len(A)):
            self.data[i + self.length - 1] = A[i]
        for i in reversed(range(self.length - 1)):
            self.data[i] = self.fn(self.data[2 * i + 1], self.data[2 * i + 2])

    # 区間[l, r)の値とxをfnで比較して更新する
    def update(self, l, r, x):  # O(logN)
        l += self.length
        r += self.length
        while l < r:
            if l & 1:
                self.data[l] = self.fn(self.data[l], x)
                l += 1
            if r & 1:
                self.data[r - 1] = self.fn(self.data[r - 1], x)
                r -= 1
            l //= 2
            r //= 2

    # i番目の要素の値を取得する
    def query(self, i):  # O(logN)
        i += len(self.data) // 2
        ret = self.data[i]
        while i > 0:
            i //= 2
            ret = self.fn(ret, self.data[i])
        return ret

N, Q = MI()
STX = [tuple(MI()) for _ in range(N)]
D = [I() for _ in range(Q)]

seg = SegmentTree([INF] * Q, INF, min)
for S, T, X in STX:
    # [S - X, T - X) に出発する人[l番目の人, r番目の人)が影響を受ける
    l = bisect_left(D, S - X)
    r = bisect_left(D, T - X)
    seg.update(l, r, X)

for i in range(Q):
    ans = seg.query(i)
    if ans == INF:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 127144
from collections import deque
import sys
# S = sys.stdin.readline()
n=int(sys.stdin.readline())
dq = deque()

def command(cm):
	if cm[0]=='insert':
		dq.appendleft(cm[1])
	if cm[0]=='delete':
		try:dq.remove(cm[1])
		except ValueError:pass
	if cm[0]=='deleteFirst':
		dq.popleft()
	if cm[0]=='deleteLast':
		dq.pop()

for i in range(n):
	command(sys.stdin.readline().split())
print(' '.join(dq))



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

int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> a(N+1);
  for(int i = 1; i < N+1; i++){
    for(int j = i; j < N+1; j = j+i){
      a.at(j)++;
    }
  }
  int64_t sum = 0;
  for(int i = 1; i < N+1; i++){
    sum = sum + i*a.at(i);
  }
  cout << sum;
}

Measured memory_bytes: 81368
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, core.bitop;

enum P = 998244353;

void main()
{
    auto ns = readln.split.to!(long[]);
    auto N = ns[0];
    auto S = ns[1];
    auto as = readln.split.to!(long[]);
    auto DP = new long[][](N, S+1);
    foreach (ref dp; DP) dp[] = -1;
    long solve(int i, long s) {
        if (s == 0) {
            return N-i+1;
        } else if (s < 0 || i == N) {
            return 0;
        }
        if (DP[i][s] == -1) {
            DP[i][s] = (solve(i+1, s-as[i]) + solve(i+1, s)) % P;
        }
        return s == S ? 0 : DP[i][s];
    }
    solve(0, S);
    long r;
    foreach (i; 0..N) r = (r + (i+1) * DP[i][S]) % P;
    writeln(r);
}

Measured memory_bytes: 74748
import java.util.*;

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

            long A = sc.nextLong();
            long B = sc.nextLong();
            long C = sc.nextLong();
            long D = sc.nextLong();

            long sum = 0;

            if(A%C == 0) {
                sum += B/C - A/C + 1;
            } else {
                sum += B/C - A/C;
            }

            if(A%D == 0) {
                sum += B/D - A/D + 1;
            } else {
                sum += B/D - A/D;
            }

            long lcm = Lcm.lcm(C,D);

            long lcmsum;
            if(lcm == -1) {
                lcmsum = 0;
            } else if(A%lcm == 0 ) {
                lcmsum = B/lcm - A/lcm + 1;
            } else {
                lcmsum = B/lcm - A/lcm;
            }
        System.out.println(B - A + 1 - sum + lcmsum);
    }
}

//import java.util.*;

class Lcm {
    //gcd 最大公約数
    public static long gcd(long m, long n) {
        if(m < n) return gcd(n,m);
        if(n == 0) return m;
        return gcd(n,m%n);
    }

    public static long lcm(long m, long n) {
        return m * n / gcd(m,n);
    }
}

Measured memory_bytes: 21844
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#define ll long long
using namespace std;



int main(){
  string S,S_reverse,S_small,S_small_reverse;
  cin>>S;

  S_reverse=S;

  reverse(S_reverse.begin(),S_reverse.end());

  for(int i=0;i<S.size()/2;i++){
    S_small+=S[i];
  }

  S_small_reverse=S_small;

  reverse(S_small_reverse.begin(),S_small_reverse.end());



  if(S==S_reverse&&S_small==S_small_reverse){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
using namespace std;
//https://codeforces.com/contest/1213/problems
//https://codeforces.com/contest/1213/submit
int main(){
    int n;
    s(n)
    int count0 = 0;
    while(n != 0){
        count0 ++;
        n /= 2;
    }
    p( 1<<(count0-1)) pn
    return 0;
}


Measured memory_bytes: 888
x = int(input())
num = x // 3
rem = x % 3
if rem == 1:
    res = (num+1)*(num**2)
elif rem == 2:
    res = ((num + 1) ** 2) * num
else:
    res = num ** 3
res2 = (x/3)**3
if res > res2:
    print(res)
else:
    print(res2)

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

string S;
int K;
int dp[2][100+1][5];

signed main() {
  cin >> S >> K;
  int n = S.size();

  dp[0][0][0] = 1;

  for(int i=0; i<n; i++) {
    int s = (int)(S[i] - '0');
    for(int k=0; k<=K; k++) {
      for(int d=0; d<=9; d++) dp[1][i+1][k + (int)(d!=0)] += dp[1][i][k];
      for(int d=0; d<s; d++)  dp[1][i+1][k + (int)(d!=0)] += dp[0][i][k];
      dp[0][i+1][k + (int)(s!=0)] += dp[0][i][k];
    }
  }
  cout << dp[1][n][K] + dp[0][n][K] << endl;
}


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

#define all(x) (x).begin(), (x).end()
#define make_unique(vec) sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin());
#define dbg(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

bool tests = false;

void solve(){
    int n, m, x;
    cin >> n >> m >> x;
    vi c(n);
    vvi a(n);

    for (int i=0; i<n; i++){
        cin >> c[i];
        a[i].resize(m);
        for (int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    bool bigok = false;
    int mini = INT_MAX;
    for (int i=1; i< 2<<n ; i++){
        vi asum(m, 0);
        int csum = 0;
        for (int j=0; j<n; j++){
            if (i & 2<<j){
                csum += c[j];
                for (int k=0; k<m; k++){
                    asum[k]+= a[j][k];
                }
            }
        }bool ok = true;
        for (int j=0; j<m; j++){
            if (asum[j] < x){
                ok = false;
            }
        }if (ok){
            bigok = true;
            mini = min(mini, csum);
        }
    }cout << (bigok ? mini : -1) << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    if (tests){
        cin >> t;
    }
    while (t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n,k;
	cin >> n >> k;
	vector <ll> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	if (n <= k ) {
		cout << 0 << endl;
		return 0;
	}
	sort(h.begin(),h.end());
	while (k>0) {
		h.pop_back();
		k--;
	}
	ll count = 0;
	for (int i = 0; i < h.size(); i++) {
		count+= h[i];
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <utility>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>p(N);
	for (auto& i : p)cin >> i;
	cout << accumulate(p.begin(), p.end(), 0) - (*max_element(p.begin(), p.end()) / 2) << endl;
	return 0;
}

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


/* macro */
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = pow(2, 62);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */



signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    
    int a, b; cin >> a >> b;

    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        print("Possible");
    }else{
        print("Impossible");
    }

    
    




    
    



    
    

    







   




    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 256
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;

int main() {
  int n,m;
  cin >> n >> m;
  int ans=n;
  int l,r,tl,tr;
  l=1,r=n;
  for(int i=0;i<m;i++){
    cin >> tl >> tr;
    if(tl>l){
      ans=ans-(tl-l);
      l=tl;
    }
    if(r>tr){
      ans=ans-(r-tr);
      r=tr;
    }
  }
  if(ans<0){
    cout << "0" << endl;
  }
  else{
  cout << ans << endl;
  }
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto b = readln.chomp;
  if (b == "A") {
    writeln("T");
  } else if (b == "T") {
    writeln("A");
  } else if (b == "C") {
    writeln("G");
  } else {
    writeln("C");
  }
}


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

void main()
{
  char a[10];
  
  for(int i=0;i<6;i++)
  {
    scanf("%c",&a[i]);
  }
  
  if((a[2]==a[3]) && (a[4]==a[5]))
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }
}  

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

class UnionFind:
	def __init__(self, n):
		self.rank = [0] * n
		self.parent = [0] * n
		self.make(n)

	def make(self, n):
		for i in range(n):
			self.parent[i] = i

	def unite(self, x, y):
		xroot = self.findset(x)
		yroot = self.findset(y)
		if self.rank[xroot] < self.rank[yroot]:
			self.parent[xroot] = yroot
		elif self.rank[xroot] > self.rank[yroot]:
			self.parent[yroot] = xroot
		else:
			self.parent[xroot] = yroot
			self.rank[yroot] += 1
			node = y
			while True:
				self.rank[node] += 1
				if self.parent[node] == node:
					break
				node = self.parent[node]
			self.rank[y] += 1

	def findset(self, x):
		if self.parent[x] == x:
			return x
		else:
			root = self.findset(self.parent[x])
			self.parent[x] = root
			return root

def main():
	n, q = map(int, input().strip().split())
	uf = UnionFind(n)
	for i in range(q):
		com, x, y = map(int, input().strip().split())
		if com == 0:
			uf.unite(x, y)
		else:
			xroot = uf.findset(x)
			yroot = uf.findset(y)
			# print("xr: {} yr: {}".format(xroot, yroot))
			if xroot == yroot:
				print("1")
			else:
				print("0")

if __name__ == '__main__':
	main()



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

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

	if(n % 10 == 3) {
		cout << "bon" << "\n";
		return 0;
	}
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
	   cout << "pon" << "\n";
	   return 0;
	}
	else {
		cout << "hon" << "\n";
		return 0;
	}
}

Measured memory_bytes: 3624
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i, j, c;
		int [] a =  new int[n + 1];
		for(i = 0; i < n * (n - 1) / 2;i++){
			int k = sc.nextInt();
			int l = sc.nextInt();
			int p = sc.nextInt();
			int q = sc.nextInt();
			if (p > q){
				a[k] = a[k] + 3;
				}
			else if(p < q){
				a[l] = a[l] + 3;
				}
			else{
				a[k] = a[k] + 1;
				a[l] = a[l] + 1;
				}
			}
		for(i = 1; i < n + 1; i++){
			c = 1;
			for(j = 0; j < n + 1; j++){
				if(a[i] < a[j])
					c = c + 1;
				}
			System.out.println(c);
			}
		}
	}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

bool isp(string s){
	int lp = 0, rp = s.size() - 1;
	while(lp < rp){
		if(s[lp] != s[rp])return false;
		lp++;
		rp--;
	}
	return true;
}
void doit(){	
	string s;
	cin >> s;
	int n = s.size();
	if(isp(s) and isp(s.substr(0,(n-1)/2)) and isp(s.substr((n+3)/2 - 1)))cout << "Yes" << nl;
	else cout << "No" << nl;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input1.txt","r",stdin);
//    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
	// cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
int main() {
  ll n,m;
  cin >> n >> m;

  vl height(n);
  REP(i,n) cin >> height[i];

  vector<bool> good(n,true);

  REP(i,m){
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    if(height[a]>=height[b]) good[b] = false;
    if(height[a]<=height[b]) good[a] = false;
  }

  ll ans = 0;
  REP(i,n) if(good[i]) ans++;
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3996
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

bool E[4][4];

int main(){
	
	for(int i = 0; i < 3; i++){
		int x, y;
		cin >> x >> y;
		E[x - 1][y - 1] = true;
		E[y - 1][x - 1] = true;
	}
	
	int a[4] = {0, 1, 2, 3};
	
	string ans = "NO";
	
	do{
		bool flag = true;
		for(int i = 0; i < 3; i++){
			if(!E[a[i]][a[i + 1]]){
				flag = false;
			}
		}
		if(flag){
			ans = "YES";
		}
	}while(next_permutation(a, a + 4));
	
	cout << ans << endl;
	
	return 0;
}


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

const int D = 365;
vector<int> C(26), ans(D, 1), last(26,-1);
vector<vector<int>> s(D, vector<int>(26));

void input()
{
    int tmp;
    cin >> tmp;
    rep(i,26) cin >> C[i];
    rep(i,D)rep(j,26) cin >> s[i][j];

    rep(i,D) cin >> ans[i];
    rep(i,D) ans[i]--;
}

void output()
{
    for(auto x : ans)
        cout << x << "\n";
}

void test()
{
    int score = 0;
    rep(i,D)
    {
        int cur = ans[i];
        score += s[i][cur];
        last[cur] = i;
        rep(j,26)
        {
            score -= C[j] * (i - last[j]);
        }
        cout << score << endl;
    }
    return;
}

int main()
{
    input();
    test();
    return 0;
}

Measured memory_bytes: 3680
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
struct UnionFind {
    int n;
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> group;
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        n=N;
    }
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void calc(){
        group.resize(n,0);
        for(int i=0;i<n;i++){
            group[root(i)]++;
        }
    }
    int size(int x){
        return group[root(x)];
    }
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
 
};
struct Node{
  int no;
  int par;
  vector<Node*> child;
  void build(int i){
    no=i;par=i;
  }
};
bool judge(Node& node,UnionFind& tree){
    int nm=node.child.size();
    bool res=true;
    rep(i,nm){
        if(!tree.same(node.no,node.child[i]->no))res=false;
    }
    return res;
}
signed main(){
  int n,m;cin>>n>>m;
  vector<Node> node(n+2);
  rep1(i,n){
      node[i].build(i);
  }
  vector<int> res(5*n+100,0);
  UnionFind tree(n+1);
  rep(i,m){
      int a,b;cin>>a>>b;
      if(i==0){
          res[2*n]=a;
          res[2*n+1]=b;
          tree.unite(a,b);
      }
      node[a].child.push_back(&node[b]);
      node[b].child.push_back(&node[a]);
  }
  int cnt=2;
  int cur=2*n;
  int left=res[cur];
  while(!judge(node[left],tree)){
      int nm=node[left].child.size();
      rep(i,nm){
          if(!tree.same(node[left].no,node[left].child[i]->no)){
              --cur;
              tree.unite(node[left].no,node[left].child[i]->no);
              res[cur]=node[left].child[i]->no;
              left=res[cur];
              ++cnt;
              break;
          }
      }
  }
  int right=res[2*n+1];
  cur=2*n+1;
  while(!judge(node[right],tree)){
      int nm=node[right].child.size();
      rep(i,nm){
          if(!tree.same(node[right].no,node[right].child[i]->no)){
              ++cur;
              tree.unite(node[right].no,node[right].child[i]->no); 
              res[cur]=node[right].child[i]->no;
              right=res[cur];
              ++cnt;
              break;
          }
      }
  }
  cout<<cnt<<"\n";
  for(auto& val:res){
      if(val==0)continue;
      cout<<val<<" ";
  }
  cout<<endl;
  return 0;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 510, M = 1010;

int n, m, k;
int f[N][N];
vector<int> L[N], R[N];

int main()
{
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < m; i ++ )
	{
		int l, r;
		scanf("%d%d", &l, &r);
		L[l].push_back(r);
		R[r].push_back(l);
	}
	
	for (int i = 1; i <= n; i ++ )
	{
		sort(L[i].begin(), L[i].end());
		sort(R[i].begin(), R[i].end());
	}
	
	for (int len = 1; len <= n; len ++ )
		for (int l = 1; l + len - 1 <= n; l ++ )
		{
			int r = l + len - 1;
			
			if (r - 1 >= l + 1) f[l][r] += f[l + 1][r - 1];
			
			int i = lower_bound(L[l].begin(), L[l].end(), r) - L[l].begin();
			f[l][r] += i;
			int j = upper_bound(R[r].begin(), R[r].end(), l) - R[r].begin();
			f[l][r] += (int)R[r].size() - j;
			
			i = lower_bound(L[l].begin(), L[l].end(), r) - L[l].begin();
			j = upper_bound(L[l].begin(), L[l].end(), r) - L[l].begin();
			f[l][r] += j - i;
		}
	
	while (k -- )
	{
		int l, r;
		scanf("%d%d", &l, &r);
		printf("%d\n", f[l][r]);
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  bool ok;
  pair<int, int> ans;
  vector<vector<int>> input(n, vector<int>(3));
  for(int i=0;i<n;i++) {
    cin >> input[i][0] >> input[i][1] >> input[i][2];
  }
  long long int ansH = 0;
  for(int cx=0;cx<=100;cx++) {
    for(int cy=0;cy<=100;cy++) {
      ok = true;
      long long int HMAX = LLONG_MAX;
      long long int H = LLONG_MAX;
      for(int i=0;i<n;i++) {
        int x = input[i][0];
        int y = input[i][1];
        int h = input[i][2];

        int z = abs(x-cx)+abs(y-cy);
        if(h == 0) {
          if(z<=HMAX) HMAX = z;
        } else {
          if(H == LLONG_MAX) H = z + h;
          else if(max(H-z, 0LL) == h) continue;
          else {
            ok = false;
            break;
          }
        }
      }

      if(H > HMAX) ok = false;
      if(ok) {
        ans.first = cx;
        ans.second = cy;
        ansH = H;
        break;
      }
    }
    if(ok) break;
  }

  cout << ans.first << " " << ans.second << " " << ansH << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
   int n,a,b;
   scanf("%d%d%d",&n,&a,&b);
   if(n==1)
   {
       if(a==b)
        printf("1\n");
       else
       {
           printf("0\n");
       }
   }
   else
   {
       if(a>b)
        printf("0\n");
       else
        printf("%lld\n",(long long)(n-2)*(b-a)+1);
   }

    return 0;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define SUM(a) accumulate(all(a),int(0))
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int m, d; cin >> m >> d;
  int ans = 0;
  FOR(i,1,m+1) FOR(j,1,d+1){
    int a = j / 10, b = j % 10;
    if(a > 1 and b > 1 and i == a * b){
      dump(i,j);
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# ある頂点で、子供に対して順に1,2,3...と辺の色を渡していく
# 親から来た色を持っておき、親から来た色と同色になったときはスキップして次の色を渡す
# グラフ構築の際に、辺の番号を持っておく

import sys
readline = sys.stdin.readline

N = int(readline())
G = [[] for i in range(N)]
for i in range(N - 1):
  a,b = map(int,readline().split())
  G[a-1].append([b-1,i])
  G[b-1].append([a-1,i])
  
ans = [0 for i in range(N - 1)]
from collections import deque
# 頂点、親から来た色、親
q = deque([[0, 0, -1]])
while q:
  v,pcol,parent = q.popleft()
  cnt = 1
  for child in G[v]:
    if child[0] == parent:
      continue
    if cnt == pcol:
      cnt += 1
    ans[child[1]] = cnt
    q.append([child[0],cnt,v])
    cnt += 1

print(max(ans))
for a in ans:
  print(a)

Measured memory_bytes: 46760
#include<iostream>
using namespace std;
int main(){
	long long A,B,K;
	cin>>A>>B>>K;
	if(A<K){
		K-=A;
		A=0;
		B-=K;
	}else{
		A-=K;
	}
	if(B<0)B=0;
	cout<<A<<" "<<B;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,K,ans=1LL;
  cin>>N>>K;
  Graph G(N+1);
  RREP(i,N-1){
    int x,y;
	cin>>x>>y;
    G[x].PB(y);
    G[y].PB(x);
  }
  
  ll PAIR[N+1],CNT[N+1];
  bool CAN[N+1];
  REP(i,N+1){
    PAIR[i]=0;
    CNT[i]=0;
    CAN[i]=false;
  }
  
  queue<int> Q;
  Q.push(1);
  
  
  while(!Q.empty()){
    int v=Q.front();
    Q.pop();
    FORE(nv,G[v]){
      if(CAN[nv]) continue;
      PAIR[nv]=v;
      Q.push(nv);
    }
    ans*=K-CNT[PAIR[v]];
    ans%=MOD;
    if(v==1) CNT[v]=1;
    else CNT[v]=2;
    CNT[PAIR[v]]++;
    CAN[v]=true;
  }
  
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
  int n;
  int ni,di;
  int x[200];
  int y[200];
  int dx[]={-1,0,1,0};
  int dy[]={0,-1,0,1};
  
  while(cin >> n,n){
    memset(x,0,sizeof(x));
    memset(y,0,sizeof(y));
    for(int i=1;i < n;i++){
      cin >> ni >> di;
      x[i] = x[ni]+dx[di];
      y[i] = y[ni]+dy[di];
    }
    int max_x=-9999;
    int min_x=9999;
    int max_y=-9999;
    int min_y=9999;
    
    for(int i=0;i < n;i++){
      max_x = max(max_x,x[i]);
      min_x = min(min_x,x[i]);
      max_y = max(max_y,y[i]);
      min_y = min(min_y,y[i]);
    }
    cout << max_x-min_x+1 << " " << max_y-min_y+1 << endl;
  }
  return 0;
}



Measured memory_bytes: 3092
from networkx import*
e=enumerate
_,*s=open(0)
g=[]
for i,t in e(s,1):
 for j,u in e(t):g+=[(k:=i*20+j,k+20)]*(u>'#'<(s+['#'*k])[i][j])+[(k,k+1)]*(u>'#'<t[j+1])
print(max(t[i]for _,t in shortest_path_length(Graph(g))for i in t))

Measured memory_bytes: 53536
#include<stdio.h>
 
int main(void){
 
  int i;
 
  char moji;

  scanf("%c", &moji);
 
  if((moji>= 'a') && (moji<='z')){
    printf("a\n");
  }else if((moji>= 'A') && (moji<='Z')){
    printf("A\n");
  }
 
  return 0;
}


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

using namespace std;

int ans = 0;
vector<string> a;
vector<int> p;
int D, x, y;

void dfs(int now, int d, int point) {
	if (now >= x+y || d >= D) {
		ans = max(ans, point);
		return;
	}

	bool usable1 = false;
	bool usable2 = false;
	if (now < x) {
		if (a[now]=="D") usable1 = true;
	} else {
		if (a[now]=="DD") usable2 = true;
	}

	if (usable1) {
		dfs(now + 1, d + 1, point + p[now]);
		dfs(now + 1, d, point);
	} else if (usable2 && d <= D-2) {
		dfs(now + 1, d + 2, point + p[now]);
		dfs(now + 1, d, point);
	} else {
		dfs(now + 1, d, point);
	}
}

int main() {
	cin >> D;

	a.assign(25, "");
	p.assign(25, 0);

	cin >> x;
	for (int i=0; i<x; i++) {
		cin >> a[i] >> p[i];
	}

	cin >> y;
	for (int i=0; i<y; i++) {
		cin >> a[x+i] >> p[x+i];
	}

	dfs(0, 0, 0);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1220
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func Max(x ...int) int {
	max := x[0]
	for _, v := range x {
		if v > max {
			max = v
		}
	}
	return max
}


func ModPow(x int, y int, mod int) int {
	total := x
	for i := 1; i < y; i++ {
		total = (total * (x % mod)) % mod
	}
	return total
}

const MOD = 998244353

func main() {
	n := nextInt()
	d := make([]int, n)
	for i := 0; i<n; i++ {
		d[i] = nextInt()
	}

	m := map[int]int{}
	max := Max(d...)

	for i := 0; i<n; i++ {
		_, ok := m[d[i]]
		if ok {
			m[d[i]] += 1
		} else {
			m[d[i]] = 1
		}
	}

	if m[0] != 1 || d[0] != 0 {
		fmt.Printf("%d", 0)
		return
	}

	total := 1
	for i := 1; i<=max; i++ {
		total = (total * ModPow(m[i - 1], m[i], MOD)) % MOD
	}

	fmt.Printf("%d", total)
}


Measured memory_bytes: 7296
#include <stdio.h>
int main ()
{
    int a, b, c, x, i, j, k, cnt=0;
    scanf("%d%d%d%d", &a, &b, &c, &x);
    for (i=0; i <= a && 500*i<=x; i++)
    {
        for (j=0; j <= b && 100*j+500*i<=x; j++)
        {
            for (k=0; k <= c && 50*k+100*j+500*i<=x; k++)
            {
                if (500*i+100*j+50*k==x)
                {
                    cnt++;
                }
            }
        }
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int m[500][500];

int main(){
	int n, k;
	
	cin >> n >> k;
	
	int ans = 1;
	
	REP(i,n){
		if (ans*2 <= ans+k) ans *= 2;
		else ans += k;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <list>
#include <iterator>

#include <cmath>

typedef std::pair<double,double> Vec;
typedef std::pair<Vec,Vec> Line;

Vec operator+(const Vec& lhs, const Vec& rhs) {
	return std::make_pair(lhs.first+rhs.first, lhs.second+rhs.second);
}

Vec operator-(const Vec& lhs, const Vec& rhs) {
	return std::make_pair(lhs.first-rhs.first, lhs.second-rhs.second);
}

Vec lineToVec(const Line& l) {
	return l.first - l.second;
}

double cross(const Vec& lhs, const Vec& rhs) {
  return lhs.first*rhs.second - lhs.second*rhs.first;
}

int main(void){
	using namespace std;

	int n;
	cin >> n;

	vector< pair<Line,Line> > input;
	input.reserve(n);

	for(int i=1; i<=n; i++){
		double x1,y1,x2,y2,x3,y3,x4,y4;
		cin
			>> x1 >> y1
			>> x2 >> y2
			>> x3 >> y3
			>> x4 >> y4;

		auto AB = make_pair( make_pair(x1,y1), make_pair(x2,y2) );
		auto CD = make_pair( make_pair(x3,y3), make_pair(x4,y4) );

		input.push_back(make_pair(AB,CD));
	}

	for(auto itr=input.begin(); itr!=input.end(); itr++){
		auto AB = itr->first;
		auto CD = itr->second;

		auto cr = cross( lineToVec(AB), lineToVec(CD) );

		if( abs(cr) <1e-10 ){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1236
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        h1: i64, m1: i64, h2: i64, m2: i64, k: i64,
    }
    puts!("{}\n", 60 * (h2 - h1) + m2 - m1 - k);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2256
def dudge(k):
    for i in reversed(range(n)):
        p = (k >> i) % 2
        #print(' i = ', i, ' p = ', p)
        if p == 0: continue

        for claim in xy[i]:
            x = claim[0]
            y = claim[1]

            truth = (k >> x-1) % 2
            #print('   x = ', x,  ' y = ', y, ' t = ', truth)
            if truth == 1 and y == 0:
                return False
            elif truth == 0 and y == 1:
                return False
    return True


n = int(input())

xy = []
for i1 in range(n):
    ai = int(input())
    xy.append([])

    for i2 in range(ai):
        xi,yi = map(int, input().split())
        xy[i1].append((xi, yi))

#print(xy)

result = 0
for k in reversed(range(1 << n)):
    #print(bin(k))

    if dudge(k):
        #print('    True')
        l = [i for i in range(n) if (k >> i) % 2 == 1]
        cnt = 0
        #for i in range(n):
        #    if (k >> i) % 2 == 1: cnt += 1
        #print('    ', l, len(l))
        result = max(result, len(l))
        #result = max(result, cnt)

print(result)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    vector< vector<int> > a(3, vector<int>(3));
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> a[i][j];
    for (int i = 1; i < 3; ++i)
        for (int j = 0; j < 3; ++j)
            a[i][j] -= a[0][j];
    bool ok = true;
    for (int i = 1; i < 3; ++i)
        for (int j = 1; j < 3; ++j)
            if (a[i][j] != a[i][0])
                ok = false;
    if (ok)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include "stdio.h"
int main(int argc, char const *argv[])
{
    int n;
    scanf("%d",&n);

    if(n==25){
        printf("Christmas\n");
    }else if(n==24){
        printf("Christmas Eve\n");
    }else if(n==23){
        printf("Christmas Eve Eve\n");
    }else if(n==22){
        printf("Christmas Eve Eve Eve\n");
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();//整数1000<N<9999
		String val = String.valueOf(n);
		String data[] = new String[4];

		for(int i=0;i<val.length();i++) {
			data[i]=String.valueOf(val.charAt(i));
		}

		if(data[0].equals(data[1])&&data[0].equals(data[2])) {
			System.out.println("Yes");
		}else if(data[3].equals(data[2])&&data[3].equals(data[1])) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

signed main(){
  string S;
  cin>>S;
  int ans=0;
  string SL="",TS="";
  rep(i,S.size()){
    TS+=S[i];
    if(TS==SL)continue;
    SL=TS;
    TS="";
    ans+=1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S, S2, S3;
    int kaibun = 1;
    cin >> S;
    int num = S.size();
    int cnt1 = (num - 1) / 2; 
    //回分である
    for(int i = 0; i < cnt1; i++){
        if(S[i] != S[num - i - 1]) kaibun = 0;
    }
    //2つめの条件
    int cnt2 = (cnt1 - 1) / 2;
    
    S2 = S.substr(0,cnt1);
    num = S2.size();
   // cout << num;
   if(cnt2 % 2 == 1){
    for(int i = 0; i < cnt2; i++){
        if(S2[i] != S2[num - i - 1]) kaibun = 0;
    }
    //3つめの条件
    S3 = S.substr(cnt1+1);
    num = S2.size();
    //cout << S3;
    for(int i = 0; i < cnt2; i++){
        if(S3[i] != S3[num - i - 1]) kaibun = 0;
    }
    //cout << kaibun;
    if(kaibun == 1) cout << "Yes";
    else cout << "No";
    }
    
    else {
    for(int i = 0; i < cnt2 + 1; i++){
        if(S2[i] != S2[num - i - 1]) kaibun = 0;
    }
    //3つめの条件
    S3 = S.substr(cnt1+1);
    num = S2.size();
    //cout << S3;
    for(int i = 0; i < cnt2 + 1; i++){
        if(S3[i] != S3[num - i - 1]) kaibun = 0;
    }
    //cout << kaibun;
    if(kaibun == 1) cout << "Yes";
    else cout << "No";        
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using ll = long long;
using namespace std;
int ct[100000 + 10];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, m;
  cin >> n >> m;


  for(int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    ct[a]++;
    ct[b]++;
  }


  for(int i = 1; i <= n; ++i) {
    if (ct[i] % 2) {
      cout << "NO" << endl;
      return 0;
    }
  }


  cout << "YES" << endl;
}

Measured memory_bytes: 640
N,K = map(int, input().split())

sunuke_list = [0 for i in range(0,N+1)]

for i in range(K):
    d = int(input())
    A_list = [int(e) for e in input().split()]
    for sunuke in A_list:
        sunuke_list[sunuke] += 1

ans = 0
for i in range(1,N+1):
    if sunuke_list[i]==0:
        ans += 1

print(ans)

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    // string s;
    // int l = siz(s);
    // vi dp(l + 1, 0);
    // rep(i, l) {
    //     if (s[i] == 'D') {
    //         umax(dp[i + 1], dp[i] + 1);
    //     } else if (s[i] == 'P') {
    //         umax(dp[i + 1], dp[i] + 1);
    //     } else {

    //     }
    // }

    string s;
    cin >> s;
    rep(i, siz(s)) {
        if (s[i] == '?') {
            s[i] = 'D';
        }
    }

    prt(s);

    return 0;
}


Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] abc= {111,222,333,444,555,666,777,888,999,1111};
		int n = sc.nextInt();

		for(int i=0;i<abc.length;i++) {
			if(n<=abc[i]) {
				System.out.println(abc[i]);
				return;
			}
		}
	}
}

Measured memory_bytes: 21716