akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
    int A[3][3];
    for(int i=0; i<3; i++){
        scanf("%d %d %d", &A[i][0], &A[i][1], &A[i][2]);
    }
    int N;
    scanf("%d", &N);
    int B[10];
    for(int i=0; i<N; i++){
        scanf("%d", &B[i]);
    }

    bool b[3][3];
    for(int y=0; y<3; y++){
        for(int x=0; x<3; x++){
            b[y][x] = false;
        }
    }

    for(int i=0; i<N; i++){
        for(int y=0; y<3; y++){
            for(int x=0; x<3; x++){
                if(A[y][x] == B[i]){
                    b[y][x] = true;
                }
            }
        }
    }

    for(int y=0; y<3; y++){
        if(b[y][0] && b[y][1] && b[y][2]){
            printf("Yes\n");
            return 0;
        }
    }

    for(int x=0; x<3; x++){
        if(b[0][x] && b[1][x] && b[2][x]){
            printf("Yes\n");
            return 0;
        }
    }

    if(b[0][0] && b[1][1] && b[2][2]){
        printf("Yes\n");
        return 0;
    }

    if(b[2][0] && b[1][1] && b[0][2]){
        printf("Yes\n");
        return 0;
    }

    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
class UnionFind(val n: Int) {

  val data = IntArray(n) { -1 }

  fun root(x: Int): Int {
    if (data[x] < 0) return x
    data[x] = root(data[x])
    return data[x]
  }

  fun unite(x: Int, y: Int) {
    var rx = root(x)
    var ry = root(y)
    if (rx == ry) return
    if (-data[rx] < -data[ry]) {
      val t = rx
      rx = ry
      ry = t
    }
    data[rx] += data[ry]
    data[ry] = rx
  }

  fun same(x: Int, y: Int) = root(x) == root(y)

  fun size(x: Int) = -data[root(x)]
}

fun main(args: Array<String>) {
  val (n, m, k) = readLine()!!.split(' ').map(String::toInt)
  val uf = UnionFind(n + 1)
  val fr = IntArray(n + 1)
  val bk = IntArray(n + 1)
  repeat(m) {
    val (a, b) = readLine()!!.split(' ').map(String::toInt)
    uf.unite(a, b)
    fr[a]++
    fr[b]++
  }
  repeat(k) {
    val (c, d) = readLine()!!.split(' ').map(String::toInt)
    if (uf.same(c, d)) {
      bk[c]++
      bk[d]++
    }
  }
  for (p in 1..n) {
    print(uf.size(p) - fr[p] - bk[p] - 1)
    print(' ')
  }
  println()
}


Measured memory_bytes: 76968
#include<bits/stdc++.h>
using namespace std;
int main(){
    int s;
    cin >> s;
    int y=s/100;
    int m=s%100;
    if(y<=12&&y>=1 && m<=12 && m>=1) cout <<"AMBIGUOUS" << endl;
    else if((y==0||y>12) && m<=12 && m>=1) cout << "YYMM" << endl;
    else if(y>=1&&y<=12 && (m>12||m==0)) cout << "MMYY" << endl;
    else  cout <<"NA" << endl;
    return 0;
}

Measured memory_bytes: 256
import math
def isprime(limit):
    if limit == 2:
        return 2
    for k in range(limit, limit + 100000):
        if k % 2 == 0:
            continue
        for divisor in range(2, math.floor(math.sqrt(k)) + 2):
            if k % divisor == 0:
                break
            if divisor == int(math.floor(math.sqrt(k)) + 1):
                return k
