akhauriyash/Code-Regression huggingface dataset:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()

    is_ok = False
    for i in range(len(S)):
        if S[i] == 'A' and S[i+1] == 'C':
            is_ok = True
            break

    if is_ok:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9984
#include<stdio.h>
#define N 100005
  
struct Node{int p,l,r;};
struct Node T[N];
   
void inorder(int);
void preorder(int);
void postorder(int);
   
int main(int argc,char *argv[]){
  int i,v,n;    
    scanf("%d",&n);
    for(i = 0;i < n;i++){
      T[i].p = T[i].l = T[i].r = -1;
    }
    for(i = 0;i < n;i++){
      scanf("%d",&v);
      scanf("%d %d",&T[v].l,&T[v].r);   
      T[T[v].l].p = v;
      T[T[v].r].p = v;
    }
	
    printf("Preorder\n");
     for(i = 0;i < n;i++){
     if(T[i].p == -1)
    preorder(i);
    }
    printf("\nInorder\n");
    for(i = 0;i < n;i++){
      if(T[i].p == -1)
    inorder(i);
    }
    printf("\nPostorder\n");
    for(i = 0;i < n;i++){ 
      if(T[i].p == -1)
    postorder(i);
    }
    printf("\n");
      
    return 0;  
}
  
void inorder(int u){
  if(u != -1){
    inorder(T[u].l);
    printf(" %d",u);   
    inorder(T[u].r); 
  }
}
void preorder(int u){
  if(u != -1){
    printf(" %d",u);  
    preorder(T[u].l);
    preorder(T[u].r);
  }
}
  
void postorder(int u){
  if(u != -1){
    postorder(T[u].l);
    postorder(T[u].r);
    printf(" %d",u);
  }
}



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

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

  int64_t Y = 0;
  int64_t M = 100;
  for(;;){
    M = (int64_t)M*1.01;
    Y++;
    if(M >= X) break;
  }

  cout << Y << endl;
  return 0;
}

