akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, yen ] <- readInts
	let
		candidate = [ ( i, j, n - i - j ) | i <- [ 0 .. 2000 ], j <- [ 0 .. 2000 ],
			i + j <= n,
			yen - 10000 * i - 5000 * j == 1000 * ( n - i - j ) ]
		( i, j, k ) = which ( head candidate ) ( -1, -1, -1 ) $ 0 < length candidate
	printf "%d %d %d\n" i j k


Measured memory_bytes: 1020
import numpy as np
import copy

def main():
    l, r = map(int, input().split())
    
    ans_tmp = 2019
    if r-l >= 2019:
        ans_tmp = 0
    else:
        for j in range(r-l):
            for k in range(j,r-l):
                ans = ((l+j)*(l+(k+1)))% 2019
                if ans == 0:
                    ans_tmp = 0
                    break
                elif ans < ans_tmp:
                    ans_tmp = ans
                
        
    print(ans_tmp)

if __name__ == '__main__':
    main()



Measured memory_bytes: 21384
#include <bits/stdc++.h>
using namespace std;
 
 
#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M 1000000007
#define mp make_pair
#define pb push_back
#define PB pop_back
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define lcase(a) (char)tolower(a)
#define ucase(a) (char)toupper(a)
#define precise(a) fixed<<setprecision(a)<<
#define F first
#define S second
#define I insert
#define pii pair<int,int>
#define trav(a, x) for(auto& a : x)
#define fl(i,n) for(int i = 0;i<n;i++)
#define rfl(n) for(int i = n-1;i>=0;i--)
#define time cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" "; cout<<endl;
#define ingrid(data,n,commands) for(int i = 0; i<n; i++){cin>>data[i];commands}
#define section(a,b,w) set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w) set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define copy(a,w) copy(a.begin(), a.end(),back_inserter(w));
#define all(data) data.begin(), data.end()
#define PI 3.14159265358979323844
#define endl '\n'
#define last(a) a[sz(a)-1]
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
 
// Graph DFS
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
 
//primes for hashing 937,991,1013,1409,1741
 
//Returns index of first element not less than key and more than key respectively
#define lb(data,key) lower_bound(all(data),key) - data.begin();
#define up(data,key) upper_bound(all(data),key) - data.begin();
#define fnd(data,key) find(all(data),key) - data.begin();
/* Long Long Int */
#define int long long int

std::vector<int> v,a;
int dp(int n,int k)
{
    if(v[n]==-1)
        {
            std::vector<int> t;
    fl(i,k)
    {
        if(n+i+1>=v.size())
            break;
        else
            t.pb(dp(n+i+1,k)+abs(a[n+i+1]-a[n]));
    }
            v[n]=*min_element(all(t));}
    return v[n];
}

void solve()
{ 
int n,k;
cin>>n>>k;

fl(i,n)
{int j;
    cin>>j;a.pb(j);v.pb(-1);

}
v[v.size()-1]=0;
v[v.size()-2]=abs(a[n-1]-a[n-2]);
int z=dp(0,k);
cout<<z;
return;
}

 
signed main()
{
    FAST
    
    
    int t = 1;
//cin>>t;
    while(t--) 
    solve();
    
 
return 0;
}   







Measured memory_bytes: 13036
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		if(x%2==0){
			if(x%3&&x%5){
				puts("DENIED");
				return 0;
			}
		}
	}
	puts("APPROVED");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		String t=sc.next();
		
		for(int i=0;i<t.length()-1;i++){
			if(t.charAt(i)==t.charAt(i+1)){
				System.out.println((i+1)+" "+(i+2));
				return;
			}
		}
		for(int i=0;i<t.length()-2;i++){
			if(t.charAt(i)==t.charAt(i+2)) {
				System.out.println((i+1)+" "+(i+3));
				return;
			}
		}
		System.out.println(-1+" "+-1);
	}
}