num = int(input())
print(isprime(num))


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

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

    for (int i = 0; i < N; i++) {
        std::cin >> a[i];
    }

    std::set<int> values;

    for (int i = 0; i < N; i++) {
        values.insert(a[i]);
    }

    std::cout << values.size();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){

  int n,m,p;
  int d[1001];
  int ans;

  while(true){
    cin >> n >> m;
    if(!n && !m) break;

    memset(d,0,sizeof(d));
    p = -1;
    ans = 0;

    for(int i=0;i<n;i++) cin >> d[i];

    sort(d,d+n);
    reverse(d,d+n);

    for(int i=0;i<n;i++){
      if(p+m == i) p += m;
      else ans += d[i];
    }

    cout << ans << endl;

  }
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL dp[305][305][305];
int h[305];
int main(){
    memset(dp, -1, sizeof(dp));
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> v;
    v.push_back(-1);
    v.push_back(0);
    for(int i=1;i<=n;i++){
        scanf("%d", &h[i]);
        v.push_back(h[i]);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for(int i=1;i<=n;i++){
        h[i] = lower_bound(v.begin(), v.end(), h[i]) - v.begin();
        if(i == 1){
            for(int j=1;j<v.size();j++){
                if(j == h[i]) dp[i][j][0] = v[j];
                else dp[i][j][1] = v[j];
            }
        }
        else{
            for(int l=0;l<=k;l++){
                LL mn = 1e18;
                for(int j=1;j<v.size();j++){
                    if(mn != 1e18) mn+=v[j]-v[j-1];
                    if(dp[i-1][j][l] != -1) mn = min(mn, dp[i-1][j][l]);
                    int nt = l+1;
                    if(h[i] == j) nt = l;
                    if(dp[i][j][nt] == -1 || dp[i][j][nt] > mn){
                        dp[i][j][nt] = mn;
                    }
                }
                mn = 1e18;
                for(int j=v.size()-1;j>=1;j--){
                    if(dp[i-1][j][l] != -1) mn = min(mn, dp[i-1][j][l]);
                    int nt = l+1;
                    if(h[i] == j) nt = l;
                    if(dp[i][j][nt] == -1 || dp[i][j][nt] > mn){
                        dp[i][j][nt] = mn;
                    }
                }
            }
        }
    }
    LL ans = 1e18;
    for(int j=1;j<v.size();j++){
        for(int l=0;l<=k;l++){
            if(dp[n][j][l] == -1) continue;
            ans = min(ans, dp[n][j][l]);
        }
    }
    printf("%lld\n", ans);
}

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

int main() {
	// your code goes here
	int N;
	string S;
	cin >> N >> S;
	int max=0;
	int x=0;
	for(int i=0;i<N;i++){
		if(S[i]=='I') x++;
		else if(S[i]=='D') x--;
		if(x > max) max = x;
	}
	cout << max;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std ;
int main() {
    long a,b,k ;
    cin>>a>>b>>k;
    for (long i = a ; i <= min(a+k-1,b);i++){
        cout << i << endl;
    }
    for (long j = max(b-k+1,a+k) ; j<=b ; j++){
        cout << j << endl;
    }

    return 0;
}

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

signed main()
{
  int X;
  cin >> X;

  int max_maisuu = X/100;
  int x = X%100;

  int maisuu = 0;

  cerr << x << " " << max_maisuu <<endl;

  for(int i=5; i>=1; i--)
  {
    int m = min((x/i), max_maisuu - maisuu);
    cerr << i << " " << m << " " << maisuu << " " << x << endl;
    maisuu += m;
    x -= m * i;
    if((x==0) || (x<=5 && max_maisuu-maisuu!=0)) {
      puts("1");
      return 0;
    }
  }
  puts("0");
}


Measured memory_bytes: 256
a, b=map(int, input().split())
if a==0 or b==0:
  print("Zero")
  exit()
if(a<=0 and b>=0):
  print("Zero")
  exit()
if a>0:
  print("Positive")
elif abs(b-a)%2==0:
  print("Negative")
else:
  print("Positive")
  
 

Measured memory_bytes: 3060
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n,d = LI()
        if n == 0:
            break

        a = [LI()[1:] for _ in range(n)]
        q = []
        sa = []
        for ai in a:
            s = sum(ai)
            sa.append([s, ai])

        f = True
        while f:
            f = False
            sa.sort()
            ls,la = sa[-1]
            if ls == 0:
                break
            ls2 = sa[-2][0]
            if ls - la[-1] >= ls2 - d:
                sa[-1] = [ls - la[-1], la[:-1]]
                f = True
                continue

            for i in range(n-2,-1,-1):
                ts, ta = sa[i]
                if ts == 0:
                    break
                if ts - ta[-1] >= ls - d:
                    sa[i] = [ts - ta[-1], ta[:-1]]
                    f = True

        if sa[-1][0] == 0:
            rr.append('Yes')
        else:
            rr.append('No')

    return '\n'.join(map(str,rr))



print(main())



Measured memory_bytes: 9388
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int count = 0;
        for(int x=0; x <= K &&  x <= S; x++){
            for(int y=0; y <= K && y <= S; y++){
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            }
        }
        System.out.print(count);
    }
}

Measured memory_bytes: 20820
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int count = 0;
		for (int i = 0; i <= A; i++) {
			for (int j = 0; j <= B; j++) {
				for (int k = 0; k <= C; k++) {
					if (X == i * 500 + j * 100 + k * 50)
						count++;
				}
			}
		}

		System.out.println(count);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22996
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    arr=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    println(arr[parseInt(readline())])
end
main()

Measured memory_bytes: 164860
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
#define pb push_back
#define fi first 
#define se second 
#define mod 1000000007
int power(ll x, ll  y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
int main() 
{ 
  ll n,k;
  cin >> n>> k ;
  vector<ll> v(n) ;
  for(ll i=0;i<n;i++) cin >> v[i] ;
  sort(v.begin(),v.end()) ;
  ll sum=0;
  for(ll i=0;i<k;i++)
  sum += v[i] ;
  cout << sum<< endl;

} 

Measured memory_bytes: 3628
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

constexpr int SELL = 1, BUY = -1;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<int> b(n);

    bool inc = true, dec = true;

    for (int i = 1; i < n; i++) {
        if (a[i] > a[i - 1]) {
            inc = true;
            if (dec == true) {
                b[i - 1] = BUY;
                dec = false;
            }
        } else if (a[i] < a[i - 1]) {
            dec = true;
            if (inc == true) {
                b[i - 1] = SELL;
                inc = false;
            }
        }
    }

    b[n - 1] = SELL;

    int money = 1000;
    int stock = 0;

    for (int i = 0; i < n; i++) {
        if (b[i] == SELL) {
            money += a[i] * stock;
            stock = 0;
        } else if (b[i] == BUY) {
            const int stocks_buy = money / a[i];
            money -= a[i] * stocks_buy;
            stock += stocks_buy;
        }
    }

    cout << money << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

string S, T, U;

int A, B;

int main(void) {

	cin >> S >> T;
	cin >> A >> B;
	cin >> U;

	if (U == S) { cout << A - 1 <<" "<<B<< endl; }
	else { cout <<A<< " "<< B - 1 << endl; }
	return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c, d = map(int, input().split())
    ans = 0
    if d - a > 0:
        ans += a
        d -= a
    else:
        ans += (d)
        print(ans)
        exit()

    if d - b > 0:
        d -= b
    else:
        print(ans)
        exit()

    ans -= (d)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct Node {
    int key;
    struct Node *prev;
	struct Node *next;
};
  
struct Node *note;
  
void init() {
    note = (struct Node *)malloc(sizeof(struct Node));
    note->next = note;
    note->prev = note;
}
  
void insert(int key) {
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->key = key;
	note->next->prev = x;
    x->next = note->next;
    note->next = x;
    x->prev = note;
}
  
struct Node* listSearch(int key) {
    struct Node *cur = note->next;
    while(cur != note && cur->key != key ) {
        cur = cur-> next;
    }
    return cur;
}
  
void deleteNode(struct Node *t) {
    if (t == note) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}
  
void deleteFirst() {
    deleteNode(note->next);
}
  
void deleteLast() {
    deleteNode(note->prev);
}
void deleteKey(int key) {
    deleteNode(listSearch(key));
}
  
void printList() {
    struct Node *cur;
    cur = note->next;
    int isf = 0;
  
    while(1) {
        if (cur == note) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}
  
  
int main(void) {
    int key, n;
    char order[20];
    scanf("%d", &n);
    init();
    for (int i = 0; i < n; i++) {
        scanf("%s%d",order, &key);
        if(order[0] == 'i') {
            insert(key);
        }else if(order[0] == 'd') {
            if(strlen(order) > 6) {
                if( order[6] == 'F') {
                    deleteFirst();
                }else if(order[6] == 'L') {
                    deleteLast();
                }
            }else {
                deleteKey(key);
            }
        }
    }
    printList();
    return 0;
}

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

class Program
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        LinkedList<int> l = new LinkedList<int>();
        for (int i = 0; i < n; i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            if (s[0] == "insert")
            {
                l.AddFirst(int.Parse(s[1]));
            }
            else if (s[0] == "delete")
            {
                l.Remove(int.Parse(s[1]));
            }
            else if (s[0] == "deleteFirst")
            {
                l.RemoveFirst();
            }
            else if (s[0] == "deleteLast")
            {
                l.RemoveLast();
            }
        }
        int[] larray = new int[l.Count];
        l.CopyTo(larray, 0);
        for (int i = 0; i < larray.Length - 1; i++)
        {
            Console.Write("{0} ", larray[i]);
        }
        Console.WriteLine(larray[larray.Length - 1]);
    }
}


Measured memory_bytes: 71320
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
  public struct arch{
  }
 
  public static void Main (string[] args) {
    var temp = Console.ReadLine().Split(' ').Select(long.Parse);
    var N = temp.ElementAt(0);
    var R = temp.ElementAt(1);
    var ans = N >= 10 ? R : R + 100 * (10 - N);
    Console.WriteLine(ans);
 
  }
  
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
vector< pair<int,int> > v[30];
int a[100005];
int main()
{
    int t,c;
    scanf("%d%d",&t,&c);
   
    int i,st,en,cc;
    for(i=0;i<t;i++)
    {
        scanf("%d%d%d",&st,&en, &cc);
        v[cc].push_back(make_pair(st,en));
    }
    for(i=1; i<=c; i++)
    {
        sort(v[i].begin(), v[i].end());
        stack< pair<int,int> > s;
        int j;
        for(j= 0; j< v[i].size(); j++)
        {
            pair<int,int> cur = v[i][j];
            if(s.size() && s.top().second >= cur.first-1)
            {
                cur.first = s.top().first;
                s.pop();
            }
            s.push(cur);
        }
        while(s.size())
        {
            pair<int,int> cur = s.top();
            s.pop();
           // printf("%d %d\n",cur.first, cur.second);
            a[cur.first]++;
            a[cur.second+1]--;
        }
    }
    int ans = 0;
    int cur = 0;
    for(i=0;i<=100000;i++)
    {
        cur += a[i];
        ans = max(ans,cur);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int[] a = new int[n];
		long sum = 0;

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

			a[i] = in.nextInt();

		}

		int max = a[0];
		int min = a[0];

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

			if(min > a[i]) {

				min = a[i];
			}
		}

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

			if(max < a[i]) {

				max = a[i];
			}
		}

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

			sum += a[i];

		}

		System.out.println(min + " " + max + " " + sum);
	}
}

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

