akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
	char search[11];
	int n;
	char yubiwa[100][11];
	int i;
	int cnt = 0;
	
	cin >> search;
	cin >> n;
	for( i = 0; i < n; i++ )
		cin >> yubiwa[i];
	
	for( i = 0; i < n; i++ ){
		char tmp[21];
		strcpy(tmp, yubiwa[i]);
		strcat(tmp, yubiwa[i]);	//strcat(yubiwa[i], yubiwa[i])??????????????????!!
		if( strstr(tmp, search) != NULL )
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1184
n=int(input())
d={'AC':0,'RE':0,'WA':0,'TLE':0}
for i in range(n):
    s=input().strip()
    d[s]=d[s]+1
print('AC x '+str(d['AC']))
print('WA x '+str(d['WA']))
print('TLE x '+str(d['TLE']))
print('RE x '+str(d['RE']))

Measured memory_bytes: 9236
#include<stdio.h>
 
int main(void){
   int N,M;
   int n,m;
   int total;
   scanf("%d %d",&N,&M);
   n=N*(N-1)/2;
   m=M*(M-1)/2;
   total=n+m;
   printf("%d",total);
   return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e6 + 5;
const ll LINF = 1e18 + 5;
int dp[N][10];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	string s;
 	cin >> s;
 	memset(dp, 0x3f, sizeof(dp));
 	dp[sz(s)][0] = 0;
 	for(int i=sz(s)-1; i>=0; i--)
 	{
 		for(int j=0; j<=9; j++)
 		{
 			if(dp[i+1][j]==INF) continue;
 			int k = s[i] - '0';
 			dp[i][(j+k)/10] = min(dp[i][(j+k)/10], dp[i+1][j] + (j+k)%10);
 			dp[i][(j+k)/10+1] = min(dp[i][(j+k)/10+1], dp[i+1][j] + 10 - (j+k)%10);
 		}
 	}
 	int ans = INF;
 	for(int i=0; i<=9; i++) ans = min(ans, dp[0][i]+i);
 	cout << ans;
	return 0;
}


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

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

  vector<int> s;
  vector<int> ord(n + 1, -1);
  int c = 1, l = 0;
  int v = 1;
  while (ord[v] == -1) {
    ord[v] = s.size();
    s.push_back(v);
    v = a[v - 1];
  }
  c = s.size() - ord[v];
  l = ord[v];

  if (k < l)
    cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l + k] << endl;
  }

  return 0;
}

Measured memory_bytes: 5884
#include <iostream>
using namespace std;
  
int main() {
  int x, y;
  cin >> y >> x;
  while (x != 0 && y != 0) {
    for(int o = 0; o < y; o++){
        for(int i = 0; i < x; i++){
          if (o % 2 == 0) {
            if (i % 2 == 0) {
              cout << "#";
            } else {
              cout << ".";
            }
          } else {
              if (i % 2 == 1) {
              cout << "#";
            } else {
              cout << ".";
            }
          }
        }
        cout << endl;
    }
    cout << endl;
    cin >> y >> x;
  }
}


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

using namespace std;