Measured memory_bytes: 13700
import java.util.Scanner;

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

		long mod = (long)(Math.pow(10, 9)+7);
		int n  = sc.nextInt();

		long sosu[] = new long[n+1];

		for(int i = 2;i <= n;i++){
			int j = i;
			while(j > 1){
				for(int k = 2;k <= j;k++){
					if(j%k == 0){
						//System.out.println("i:"+i+" j:"+j);
						sosu[k]++;
						j /= k;
						break;
					}
				}
			}
		}
		long answer = 1;
		for(int i = 2;i < sosu.length;i++){
			if(sosu[i] > 0)answer = (answer*(sosu[i]+1))%mod;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 9812
#include<iostream>
using namespace std;
int main(){
    int p,q,r,s,t,u;
    cin>>p>>q>>r;
    s=p+q;
    t=q+r;
    u=p+r;
    if(s>t){
        s=t;
    }
    if(s>u){
        s=u;
    }
    cout<<s<<endl;
}


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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(a, x) memset(a, x, sizeof(a))
#define len(x) (x).size()
#define pb push_back
#define eb emplace_back
#define f first
#define s second

const double eps = 1e-9;
const double pi = acos(-1.0);
const int inf = 1e9 + 7;
const int maxn = 1e5+5;

int n, k;
int h[maxn];
bool seen[maxn];
int dp[maxn];

int solve(int idx = 0) {
    if (idx == n-1) return 0;
    if (seen[idx]) return dp[idx];
    seen[idx] = true;
    int ans = inf;
    for (int i = 1; i <= k; ++i) {
        if (idx + i >= n) break;
        ans = min(ans, solve(idx + i) + abs(h[idx] - h[idx + i]));
    }
    return dp[idx] = ans;
}

int main() {
    fastIO();
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> h[i];
    cout << solve() << "\n";
    return 0;
}



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

int main(){
	int a;
	int b;
	cin >> a;
	cin >> b;
	if (a < b)
		cout << "a < b" << endl;
	else if (a == b)
		cout << "a == b" << endl;
	else if (a > b)
		cout << "a > b" << endl;
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MODD 1000000007
#define ll long long
#define Inf 1000000000
using namespace std;
int H,W;

int A[2][111];

int main() {
    int N;
    cin>>N;
    for(int i=1;i<=2;i++)
        for(int j=1;j<=N;j++)
            cin>>A[i][j];
    
    
    int ans=0;
    
    for(int m=1;m<=N;m++) {
        int curr = 0;
        for(int i=1;i<=m;i++)
            curr += A[1][i];
        for(int i=m;i<=N;i++)
            curr += A[2][i];
        ans = max(ans, curr);
    }
    cout << ans << endl;
    
}

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

int main()
{

  int i,j,k;
  int N;
  scanf("%d",&N);
  char S[N];
  scanf("%s",S);
  
  int count = 0;
  
  j = 0;
  k = -1;
  for(i=0;i<N;i++){
    while( S[i] == S[j] && j < N ){
      j++;
    }
    count++;
    i = j - 1;
  }
  
  printf("%d\n",count);
  
  return 0; 
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	s := getNextString(scanner)
	l := 0
	r := n>>1 + 1
	for l < r {
		m := (l + r) >> 1
		enable := false
		for i := 0; i+m <= n && !enable; i++ {
			for j := i + m; j+m <= n && !enable; j++ {
				if s[i:i+m] == s[j:j+m] {
					enable = true
				}
			}
		}
		if enable {
			l = m + 1
			continue
		}
		r = m
	}
	fmt.Fprintln(writer, l-1)
	writer.Flush()
}


Measured memory_bytes: 640
#include <cstdio>
#include <set>

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

  std::set<int> A;
  for (int i = 0; i < N; ++i) {
    int a;
    scanf("%d", &a);
    if (A.count(a)) {
      A.erase(a);
    } else {
      A.insert(a);
    }
  }
  printf("%zu\n", A.size());
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
const int MOD = 1000000007;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}


int main() {
    int n; cin >> n;
    int a[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    
    for(int i = 0;i < n-1;i++){
        if(a[i+1] - a[i] >= 1){
            a[i+1]--;
        }else if(a[i+1] >= a[i]){
            continue;
        }else{
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 4020
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n;
  cin >> n;
  ll a[n], b[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a,a+n);
  sort(b,b+n, greater<int>());
  ll ans = abs(a[0]-b[0]);
  for(int i=1;i<n/2;i++){
    ans += abs(a[i-1]-b[i])+ abs(b[i-1]-a[i]);
  }
  if (n % 2 == 1){
    ans += max(abs(a[n/2-1]-b[n/2]),abs(b[n/2-1]-a[n/2]));
  }
  cout << ans << endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double theta = 5.5f * (60 * h + m) / 180 * acos(-1);
  cout << fixed << setprecision(20);
  cout << sqrt(a * a + b * b - 2 * a * b * cos(theta)) << endl;
  return 0;
}

Measured memory_bytes: 4244
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
    int k,n,max=0,i;
    cin>>k>>n;
    int a[n];
    for( i=0;i<n;i++)
    cin>>a[i];
    for(i=1;i<n;i++)
    {
       if(a[i]-a[i-1]>max)
       max=a[i]-a[i-1];
    }
    if(k-a[n-1]+a[0]>max)
    max=k-a[n-1]+a[0];
    cout<<k-max<<endl;
    
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
    int n,max=0,a,s,x;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        x = i;
        a=0;
        while (x%2!=1) {
            x /=2;
            a++;
        }
        if(a > max){
            s = i;
            max = a;
        }
    }
    if(n==1) s++;
    printf("%d",s);
}


Measured memory_bytes: 128
#include <stdio.h>
#define N 100
#define W 0
#define G 1
#define B 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs(void);
void dfs_visit(int);

int main(){
  int u, k, v;
  int i, j;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++)M[i][j] = 0;
  }
  for(i=0; i<n; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0; j<k; j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();
  return 0;
}

void dfs(){
  int u;
  for(u=0; u<n; u++)color[u] = W;
  tt = 0;
  for(u=0; u<n; u++){
    if(color[u] == W)dfs_visit(u);
  }
  for(u=0; u<n; u++)printf("%d %d %d\n",u+1,d[u],f[u]);
}

void dfs_visit(int u){
  int v;
  color[u] = G;
  d[u] = ++tt;
  for(v=0; v<n; v++){
    if(M[u][v] == 0)continue;
    if(color[v] == W)dfs_visit(v);
  }
  color[u] = B;
  f[u] = ++tt;
}



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

int main(){
  char a,b;
  cin >> a >> b;
  if(a=='H'){
    if(b=='H')
      cout << "H" << endl;
    else
      cout << "D" << endl;
  }
  else{
    if(b=='H')
      cout << "D" << endl;
    else
      cout << "H" << endl;
  }
}

Measured memory_bytes: 256
import bisect

# Receive input
s = input()
t = input()

# preparations
s_len = len(s)
t_len = len(t)

index_in_s = {}
for ch in "abcdefghijklmnopqrstuvwxyz":
    index_in_s[ch] = [] # store positions of each character in s

for j in range(0, s_len):
    index_in_s[s[j]].append(j)


subtract = 0
current = s_len # so that the first iteration falls into the last "else" block
is_subsequence = True
for ch in t:
    # t is not a subsequence of s
    if len(index_in_s[ch]) == 0:
        is_subsequence = False
        break
    else:
        pos = bisect.bisect_right(index_in_s[ch], current)
        if pos < len(index_in_s[ch]): # index_in_s[ch] has a value larger than current
            subtract += 1
            current = index_in_s[ch][pos]
        else: # index_in_s[ch] doesn't have a value larger than current
            # Look for ch in "the next" s
            current = index_in_s[ch][0]


if is_subsequence:
    i = (t_len - 1 - subtract) * s_len + current + 1
else:
    i = -1

print(i)


Measured memory_bytes: 46320
import sys


def input_data():
    a = []
    for line in sys.stdin:
        a.append(str(line))

    return a


def how_in(string, pattern):
    match_num = 0
    for i in range(len(string) - 2):
        if pattern == string[i:i + 3]:
            match_num += 1

    return match_num


yeah = input_data()
for pattern in yeah:
    print(how_in(pattern, 'JOI'))
    print(how_in(pattern, 'IOI'))

Measured memory_bytes: 5576
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define F first
#define S second
#define pb(n) push_back(n)
const int N=303;
const ll M=1e9+7;
const ll INF=1e18;

double dp[N][N][N];

int main()
{
	int n,x;
	scn(n);
	int ct[4]={0};
	rep(i,0,n)
	{
		scn(x);
		ct[x]++;
	}

	for(int c=0;c<=n;c++)
	{
		for(int b=0;b<=n;b++)
		{
			for(int a=0;a<=n;a++)
			{
				double n1=0.0,n2=0.0,n3=0.0;
				if(a)
					n1=dp[a-1][b][c];
				if(b)
					n2=dp[a+1][b-1][c];
				if(c)
					n3=dp[a][b+1][c-1];

				if(a or b or c)
				{
					dp[a][b][c]=(1.0*n)/(a+b+c);
					dp[a][b][c]*=(a*n1+b*n2+c*n3)/n + 1;					
				}
			}
		}
	}
	printf("%.10f",dp[ct[1]][ct[2]][ct[3]]);

}

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

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

int main() {

	int n;
	cin >> n;

	long arr[n], temp[n];
	for (int i = 0; i < n; i++) cin >> arr[i];

	temp[0] = 0;
	temp[1] = abs(arr[0] - arr[1]);

	for (int i = 2; i < n; i++)
		temp[i] = min(abs(arr[i] - arr[i - 1]) + temp[i - 1], abs(arr[i] - arr[i - 2]) + temp[i - 2]);

	cout << temp[n - 1];
  	return 0;
}

Measured memory_bytes: 5144
### constant

INF = Float::INFINITY
DELTA = 1e-12

MIN_X = MIN_Y = -100.0
MAX_X = MAX_Y =  100.0

### subroutines

def min_z2(x, y)
  mz2 = INF
  $rps.each do |xi, yi, li2|
    z2 = li2 - (x - xi) ** 2 - (y - yi) ** 2
    mz2 = z2 if mz2 > z2
  end
  mz2
end

def rec_y(x)
  min_y = MIN_Y
  max_y = MAX_Y
  while (max_y - min_y > DELTA)
    y0 = (min_y * 2 + max_y) / 3
    y1 = (min_y + 2 * max_y) / 3
    mz20 = min_z2(x, y0)
    mz21 = min_z2(x, y1)
    if mz20 > mz21
      max_y = y1
    else
      min_y = y0
    end
  end
  min_z2(x, (min_y + max_y) / 2)
end

def rec_xy()
  min_x = MIN_X
  max_x = MAX_X
  while (max_x - min_x > DELTA)
    x0 = (min_x * 2 + max_x) / 3
    x1 = (min_x + 2 * max_x) / 3
    mz20 = rec_y(x0)
    mz21 = rec_y(x1)
    if mz20 > mz21
      max_x = x1
    else
      min_x = x0
    end
  end
  rec_y((x0 + x1) / 2)
end

### main

loop do 
  n = gets.to_i
  break if n == 0

  $rps = []
  n.times do
    xi, yi, li = gets.split.map(&:to_f)
    $rps << [xi, yi, li * li]
  end    
  #p $rps

  puts "%.7f" % Math.sqrt(rec_xy)
end

Measured memory_bytes: 6180
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

    string s;
    while(cin >> s, s != "-") {
        int m;
        cin >> m;
        rep(i, m) {
            int h;
            cin >> h;
            s = s.substr(h) + s.substr(0, h); 
        }
        cout << s << endl;

    }
    return 0;
}