public class Main {

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int noOfItems = in.nextInt();
    int W = in.nextInt();
    Item[] items = new Item[noOfItems + 1];
    items[0] = new Item(0, 0);
    for (int k = 0; k < noOfItems; k++) {
      items[k + 1] = new Item(in.nextInt(), in.nextInt());
    }
    Arrays.sort(items);
    long[][] dp = new long[items.length][W + 1];
    for (int i = 0; i < dp.length; i++) {
      dp[i][0] = 0;
    }
    for (int j = 0; j < dp[0].length; j++) {
      dp[0][j] = 0;
    }

    for (int i = 1; i < dp.length; i++) {
      for (int j = 1; j < dp[0].length; j++) {
        if (items[i].weight > j) {
          dp[i][j] = dp[i - 1][j];
        } else {
          long secWeight = 0;
          if (j - items[i].weight > 0) {
            secWeight = dp[i - 1][j - items[i].weight];
          }
          dp[i][j] = Math.max(dp[i - 1][j], items[i].price + secWeight);
        }
      }
    }
    System.out.println(dp[items.length - 1][W]);
    in.close();
  }

  static class Item implements Comparable<Item> {
    int weight;
    int price;

    public Item(int w, int p) {
      this.weight = w;
      this.price = p;
    }

    public int compareTo(Item t) {
      return this.weight - t.weight;
    }
  }
}


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

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

  long long a = 1;
  long long b = 3;

  for(int i = 0; i < n - 2; i++){
    if(a >= b){
      b = a + b;
    }
    else{
      a = a + b;
    }
  }

  if(n == 1){
    cout << 1 << endl;
  }
  else if(n == 2){
    cout << 3 << endl;
  }
  else{
    cout << max(a, b) << endl;
  }

}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end(), greater<int>());
    if(k > n) k = n;
    rep(i, k) h[i] = 0;
    ll sum = 0;
    rep(i, n) sum += h[i];
    
    cout << sum << endl;
}



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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;