int main(void){
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  while(true){
    C -= B;
    if(C <= 0){
      cout << "Yes"; 
      break;
    }
    A -= D;
    if(A <= 0){
      cout << "No";
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 3620
import java.util.*;
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();
        if(A == 5 && B==5 && C ==7 || A==5 && B==7 && C==5 || A==7 && B==5 && C==5){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21716
S = list(input())

b = 0

ans = [0]

for n, i in enumerate(S, 1):
  if (i == 'A' or i == 'G' or i == 'C' or i == 'T'):
    b += 1
  else:
    b = 0
  ans.append(b)
print(max(ans))   

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

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N), y(N);
  REP(i, N) {
    char c;
    cin >> x[i] >> y[i] >> c;
    if (c == 'W') {
      x[i] += K;
    }
    x[i] = x[i]%(2*K);
    y[i] = y[i]%(2*K);
    if (y[i] >= K) {
      x[i] += K;
      y[i] += K;
      x[i] = x[i]%(2*K);
      y[i] = y[i]%(2*K);
    }
  }

  vector<vector<int>> v(2*K+1, vector<int>(K+1, 0));
  REP(i, N) {
    v[x[i]][y[i]]++;
    v[x[i]][min(y[i]+K, K)]--;
    v[min(x[i]+K, 2*K)][y[i]]--;
    v[min(x[i]+K, 2*K)][min(y[i]+K, K)]++;

    if (x[i] <= K-1) {
      if (x[i] != 0 && y[i] != 0) {
        v[0][0]++;
        v[0][y[i]]--;
        v[x[i]][0]--;
        v[x[i]][y[i]]++;
      }
      if (y[i] != 0) {
        v[x[i]+K][0]++;
        v[x[i]+K][y[i]]--;
        v[2*K][0]--;
        v[2*K][y[i]]++;
      }
    } else {
      if (y[i] != 0) {
        v[x[i]-K][0]++;
        v[x[i]-K][y[i]]--;
        v[x[i]][0]--;
        v[x[i]][y[i]]++;
      }
      if (x[i] != K) {
        v[0][y[i]]++;
        v[0][K]--;
        v[x[i]-K][y[i]]--;
        v[x[i]-K][K]++;
      }
    }
  }
  
  FOR(j, 0, K+1) {
    FOR(i, 1, 2*K+1) {
      v[i][j] += v[i-1][j];
    }
  }

  FOR(i, 0, 2*K+1) {
    FOR(j, 1, K+1) {
      v[i][j] += v[i][j-1];
    }
  }
  
  int result = 0;
  REP(i,2*K) {
    REP(j, K) {
      if (result < v[i][j]) {
        result = v[i][j];
      }
    }
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 8960
import math
A, B, H, M = map(int, input().split())

start = 30*H
start -= 5.5*M
if start >=180:
  start = 360-start

syahen = A**2 + B**2 - 2*A*B*math.cos(math.radians(start))
print(math.sqrt(syahen))


Measured memory_bytes: 9376
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int A[3][3],C[3][3];
  REP(h,3)REP(w,3)cin>>A[h][w];
  REP(h,3)REP(w,3)C[h][w]=0;
  int N;
  cin>>N;
  REP(i,N){
    int b;
    cin>>b;
    REP(h,3)REP(w,3)if(b==A[h][w])C[h][w]=1;
  }
  bool ans=false;
  REP(h,3){
    int temp=0;
    REP(w,3)temp+=C[h][w];
    if(temp==3)ans=true;
  }
  REP(w,3){
    int temp=0;
    REP(h,3)temp+=C[h][w];
    if(temp==3)ans=true;
  }
  int temp=0;
  REP(i,3){
    temp+=C[i][i];
  }
  if(temp==3)ans=true;
  temp=0;
  REP(i,3){
    temp+=C[i][2-i];
  }
  if(temp==3)ans=true;
  cout<<(ans?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, int) {
	x, y := scanInt(sc), scanInt(sc)
	return x, y
}

func resolve(x, y int) int {
	ex := 0
	for cur := x; cur <= y; cur <<= 1 {
		ex++
	}
	return ex
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a[100],i,b,sum;
	scanf("%d",&n);
	scanf("%d",&b);
	a[0]=b;	a[1]=b;
	for(i=1;i<n-1;i++)	{
		scanf("%d",&b);
		a[i]=min(a[i],b);
		a[i+1]=b;
	}
	sum=0;
	for(i=0;i<n;i++)	sum+=a[i];
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

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

func nextString() string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

// 1: 0-1
// 2: 0-2
//    0-1-2
// 3: 0-1-2-3
//    0-2-3
//    0-1-3
// 4: 0-1-2-3-4
//    0-1-3-4
//    0-2-3-4
//    0-2-4
//    0-1-2-4

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt() + 1
	m := nextInt()
	a := make([]int, m+1)
	dp := make([]int, n)

	for i := 0; i < m; i++ {
		a[i] = nextInt()
	}
	idx := 0

	for i := range dp {
		if i == 0 {
			dp[i] = 1
			continue
		}
		if i == 1 {
			if a[idx] == i {
				dp[i] = 0
				idx++
			} else {
				dp[i] = 1
			}
			continue
		}
		if a[idx] == i {
			dp[i] = 0
			idx++
		} else {
			dp[i] = (dp[i-1] + dp[i-2]) % 1000000007
		}
	}
	debugf("%v\n", dp)

	_, _ = fmt.Fprintf(writer, "%d", dp[n-1])
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 2816
def main():
    S = input()
    answer = solve(S)
    print(answer)


def solve(S):
    patterns = {
        'SSS': 0,
        'SSR': 1,
        'SRS': 1,
        'SRR': 2,
        'RRR': 3,
        'RRS': 2,
        'RSR': 1,
        'RSS': 1
    }

    return patterns[S]


if __name__ == "__main__":
    main()


Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 998244353
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int isok[114514];
int sum[114514];
map<int,int> ai,bi;
signed main(){
	int n;
	cin>>n;
	vector<int> a,b;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		b.pb(x);
	}
	vector<int> sa,sb;
	sa = a;
	sb = b;
	sort( sa.begin(), sa.end() );
	sort( sb.begin(), sb.end() );
	for(int i=0;i<n;i++){
		ai[ sa[i] ] = i;
	}
	for(int i=n-1;i>=0;i--){
		bi[ sb[i] ] = i;
	}
	for(int i=0;i<n;i++){
		if( sa[i] > sb[i] ){
			cout<<"No"<<endl;
			return 0;
		}
		if( i!=n-1 && sa[i+1] <= sb[i] ){
			isok[i] = 1;
		}
	}
	for(int i=1;i<=n;i++){
		sum[i] = sum[i-1] + isok[i-1];
	}
	for(int i=0;i<n;i++){
		if( a[i] <= b[i] ){
			int aid = ai[ a[i] ];
			int bid = bi[ b[i] ];
			int goodness = sum[bid] - sum[aid];
			if( bid <= aid ){
				cout<<"Yes"<<endl;
				return 0;
			}
			else if( goodness == bid - aid ){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	vector< pair<int,int> > P;
	for(int i=0;i<n;i++){
		P.pb( mp( b[i], a[i] ) );
	}
	sort( P.begin(), P.end() );
	pair<int, int> arrPos[n]; 
    for (int i = 0; i < n; i++) 
    { 
        arrPos[i].first = P[i].second; 
        arrPos[i].second = i; 
    } 
  
    // Sort the array by array element values to 
    // get right position of every element as second 
    // element of pair. 
    sort(arrPos, arrPos + n); 
  
    // To keep track of visited elements. Initialize 
    // all elements as not visited or false. 
    vector<bool> vis(n, false); 
  
    // Initialize result 
    int ans = 0; 
  
    // Traverse array elements 
    for (int i = 0; i < n; i++) 
    { 
        // already swapped and corrected or 
        // already present at correct pos 
        if (vis[i] || arrPos[i].second == i) 
            continue; 
  
        // find out the number of  node in 
        // this cycle and add in ans 
        int cycle_size = 0; 
        int j = i; 
        while (!vis[j]) 
        { 
            vis[j] = 1; 
  
            // move to next node 
            j = arrPos[j].second; 
            cycle_size++; 
        } 
  
        // Update answer by adding current cycle.  
        if (cycle_size > 0) 
        { 
            ans += (cycle_size - 1); 
        } 
    }
	if( ans == n-1 ){
		cout<<"No"<<endl;
		return 0;
	}
	else{
		cout<<"Yes"<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 19824
#!/usr/bin/env python3
# -*- coding: utf-8 -*-



def main():
    N = int(input())
    T = list(map(int, input().split()))

    M = int(input())

    s = sum(T)
    for _ in range(M):
        p, x = map(int, input().split())
        p -= 1 # 0-based
        print(s - T[p] + x)

if __name__ == "__main__": main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

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

int main(void)
{
    ll n;
    cin >> n;
    while(1){
        if(prime(n)){
            cout << n << endl;
            break;
        }else n++;
    }
    return 0;
}

Measured memory_bytes: 3592
//#define CCF
#define OLD

#ifndef CCF
    #pragma comment(linker, "/STACK:102400000,102400000")
    #ifdef OLD
        #pragma GCC diagnostic error "-std=c++14"
    #endif
    #pragma GCC optimize ("O3")
    #pragma GCC -mcmodle=large
#endif

#include <bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
  	string s;
  	cin>>s;
  	set<string> st;
  	for(int i=0;i<s.size();i++){
    	for(int j=1;j<=10;j++){
      		st.insert(s.substr(i,j));
    	}
  	}
  	auto cur=st.begin();
  	int K;
  	cin>>K;
  	--K;
  	while(K--) ++cur;
  	cout<<*cur<<endl;
}

Measured memory_bytes: 3968
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

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

print((B-(B//C+B//D-B//lcm(C,D)))-(A-(A//C+A//D-A//lcm(C,D))))

Measured memory_bytes: 5048
#include<iostream>
#include<algorithm>
#include<cstdio>
	using namespace std;
int main(){

	int a,b;
	cin>>a>>b;
	while(b!=0){
		
		int x=max(a,b);
		int y=min(a,b);
		a=y;b=x%y;
	}
	cout<<a<<endl;


	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/ruby
class TLLI
	def initialize
		@trianies=[nil,[0,0,0]]
	end
	def root_triany
		1
	end
	def allocate_triany
		siz=@trianies.size
		@trianies[siz]=[0,0,0]
		return siz
	end
	def set_a(id,value)
		return if !@trianies[id]
		@trianies[id][0]=value
	end
	def set_b(id,value)
		return if !@trianies[id]
		@trianies[id][1]=value
	end
	def set_c(id,value)
		return if !@trianies[id]
		@trianies[id][2]=value
	end
	def get_a(id)
		return if !@trianies[id]
		@trianies[id][0]
	end
	def get_b(id)
		return if !@trianies[id]
		@trianies[id][1]
	end
	def get_c(id)
		return if !@trianies[id]
		@trianies[id][2]
	end
end

class SETI <TLLI # a=>key, b=>left, c=>right
	def set_entry(key)
		x=root_triany
		y=0
		while x!=0&&!(x==root_triany&&get_a(x)==0) #fixme
			y=x
			if key<get_a(x)
				x=get_b(x)
			else
				x=get_c(x)
			end
		end
		if y==0
			set_a(root_triany,key)
		else
			leaf=allocate_triany
			set_a(leaf,key)
			if key<get_a(y)
				set_b(y,leaf)
			else
				set_c(y,leaf)
			end
		end
	end
	def find_entry(key)
		t=root_triany
		loop{
			return true if key==get_a(t)
			if key<get_a(t)
				t=get_b(t)
				return false if t==0
			else
				t=get_c(t)
				return false if t==0
			end
		}
	end
	def delete_entry(key)
		left=false
		prev=nil
		t=root_triany
		loop{
			break if key==get_a(t)
			prev=t
			if key<get_a(t)
				t=get_b(t)
				left=true
				return false if t==0
			else
				t=get_c(t)
				left=false
				return false if t==0
			end
		}
		if get_b(t)>0&&get_c(t)>0
			children=inorder_internal(get_c(t))+[t]
			set_a(t,get_a(children[0]))

			prev=children[1]
			#left of parent of t
			if prev!=t
				set_b(prev,0)
				left=true
			else
				left=false
			end
			t=children[0]
		end
		if t==root_triany
			if get_b(root_triany)>0
				set_a(root_triany,get_a(get_b(root_triany)))
				set_c(root_triany,get_c(get_b(root_triany)))
				set_b(root_triany,get_b(get_b(root_triany)))
			elsif get_c(root_triany)>0
				set_a(root_triany,get_a(get_c(root_triany)))
				set_b(root_triany,get_b(get_c(root_triany)))
				set_c(root_triany,get_c(get_c(root_triany)))
			end
		else
			raise if !prev
			if get_b(t)+get_c(t)>0
				n=get_b(t)+get_c(t)
				if left
					set_b(prev,n)
				else
					set_c(prev,n)
				end
			else
				if left
					set_b(prev,0)
				else
					set_c(prev,0)
				end
			end
		end
	end
	def inorder_internal(t)
		t==0 ? [] : inorder_internal(get_b(t))+[t]
	end
	def print_preorder(t)
		return if t==0
		Kernel.print " #{get_a(t)}"
		print_preorder(get_b(t))
		print_preorder(get_c(t))
	end
	def print_inorder(t)
		return if t==0
		print_inorder(get_b(t))
		Kernel.print " #{get_a(t)}"
		print_inorder(get_c(t))
	end
	def print_postorder(t)
		return if t==0
		print_postorder(get_b(t))
		print_postorder(get_c(t))
		Kernel.print " #{get_a(t)}"
	end
	def print
		print_inorder(root_triany);puts
		print_preorder(root_triany);puts
	end
end

seti=SETI.new
gets.to_i.times{
	a=gets.split
	if a[0]=='insert'
		seti.set_entry(a[1].to_i)
	elsif a[0]=='find'
		puts seti.find_entry(a[1].to_i) ? :yes : :no
	elsif a[0]=='delete'
		seti.delete_entry(a[1].to_i)
	elsif a[0]=='print'
		seti.print
	end
}

Measured memory_bytes: 53664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
typedef long long ll;
 
int main() {
   int n;
   cin >> n;
   int a[110];
   rep(i,n)
   cin >> a[i];
   
   int ans=INF;
   for(int i=-100;i<=100;i++){
   int sum=0;
   rep(j,n)
   sum+=(a[j]-i)*(a[j]-i);
   ans=min(ans,sum);
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]
    
    def merge(self, a, b):
        if self.issame(a,b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
    
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    
    def getsize(self, x):
        return self.size[self.root(x)]
n,m = map(int,input().split())
uf=UnionFind(n)
ans = n-1
for i in range(m):
    a,b = map(int,input().split())
    a-=1;b-=1
    if uf.issame(a,b):continue
    uf.merge(a,b)
    ans-=1
print(ans)

Measured memory_bytes: 13728
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		ArrayList<Integer> listA = new ArrayList<>();
		ArrayList<Integer> listB = new ArrayList<>();
		int[] city = new int[N];
		for(int i = 0; i < M; i++) {
			listA.add(Integer.parseInt(sc.next()) - 1);
			listB.add(Integer.parseInt(sc.next()) - 1);
		}
		sc.close();

		Arrays.fill(city, 0);
		for(int i = 0; i < M; i++) {
			city[listA.get(i)]++;
			city[listB.get(i)]++;
		}
		for(int i = 0; i < N; i++) {
			System.out.println(city[i]);
		}
	}

}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a,b;
    cin >> a >> b;
    if(a >= 13) cout << b;
    else if(a >= 6) cout << b/2;
    else cout << 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	for(int i = 0; i < n; ++i){ cin >> b[i]; }
	int answer = 0;
	for(int s = 0; s < 30; ++s){
		const int lsb = (1 << s);
		vector<int> aa(n), bb(n);
		for(int i = 0; i < n; ++i){
			aa[i] = a[i] & ((2 << s) - 1);
			bb[i] = b[i] & ((2 << s) - 1);
		}
		sort(aa.begin(), aa.end());
		sort(bb.begin(), bb.end());
		for(const int x : aa){
			const int t = x & (lsb - 1);
			const auto p0 = lower_bound(bb.begin(), bb.end(), lsb - t);
			const auto p1 = lower_bound(bb.begin(), bb.end(), lsb - t + lsb);
			if(x & lsb){
				if(distance(bb.begin(), p0) & 1){ answer ^= lsb; }
				if(distance(p1, bb.end()) & 1){ answer ^= lsb; }
			}else{
				if(distance(p0, p1) & 1){ answer ^= lsb; }
			}
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 3456
import itertools
import math

n = int(input())
town = [tuple(map(int, input().split())) for i in range(n)]
w = [i for i in range(n)]


def length(a, b):
    return math.sqrt(
        (a[0]-b[0])**2 + (a[1]-b[1])**2
    )
# x = (0, 1, 2,)　のtuple


def root(x):
    a = 0
    for i in range(len(x)-1):
        a += length(town[x[i]], town[x[i+1]])
    return a

fs = tuple(itertools.permutations(w))

ans = 0
for f in fs:
    ans += root(f)

ans = ans / math.factorial(n)
print(ans)


Measured memory_bytes: 47340
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Reader.init(System.in);

		int n=Reader.nextInt();
		int k=Reader.nextInt();
		int[] h= new int[n+1];
		for(int i=1; i<=n; i++) {
			h[i]=Reader.nextInt();
		}
		
		int[] dp= new int[n+1];
		dp[1]=0;
		dp[2]= Math.abs(h[2]-h[1]);
		
		
		for(int i=3; i<=n; i++) {
			int mini= Integer.MAX_VALUE;

			for(int j=1; j<=k ; j++) {
				if((i-j)>=1)
			mini= Math.min(dp[i-j]+ Math.abs(h[i]-h[i-j]),
					mini);
			
			}
			dp[i]=mini;
		}
		System.out.println(dp[n]);
}
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {

        	tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    



}


Measured memory_bytes: 44072
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector <int> x(n+1),y(n+1);
	for (int i=0;i<n;i++) cin>>x[i]>>y[i];
	sort (x.rbegin(),x.rend());
	sort (y.begin(),y.end());
	long long ans=0;
	for (int i=0;i<n+1;i++){
		if (x[i]>y[i]){
			ans+=2*(x[i]-y[i]);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
signed main() {
  int n;
  cin >> n;
  double a;
  double ans=0;
  rep(i, n) {
    cin >> a;
    ans += 1.0/a;
  }
  cout << setprecision(20)<< 1.0/ans << endl;

  return 0;
}


Measured memory_bytes: 3784
def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    Neg=[-a for a in A if a<0]
    Pos=[a for a in A if a>=0]
    Neg.sort(); Pos.sort()
    ln,lp=len(Neg),len(Pos)
 
    def cnt(x):
        ret=0
        if x<0:
            x=-x
            pos_idx=0
            for num in Neg[::-1]:
                while pos_idx<lp and Pos[pos_idx]*num<x:
                    pos_idx+=1
                ret+=lp-pos_idx
                if pos_idx==lp:
                    break
            return ret
        idx=0
        for num in Neg[::-1]:
            if num**2<=x:
                ret-=1
            while idx<ln and Neg[idx]*num<=x:
                idx+=1
            ret+=idx
        idx=0
        for num in Pos[::-1]:
            if num**2<= x:
                ret-=1
            while idx<lp and Pos[idx]*num<=x:
                idx+=1
            ret+=idx
        ret//=2
        ret+=ln*lp
        return ret
    
    l,r=-(10**18+1),10**18+1
    while r-l>1:
        m=(l+r)//2
        if cnt(m)<k:
            l=m
        else:
            r=m
    print(r)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 119812
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 998244353;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N = 0;
  // ll R = 0, G = 0, B = 0;
  vl DP1(3, 0); // 1つしか決まってないやつ
  vl DP2(3, 0); // 2つしか決まってないやつ
  string S;
  cin >> N;
  cin >> S;
  ll ans = 1;
  REP(i, 3 * N) {
    ll x = 0;
    if (S[i] == 'R')
      x = 0;
    else if (S[i] == 'G')
      x = 1;
    else
      x = 2;
    ll x1 = (x + 1) % 3;
    ll x2 = (x + 2) % 3;
    if (DP2[x] > 0) {
      ans *= DP2[x];
      ans %= MOD;
      DP2[x]--;
    } else if (DP1[x1] > 0) {
      ans *= DP1[x1];
      ans %= MOD;
      DP2[x2]++;
      DP1[x1]--;
    } else if (DP1[x2] > 0) {
      ans *= DP1[x2];
      ans %= MOD;
      DP2[x1]++;
      DP1[x2]--;
    } else {
      DP1[x]++;
    }
  }

  REP(i, N) {
    ans *= (i + 1);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 832
fun main(args: Array<String>) {
    val line = readLine()!!
    val K = line.split(" ")[0].toInt()
    val X = line.split(" ")[1].toInt()

    for (i in (X-K+1)  until (X+K)) {
        if (i < X+K-1) {
            print(i)
            print(" ")
        } else {
            println(i)
        }
    }
}

Measured memory_bytes: 37956
#include<iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n ;
  cin >> n ;
  int min,max;

  for(int i=0;i<n;i++){
    if(i==0){
      cin >> min ;
      max = min ;
      continue;
    }
    int tmp ;
    cin >> tmp ;
    if(tmp<=min){
      min = tmp;
    }
    if(tmp>=max){
      max = tmp;
    }
  }
   cout << abs(max-min) << "\n" ;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  double x1,y1,x2,y2,a,b;
  double distance;
  cin >> x1 >> y1 >> x2 >> y2 ;
  a=x2-x1;
  b=y2-y1;
  distance = sqrt(a*a+b*b);
  printf("%.8f\n",distance);
  return 0;
}

Measured memory_bytes: 1240
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    Scanner s=new Scanner (System.in);
	  int n=s.nextInt();
	  int m=s.nextInt();
	  int r=0;
	  int t=0;
	  if(n<=m)
	  {
	      r=n;
	      for(int i=1; i<m; i++ ){
	          
	          t=n*10;
	          n=t+r;
	          
	      }
	      System.out.println(""+n);
	          
	  }
	  else
	  {
	      r=m;
	      for(int i=1; i<n; i++ ){
	          
	          t=m*10;
	          m=t+r;
	          
	      }
	      System.out.println(""+m);
	          
	  }
	  
	  
	  
	  
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2050;
vector<int> G[maxn];
int dp[maxn];
int cnt[maxn];
int low[maxn];
const int INF=0x3f3f3f3f;
int ans;
string s;
void dfs(int u,int fa=-1)
{
	vector<int> cur;
	cnt[u]=(s[u-1]=='1');
	int sum=0,mxi=0;
	for(auto &v:G[u])if(v!=fa)
	{
		dfs(v,u);
		cnt[u]+=cnt[v];
		dp[v]+=cnt[v];
		dp[u]+=dp[v];
		low[v]+=cnt[v];
		if(low[mxi]<low[v]) mxi=v;
		sum+=dp[v];
		low[u]^=(dp[v]&1);
	}
	sum-=dp[mxi];
	low[u]=max(low[u],low[mxi]-sum);
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	cin>>s;
	for(int i=1,u,v;i<n;i++)
	{
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	ans=INF;
	for(int i=1;i<=n;i++)
	{
		memset(dp,0,sizeof(dp));
		memset(cnt,0,sizeof(cnt));
		memset(low,0,sizeof(low));
		dfs(i);
	//	cout<<i<<":"<<low[i]<<" "<<dp[i]<<endl;
		if(!low[i]) ans=min(ans,dp[i]/2);
	}
	if(ans==INF) cout<<-1<<endl;
	else cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <unordered_map>
using namespace std;
 
#define SR (1 << 15)
const int mod = 1000000007;
 typedef pair<int, int> pii;
namespace std {
	template <>  
	struct hash<pii> {
		size_t operator()(const pii &key) const {    
			return ((hash<int>()(key.first)  
				^ (hash<int>()(key.second) << 1)) >> 1);  
		}  
	};  
}  

//unordered_map<pii, int> c0, c1;
int c[SR];
int n, m, f[16][SR][2], bc[SR], bk[SR], e[20];

int main() {
	scanf("%d%d", &n, &m);
	int M = 1 << n;
	
	for (int i = 0; i < n; ++i) bk[1 << i] = i;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		--x, --y;
		e[x] |= 1 << y;
	}
	for (int s = 0; s < M; ++s) bc[s] = bc[s >> 1] + (s % 2);
	//for (int s = 0; s < M; ++s) c0[pii(0, s)] = c1[pii(0, s)] = 1, bc[s] = bc[s >> 1] + (s % 2);
	/*for (int s = 1; s < M; ++s) {
		int r = M -  1 - s;
		for (int t = r; ; t = (t - 1) & r) {
			int lb = s & -s, x = bk[lb];
			c0[pii(s, t)] = 1ll * c0[pii(s - lb, t)] * ((1 << bc[e[x] & t]) - 1) % mod;
			c1[pii(s, t)] = 1ll * c1[pii(s - lb, t)] * (1 << bc[e[x] & t]) % mod;
			//if (cnt[s][t]) printf("cnt[%d][%d] = %d\n", s, t, cnt[s][t]);
			
			if (t == 0) break;
		}
	}*/
	
	f[0][0][0] = 1;
	
	for (int s = 0; s < M; ++s) c[s] = 1;
	for (int s = 0; s < M; ++s) {
		for (int t = s; ; t = (t - 1) & s) {

			for (int i = 0; i < n; ++i) {
				if ((M - s - 1) >> i & 1)
					c[t] = 1ll * c[t] * ((1 << bc[e[i] & t]) - 1) % mod;
				if ((s - t) >> i & 1)
					c[t] = 1ll * c[t] * (1 << bc[e[i] & t]) % mod;
			}
			if (t == 0) break;
		//	if (s == 131) printf("%d ", c[t]);
		}
		
		for (int i = 1; i <= n; ++i) {
			for (int t = s; ; t = (t - 1) & s) {
				bool _d = (t % 2) && (t / 2 % 2);
				for (int d = 0; d < 2; ++d)
					f[i][s][d | _d] = (f[i][s][d | _d] + 1ll * f[i - 1][s - t][d] * c[t]) % mod;	
				if (t == 0) break;		
			}
		}
		for (int t = s; ; t = (t - 1) & s) { c[t] = 1; if (t == 0) break; }
	}
	
/*	for (int i = 1; i <= n; ++i) {
		//sg[i][s] = sg[i-1][t] * cnt[M-s-t][t]
		for (int s = 0; s < M; ++s) {
			for (int t = s; ; t = (t - 1) & s) {
				bool _d = (t % 2) && (t / 2 % 2);
				for (int d = 0; d < 2; ++d)
					f[i][s][d | _d] = (f[i][s][d | _d] + 1ll * f[i - 1][s - t][d] * c0[pii(M - 1 - s, t)] % mod * c1[pii(s-t, t)]) % mod;
					
				if (t == 0) break;
			}
			
			//if (f[i][s][0]) printf("f[%d][%d][0] = %d\n", i, s, f[i][s][0]);
			//if (f[i][s][1]) printf("f[%d][%d][1] = %d\n", i, s, f[i][s][1]);
		}
	}*/
	
	int wh = 1;
	for (int i = 1; i <= m; ++i) wh = wh * 2 % mod;
	printf("%d\n", (wh - f[n][M - 1][1] + mod) % mod);
	return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;
#define lli long ling int;

int main()
{
    int S, W;
    scanf("%d %d", &S, &W);

    if(W>=S) {
        printf("unsafe\n");
        return 0;
    }
    else {
        printf("safe\n");
        return 0;
    }

    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{

	int A, B;
	cin >> A >> B;

	if (A - 2 * B >= 0) {
		cout << A - 2 * B << endl;
	}
	else {
		cout << 0 << endl;
	}
	
	

	
}


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main()
{
  int s;
  cin>>s;
  int a=s/100;
  int b=s%100;
  if(a==0 || b==0)
  {
  if(a==0 && b==0)
  {
    cout<<"NA";
    return 0;
  }
  if(a==0 && b<=12)
  {
    cout<<"YYMM";
   return 0;
  }
  if(b==0 && a<=12)
  {
    cout<<"MMYY";
   return 0;
  }  
  cout<<"NA";
  return 0;
  }
  if(a<=12 && b<=12)
  {
    cout<<"AMBIGUOUS";
    return 0;
  }
  if(a<=12)
  {
    cout<<"MMYY";
    return 0;
  }
  if(b<=12)
  {
    cout<<"YYMM";
    return 0;
  }
  cout<<"NA";
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    	int n = sc.nextInt();
    	int max = sc.nextInt();
    	int[] w = new int[n];
    	int[] v = new int[n];
    	for(int i = 0; i < n; i++) {
    		w[i] = sc.nextInt();
    		v[i] = sc.nextInt();
    	}

    	int sum = 0;
    	for(int i : v)
    		sum += i;

    	long[] dp = new long[sum+1];
    	Arrays.fill(dp, Integer.MAX_VALUE);
    	dp[0] = 0;
    	for(int i = 0; i < n; i++) {
    		for(int j = sum; j >= v[i]; j--) {
    			dp[j] = Math.min(dp[j], dp[j-v[i]] + w[i]);
    		}
    	}

    	int ans = 0;
    	for(int i = sum; i > 0; i--) {
    		if(dp[i] > 0 && dp[i] <= max) {
    			// System.out.println("ans");
    			ans = i;
    			break;
    		}
    	}

    	// System.out.println(Arrays.toString(dp));
    	System.out.println(ans);
    }
}

Measured memory_bytes: 37424
#include <stdio.h>
#define N 100000

int Search(int, int, int);

int S[N];

int main () {
  int n = 0, q = 0, cnt = 0, i;
  int T[50000];
 
  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) {
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i = 0 ; i < q ; i++) {
    scanf("%d",&T[i]);
  }

  for(i = 0 ; i < q ; i++) {
    if(Search(T[i], n, 0) == 1) cnt++;
  }

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

  return 0;

}

int Search(int x, int right, int left) {
  int mid = 0;

  mid = (right + left) / 2;

  if(left >= right) return 0;
  if(x == S[mid]) return 1;
  if(x > S[mid]) return Search(x, right, mid+1);
  else if(x < S[mid]) return Search(x, mid, left);
}



Measured memory_bytes: 2328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, Q;
        public long MOD = 1000000007;

        public void Run()
        {
            string b = Console.ReadLine();

            if(b == "A") Console.WriteLine("T");
            if (b == "T") Console.WriteLine("A");
            if (b == "C") Console.WriteLine("G");
            if (b == "G") Console.WriteLine("C");
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 11092
n,m=map(int,input().split())
mod=10**9+7
nkai=1
mkai=1
for i in range(1,n+1):
  nkai*=(i%mod)
  nkai=(nkai%mod)
for i in range(1,m+1):
  mkai*=(i%mod)
  mkai=(mkai%mod)
if abs(n-m)>=2:
  print(0)
elif abs(n-m)==1:
  print((mkai*nkai)%mod)
elif abs(n-m)==0:
  print((mkai*nkai*2)%mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  int ans = A - B;
  if (K % 2 == 1) ans *= -1;

  cout << ans << endl;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	int n = N * N;
	vector<int> P(n);
	for (int i = 0; i < n; ++i) {
		cin >> P[i];
		--P[i];
	}

	vector<int> cost(n, 0);
	for (int i = 0; i < n; ++i) {
		int x = i % N, y = i / N;
		cost[i] = min({ x, N - 1 - x, y, N - 1 - y });
	}

	int dx[4] = { 0, 0, 1, -1 };
	int dy[4] = { 1, -1, 0, 0 };
	auto in = [&](int x, int y) -> bool {
		return x >= 0 && x < N && y >= 0 && y < N;
	};
	int ans = 0;
	vector<bool> rest(n, true);
	for (int i = 0; i < n; ++i) {
		ans += cost[P[i]];
		rest[P[i]] = false;

		deque<int> que;
		que.emplace_back(P[i]);
		while (!que.empty()) {
			int v = que.back(); que.pop_back();
			int x = v % N, y = v / N;
			for (int k = 0; k < 4; ++k) {
				int nx = x + dx[k];
				int ny = y + dy[k];
				int nv = ny * N + nx;
				if (!in(nx, ny) || cost[nv] <= cost[v] + rest[v]) {
					continue;
				}
				cost[nv] = cost[v] + rest[v];
				que.emplace_back(nv);
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5576
import sys
a = [[int(i) for i in input().split()] for l in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for target in b:
    for i in range(len(a)):
        for j in range(len(a[0])):
            if a[i][j] == target:
                a[i][j]=0

for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==0 or a[0][i]==a[1][i]==a[2][i]==0:
        print("Yes")
        sys.exit()

if a[1][1] == a[2][2] == a[0][0]==0 or a[0][2] == a[1][1] == a[2][0]==0:
    print("Yes")
    sys.exit()

print("No")

Measured memory_bytes: 3064
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
int main(){
    int n, m;
    cin >> n >> m;
    if(n >= 10){
        cout << m << endl;
    }else{
        cout << m + 100 * (10 - n) << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string str;
    while(cin >> str){
        if(str == "-") break;
        int num;
        cin >> num;
        int pos;
        for(int i=0; i<num; i++){
            cin >> pos;
            str = str.substr(pos, str.size()) + str.substr(0, pos);
        }
        cout << str << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;

int n, m, k;
int dp[2][10000010];

int w[maxn], v[maxn];
int cnt[10], base[10], t[10];

long long calc(int u) {
    long long ans = 0;
    ans += (long long)(u % cnt[0]) * k;       u /= cnt[0];
    ans += (long long)(u % cnt[1]) * (k + 1); u /= cnt[1];
    ans += (long long)(u % cnt[2]) * (k + 2); u /= cnt[2];
    ans += (long long)u * (k + 3);
    return ans;
}
int main() {

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

    cnt[0] = cnt[1] = cnt[2] = cnt[3] = 1;
    for(int i = 0; i < n; i++) {
        scanf("%d%d", &w[i], &v[i]);
        if(i == 0) k = w[i];
        ++cnt[ w[i] -= k ];
    }

    for(int i = 0; i < 4; i++) t[i] = cnt[i];

    base[0] = 1;
    for(int i = 1; i < 4; i++) 
        base[i] = t[i-1], t[i] *= t[i-1];

    int cur = 1;
    memset(dp, -1, sizeof dp);

    dp[0][0] = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 10000000+10-1; j >= base[w[i]]; j--) {
            dp[cur][j] = dp[cur^1][j]; 
            if(dp[cur^1][j-base[w[i]]] >= 0)
                dp[cur][j] = max(dp[cur][j], dp[cur^1][j-base[w[i]]] + v[i]);
        }

        for(int j = base[w[i]]-1; j >= 0; j--)
            dp[cur][j] = dp[cur^1][j];

        cur ^= 1;
    }
    int ans = 0, lim = 0;
    for(int i = 0; i < n; i++) lim += base[w[i]];

    if(lim >= 10000000) for(;;);

    for(int j = 0; j <= lim; j++) {
        if(calc(j) <= m) {
            if(dp[cur^1][j] > ans) {
                ans = dp[cur^1][j];
            }
        }
    }
    printf("%d\n", ans);
    
    return 0;
}


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

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	for (string s; cin >> s&&s != "#";) {
		string t = "";
		int a = -1;
		int n = 0;
		rrep(i, 0, s.size()) {
			if (s[i] == 'n') {
				if (a == -1)a = 0;
				else {
					a *= 2;
					a -= 90;
				}
				n++;
			}
			else if (s[i] == 'w') {
				if (a == -1)a = 90;
				else {
					a *= 2;
					a += 90;
				}
				n++;
			}
		}
		if (n <= 2)cout << a / n << endl;
		else cout << a / 2 << "/" << pow(2, n - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

int main()
{
    ll a, b;
    cin >> a >> b;

    if (a > 0 && b > 0)
    {
        cout << "Positive" << endl;
        return 0;
    }
    if (max(a, b) >= 0 && min(a, b) <= 0)
    {
        cout << "Zero" << endl;
        return 0;
    }
    if ((max(a, b) - min(a, b)) % 2 == 0)
    {
        cout << "Negative" << endl;
    }
    else
    {
        cout << "Positive" << endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  int answer = b / 100 - a / 100 - 1;
  if (a / 10000 + (a - a / 10000 * 10000) / 1000 * 10 >= a % 100){
    answer ++;
  }
  if (b / 10000 + (b - b / 10000 * 10000) / 1000 * 10 <= b % 100){
    answer ++;
  }
  cout << answer << endl;
}

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

namespace AOJHelloWorld1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            
            Array.Sort(x);
            Console.WriteLine(x[0] + " " + x[1] + " " + x[2]);
        }
    }
}


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

#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

static const double EPS = 1e-10;
static const int MAX_N = 50;
static const double G = 9.8;

int N;
double V, X, Y;
double L[MAX_N], B[MAX_N], R[MAX_N], T[MAX_N];

double calc(double vy, double t) {
  return vy * t - 0.5 * G * t * t;
}

int cmp(double a, double b, double x) {
  if (x < a + EPS) return -1;
  if (x > b - EPS) return 1;
  return 0;
}

bool check(double tx, double ty) {
  double a = (1.0 / 4.0) * G * G;
  double b = G * ty - V * V;
  double c = tx * tx + ty * ty;

  double D = b * b - 4.0 * a * c;
  if (fabs(D) <= EPS) D = 0.0;
  if (D < 0) return false;
  for (int d = -1; d <= 1; d+=2) {
    double t_squared = (-b + d * sqrt(D)) / (2.0 * a);
    if (t_squared <= 0) continue;

    // calc initial velocity to hit (tx, ty)
    double t = sqrt(t_squared);
    double vx = tx / t;
    double vy = (ty + 0.5 * G * t * t) / t;

    // check if the course is beyond pig
    double py = calc(vy, X / vx);
    if (py < Y - EPS) continue;

    // check if the course is clear
    bool isClear = true;
    for (int i = 0; i < N; i++) {
      if (L[i] >= X) continue;
      if (R[i] >= X && T[i] >= Y && B[i] <= py) {
        isClear = false;
        break;
      }
      double ly = calc(vy, L[i] / vx);
      double ry = calc(vy, R[i] / vx);
      int posL = cmp(B[i], T[i], ly);
      int posR = cmp(B[i], T[i], ry);
      if (posL * posR <= 0) {
        isClear = false;
        break;
      }

      double ht = vy / G;
      int posX_high = cmp(L[i], R[i], vx * ht);
      double hy = calc(vy, ht);
      int posH = cmp(B[i], T[i], hy);
      if (posX_high == 0 && posH >= 0 && posL < 0) {
        isClear = false;
        break;
      }
    }
    if (isClear) return true;
  }
  return false;
}

bool solve() {
  for (int i = 0; i < N; i++) {
    R[i] = min(R[i], X);
  }
  if (check(X, Y)) return true;
  for (int i = 0; i < N; i++) {
    if (check(L[i], T[i]) || check(R[i], T[i])) return true;
  }
  return false;
}

int main() {
  cin >> N >> V >> X >> Y;
  for (int i = 0; i < N; i++) {
    cin >> L[i] >> B[i] >> R[i] >> T[i];
  }

  bool isOK = solve();
  cout << (isOK ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3224