Measured memory_bytes: 3224
n = int(input())
A = list(map(int, input().split()))
cnt = 0

for i in range(n):
    min_j = i
    for j in range(i+1,n):
        if A[j] < A[min_j]:
            min_j = j
    if min_j != i:
        buf = A[i]
        A[i] = A[min_j]
        A[min_j] = buf
        cnt += 1
for k in range(n):
    if k != n-1:
        print(A[k],"",end="")
    else:
        print(A[k])
print(cnt)


Measured memory_bytes: 5616
#include<iostream>
using namespace std;
int main(){
   int m,n,r;
   while(true){
       cin >> m >> n >> r;
       if(m == -1 && n ==-1 && r == -1)break;
       
       if(m == -1 || n == -1 || m+n<30){
           cout << "F" << endl;
       }else if(80<=(m+n))cout << "A" << endl;
        else if(65<=(m+n))cout << "B" << endl;
        else if(50<=(m+n) || (m+n>=30 && r>=50))cout << "C" << endl;
        else if(30<=(m+n))cout << "D" << endl;
        else if(m+n<30)cout << "F" << endl; 
       
   }
}


Measured memory_bytes: 3108
INF = 105 * 10**7
dp = [INF] * 100010

N = int(input())
h = list(map(int, input().split()))

dp[0] = 0