int n,mod,f[5005][5005],a[maxn],g[10002];

int main() {
    read(n),read(mod);
    f[1][n]=1;a[2]=1;
    for(int i=3,j=n;i<=j;i++,j--) a[i]=a[j]=a[i-1]+1;
    for(int x=2;x<=n;x++) 
        for(int i=n;i;i--) f[x][i]=((i+a[x]<=n?f[x][i+a[x]]:0)+f[x-1][i])%mod;
    int ans=0;
    for(int i=1;i<=n;i++) ans=(ans+1ll*i*f[n][i]%mod)%mod;
    write(ans);
    return 0;
}


Measured memory_bytes: 99968
#include<stdio.h>
int main(void)
{
	int x,a;
	scanf("%d",&x);
	a=x%7;
	if(a==0){
		printf("thu\n");
	}
	else if(a==1){
		printf("fri\n");
	}
	else if(a==2){
		printf("sat\n");
	}
	else if(a==3){
		printf("sun\n");
	}
	else if(a==4){
		printf("mon\n");
	}
	else if(a==5){
		printf("tue\n");
	}
	else {
		printf("wed\n");
	}
	return 0;
}


Measured memory_bytes: 2100
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int []a= new int[N];
		for(int i=0;i<N;i++){
			a[i]=sc.nextInt();
		}
		for(int i=0;i<N-1;i++) {
			for(int j=0;j<N-1-i;j++){
				if(a[j]<a[j+1]) {
                int temp = a[j];
                a[j] = a[j+1];
                a[j+1]= temp;
			}
		}
	}
		int countA=0;
		int countB=0;
		for(int i=0;i<N;i++) {
			if(i%2==0) {
				countA+=a[i];
			}
			else if(i%2==1){
				countB+=a[i];
			}
		}
		System.out.println(countA-countB);
		}
		}