Measured memory_bytes: 3632
/*
      author : nishi5451
      created: 11.08.2020 22:00:58
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    if(a>=13) cout << b << endl;
    else if(a<=5) cout << 0 << endl;
    else cout << b/2 << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000;
struct edge {int to, label;};
//隣接リスト
vector<edge> G[50];

bool dfs(int v, int p, int target, ll &path) {
  if (v == target) {
    return true;
  }
  for (int i; i < G[v].size(); i++) {
    edge e = G[v][i];
    if (e.to == p) continue;
    if (dfs(e.to, v, target, path)) {
      path |= (1LL << e.label);
      return true;
    }
  }
  return false;
}

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N-1; i++) {
    int a, b;
    cin >> a >> b; a--; b--;
    G[a].push_back({b, i});
    G[b].push_back({a, i});
  }
  
  //path[i] はi番目のpathに含まれる辺たちを記録
  int M;
  cin >> M;
  
  ll path[M];
  for (int i = 0; i < M; i++) {
    path[i] = 0;
  }
  
  for (int i = 0; i < M; i++) {
    int u, v; cin >> u >> v; u--; v--;
    dfs(u, -1, v, path[i]);
  }
  
  //共通部分はor演算で求まる
  ll bits;
  ll ans = 0;
  
  for (bits = 0; bits < (1LL << M); bits++) {
    ll val = 0;
    for (int i = 0; i < M; i++) {
      if (bits & (1LL << i)) {val |= path[i];}
    }
    int c = __builtin_popcountll(val);
    int b = __builtin_popcountll(bits);
    if (b % 2 == 1) { ans -= 1LL<<(N-1-c); }
    else { ans += 1LL<<(N-1-c); }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()

    max_len = 41
    popcount = [0] * max_len

    for ai in a:
        cnt = 0
        while ai > 0:
            if ai & 1:
                popcount[cnt] += 1
            ai >>= 1
            cnt += 1
    popcount.reverse()

    dp1 = [0 for _ in range(max_len + 1)]
    dp2 = [-1 for _ in range(max_len + 1)]

    for i in range(max_len):
        tmp = pow(2, max_len - 1 - i)
        ki = k >> (max_len - 1 - i) & 1

        one = popcount[i]
        zero = n - popcount[i]

        if ki:
            dp1[i + 1] = dp1[i] + zero * tmp
            dp2[i + 1] = dp1[i] + one * tmp
            if dp2[i] != -1:
                dp2[i+1] = max(dp2[i+1], dp2[i] + zero * tmp, dp2[i] + one * tmp)

        else:
            dp1[i + 1] = dp1[i] + one * tmp
            if dp2[i] != -1:
                dp2[i + 1] = max(dp2[i] + zero * tmp, dp2[i] + one * tmp)

    print(max(dp1[max_len], dp2[max_len]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 21012
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    if(a == 0 && b == 0){
        cout << 0 << endl;
        return 0;
    }
    long long set = n / (a + b);
    long long w = n % (a + b);
    if(w > a) w = a;

    cout << (set * a) + w << endl;
    return 0;
}


Measured memory_bytes: 256
H,W=map(int,raw_input().split())
A=[ map(int,raw_input().split()) for i in range(H) ] 

S=[]

for y in range(H-1):
	for x in range(W):
		if A[y][x]%2==1:
			A[y][x]-=1
			A[y+1][x]+=1
			S.append( (y+1,x+1,y+1+1,x+1) )

y=H-1
for x in range(W-1):
	if A[y][x]%2==1:
		A[y][x]-=1
		A[y][x+1]+=1
		S.append( ( y+1,x+1,y+1,x+1+1 ) )


print len(S)
for y1,x1,y2,x2 in S:
	print y1,x1,y2,x2



Measured memory_bytes: 58780
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;int n=s.size();
  for(int i=0;i<26;i++){
    int a=0;
    for(int j=0;j<n;j++){
      if(s.at(j)=='a'+i){
        a++;
        break;
      }
    }
    if(a==0){
      char A='a'+i;
      cout<<A<<endl;
      break;
    }
    else if(i==25)cout<<"None"<<endl;
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[12] = {2, 2, 2, 1, 0, -1, -2, -2, -2, -1, 0, 1};
int dy[12] = {1, 0, -1, -2, -2, -2, -1, 0, 1, 2, 2, 2};
int main(void){
	int px, py, N;
	while(cin >> px >> py && (px||py)){
		int pyon = (10*py+px);
		cin >> N;
		int spr[11];
		rep(i, N){
			int a, b;
			cin >> a >> b;
			spr[i] = (10*b)+a;
		}
		if(N == 0){
			FIN("NA");
			continue;
		}
		bool flag = false;
		queue<P> que;
		que.push(P(pyon, 0));
		while(!que.empty()){
			P p = que.front();
			que.pop();
			int x = p.first%10;
			int y = p.first/10;
			int spX = spr[p.second]%10;
			int spY = spr[p.second]/10;
			if(p.second == N){
				flag = true;
				break;
			}
			rep(i, 12){
				int nx = x+dx[i];
				int ny = y+dy[i];
				if(nx >= 0 && nx < 10 && ny >= 0 && ny < 10){
					if( abs(spX-nx) <= 1 && abs(spY-ny) <= 1){
						que.push(P(((10*ny)+nx), p.second+1));
					}
				}
			}
		}
		cout << (flag?"OK":"NA") << endl;
	}
	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
template<class T> inline void read(T &x){
	x=0;register char c=getchar();register bool f=0;
	while(!isdigit(c))f^=c=='-',c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar();if(f)x=-x;
}
const int N=1e3+10,M=2e5+10;
int n,m,f[N],g[N],id[N][N];
bool ans[M],vis[N][N];
std::vector<int> G[N];
void dfs(int u,bool *vis){vis[u]=1;for(int v:G[u])if(!vis[v])dfs(v,vis);}
void search(int u,int *f){for(int v:G[u])if(!f[v])f[v]=f[u],search(v,f);}
int main(){
#ifdef memset0
	freopen("1.in","r",stdin);
#endif
	read(n),read(m);
	for(int u,v,i=1;i<=m;i++)read(u),read(v),G[u].push_back(v),id[u][v]=i;
	for(int i=1;i<=n;i++)dfs(i,vis[i]);
	for(int u=1;u<=n;u++){
		for(int i=1;i<=n;i++)f[i]=g[i]=0; f[u]=g[u]=-1;
		for(int v:G[u])if(!f[v])f[v]=v,search(v,f); std::reverse(G[u].begin(),G[u].end());
		for(int v:G[u])if(!g[v])g[v]=v,search(v,g); std::reverse(G[u].begin(),G[u].end());
		for(int v:G[u])if(vis[v][u]^(f[v]!=v||g[v]!=v))ans[id[u][v]]=true;
	}
	for(int i=1;i<=m;i++)puts(ans[i]?"diff":"same");
}

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


int main() {
  int a , b , c ;
  cin >> a >> b >> c ;
  
  if(a<b&&b<c){
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3096
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	H, W := sc.nextInt(), sc.nextInt()
	S := make([][]rune, H)
	for i := 0; i < H; i++ {
		S[i] = sc.nextRuneSlice()
	}
	Yoko := make([][]int, H)
	Tate := make([][]int, H)
	for i := 0; i < H; i++ {
		Yoko[i] = make([]int, W)
		Tate[i] = make([]int, W)
	}
	for i := 0; i < H; i++ {
		l := 0
		r := 0
		for j := 0; j < W; j++ {
			if S[i][j] == '#' {
				l = j + 1
				r++
				continue
			}
			for r < W && S[i][r] != '#' {
				r++
			}
			Yoko[i][j] = r - l
		}
	}
	for i := 0; i < W; i++ {
		u := 0
		d := 0
		for j := 0; j < H; j++ {
			if S[j][i] == '#' {
				u = j + 1
				d++
				continue
			}
			for d < H && S[d][i] != '#' {
				d++
			}
			Tate[j][i] = d - u
		}
	}
	ans := 0
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if Yoko[i][j]+Tate[i][j]-1 > ans {
				ans = Yoko[i][j] + Tate[i][j] - 1
			}
		}
	}

	//fmt.Fprintln(wtr, Yoko)
	//fmt.Fprintln(wtr, Tate)
	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 85888
#include <bits/stdc++.h>
using namespace std;
int a,b,c,i;
int main()
{
    cin>>a>>b>>c;
    for(i=1;i<=b;i++)
    {
    	if((a*i)%b==c)
    	{
    		cout<<"YES"<<endl;
    		return 0;
    	}
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("\\s");
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(b > c){
			int x = b;
			b = c;
			c = x;
		}
		if(a > b){
			int x = a;
			a = b;
			b = x;
		}
		if(b > c){
		    int x = b;
			b = c;
			c = x;
		}
		System.out.println(a + " " + b + " " + c);
	}

}

Measured memory_bytes: 26244
n = gets.to_i
h = gets.chomp.split(" ").map(&:to_i)

dp = []
dp[0] = 0
dp[1] = (h[1] - h[0]).abs

for i in 2.. n - 1
    step1 = dp[i - 1] + (h[i] - h[i - 1]).abs
    step2 = dp[i - 2] + (h[i] - h[i - 2]).abs
    
    if step1 < step2
        dp << step1
    else
        dp << step2
    end
end

puts dp[n - 1]

Measured memory_bytes: 11392
n = input()
if n[-1] == "3":
    print("bon")
elif n[-1] == "0":
    print("pon")
elif n[-1]== "1":
    print("pon")
elif n[-1]=="6":
    print("pon")
elif n[-1]=="8":
    print("pon")
else:
    print("hon")

Measured memory_bytes: 8988
#include<bits/stdc++.h>
using namespace std;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define MOD 1000000007
#define endl "\n"
#define deb(n) cout<<"[ "#n<<" = "<<n<<" ]"<<endl;
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const long long  MAX = 1 << 18;
int case_no=1;
#define w(x) int x; cin>>x; while(x--)

int main() {
	FIO
	int x; cin >> x;
	for(int i = 1; i <= 360; i++) {
		if((x * i) % 360 == 0) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
template<class T>void sort(vector<T> &v){sort(v.begin(),v.end());}

int main(){
	int n,m;cin>>n>>m;
	vector<int> p(m);
	vector<string> s(m);
	for(int i=0;i<m;i++)cin>>p[i]>>s[i];

	for(int i=0;i<m;i++)p[i]--;
	vector<int> pen(n);
	set<int> done;

	for(int i=0;i<m;i++){
		if(s[i]=="WA" && done.count(p[i])==0)pen[p[i]]++;
		if(s[i]=="AC")done.insert(p[i]);
	}

	set<int> sac;
	for(int i=0;i<m;i++)if(s[i]=="AC")sac.insert(p[i]);
	vector<int> ac;
	for(auto itr=sac.begin(); itr!=sac.end();itr++)ac.push_back(*itr);
	
	int ans=0;
	for(auto i:ac)ans+=pen[i];

	cout<<ac.size()<<" "<<ans<<endl;
	return 0;
}

Measured memory_bytes: 16508
# list の append だけで実装する

S = input()
Q = int(input())

T = 0
l = []
r = []
for _ in range(Q):
    Query = list(input().split())
    if len(Query) == 1:
        T ^= 1
    elif T == 0:
        s = Query[2]
        if Query[1] == '1':
            l.append(s)
        else:
            r.append(s)
    else:
        s = Query[2]
        if Query[1] == '1':
            r.append(s)
        else:
            l.append(s)

if T == 1:
    r.reverse()
    ans = ''.join(r) + S[::-1] + ''.join(l)
else:
    l.reverse()
    ans = ''.join(l) + S + ''.join(r)

print(ans)


Measured memory_bytes: 5740
n, y = map(int, input().split())

ans = ''

for i in range(n + 1):
    for j in range(n - i + 1):
        for k in range(n - i - j, n - i - j + 1):
            if y == 10000 * i + 5000 * j + 1000 * k:
                ans = '{} {} {}'.format(i, j, k)

if ans == '':
    print('-1 -1 -1')
else:
    print(ans)

Measured memory_bytes: 3060
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]

N,L = map(int,input().split())
if L >= 0:
    print((N-1)*(2*L+N)//2)
elif L > 1-N:
    print(N*(2*L+N-1)//2)
else:
    print((N-1)*(2*L+N-2)//2)

Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 1000;
constexpr LL mod = 1000000007;
char s[maxn + 1][maxn + 2];
LL power(LL a, LL r){
    LL res = 1;
    for(; r; r >>= 1, a = a * a % mod)
        if(r & 1) res = res * a % mod;
    return res;
}
struct mat{
    LL a, b, c, d;
    mat operator * (const mat& other)const{
        return{(a * other.a + b * other.c) % mod, (a * other.b + b * other.d) % mod,
               (c * other.a + d * other.c) % mod, (c * other.b + d * other.d) % mod};
    }
};
mat power(mat a, LL r){
    mat res = {1, 0, 0, 1};
    for(; r; r >>= 1, a = a * a)
        if(r & 1) res = res * a;
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    int H, W;
    LL K;
    cin >> H >> W >> K;
    for(int i = 1; i <= H; i += 1) cin >> (s[i] + 1);
    LL a = 0, b = 0, c = 0, d = 0, e = 0;
    for(int i = 1; i <= H; i += 1) for(int j = 1; j <= W; j += 1) a += s[i][j] == '#';
    for(int i = 1; i <= H; i += 1) for(int j = 1; j < W; j += 1) b += (s[i][j] == '#' and s[i][j + 1] == '#');
    for(int i = 1; i <= H; i += 1) c += (s[i][1] == '#' and s[i][W] == '#');
    for(int i = 1; i < H; i += 1) for(int j = 1; j <= W; j += 1) d += (s[i][j] == '#' and s[i + 1][j] == '#');
    for(int i = 1; i <= W; i += 1) e += (s[1][i] == '#' and s[H][i] == '#');
    if(c and e) cout << 1;
    else if(not c and not e) cout << power(a, K - 1);
    else{
        mat m = c ? power({a, mod - b, 0, c}, K - 1) : power({a, mod - d, 0, e}, K - 1);
        cout << (m.a + m.b) % mod;
    }
    return 0;
}

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

#define int long long int
#define fi first
#define so second
#define pii pair<int,int>
#define ps push_back
#define TT int tt;cin>>tt;for(int cc=1;cc<=tt;cc++)

signed main()
{
    int n;
    cin>>n;
    int k = 1000-(n%1000);
if(k==1000) k=0;
cout<<k;
}


Measured memory_bytes: 3632
N = int(input())
A = [int(i) for i in input().split()]
count = 0
COUNT = 0
while 1:
  for i in range(N):
    if A[i]%2==0:
      A[i]/=2
      count+=1
  if count == N:
    COUNT+=1
    count=0
  else:
    break
print(COUNT)

Measured memory_bytes: 3060
import sys

def solve():
    input = sys.stdin.readline
    N, T = map(int, input().split())
    food = [[int(i) for i in input().split()] for _ in range(N)]
    food.sort()
    DP = [[0 for _ in range(T)] for i in range(N + 1)]
    for i in range(N):
        a, b = food[i]
        for t in range(T):
            DP[i+1][t] = max(DP[i][t], DP[i+1][t])
            if t+a < T: DP[i+1][t+a] = max(DP[i+1][t+a], DP[i][t] + b)
    max_dish = 0
    for i in range(N):
        max_dish = max(max_dish, max(DP[i]) + food[i][1])
    print(max_dish)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 120924
# https://atcoder.jp/contests/abc130/tasks/abc130_e
"""
タグ: LCS、二次元累積和
"""
import sys
input = sys.stdin.readline
MOD = 10**9 + 7

N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
dp = [[0]*(M+1) for _ in range(N+1)]
cum = [[0] * (M + 1) for _ in range(N + 1)]
for i in range(N):
    for j in range(M):
        if S[i]==T[j]:
            dp[i][j] += cum[i][j] + 1
            dp[i][j]%=MOD
        cum[i + 1][j + 1] = cum[i][j + 1] + cum[i + 1][j] - cum[i][j] + dp[i][j]
        cum[i + 1][j + 1]%=MOD
print(cum[N][M]+1)

Measured memory_bytes: 134596
using System;
using System.IO;

namespace Integral
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            while (true)
            {
                var str = Console.ReadLine();
                if (string.IsNullOrEmpty(str))
                {
                    break;
                }
                var input = int.Parse(str);
                int sum = 0;
                for (int i = input; i < 600; i += input)
                {
                    sum += (int)Math.Pow(i, 2) * input;
                }
                Console.WriteLine(sum);
            }
            Console.Out.Flush();

        }
    }
}



Measured memory_bytes: 15884
import math

def combinations_count(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n=int(input())
a=list(map(int,input().split()))
cnt={}
comb={}
ans=0
for i in a:
    if i in cnt:
        cnt[i]+=1
    else:
        cnt[i]=1
        
for i in cnt.values():
    if i<2:
        continue
    if not i in comb:
        comb[i]=combinations_count(i,2)
    ans+=comb[i]

for i in range(n):
    pans=ans
    if cnt[a[i]] in comb:
        pans-=comb[cnt[a[i]]]
    c=cnt[a[i]]-1
    if c>1:
        if not c in comb:
            comb[c]=combinations_count(c,2)
        pans+=comb[c]
    print(pans)


Measured memory_bytes: 25644
# tokenakatta ...
def main():
    N, M, V, P = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    l = 0
    r = N - P + 1
    while l != r:
        k = (l + r)//2
        m = P * M + k * M
        t = A[k] + M
        if t < A[N - P]:
            l = k + 1
            continue
        for i in range(k+1, N-P+1):
            m += t - A[i]
        if m < M * V:
            l = k + 1
        else:
            r = k
    return N - r
print(main())


Measured memory_bytes: 14396
# include <stdio.h>

int main(void){
    // Here your code !
    int a, b;
    scanf("%d%d", &a, &b);
    if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) printf("Possible");
    else printf("Impossible");
    return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

bool check(ll x, set<ll> &s) { // x以上が作れるかどうか
  bool ret = false;
  for (auto it: s) {
    if (Find(s, x - it)) {
      ret = true;
      break;
    }
  }

  return ret;
};

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

  int n;
  int m;
  while (cin >> n >> m, n) {
    set<int> s;
    vector<int> P(n+1, 0);
    rep(i, 1, n+1) {
      cin >> P[i];
    }

    sort(All(P));

    rep(i, 0, n+1) {
      rep(j, i, n+1) {
        s.insert(P[i]+P[j]);
      }
    }

    vector<int> possible; // 二本の矢での取り得る点数
    for (auto it: s) {
      possible.pb(it);
    }
    sort(All(possible)); // (N^2long(N^2))

    int ans = 0;

    rep(i, 0, n+1) {
      int a = P[i];
      rep(j, i, n+1) {
        int b = P[j];
        int ab = a+b;
        if (ab > m) break;

        int ng = possible.size();
        int ok = 0;
        while (abs(ng - ok) > 1) {
          ll mid = (ok + ng) / 2;
          if (possible[mid] <= (m - ab)) {
            ok = mid;
          } else {
            ng = mid;
          }
        }

        ans = max(ans, possible[ok] + ab);
      }
    }

    cout << ans << endl;
  }


  return 0;
};



Measured memory_bytes: 30036
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,k;
	cin>>n>>k;
	if(n<k)
	{
		cout<<min(n,abs(n-k))<<endl;
	}
	else
	{
		if(n%k==0)
		{
			cout<<0<<endl;
		}
		else
		{
			cout<<(((n/k)+1)*k)-n<<endl;
		}
	}
	
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    long long ret = 0;
    map<int, int> mp;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        ret += mp[i - a];
        mp[i + a]++;
    }

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 20724
#include<stdio.h>
#include<map>
using namespace std;
map<int,bool> m;
int main(){
	int N;int no;int ans=0;
	scanf("%d",&N);
	while(N--){
		scanf("%d",&no);
		if(m.find(no)==m.end()){
			m[no]=true;
			ans++;
		}
		else if(m[no]==false){
			m[no]=true;
			ans++;
		}
		else{
			m[no]=false;
			ans--;
		}
	}
	printf("%d\n",ans);
	return  0;
}

Measured memory_bytes: 4864
from fractions import gcd
A,B,C,D,E,F = map(int,input().split())
# d = b/(a+b)を最大化したい
# 条件1: 100*b <= a*E
# 条件2: a + b <= F
# 条件3: a % (100*gcd(A,B)) == 0
# 条件4: b % gcd(C,D) == 0
# (100A)i + (100B)j = a となる非負整数i,jが存在する => 条件3
# (C)k + (D)l = b となる非負整数k,lが存在する => 条件4
# d <= d'  <=>  b/(a+b) <= b'/(a'+b')  <=>  (a'+b')b <= (a+b)b'
a_d = 100*gcd(A,B); b_d = gcd(C,D)
ans_a = 100*A; ans_b = 0
candidate = []
# 必要条件で絞り込み
for a in range(a_d,F+1,a_d):
    b_sup = F - a
    for b in range(b_d,b_sup+1,b_d):
        if not(100*b <= a*E and a % a_d == 0 and b % b_d == 0):
            continue
        candidate.append([a,b])
# 十分性の確認
for a, b in candidate:
    cnt = 0
    nA = (100*A) // a_d; nB = (100*B) // a_d; na = a // a_d
    # nAi + nBj = a を満たす非負整数i,jの存在を判定
    # nAi <= na  <=>  i <= na / nA
    for i in range(-(-na // nA)+1):
        # j = (a-Ai) / B, jは整数
        if (na-nA*i) % nB == 0:
            cnt += 1
            break
    nC = C // b_d; nD = D // b_d; nb = b // b_d
    # nCk + nDl = nb を満たす非負整数k,lの存在を判定
    # nCk <= nb  <=>  k <= nb / nC
    for k in range(-(-nb//nC)+1):
        # l = (nb-nCk) / nD, lは整数
        if (nb-nC*k) % nD == 0:
            cnt += 1
            break
    if cnt == 2 and (a+b)*ans_b <= (ans_a+ans_b)*b:
        ans_a = a; ans_b = b
print(ans_a+ans_b,ans_b)

Measured memory_bytes: 6908
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for ai in a:
  if ai in d:
    d[ai] += 1
  else:
    d[ai] = 1
l = [d[key] for key in d]
l.sort(reverse = True)
if len(l) < k:
  print(0)
else:
  print(n - sum(l[:k]))


Measured memory_bytes: 32184
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;
int N, K;
int h[MAX_N];
int dp[MAX_N];

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

  cin >> N >> K;
  rep(i, N) cin >> h[i];

  fill(dp, dp+N, INFINT);
  dp[0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 1; j <= K; ++j) {
      if (i+j < N) {
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
      }
    }
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin>>n>>m;
	vector<ar<ll,3> >v;
	for(ll i=0,j,k,c; i<m; i++)
	{
		cin>>j>>k>>c, --j,--k;
		c = -c;
		v.push_back({j,k,c});
	}
	ll dist[n];
	fill(dist,dist+n,(ll)(1e18));
	dist[0]=0;
	for(int i = 0; i<n-1; i++)
	{
		for(auto it:v)
			dist[it[1]] = min(dist[it[1]],dist[it[0]]+ it[2]);
	}

	bool vis[n] = {0};
	for(auto it:v)
	{
		if(dist[it[0]]+it[2]<dist[it[1]])
			vis[it[1]] = 1;
		if(vis[it[0]])
			vis[it[1]]=1;
	}
	if(vis[n-1])
		cout<<"inf"<<endl;
	else
		cout<<(-dist[n-1])<<endl;
	return 0;
}

Measured memory_bytes: 384
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, x = map(int, input().split())
    l = list(map(int, input().split()))

    ans = 1
    d = 0
    for li in l:
        if d + li <= x:
            ans += 1
            d += li
        else:
            break
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ret = 0
    sum_list = [None] * n + [0]
    for i in range(n-1, -1, -1):
        sum_list[i] = sum_list[i+1] + a[i]
    for i in range(n):
        ret += a[i] * sum_list[i+1]
        ret %= 1000000007
    print(ret)

if __name__ == "__main__":
    main()


Measured memory_bytes: 31444
#include<stdio.h>
#define H_MAX 250

int A[H_MAX];

int main(){
  int H;
  int i;

  scanf("%d", &H);

  for(i=1; i<H+1; i++){
    scanf("%d", &A[i]);
  }

  for(i=1; i<H+1; i++){
    printf("node %d: key = %d, ", i, A[i]);

    if(i==1){
      printf("left key = %d, right key = %d, \n", A[i*2], A[i*2+1]);
      continue;
    }
    printf("parent key = %d, ", A[i/2]);

    if(i*2 == H)
      printf("left key = %d, ", A[i*2]);

    if(i*2 < H){
      printf("left key = %d, right key = %d, \n", A[i*2], A[i*2+1]);
    }
    else
      printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main(){
  int a,b,c,d;

  cin >> a >> b >> c >> d;
  
  if(a <= c){
    if((c - a) <= d){
      cout << "Yes" << endl;
      return 0;
    } 
  } else {
    if((a - c) <= d){
      cout << "Yes" << endl;
      return 0;
    }
  }

  if(a <= b){
    if((b - a) <= d){
	if((c - b) <= d){
	  cout << "Yes" << endl;
	  return 0;
	}
    }
  } else {
    if((a - b) <= d){
      if((b - c) <= d){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define push push_back
#define mem(a,val) memset(a,val,sizeof(a))
const ll mod=1000000007;
int32_t main()
{
	IOS
	ll i,h,w,j;
	cin>>h>>w;
	char s[1002][1002];
	ll dp[1002][1002]={0};
	for(i=0;i<h;i++)
		cin>>s[i];
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(i==0 and j==0)
			{
				dp[i][j]=1;
				continue;
			}
            if(i==0 and s[i][j]=='.')
            {
                dp[i][j]+=dp[i][j-1]%mod;
             	continue;
            }
            if(j==0 and s[i][j]=='.')
            {
                dp[i][j]+=dp[i-1][j]%mod;
               continue;
            }
			if(s[i][j]=='.')
				dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
		}
	}
	cout<<dp[h-1][w-1]%mod;
}

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

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h,vector<char>(w));
    for(int i=0; i<h; i++) for(int j=0; j<w; j++) cin>>c[i][j];
    int ans=0;
    for(int i=0; i<(1<<h); i++){
        for(int j=0; j<(1<<w); j++){
            int cnt=0;
            for(int k=0; k<h; k++){
                for(int l=0; l<w; l++){
                    if(!(i&(1<<k))&&!(j&(1<<l))&&c[k][l]=='#'){
                        cnt++;
                    }
                }
            }
            if(cnt==k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

typedef pair <int, int> pii;

const int MAXN = 305;
const int MOD = 1000000007;

int N, M;
vector <pii> Q[MAXN];
int dp[MAXN][MAXN][MAXN];

void load() {
  scanf("%d%d", &N, &M);
  while (M--) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    Q[r].push_back(pii(l, x));
  }
}

inline int add(int x, int y) {
  x += y;
  if (x >= MOD)
    x -= MOD;
  return x;
}

int rec(int r, int g, int b) {
  int &ref = dp[r][g][b];
  if (ref != -1)
    return ref;
  ref = 0;
  if (r == g && r)
    return ref;
  if (g == b && g)
    return ref;
  if (b == r && b)
    return ref;
  int pos = max(max(r, g), b);
  for (int i = 0; i < Q[pos].size(); i++)
    if ((r >= Q[pos][i].first) + (g >= Q[pos][i].first) + (b >= Q[pos][i].first) != Q[pos][i].second)
      return ref;
  if (pos == N)
    return ref = 1;
  ref = add(ref, rec(pos + 1, g, b));
  ref = add(ref, rec(r, pos + 1, b));
  ref = add(ref, rec(r, g, pos + 1));
  return ref;
}

int solve() {
  memset(dp, -1, sizeof dp);
  return rec(0, 0, 0);
}

int main() {
  load();
  printf("%d\n", solve());
  return 0;
}

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

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

	int n, t;
	cin >> n;

	double ans = 0;
	while (n--) {
		cin >> t;
		ans += 1.0 / t;
	}

	cout.precision(30);
	cout << 1.0 / ans;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

#define N 100010
vii G(N, vi());

int dfs(int parent, int now) {
	if (parent != -1 && G[now].size() == 1) {
		return 1;
	}
	int res = 0;
	for (int i = 0; i < G[now].size(); i++) {
		if (G[now][i] == parent) {
			continue;
		}
		res += dfs(now, G[now][i]);
	}
	if (res >= 2) {
		cout << "First" << endl;
		exit(0);
	}
	else if (res == 1) {
		return 0;
	}
	else {
		return 1;
	}
}

int main() {
	int n, i, j;
	cin >> n;
	vi a(n - 1), b(n - 1);
	for (i = 0; i < n - 1; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	int res = dfs(-1, 0);
	if (res == 1) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
}

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

typedef long long ll;
using namespace std;

ll nC2(ll n) {
    return n * (n - 1) / 2;
}

ll N, M;
ll A[100000], B[100000];
ll ans[100001];
vector<ll> groupusers[100000];
vector<ll> usergroup;
set<int> emptygroupID;

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }
    for (int i = 0; i < N; i++) {
        emptygroupID.insert(i);
        usergroup.push_back(-1);
    }
    ll u = nC2(N);
    ans[M] = u;
    for (int i = M - 1; i >= 0; i--) {
        if (usergroup[A[i]] == -1 && usergroup[B[i]] == -1) {
            int a = *(emptygroupID.begin());
            emptygroupID.erase(emptygroupID.begin());
            groupusers[a].push_back(A[i]);
            groupusers[a].push_back(B[i]);
            usergroup[A[i]] = usergroup[B[i]] = a;
            ans[i] = ans[i + 1] - 1;
        } else if (usergroup[A[i]] == -1 || usergroup[B[i]] == -1) {
            if (usergroup[B[i]] == -1) {
                swap(A[i], B[i]);
            }
            int a = usergroup[B[i]];
            groupusers[a].push_back(A[i]);
            usergroup[A[i]] = a;
            ans[i] = ans[i + 1] - nC2(groupusers[a].size()) + nC2(groupusers[a].size() - 1);
        } else if (usergroup[A[i]] != usergroup[B[i]]) {
            int a = usergroup[A[i]], b = usergroup[B[i]];
            ans[i] = ans[i + 1] + nC2(groupusers[a].size()) + nC2(groupusers[b].size());
            if (groupusers[a].size() < groupusers[b].size()) {
                swap(A[i], B[i]);
                swap(a, b);
            }
            for (long long f : groupusers[b]) {
                usergroup[f] = a;
            }
            groupusers[a].insert(groupusers[a].end(), groupusers[b].begin(), groupusers[b].end());
            groupusers[b].erase(groupusers[b].begin(), groupusers[b].end());
            emptygroupID.insert(b);
            ans[i] -= nC2(groupusers[a].size());
        } else {
            ans[i] = ans[i + 1];
        }
    }
    for (int i = 1; i <= M; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 19252
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    sc.close();
    
    Set<Integer> set = new HashSet<>();
    set.add(A);
    set.add(B);
    set.add(C);
    System.out.println(set.size() == 2 ? "Yes" : "No");
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int ar[n];
    for(int i = 0; i<n; i++){
        cin >> ar[i];
        ar[i]--;
    }
    int ans = 0;
    for(int i = 0; i+1<n; i++){
        if(ar[i]==i){
            ar[i] ^= ar[i+1];
            ar[i+1] ^= ar[i];
            ar[i] ^= ar[i+1];
            ans++;
        }
    }
    if(ar[n-1]==n-1){
        ans++;
    }
    cout << ans << endl;
    
    return 0;
}

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

int main() {
	int N,A,B;
	cin >> N >> A;
	B = N - 500 * (N / 500);
	if (A >= B) {
		cout << "Yes" << endl;
	}
	else{
      	cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import math

A, B, C = map(int, input().split())

if list(filter(lambda x:not(x % 2), [A, B, C])):
	print(0)
	exit()

tl = [A, B, C]
tm = max(tl)
tl.remove(tm)
t2, t3 = tl

print(t2 * t3)


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

struct edge{
    lli to,cost;
};
vector<vector<edge>> G;
lli dist[100100];
void func(lli now,lli from){
    for(auto e:G[now]){
        if(e.to==from)continue;
        dist[e.to] = dist[now] + e.cost;
        func(e.to,now);
    }
}

void func(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, long long Q, long long K, std::vector<long long> x, std::vector<long long> y){
    G.resize(N);
    REP(i,0,N-1){
        G[a[i]].push_back({b[i],c[i]});
        G[b[i]].push_back({a[i],c[i]});
    }
    dist[K]=0;
    func(K,-1);

    REP(i,0,Q){
        cout<<dist[x[i]]+dist[y[i]]<<endl;
    }
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    std::vector<long long> c(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
        a[i]--,b[i]--;
    }
    long long Q;
    scanf("%lld",&Q);
    long long K;
    scanf("%lld",&K);
    K--;
    std::vector<long long> x(Q);
    std::vector<long long> y(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        x[i]--,y[i]--;
    }
    func(N, std::move(a), std::move(b), std::move(c), Q, K, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 18176
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;

int main() {
	double r, s, l;
	//double pi = 3.14159265358979;

	scanf("%lf", &r);

	s = M_PI * r * r;
	l = 2 * M_PI * r;

	printf("%lf %lf\n", s, l);

	return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef double d;
typedef pair<int, int> pr;
typedef priority_queue<int> p_int_max;
typedef priority_queue<int, vector<int>, greater<int>> p_int_min;

int p[200005];
int n, pi, k;
double s, ans;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> k;
    rep(i, n) cin >> p[i];

    rep(i, k) s += (p[i] + 1) / 2.0;
    ans = s;
    for (int i = k; i < n; i++)
    {
        s += (p[i] + 1) / 2.0;
        s -= (p[i - k] + 1) / 2.0;
        ans = max(s, ans);
    }
    cout << setprecision(20) << fixed << ans << "\n";
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var N = IO.RInt;
            var a = IO.RSInt;
            for (int i = 0; i < N; i++)
            {
                a[i] = a[i] - (i + 1);
            }

            Array.Sort(a);
            long ans = 0;
            //if (N % 2 == 0)
            //{
            //    //var left = a[N / 2 - 1];
            //    var right = a[N / 2];

            //}
            //else
            //{
            var mid = a[N / 2];
            for (int i = 0; i < N; i++)
            {
                ans += Abs(a[i] - mid);
            }
            //}
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int field[120][120];

int main(){
	int t, n;
	while(cin >> t>> n, t+n){
		rep(i, 120)rep(j, 120) field[i][j] = inf;
		for(int i=0; i< n; i++){
			int x, y; cin >> x >> y;
			field[x+60][y+60] = -1;
		}
		int mx, my; cin >> mx >> my;
		mx += 60; my += 60;
		field[mx][my] = 1;
		queue<pair<int, int> > q;
		q.push(make_pair(mx, my));
		while(!q.empty()){
			pair<int, int> p = q.front(); q.pop();
			int x = p.first, y = p.second;
			if(field[x][y]-1 == t) continue;

			int dx[6] = {0, 1, 1, 0, -1, -1};
			int dy[6] = {1, 1, 0, -1, -1, 0};
			for(int i=0; i< 6; i++){
				int nx = dx[i]+x, ny = dy[i]+y;
				if(field[nx][ny] != -1 && field[x][y]+1 < field[nx][ny]){
					field[nx][ny] = field[x][y]+1;
					q.push(make_pair(nx, ny));
				}
			}
		}
		int ret = 0;
		for(int i=0; i< 120; i++)for(int j=0; j< 120; j++) if(0 < field[i][j] && field[i][j] != inf) ret++;
		cout << ret << endl;
	}
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I=ll(A);I<ll(B);++I)

ll n,m,l;
ll a[100][100],b[100][100],c[100][100];
void calc(){
	FOR(i,0,n){
		FOR(j,0,l){
			FOR(k,0,m){
				c[i][j] += a[i][k]*b[k][j];
			}
		}
	}
}
void print(){
	FOR(i,0,n){
		cout << c[i][0];
		FOR(j,1,l){
			cout << " " << c[i][j];
		}
		cout << '\n';
	}
}

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

	cin >> n >> m >> l;
	FOR(i,0,n)FOR(j,0,m)cin>>a[i][j];
	FOR(i,0,m)FOR(j,0,l)cin>>b[i][j];
	calc();
	print();
}


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

namespace AizuOnlineJudge {
    class Program {
        static void Main() {
            Console.ReadLine();
            var work = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int result = int.MaxValue, sum = 0;
            for (var i = 0; i < work.Length; ++i) {
                sum += work[i];
                result = Math.Min(result, sum / (i + 1));
            }

            Console.WriteLine(result);
        }
    }
}



Measured memory_bytes: 18364