for i in range(1, N):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N-1])


Measured memory_bytes: 14696
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:#?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let (N, M) = read!(usize, usize);
    let mut A = read![usize, usize; M];

    A.sort_by_key(|&(_, v)| v);

    let mut k = 0;
    let mut l = 0;
    for (u, v) in A {
        if u < l {
            continue;
        }

        l = v;
        k += 1;
    }

    println!("{}", k);
    return;
}


Measured memory_bytes: 6396
/* A - Kyu in AtCoder */

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

int main(){
  int X, ans = 0;
  cin >> X;
  if(X >= 400 && X <= 599){
    ans = 8;
  }else if(X >= 600 && X <= 799){
    ans = 7;
  }else if(X >= 800 && X <= 999){
    ans = 6;
  }else if(X >= 1000 && X <= 1199){
    ans = 5;
  }else if(X >= 1200 && X <= 1399){
    ans = 4;
  }else if(X >= 1400 && X <= 1599){
    ans = 3;
  }else if(X >= 1600 && X <= 1799){
    ans = 2;
  }else if(X >= 1800 && X <= 1999){
    ans = 1;
  }else{
    fprintf(stderr, "Error!\n");
    exit(1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
N = input()
s1 = []
s2 = []
res = []
ans = []
cnt = 0
for i in range(len(N)):
    if N[i] == "\\":
        s1.append(i)
    elif N[i] == "/" and s1:
        idx = s1.pop()
        tmp = i - idx
        cnt += tmp

        while s2 and idx < s2[-1][0]:
            tmp += s2.pop()[1]
        s2.append((idx, tmp))

res.append(len(s2))
for i in range(len(s2)):
    ans.append(s2[i][1])
res.extend(ans)
print(cnt)
print(" ".join(map(str, res)))


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

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = 0;
	if (a < b)
		ans += a;
	else
		ans += b;
	if (c < d)
		ans += c;
	else
		ans += d;

	cout << ans << endl;
}

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

#define INIT_CAP 10
#define INF 1000000000

#define min(a, b) (((a) < (b)) ? (a) : (b))

const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};

typedef struct {
	int to, w;
} Edge;

typedef struct {
	Edge *elem;
	int cap, size;
} VecEdge;

typedef struct {
	int num, d;
} PNumDis;

VecEdge adj[30 * 30 * 4];
PNumDis heap[30 * 30 * 4 * 4];
int hsize;
int d[30 * 30 * 4];

int w, h;
int field[30][30];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

void freeAll(int n) {
	while (n--)
		free(adj[n].elem);
}

inline void insert(int num, int d) {
	int i;
	for (i = hsize++; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1)
		heap[i] = heap[i - 1 >> 1];
	heap[i] = (PNumDis){num, d};
}

inline int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

inline PNumDis delete(void) {
	int i;
	int nextIdx;
	const PNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
		heap[i] = heap[nextIdx];
	heap[i] = last;

	return root;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++)
		d[i] = INF;

	d[s] = 0;
	insert(s, 0);
	while (hsize > 0) {
		const PNumDis fromP = delete();

		if (fromP.d > d[fromP.num])
			continue;

		for (i = 0; i < adj[fromP.num].size; i++) {
			const Edge e = adj[fromP.num].elem[i];
			if (fromP.d + e.w < d[e.to]) {
				d[e.to] = fromP.d + e.w;
				insert(e.to, d[e.to]);
			}
		}
	}
}