Measured memory_bytes: 22740
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
//#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

bool cmp(const pii &a, const pii &b) //セカンドキー->ファーストキーの順ソート
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void)
{
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, 0, s.size())
    {
        mp[s[i]]++;
    }
    Print(abs(mp['a'] - mp['b']) <= 1 &&
          abs(mp['c'] - mp['b']) <= 1 &&
          abs(mp['a'] - mp['c']) <= 1);
}

Measured memory_bytes: 512
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

bool isprime[1000000];
int ans[1000000];

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

	rep(i, 0, 1000000)isprime[i] = true;
	isprime[0] = false;
	isprime[1] = false;
	ans[0] = ans[1] = 0;
	int n = 0;
	rep(i, 2, sqrt(1000000) + 1)
	{
		if (isprime[i])
		{
			for (int j = 2 * i; j < 1000000; j += i)
			{
				isprime[j] = false;
			}
		}
	}
	rep(i, 2, 1000000)
	{
		if (isprime[i])
		{
			n++;
		}
		ans[i] = n;
	}

	int N;
	while (cin >> N)
	{
		cout << ans[N] << endl;
	}

	return 0;
}


Measured memory_bytes: 8032
/*
* @Author: Samson
* @Date:   2018-05-04 10:11:57
* @Last Modified by:   Samson
* @Last Modified time: 2018-05-04 11:58:19
*/
//   @URL : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_D
#include<bits/stdc++.h>
#include<algorithm>
#include <cstdlib>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int MAXN = 2*1e5+10;

int a[MAXN],n,L[MAXN/2],R[MAXN/2];

LL merge(int left,int mid,int right)
{
	int i,j,k;
	LL cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for(i = 0; i < n1; ++i)	L[i] = a[left+i];
	for(i = 0; i < n2; ++i)	R[i] = a[mid+i];
	L[n1] = R[n2] = INF;
	i = j = 0;
	for(k = left; k < right; ++k)
	{
		if(L[i] <= R[j])
		{
			a[k] = L[i++];
		}
		else
		{
			a[k] = R[j++];
			cnt += n1-i;
		}
	}
	return cnt;
}

LL mergesort(int left,int right)
{
	int mid;
	LL v1,v2,v3;
	if(left + 1 < right)
	{
		mid = (left+right)/2;
		v1 = mergesort(left,mid);
		v2 = mergesort(mid,right);
		v3 = merge(left,mid,right);
		return v1+v2+v3;
	}
	else
		return 0;
}