int main(void) {
	int i, j, k, l;

	while (scanf("%d %d", &w, &h), w) {
		int c[4];

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				scanf("%d", field[i] + j);

		for (i = 0; i < 4; i++)
			scanf("%d", c + i);

		init(h * w * 4);
		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				for (k = 0; k < 4; k++)
					for (l = 0; l < 4; l++) {
						int nd = k + l & 3;
						int ni = i + di[nd], nj = j + dj[nd];
						if (ni >= 0 && ni < h && nj >= 0 && nj < w)
							add(i * w * 4 + j * 4 + k, ni * w * 4 + nj * 4 + nd, l == field[i][j] ? 0 : c[l]);
					}

		dijkstra(h * w * 4, 1);

		printf("%d\n", min(d[(h - 1) * w * 4 + (w - 1) * 4 + 1], d[(h - 1) * w * 4 + (w - 1) * 4 + 2]));

		freeAll(h * w * 4);
	}

	return 0;
}

Measured memory_bytes: 1032
#include<cstdio>

int main(){
	int K, A;
	long long B;
	scanf("%d %d %lld", &K, &A, &B);
	if(B <= A + 2 || K <= A) printf("%d\n", K + 1);
	else printf("%lld\n", A + (B - A)*((K - A + 1) >> 1) + ((K - A + 1) & 1));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){

    int N, K;
    cin >> N >> K;

    ll result = 0;
    int good_num = 0;
    int good_num_K2 = 0;

    if(K%2 == 1){
        for(int i = 1; i <= N; i++){
            if(i%K == 0){
                good_num++;
            }
        }
    }else{
        for(int i = 1; i <= N; i++){
            if(i%K == 0){
                good_num++;
            }else if(i%K == K/2){
                good_num_K2++;
            }
        }
    }

    //cout << "good_num : " << good_num << endl;
    //cout << "good_num_K2 : " << good_num_K2 << endl;

    result = pow(good_num,3) + pow(good_num_K2,3);

    cout << result << endl;

    return 0;

}


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

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

#define l_ength size

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

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

std::vector<ll> v;