int main(void)
{
	ios::sync_with_stdio(false); 
	//cin.tie(0);
	cin>>n;
	for(int i = 0; i < n; ++i)
		cin>>a[i];
	LL ans = mergesort(0,n);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 4752
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  ll n,x,m; cin >> n >> x >> m;
  vi num;
  map<int,int> mp;
  while(1){
    if(mp[x] == 2) break;
    num.push_back(x);
    mp[x]++;
    x = x*x%m;
  }
  int once = 0, twice = 0;
  for(auto a : mp){
    if(a.second == 1) once++;
    if(a.second == 2) twice++;
  }
  ll start = 0, roop = 0;
  vi one,two;
  rep(i,num.size()){
    if(i < once){
      one.push_back(num[i]);
      start += num[i];
    }
    if(once <= i && i < once+twice){
      two.push_back(num[i]);
      roop += num[i];
    }
  }
  ll ans = 0;
  if(n <= once){
    rep(i,once) ans += one[i];
  }else{
    ans += start;
    n -= once;
    ans += roop*(n/twice);
    n %= twice;
    rep(i,n){
      ans += two[i];
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 6448
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int n; cin >> n;
    vector<bool> ar(n);
    rep(i,n){
        int a, b; cin >> a >> b;
        if (a == b) ar[i] = true;
        else ar[i] = false;
    }
    bool t = false;
    rep(i,n-2){
        if (ar[i]&&ar[i+1]&&ar[i+2]) t = true;
    }
    if (t) yes();
    else no();
}

Measured memory_bytes: 3628
N,A,B = map(int,input().split())
ARR = list(map(int,input().split()))
def calculate(n,a,b,arr):

    result = 0
    for i in range(1,n):
        result += min(B,(arr[i] - arr[i-1]) * A)

    print(result)

calculate(N,A,B,ARR)

Measured memory_bytes: 19932
buf = input()
H,W = buf.split()
H = int(H)
W = int(W)
pic = []
 
for i in range(H):
    pic.append(input())
 
#for row in pic:
#    print(row)
 
for i in range(W+2):
    print("#",end="")
print()
 
for i in range(H):
    print("#"+pic[i]+"#")
 
for i in range(W+2):
    print("#",end="")

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

#define maxn 200005
#define mod 1000000007

typedef pair<int, int> P;

int n, k;
double p[maxn];
double cnt[maxn];

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        scanf("%lf", &p[i]);
        cnt[i] = cnt[i - 1] + (1 + p[i]) / 2.0;
    }
    double ans = 0;
    for (int i = 0; i + k <= n; i++)
        ans = max(ans, cnt[i + k] - cnt[i]);
    printf("%.15f\n", ans);
    return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int a[12];
int main(){
	int T;
	int i = 0;
	int sum = 0;
	scanf("%d", &T);
	for(int i = 1; i <= T; i++){
		scanf("%d ", &a[i]);	
	}
	sort(a + 1, a + 1 + T);
	sum = a[T]/2;
	for(int i = 1; i <= T - 1; i++){
		sum += a[i];	
	}
	printf("%d\n", sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Og")
#pragma GCC push_options
#pragma GCC pop_options
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int dem = 0;
    while (s.find("ABC") != string::npos)
    {
        dem++;
        s.erase(s.find("ABC"), 3);
    }
    cout << dem;
}

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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int m; cin >> m;
  vector<int> b(m);
  rep(i,m) cin >> b[i];

  vector<int> ans;
  set_union(a.begin(), a.end(),
  b.begin(), b.end(),
  inserter(ans, ans.end()));

  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 6464
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop
import itertools


# read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
A = list(map(int, input().split()))

A = [0] + A
A = list(itertools.accumulate(A))
A = [x % K for x in A]

cnt = defaultdict(int)
ans = 0
for i, a in enumerate(A):
    x = (a - i) % K
    #print("i", i, "a", a, "x", x, "cnt", cnt)

    ans += cnt[x]
    cnt[x] += 1

    if i >= K-1:
        y = (A[i-K+1] - (i-K+1)) % K
        cnt[y] -= 1

print(ans)


Measured memory_bytes: 47172
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
void fail(){
    cout<<"NO";
    exit(0);
}
int main(){
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (v <= w) fail();
    v = v - w;
    a = abs(a - b);
    if (t * v < a) fail();
    cout << "YES";
    return 0;
}


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

int main()
{
  string num;
  while (cin >> num, num != "0"){
    int res = 0;
    for (int i = 0; i < num.size(); i++){
      res += (num[i] - '0');
    }
    
    cout << res << endl;
  }
}

Measured memory_bytes: 1188
N, K= map(int, input().split())
S = input()
str_list = list(S)
if str_list[K-1] == "A":
    str_list[K-1] = "a"
if str_list[K-1] == "B":
    str_list[K-1] = "b"
if str_list[K-1] == "C":
    str_list[K-1] = "c"
ans = "".join(str_list)
print(ans)

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define repN_1(i, n) for(int i = 0; i < (int)(n - 1); i++)
#define repM(i, n) for(int i = (int)(n - 1); i >= 0; i--)
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; }

unsigned long long int gcd(unsigned long long int a, unsigned long long int b)
{
	if (b == 0)
		return a;

	return gcd(b, a % b);
}

int main()
{
	ll k, tmp;
	ll ans = 0;
	

	cin >> k;

	rep1(i, k)
	{
		rep1(j, k)
		{
			tmp = gcd(i, j);
			rep1(l, k)
			{
				ans += gcd(tmp, l);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

set<string> st;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    int n;
    cin >> n;
    while (n--) {
        string cmd;
        cin >> cmd;
        if (cmd.front() == 'i') {
            string s;
            cin >> s;
            st.insert(s);
        } else {
            string s;
            cin >> s;
            cout << (st.count(s) ? "yes" : "no") << endl;
        }
    }
}


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

template<typename T>
struct Kruskal{
    struct edge{
        int from,to,used; T cost;
        edge(int from,int to,T cost):
            from(from),to(to),cost(cost),used(0){}
        bool operator<(const edge &e) const{
            if (cost!=e.cost) return cost<e.cost;
            else if (from!=e.from) return from<e.from;
            else return to<e.to;
        }
    };
    int num;
    vector<int> par,rank;
    vector<edge> es;
    Kruskal(int n):num(n),par(n),rank(n,1){
        iota(par.begin(),par.end(),0);
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    bool merge(int x, int y){
        x=root(x),y=root(y);
        if (x==y) return false;
        if (rank[x]<rank[y]) swap(x,y);
        par[y]=x;
        rank[x]+=rank[y];
        --num;
        return true;
    }
    bool same(int x, int y){return root(x)==root(y);}
    int size(int x){return rank[root(x)];}
    int count(){return num;}
    void add_edge(int u,int v,T c){
        es.emplace_back(u,v,c);
    }
    T build(){
        sort(es.begin(),es.end());
        T res=0;
        for (auto &e:es){
            if (!same(e.from,e.to)){
                res+=e.cost;
                merge(e.from,e.to);
                e.used=1;
            }
        }
        return res;
    }
    vector<int> used_es(T &c){
        int E=es.size();
        map<edge,int> m;
        for (int i=0;i<E;++i) m[es[i]]=i;
        c=build();
        vector<int> list(E);
        for (int i=0;i<E;++i) list[m[es[i]]]=es[i].used;
        return list;
    }
};

// https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_12_A

void ALDS1_12_A(){
    int n; cin >> n;
    Kruskal<int> K(n);
    vector<vector<int>> a(n,vector<int>(n));
    for (int i=0;i<n;++i){
        for (int j=0;j<n;++j){
            cin >> a[i][j];
            if (j>i&&~a[i][j]) K.add_edge(i,j,a[i][j]);
        }
    }
    cout << K.build() << '\n';
}

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


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge {
  ll to, cost;
};

int main() {
  int H, W; cin >> H >> W;
  int M; cin >> M;
  vector<int> h(M), w(M);
  REP(i, M) {
    cin >> h[i] >> w[i];
    h[i]--; w[i]--;
  }
  vector<ll> x(H, 0), y(W, 0);
  REP(i, M) {
    x[h[i]]++; y[w[i]]++;
  }
  ll ans = 0;
  ll max_x = *max_element(all(x));
  ll max_y = *max_element(all(y));
  vector<ll> p, q;
  REP(i, H) if(x[i] == max_x) p.push_back(i);
  REP(i, W) if(y[i] == max_y) q.push_back(i);
  ans = max_x + max_y;
  bool flag = false; ll cnt = 0;
  REP(i, M) {
    if(binary_search(all(p), h[i]) && binary_search(all(q), w[i])) {
      cnt++;
    }
  }
  if(p.size() * q.size() == cnt) cout << ans - 1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 18684
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    mod = 10**10+7
    mod2 = 10**10+9
    mod3 = 998244353
    N, L = map(int, input().split())
    dic = defaultdict(int)
    dic2 = defaultdict(int)
    dic3 = defaultdict(int)
    h_list = []
    h2_list = []
    h3_list = []
    pair = {}
    pair2 = {}
    pair3 = {}
    M = 0
    for _ in range(N):
        s = input().rstrip('\n')
        h = 0
        h2 = 0
        h3 = 0
        for i in range(len(s)):
            M += 1
            h = (h*1007 + int(s[i]) + 1) % mod
            pair[h] = (h + 1)%mod if s[i] == '0' else (h-1)%mod
            h2 = (h2 * 2009 + int(s[i]) + 1) % mod2
            pair2[h2] = (h2 + 1)%mod2 if s[i] == '0' else (h2-1)%mod2
            h3 = (h3 * 3001 + int(s[i]) + 1) % mod3
            pair3[h3] = (h3 + 1) % mod3 if s[i] == '0' else (h3 - 1) % mod3
            dic[h] = i+1
            dic2[h2] = i+1
            dic[h3] = i+1
            h_list.append(h)
            h2_list.append(h2)
            h3_list.append(h3)

    g = 0
    seen = defaultdict(int)
    seen2 = defaultdict(int)
    seen3 = defaultdict(int)
    for i in range(M):
        s, s2, s3 = h_list[i], h2_list[i], h3_list[i]
        if seen[s] and seen2[s2] and seen3[s3]:
            continue
        t = pair[s]
        t2 = pair2[s2]
        t3 = pair3[s3]
        if dic[t] == 0 or dic2[t2] == 0 or dic3[t3] == 0:
            p = [dic[s], dic2[s2], dic3[s3]]
            p.sort()
            tmp = L - p[1] + 1
            '''
            if not seen[s]:
                tmp = L - dic[s] + 1
            elif not seen[s2]:
                tmp = L - dic2[s2] + 1
            else:
                tmp = L - dic3[s3] + 1
            '''
            cnt = 0
            while tmp % 2 == 0:
                tmp //= 2
                cnt += 1
            g ^= (2**cnt)
            #print(g, s, s2, t, t2, dic[t], dic2[t2])
        seen[s] = 1
        seen2[s2] = 1
        seen3[s3] = 1

    if g:
        print('Alice')
    else:
        print('Bob')


if __name__ == '__main__':
    main()


Measured memory_bytes: 135008
def doit(a,b)
	1.upto(1251) do |n|
		n8 = (n*0.08).to_i
		n10 = (n*0.1).to_i
		if n8==a && n10==b then
			return n
		end
	end
	return -1
end

a, b= gets.chomp.split(" ").map{|e|e.to_i}


print(doit(a,b))

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

#define N_MAX 100002

using namespace std;

int n, m;

vector <int> edges[N_MAX];

int indeg[N_MAX];

queue <int> q;

int d[N_MAX];

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        indeg[v]++;
        edges[u].push_back(v);
    }
    for(int i = 1; i <= n; i++)
        if(indeg[i] == 0)
        {
            d[i] = 0;
            q.push(i);
        }
    int ans = 0;
    while(!q.empty())
    {
        int f = q.front();
        q.pop();
        for(int u : edges[f])
        {
            indeg[u]--;
            if(indeg[u] == 0)
            {
                d[u] = d[f] + 1;
                ans = max(ans, d[u]);
                q.push(u);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6528
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 330;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;

#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL DP[101][SIZE];
bool finished[101][SIZE];
LL DP2[SIZE2][SIZE2];
LL DP3[SIZE3][SIZE3][SIZE3];
LL A[SIZE][3];
LL WW[SIZE];
LL VV[SIZE];
LL solve2(LL n,LL v) {
	if (v <= 0) return 0;
	if (n==0 and v>0) return INF;
	if (finished[n][v]) return DP[n][v];
	if (n== 0) return 0;
	finished[n][v] = true;
	DP[n][v] = min(solve2(n-1,v),solve2(n-1,v-VV[n])+WW[n]);
	return DP[n][v];
}
LL solve() {
	cin >> N >> W;
	EFOR(i, 1,N) {
		cin >> WW[i] >> VV[i];
	}
	LL ans = 0;
	EFOR(i, 1, 5+1e5)
		if (solve2(N, i) <= W) ans = i;
	cout << ans<<endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(12);
	solve();
	cin >> N;
	return 0;

}

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

int main() {
  string foo; cin >> foo;
  
  string ans = "No";
  if(foo.at(2) == foo.at(3) && foo.at(4) == foo.at(5)) {
    ans = "Yes";
  }
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
using namespace std;
int n,s,a[100001];
int main(){
	cin>>n>>s;int R=0,p=0,minx=1000000;
	for(int i=0;i<n;i++)cin>>a[i];a[n]=1000000007;
	for(int i=0;i<n;i++){
		while(p<s && R<n){p+=a[R];R++;}
		if(p>=s)minx=min(minx,R-i);p-=a[i];
	}
	if(minx==1000000)minx=0;
	cout<<minx<<endl;
}

Measured memory_bytes: 3464
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a=round(sqrt(N));
  int ans;
  for(int i=a-1;i<=a+1;i++){
    if(i*i <= N) ans = i*i;
  }
  cout << ans << endl;
}


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


int main() {
  long long n;
  cin >> n;
  string s;
  set<string> a;
  for(int i=0;i<n;i++){
    cin >> s;
    a.insert(s);
  }
  
  cout << a.size() << endl;
    
  return 0;
}

Measured memory_bytes: 19216