int main(void){
	int n,i=0;
	ll a,ans=0ll;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a;
		v.push_back(a);
		v.push_back(a);
	}
	std::sort(v.begin(),v.end(),std::greater<ll>());
	for(i=1; i<n; ++i){
		ans += v[i];
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 7452
// F.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cmath>

using namespace std;

typedef long double LD;
const LD EPS = 1e-8;

struct Point {
	long double x;
	long double y;
	long double z;
	int i;
	bool operator < (const Point& p) const {
		return x < p.x || (x == p.x && y < p.y);
	}
};

long double cross(const Point& O, const Point& A, const Point& B) {
	return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
}

vector<Point> convex_hull(vector<Point>& P)
{
	int n = (int)P.size(), k = 0;
	if (n <= 2) {
		return P;
	}
	vector<Point> H(2 * n);
	sort(P.begin(), P.end());
	for (int i = 0; i < n; ++i) {
		while (k >= 2 && cross(H[k - 2], H[k - 1], P[i]) <= 0) k--;
		H[k++] = P[i];
	}
	for (int i = n - 2, t = k + 1; i >= 0; i--) {
		while (k >= t && cross(H[k - 2], H[k - 1], P[i]) <= 0) k--;
		H[k++] = P[i];
	}
	return vector<Point>(H.begin(), H.begin() + k - 1);
}

bool circumscribed_circle(LD x1, LD y1, LD x2, LD y2, LD x3, LD y3, LD& cx, LD& cy, LD& r)
{
	LD ea = x3 - x1;
	LD ca = x2 - x1;
	cy = (ea * (x1 * x1 + y1 * y1 - x2 * x2 - y2 * y2) - ca * (x1 * x1 + y1 * y1 - x3 * x3 - y3 * y3)) /
		(2 * ea * (y1 - y2) - 2 * ca * (y1 - y3));
	if (fabs(ca) <= EPS) {
		cx = (2 * (y1 - y3) * cy - x1 * x1 - y1 * y1 + x3 * x3 + y3 * y3) / (2 * (x3 - x1));
	} else {
		cx = (2 * (y1 - y2) * cy - x1 * x1 - y1 * y1 + x2 * x2 + y2 * y2) / (2 * ca);
	}
	r = sqrt((x1 - cx) * (x1 - cx) + (y1 - cy) * (y1 - cy));
	return true;
}

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1;
		cin >> n;
		if (n <= 0) return 0;
		vector<Point> xy(n);
		for (int i = 0; i < n; ++i) {
			cin >> xy[i].x >> xy[i].y;
			xy[i].i = i;
		}
		LD ans = 1e10;
		vector<Point> ch = convex_hull(xy);
		int sz = ch.size();
		for (int i = 0; i < sz; ++i) {
			for (int j = i + 1; j < sz; ++j) {
				LD cx = (ch[i].x + ch[j].x) * 0.5, cy = (ch[i].y + ch[j].y) * 0.5;
				LD dx = ch[i].x - ch[j].x, dy = ch[i].y - ch[j].y;
				LD rr = sqrt(dx * dx + dy * dy) * 0.5;
				bool ok = true;
				for (int l = 0; l < sz; ++l) {
					LD dx = ch[l].x - cx;
					LD dy = ch[l].y - cy;
					if (sqrt(dx * dx + dy * dy) > rr + 0.0001) {
						ok = false;
						break;
					}
				}
				if (ok) {
					ans = min(ans, rr);
				}
			}
		}
		for (int i = 0; i < sz; ++i) {
			for (int j = i + 1; j < sz; ++j) {
				for (int k = j + 1; k < sz; ++k) {
					LD cx, cy, rr;
					if (!circumscribed_circle(ch[i].x, ch[i].y, ch[j].x, ch[j].y, ch[k].x, ch[k].y, cx, cy, rr)) {
						continue;
					}

					bool ok = true;
					for (int l = 0; l < sz; ++l) {
						LD dx = ch[l].x - cx;
						LD dy = ch[l].y - cy;
						if (sqrt(dx * dx + dy * dy) > rr + 0.0001) {
							ok = false;
							break;
						}
					}
					if (ok) {
						ans = min(ans, rr);
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;

int main(){

 long int n,i,j,cnt=0,tanka,kazu,sum[4002]={0};
  char syain[4000][5],*syokika="GO";

  while(1){

    scanf("%ld",&n);
    if(n==0){
      break;
    }

    for(i=0;i<n;i++){
      scanf("%s",syain[i]);
      scanf("%ld",&tanka);
      scanf("%ld",&kazu);
      sum[i]=tanka*kazu;
    
    }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(strcmp(syain[i],syain[j])==0 && i!=j){
	  sum[i]=sum[i]+sum[j];
	  sum[j]=0;
	  strcpy(syain[j],syokika);
	}
      }
    }

    for(i=0;i<n;i++){
      if(sum[i]>=1000000){
	cnt=1;
	printf("%s\n",syain[i]);
      }
    }
    if(cnt==0){
      printf("NA\n");
    }

    cnt=0;

  }

  return 0;
}

Measured memory_bytes: 1224
use proconio::{input};

const MOD: i64 = 1e9 as i64 + 7;

fn main(){
    input!{
        n: i64,
        k: i64
    }
    let mut min: i64 = 0;
    let mut max: i64 = 0;
    let mut ans: i64 = 0;
    for i in 0 .. k {
        min += i;
        max = max + n - i;
    }
    ans += max - min + 1;
    for i in k .. n+1 {
        min += i;
        max += n - i;
        ans += max - min + 1
    }
    println!("{}", ans % MOD);
}

Measured memory_bytes: 2128
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = sum(B)
for i in range(1,N) :
    if A[i-1] + 1 == A[i] :
        ans += C[A[i-1]-1]
print(ans)



Measured memory_bytes: 38256
import sys
a,b=list(map(int,input().split()))
ss=input()

n=[str(i) for i in range(0,10)]
i=1


for s in ss:
    if s not in n and i!=a+1:
        print("No")
        sys.exit()
    if i==a+1:
        if s !="-":
            print("No")
            sys.exit()
    i+=1

print("Yes")

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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
    	int r;
    	cin >> r;
    	cout << r * r << '\n';
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

typedef long long ll;

using namespace std;

 int L, R, res = 2020;

int solve() {

	if ( R / 2019 > L /2019 ) return 0;

	for ( int i = L; i <= R; i++ ) {
		for ( int j = i + 1; j <= R; j++) {
			ll x = (ll) i * j;
			res = min(res, (int) (x % 2019));	
		}
	}
	return res;
}

int main() {

	scanf("%d %d", &L, &R);

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

}

Measured memory_bytes: 256
x = int(input())
total = 0
if x % 10 == 9:
        total += 104 + 105
elif x % 10 == 8:
        total += 104 + 104
elif x % 10 == 7:
        total += 103 + 104
elif x % 10 == 6:
        total += 105 + 101
elif x % 10 == 5:
        total += 105
elif x % 10 == 4:
        total += 104
elif x % 10 == 3:
        total += 103
elif x % 10 == 2:
        total += 102
elif x % 10 == 1:
        total += 101

if x % 100 // 10 == 1:
        total += 105 + 105
elif x % 100 // 10 == 2:
        total += 105 * 4
elif x % 100 // 10 == 3:
        total += 105 * 6
elif x % 100 // 10 == 4:
        total += 105 * 8
elif x % 100 // 10 == 5:
        total += 105 * 10
elif x % 100 // 10 == 6:
        total += 105 * 12
elif x % 100 // 10 == 7:
        total += 105 * 14
elif x % 100 // 10 == 8:
        total += 105 * 16
elif x % 100 // 10 == 9:
        total += 105 * 18

if total <= x:
        print(1)
else:
        print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
vi a,b,dp;
vvi g;

int dfs(int v){
	int B=0;
	for(auto u:g[v]) if(a[u]<a[v]&&!dfs(u)) B=1;
	return dp[v]=B;
}

int main(){
	cin>>n;
	a=dp=vi(n);
	g=vvi(n);
	fill(dp.begin(),dp.end(),-1);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=0;i<n;i++) if(dp[i]==-1) dfs(i);
	for(int i=0;i<n;i++) if(dp[i]==1) b.push_back(i+1);
	for(int i=0;i<b.size();i++){
		if(i) cout<<' ';
		cout<<b[i];
	}
	cout<<endl;
}

Measured memory_bytes: 512
k = int(input())
s = input()

# nCr(n, r, m)
mod = 1000000007
n = len(s) + k

fac = [1,1] # 階乗 n!
inv = [0,1] # 逆元 1/n
finv = [1,1] # 逆元の階乗 (n^-1)! = (1/n)!

for i in range(2, n+1):
    fac.append( (fac[-1] * i ) % mod )
    inv.append( (-inv[mod%i] * (mod//i)) % mod )
    finv.append( (finv[-1] * inv[-1]) % mod )

def nCr(n, r, m):
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m

i25, i26 = [1], [1]
for _ in range(k):
    i25.append(i25[-1] * 25 % mod)
    i26.append(i26[-1] * 26 % mod)

n = len(s)
ans = 0
for i in range(k+1):
    ans += i25[i] * i26[k-i] * nCr(i+n-1, n-1, mod)
    ans %= mod
print(ans)


Measured memory_bytes: 244184
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    int n;
    cin>>n;
    int ans=(n+1000-1)/1000;
    ans=ans*1000-n;
    cout<<ans<<endl;
}

Measured memory_bytes: 3192
import math
N = int(input())
x = list(map(int, input().split()))
kyori = [x[i + 1] - x[i] for i in range(N - 1)]
MOD = 10 ** 9 + 7
kai = [0] * (N + 1)
kai[0] = 1
for i in range(1, N + 1):
    kai[i] = (kai[i - 1] * i) % MOD
c = [0] * N
c[0] = 0
for i in range(1, N):
    c[i] = ((kai[N - 1] * pow(i, MOD - 2, MOD) % MOD) + c[i - 1]) % MOD
ans = 0
for i in range(N - 1):
    ans = (ans + kyori[i] * c[i + 1] % MOD) % MOD

print(ans)

Measured memory_bytes: 20708
#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset> 
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
 
template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod 
	ll ans=1;
	while(n){
		if(n&1) ans=(ans*a)%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
const int maxn=200000+100;
ll n,a[maxn];
vector<ll> ans;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
	read(n);rep(i,1,n) read(a[i]);
	int tmp=0;
	rep(i,1,n) tmp^=a[i];
	rep(i,1,n){
		ans.push_back(tmp^a[i]);
	}
	rep(i,0,ans.size()-1){
		if(i) putchar(' ');
		write(ans[i]);
	}
	//===========================================================
	return 0;
}

Measured memory_bytes: 6732
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
            b[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int result = 0;
        for (int i = 0; i < n; i++) {
            if (h <= a[i] && w <= b[i]) {
                result++;
            }
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 24000
import java.util.*;

import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	boolean[][] map = new boolean[50][50];
	int[] dx = {-1, -1, -1, 0, 0, 1, 1, 1};
	int[] dy = {-1, 0, 1, -1, 1, -1, 0, 1};
	int w, h;
	
	void dfs(int x, int y) {
		map[x][y] = false;
		for (int k = 0; k < 8; k++) {
			if (x+dx[k] >= 0 && x+dx[k] < h && y+dy[k] >= 0 && y+dy[k] < w 
					&& map[x+dx[k]][y+dy[k]]) {
				dfs(x+dx[k], y+dy[k]);
			}
		}
	}
	
	void run() {
		while (true) {
			w = sc.nextInt(); h = sc.nextInt();
			if (w == 0) break;
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++)
					map[i][j] = (sc.nextInt() == 1);
			
			int ans = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (map[i][j]) {
						ans++;
						dfs(i, j);
					}
				}
			}
			out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 43360
def judge(n):
    global num_of_split
    if n==0:
        return
    elif n%2==0:
        num_of_split+=1
        judge(n//2)
    else:
        judge(n-1)

num_of_split=0
H=int(input())
judge(H)
print(pow(2,num_of_split+1)-1)

Measured memory_bytes: 3060
import sys
import queue

N = 3

f = ''.join(sys.stdin.readline().split())
f += ''.join(sys.stdin.readline().split())
f += ''.join(sys.stdin.readline().split())

dd = [[-1, 0], [0, -1], [1, 0], [0, 1]]

Q = [[f,f.index('0'),0]]
V = { f: True }

while len(Q)>0:
    u = Q.pop(0)
    if u[0] == '123456780':  break
    sx, sy = u[1]//N, u[1]%N
    for dx, dy in dd:
        tx, ty = sx+dx, sy+dy
        if tx<0 or ty<0 or tx>=N or ty>=N: continue
        v = u[:]
        n1, n2 = u[1], tx*N+ty
        v[1] = n2
        if n1>n2: n1, n2 = n2, n1
        v[0] = v[0][0:n1]+v[0][n2]+v[0][n1+1:n2]+v[0][n1]+v[0][n2+1:]
        if not V.get(v[0], False):
            V[v[0]] = True
            v[2] += 1 # dir[r]                                                       
            Q.append(v)

print(u[2])


Measured memory_bytes: 34452
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	ll k; cin>>k;
	n = n%k;
	n = n<abs(n-k) ? n :abs(n-k);
	cout<<n<<endl;
	return 0;
}


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

using namespace std;

using int64 = long long;

int main() {
  int n;
  cin >> n;
  int m = n, s = 0;
  while(m > 0) {
    s += m % 10;
    m /= 10;
  }
  if(n % s == 0) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
キュー　queue<int> q;
   q.push(7);　//７が入る
   cout << q.front() << endl;  // 先頭の値を出力
   q.pop();  // 先頭の値を削除
   q.empty();
*/
//座標　corrdinateト深さヲ保持スルタメノ構造体
struct Coor{
  ll y;
  ll x;
  ll depth;
};
 ll N,M;  
 ll sy,sx,gy,gx;
 ll y,x,depth;//キューから取り出した座標
vector<string> vec;
queue<Coor> q;
vector<ll> y_vec={0,0,-1,+1};//technique
vector<ll> x_vec={-1,+1,0,0};

int BFS(){
  while(!q.empty()){
    Coor now=q.front();q.pop();//キューの先頭を取り出す
    y=now.y,x=now.x,depth=now.depth;
    
    //停止条件
    if(y==gy&&x==gx){return depth;}
    
    //上下左右４方向を探索、進むことができればキューに格納
    for(int i=0;i<4;i++){
      Coor next={y+y_vec[i],x+x_vec[i],depth+1};
      if(0<=next.y&&next.y<=N-1&&0<=next.x&&next.x<=M-1&&vec[next.y][next.x]=='.'){
        vec[next.y][next.x]='x';//同じ場所を探索しないようにする
        q.push(next);
      }
    }
  }
  return 0;
}
                   
  


int main(void){
cout<<fixed<<setprecision(14);
//cin.tie(0); ios::sync_with_stdio(false);

ll N;cin>>N;
  cout<<N/3<<endl;
 

  
  
}



Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $b);
switch ($b) {
    case 'A':
        echo 'T';
        break;
    case 'T':
        echo 'A';
        break;
    case 'C':
        echo 'G';
        break;
    case 'G':
        echo 'C';
        break;
}

Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

void bubS(vector<int> &data){
	int count = 0;
	for (int i = 0; i < data.size(); ++i){
		for (int j = data.size() - 1; j > i; --j){
			if (data[j] < data[j-1]){
				swap(data[j], data[j - 1]);
				count++;
			}
		}
	}
	for (int i = 0; i < data.size(); ++i){
		cout << data[i];
		if (i == data.size() - 1) cout << endl;
		else cout << " ";
	}
	cout << count << endl;
}


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

	bubS(data);
}

Measured memory_bytes: 3092
#include <iostream>
using namespace std;
int main(void){
    
  int N, quo, rem;
  
  cin >> N;
  
  quo = N / 111;
  rem = N % 111;
  
  if(rem == 0) cout << N << endl;
  else cout << (quo + 1) * 111 << endl;
  
  return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;
 
#define Endl endl
 
map<string, string> mp, mpg, mpa;
 
 
/*--------------------template--------------------*/
 
 
int main() {
    string t;
    vs v;
    cin >> s >> t;
    if (t.size() > s.size()) {
        cout << "UNRESTORABLE" << Endl;
        return 0;
    }
    REP(i, s.size() - t.size()+1) {
        REP(j, t.size()) {
            string a;
            if (j == t.size() - 1) {
                if (s[i + j] == t[j] || s[i + j] == '?') {
                    REP(k, i) {
                        a.push_back(s[k]);
                    }
                    REP(k, t.size()) {
                        a.push_back(t[k]);
                    }
                    FOR(k, i + t.size(), s.size()) {
                        a.push_back(s[k]);
                    }
                    v.push_back(a);
                    a.clear();
                }
            }
 
            if (s[i+j] == t[j] || s[i+j] == '?') {
                continue;
            } else {
                break;
            }
        }
    }
    if (v.size() == 0) {
        cout << "UNRESTORABLE" << Endl;
    } else {
        sort(ALL(v));
        REP(i, v[0].size()) {
            if (v[0][i] != '?') {
                cout << v[0][i];
            } else {
                cout << 'a';
            }
        }
    }
    
    
 
 
}

Measured memory_bytes: 256