akhauriyash/Code-Regression huggingface dataset:
local n, l = io.read("*n", "*n")
local t = {}
for i = 1, n do
  t[i] = i + l - 1
end
local rm = t[1]
local sum = 0
for i = 1, n do
  sum = sum + t[i]
  if math.abs(t[i]) < math.abs(rm) then
    rm = t[i]
  end
end
print(sum - rm)


Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            
            while((line = stdReader.readLine()) != null) {
                String[] input = line.split(" ", 0);
                int h = Integer.parseInt(input[0]);
                int w = Integer.parseInt(input[1]);
                
                if(h == 0 && w == 0) {
                    break;
                }
                for(int i = 0; i < h; i++) {
                    for(int j = 0; j < w; j++) {
                        // ??????????????¨????????????????????????#
                        if(i == 0 || i == (h - 1)) {
                            System.out.print("#");
                        } else if(j == 0 || j == (w - 1)) {
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }
            stdReader.close();
        } catch(Exception e) {
            e.getStackTrace();
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 30184
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int N,sum = 0;
	cin >> N;
	int B[150];
	for (int i = 0; i < N-1; i++)
	{
		cin >> B[i];
	}
	sum += B[0];
	for (int i = 1; i < N-1; i++)
	{
		sum += min(B[i], B[i - 1]);
	}
	sum += B[N - 2];
	cout << sum;
}



Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    
    if((a * b) % 2 == 0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
    }
  }
}

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

int main()
{
  int a,b,c,n;
  cin>>a>>b>>c>>n;
  int x=0,y=0;
  while(b<=a)b*=2,x++;
  while(c<=b)c*=2,y++;

  
  if(x+y<=n)cout<<"Yes\n";
  else cout<<"No\n";
}

Measured memory_bytes: 3616
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val XS = readLine()!!.split(" ").map(String::toInt)
    val P = XS.average()

    var min = Int.MAX_VALUE

    val floor = Math.floor(P).toInt()
    val ceil = Math.ceil(P).toInt()

    min = Math.min(XS.map { (it - floor) * (it - floor) }.sum(), min)
    min = Math.min(XS.map { (it - ceil) * (it - ceil) }.sum(), min)

    println(min)
}





Measured memory_bytes: 37996
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        S: String,
    }
    let mut ret = 700;
    for c in S.chars() {
        if c == 'o' {
            ret += 100;
        }
    }

    println!("{}", ret);

}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
typedef long long ll;
const int INF = 1001001001;
const int mod = 1000000007;

void dfs(int x, int y) {}

int main() {
    int N;
    cin >> N;
    vector<int> T(N);
    rep(i, N) cin >> T[i];
    int M;
    cin >> M;
    vector<int> P(M), X(M);
    rep(i, M) cin >> P[i] >> X[i];

    int sum = 0;
    rep(i, N){
        sum += T[i];
    }

    rep(i, M){
        int opt = sum - T[P[i]-1] + X[i];
        cout << opt << endl;
    }
    return 0;

    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
int a[4][3][10]={0};
int i,n,tou,kai,heyaban,nyuukyosya,j,k;

scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d %d %d",&tou,&kai,&heyaban,&nyuukyosya);
a[tou-1][kai-1][heyaban-1]+=nyuukyosya;}


for(i=0;i<4;i++){
 for(j=0;j<3;j++){
   for(k=0;k<10;k++){

printf(" %d",a[i][j][k]);

}
printf("\n");
}
if(i<3){printf("####################\n");}
}



return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;


int N;
string S;
vint idx[26];
int dp[2222][2222];

const int INF=1001001001;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

int uku[26][2222];
int beet[26][2222];

signed main(){
    cin>>S;
    N=S.size();

    fill_n(*uku,26*2222,INF);
    fill_n(*beet,26*2222,-1);

    rep(i,N){
        uku[S[i]-'a'][i]=i;
        beet[S[i]-'a'][i]=i;
    }
    for(int k=0;k<26;k++)for(int i=N-1;i>=0;i--)chmin(uku[k][i],uku[k][i+1]);
    for(int k=0;k<26;k++)for(int i=0;i<N;i++)chmax(beet[k][i+1],beet[k][i]);

    rep(i,N){
        dp[i][i]=1;
        dp[i][i+1]=2;
    }

    vint s(26),t(26);

    for(int len=2;len<=N;len++){
        for(int i=0;i+len<=N;i++){
            int j=i+len;
            dp[i][j]=1;
            rep(k,26){
                s[k]=uku[k][i];
                t[k]=beet[k][j-1];
            }
            rep(k,26){
                if(i<=s[k]&&s[k]<j)dp[i][j]++;
                if(j<=s[k])continue;
                if(s[k]>=t[k])continue;
                add(dp[i][j],dp[s[k]+1][t[k]]);
            }
        }
    }
    cout<<(dp[0][N]-1+mod)%mod<<endl;
    return 0;
}



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

int main(){
  int i,N,H[100001] ;
  int n,m ;

  cin >> N ;

  for(i=0;i<N;i++){
    cin >> H[i] ;
  }

  n=0 ;
  m=0 ;

  for(i=0;i<N-1;i++){
    if(H[i]>=H[i+1]) m++ ;
    else {
      if(n<=m){
        n=m;
      }
      m=0 ;
    }

    if(i == N-2 && n<=m) n=m ; 
  }

  cout << n ;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  
        static StringBuilder a = new StringBuilder();
        static StringBuilder b = new StringBuilder();
        static StringBuilder c = new StringBuilder();
	
	public static void main(String[] args) {
      
		Scanner sc = new Scanner(System.in);   
      
        a.append(sc.next());
        b.append(sc.next());
        c.append(sc.next());
      
        char tmp = a.charAt(0);
        a.deleteCharAt(0);
      
        Main.nextTurn(tmp);
        
       
	} 
  
    public static void nextTurn(char card) {
        if (card == 'a') {
           if(a.length() == 0) {
             System.out.println("A");
             return;
           }
          
           //System.out.println("Turn A"); //最後に消す
           char tmp = a.charAt(0);
           a.deleteCharAt(0);
                     
           Main.nextTurn(tmp);
          
        } else if (card == 'b') {
           if(b.length() == 0) {
             System.out.println("B");
             return;
           }
          
           //System.out.println("Turn B"); //最後に消す
           char tmp = b.charAt(0);
           b.deleteCharAt(0);
          
           Main.nextTurn(tmp);
        } else if (card == 'c') {
           if(c.length() == 0) {
             System.out.println("C");
             return;
           }
          
           //System.out.println("Turn C"); //最後に消す
           char tmp = c.charAt(0);
           c.deleteCharAt(0);
          
           Main.nextTurn(tmp);
        }
    }
}

Measured memory_bytes: 22996
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 50
#define LARGENUM 1000000007
#define INF 9223372036854775807
#define ull unsigned long long 
typedef pair <int, int> P;

int main(){
    int L, R, d, n = 0;
    cin >> L >> R >> d;
    for (int i = L; i <= R; i++){
        if (i % d == 0) n++;
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <typeinfo>

using namespace std;

int main(void){
    int a, b;
    int maxCount;
    vector<int> vc;
    vector<int> vc2;
    vector<int>::iterator itr;
    scanf("%d", &a);
    int temp;
    for(int i = 0; i < a; i++){
        cin >> temp;
        vc.emplace_back(temp);
    }
    copy(vc.begin(), vc.end(), back_inserter(vc2));
    auto maxElem = max_element(vc.begin(), vc.end());
    maxCount = count(vc.begin(), vc.end(), *maxElem);
    if(maxCount > 1){
        for(int i = 0; i < a; i++){
            cout << *maxElem << endl;
        }
    }
    else{
        sort(vc.begin(), vc.end());
        vector<int>::iterator uniqu_finish = unique(vc.begin(), vc.end());
        vc.erase(uniqu_finish, vc.end());
        auto maxIndex = max_element(vc.begin(), vc.end());
        vc.erase(maxIndex);
        auto maxIndex2 = max_element(vc.begin(), vc.end());
        for(auto it = vc2.begin(); it != vc2.end(); it++) {
            if (*it != *maxIndex) {
                cout <<  *maxIndex << endl;
            } else {
                cout <<  *maxIndex2 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main(){
	int n;
	
	while(1){
		int temp[55],s,e;
		cin >> n;
		if(!n) break;
		
		for(int i=0;i < n;i++)cin >> temp[i];
		
		for(int i=0;i < n;i++){
			int j;
			s = e = temp[i];
			for(j=i+1;j < n;j++) if(temp[j] != temp[j-1] + 1) break;
			e = temp[j-1];
			i = j-1;
			if (s != temp[0]) printf(" ");
			if (s == e) cout << s;
			else printf("%d-%d",s,e);
		}
		
		puts("");
		
	}
	
	return 0;
}

Measured memory_bytes: 0
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
import numpy as np
kx = np.array(read().split(),np.int32)
a = kx[::2]
b = kx[1::2]
a.sort()
b.sort()
if n%2 == 1:
  L = a[n//2]
  R = b[n//2]
  ans = R-L+1
else:
  LL = a[n//2-1]
  LR = b[n//2-1]
  RL = a[n//2]
  RR = b[n//2]
  ans = RR+LR-LL-RL+1
print(ans)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, x;

int main() {
    scanf("%d", &n);
    int ans = 0;
    forn(i, n) {
        scanf("%d", &x);
        while (x % 2 == 0) {
            x /= 2;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
li = list(map(int,input().split()))
n=li[0]
ans = 0

def asd(x):
    global ans
    if x>0:
        for i in range(0,35):
            max = 0
            l=0
            for j in range (0,i,2):
                max += pow(-2,j)
            if max >= x:
                ans += pow(10,i-1)
                #print(pow(-2,i-1))
                return asd(x-(pow(-2,i-1)))
                #asd(x-pow(-2,i-1))
    elif x<0:
        for i in range(0,35):
            min =0
            for j in range (1,i,2):
                min += pow(-2,j)
            if min <= x:
                ans += pow(10,i-1)
                #print(pow(-2,i-1))
                return asd(x-(pow(-2,i-1)))
                
                


    elif x==0:
        return 0
asd(n)
print(ans)
    

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

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

print(ceil((B-1)/(A-1)))


Measured memory_bytes: 64620
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll x;
	cin>>x;
	ll ans = 1000*(x/500);
	x = x%500;
	ans += 5*(x/5);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import fractions
def answer(x, i, j):
    lcm = (i * j) // fractions.gcd(i, j)
    xi = x // i
    xj = x // j
    xlcm = x // lcm
    return x - xi - xj + xlcm
a, b, c, d = map(int, input().split())
ans = answer(b, c, d) - answer(a-1, c, d)
print(ans)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long i = 1; i < (long)(n); i++)
int main() {
  long a,b;
  cin>>a>>b;
  long A=a;
  long gcd=1;
  if(a>b){
    a=b;
    b=A;
  }
  rep(i,a+1){
    if(a%i==0 && b%i==0) gcd=i;
  }
  cout<<a*b/gcd<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,k,q,a;
    cin>>n>>k>>q;
    vector<ll> c(n,0);
    for(ll i=0;i<q;i++){
        cin>>a;
        c[a-1]++;
    }
    if(k>q){
        for(ll i=0;i<n;i++){
            cout<<"Yes"<<endl;
        }
    }else{
        for(ll i=0;i<n;i++){
            if(c[i]>=q-k+1){
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))
q = int(input())
s = [list(map(int, input().split())) for i in range(q)]

ans = sum(a)
from collections import Counter
cnt = Counter(a)

for i, j in s: 
    if j in cnt:
        cnt[j] += cnt[i]
    else:
        cnt[j] = cnt[i]    
    ans = ans - i * cnt[i] + cnt[i] * j
    if i in cnt:
        #cnt.pop(i)
        cnt[i] = 0
    print(ans)

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

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

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

    sort(a, a + n);

    int i;
    for (i = 0; i < n; i++) {
        x -= a[i];
        if (x < 0) {
            break;
        }
    }

    if (i == n && x > 0) i--;

    cout << i << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#define EPS 1e-10
struct vektor{
	double x,y;
	vektor(){}
	vektor(double xx,double yy){
		x=xx;
		y=yy;
	}
	double add(double a,double b){
		if(fabs(a+b)<EPS*(fabs(a)+fabs(b)))return 0;
		return a+b;
	}
	vektor operator +(vektor v){
		return vektor(x+v.x,y+v.y);
	}

	vektor operator -(vektor v){
		return vektor(x-v.x,y-v.y);
	}
	vektor operator *(double d){
		return vektor(x*d,y*d);
	}
	double dot(vektor v){
		return add(x*v.x,y*v.y);
	}
	double det(vektor v){
		return add(x*v.y,-y*v.x);
	}
};

bool on_seg(vektor p1,vektor p2,vektor q){
	return fabs((p1-q).det(p2-q))==0 && (p1-q).dot(p2-q)<=0;
}
vektor intersection(vektor p1,vektor p2,vektor q1,vektor q2){
	return p1+(p2-p1)*((q2-q1).det(q1-p1)/(q2-q1).det(p2-p1));
}

int n;
vektor vek[5];

bool check(){
	vektor v[5];
	for(int i=1;i<=4;i++){
		v[i]=vek[i]-vek[0];
	}
	double s=(v[3].x*v[2].y-v[3].y*v[2].x)/(v[1].x*v[2].y-v[1].y*v[2].x);
	double t=(v[3].x*v[1].y-v[3].y*v[1].x)/(v[1].y*v[2].x-v[1].x*v[2].y);
	int data3,data4;
	if(s>0 && t>0 && s+t<1)data3=1;
	else data3=-1;
	s=(v[4].x*v[2].y-v[4].y*v[2].x)/(v[1].x*v[2].y-v[1].y*v[2].x);
	t=(v[4].x*v[1].y-v[4].y*v[1].x)/(v[1].y*v[2].x-v[1].x*v[2].y);
	if(s>0 && t>0 && s+t<1)data4=1;
	else data4=-1;
	return data3*data4<0;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		for(int j=0;j<5;j++){
			scanf("%lf %lf",&vek[j].x,&vek[j].y);
		}
		bool flag=check();
		printf("%s\n",flag?"OK":"NG");
	}
	return 0;
}

Measured memory_bytes: 1048
#include <bits/stdc++.h>
using namespace std;
const int N=100005,mod=998244353;
int n,a[N];
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int main(){
	cin >> n;
	for (int i=0;i<n;i++)
		cin >> a[i];
	sort(a,a+n);
	int ans=1;
	for (int i=0;i<n;i++)
		ans=1LL*ans*gcd(a[i],i)%mod;
	cout << ans;
	return 0;
}

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

int main()
{
	long long int A,B,K;
	cin>>A>>B>>K;
	long long int temp;
	temp=K-A;
	if(temp>0)
	{
		A=0;
		
		long long int temp2=temp-B;
		if(temp2>=0)
		{
			cout<<0<<" "<<0<<endl;
		}
		else
		{
			cout<<0<<" "<<B-temp<<endl;
		}


	}
	else
	{
		A=A-K;
		cout<<A<<" "<<B<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <cstring>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int build[110][110] = {};

int dx[2][6] = {{0, 1, 0, -1, -1, -1}, {1, 1, 1, 0, -1, 0}};
int dy[6] = {-1, 0, 1, 1, 0, -1};
int w, h;

ll dfs(int x, int y){
	ll res = 0;
	if(build[x][y] == 2) return 0;
	build[x][y] = 2;
	REP(i, 6){
		int tx = x+dx[y%2][i], ty = y+dy[i];

		if(tx < 0 || w+1 < tx || ty < 0 || h+1 < ty) continue;

		if(build[tx][ty] == 1) res++;
		else if(build[tx][ty] == 0) res += dfs(tx, ty);
	}
	return res;
}

int main(void){
	cin >> w >> h;
	FOR(i, 1, h+1){
		FOR(j, 1, w+1){
			cin >> build[j][i];
		}
	}
	cout << dfs(0, 0) << endl;
}

Measured memory_bytes: 3368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b;
  cin >> a >> b;
  cout << a * b << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int i,j,k;
map<vector<vector<int> > , int> memo;

bool is_goal(vector<vector<int> > inans){
	vector<vector<int> > ans(2, vector<int>(4));	//テ・ツ按敕ヲツ慊淌・ツ個姪・ツソツ?ゥツ??
	for(i=0; i<8; i++){
			int x = i % 4;
			int y = i / 4;
			ans[y][x] = i;
	}
	//cout << "goalテ・ツョツ淌ィツ。ツ? <<endl;
	if(inans == ans)	return true;
	return false;
}
/*
void checker(vector<vector<int>> check, string str, int i){
	cout << str << " , " << i << endl;
	for(i=0; i<8; i++){
			int x = i % 4;
			int y = i / 4;
			cout << "check[" << y << "][" << x << "]=" << check[y][x] <<endl;
	}
	cout << " " << endl;
}
*/

int BFS(vector<vector<int> > inans){

	memo[inans] = 0;
	queue<vector<vector<int> > > q;
	q.push(inans);

	while( !q.empty() ){
		vector<vector<int> > now = q.front();
		q.pop();
	//					checker(now,"now",500);
	//	if(is_goal(now) == true)	return memo[now];

		int nowcost = memo[now];
	//					cout << "nowcost = " <<nowcost <<endl;

		//vector<vector<int>> next = now;

		for(i=0; i<8; i++){
			int x = i % 4;
			int y = i / 4;
			//left
			if(x != 0 && now[y][x]==0){
				swap(now[y][x-1] , now[y][x]);
				while( !memo.count(now) ){
					memo[now] = nowcost + 1;
					q.push(now);
				}
	//			checker(now,"left",i);
				swap(now[y][x-1] , now[y][x]);
			}
			//down
			if(y != 1 && now[y][x]==0){
				swap(now[y+1][x] , now[y][x]);
				while( !memo.count(now) ){
					memo[now] = nowcost + 1;
					q.push(now);
				}
	//			checker(now,"down",i);
				swap(now[y+1][x] , now[y][x]);
			}
			//right
			if(x != 3 && now[y][x]==0){
				swap(now[y][x+1] , now[y][x]);
				while( !memo.count(now) ){
					memo[now] = nowcost + 1;
					q.push(now);
				}
	//			checker(now,"right",i);
				swap(now[y][x+1] , now[y][x]);
			}
			//up
			if(y != 0 && now[y][x]==0){
				swap(now[y-1][x] , now[y][x]);
				while( !memo.count(now) ){
					memo[now] = nowcost + 1;
					q.push(now);
				}
	//			checker(now,"up",i);
				swap(now[y-1][x] , now[y][x]);
			}
		} //cout << q.size() <<endl;
	}
	return -1;
}



int main()
{
	    vector<vector<int> > a(2, vector<int>(4)); 
        for(i = 0; i < 8; i++){ 
            int xx = i % 4, yy = i / 4; 
            a[yy][xx] = i; 
        } 
        // テ・ツケツ?・ツ?ェテ・ツ?暗ヲツ篠「テァツエツ「 (テヲツ慊?・ツ按敕」ツ?ォテ」ツ?凖」ツ?ケテ」ツ?ヲテ」ツ?ョティツァツ」テ」ツつ津ヲツアツづ」ツつ?」ツ?ヲテ」ツ?甘」ツ?? 
        int ans = BFS(a); 
		
		


	vector<vector<int> > in(2, vector<int>(4));	//テ・ツ按敕ヲツ慊淌・ツ個姪」ツ?療」ツ?ェテ」ツ??」ツ?ィテ」ツつィテ」ツδゥテ」ツδシテ・ツ?コテ」ツつ?
	while(cin >> in[0][0]){
		for(i=1; i<8; i++){
			int x = i % 4;
			int y = i / 4;
			cin >> in[y][x];
		}
	//	checker(in,"first",100);
		cout << memo[in] << endl;
	}
}

Measured memory_bytes: 5352
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    int c = 0;
	    if(n==0) {
		break;
	    }
	    else if(n==6174){
		System.out.println(c);
	    }
	    else{
		while(n!=6174){
		    c++;
		    int[] num = new int[4];
		    num[0] = (n/1000);
		    num[1] = (n-num[0]*1000)/100;
		    num[2] = (n-num[0]*1000-num[1]*100)/10;
		    num[3] = n-num[0]*1000-num[1]*100-num[2]*10;
		    
		    //System.out.println(num[0]+" "+num[1]+" "+num[2]+" "+num[3]);

		    if(num[0]==num[1] && num[2]==num[3] && num[1]==num[2]){
			System.out.println("NA");
			break;
		    }
		    else{
			//テ」ツつステ」ツδシテ」ツδ?
			for(int i=0; i<num.length; i++){
			    for(int j=i; j<num.length; j++){
				if(num[i]<num[j]){
				    int w = num[i];
				    num[i] = num[j];
				    num[j] = w;
				}
			    }
			}
			//ティツィツ暗ァツョツ?
			int L = num[0]*1000 + num[1]*100 + num[2]*10 + num[3];
			int S = num[3]*1000 + num[2]*100 + num[1]*10 + num[0];
			n = L-S;
			//System.out.println(n);
		    }
		}
		if(n==6174) System.out.println(c);
	    }
	}
    }
}

Measured memory_bytes: 35136
N = int(input())

s = input().split()
A = []
for i in range(N):
  A.append(int(s[i]))

result = 1

if 0 in A:
  result = 0
else:
  for i in range(N):
    result = result * A[i]
    if result > 10**18:
      result = -1
      break

print(result)

Measured memory_bytes: 21648
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;

int main() {
    ll N, K;
    ll ans;
    cin >> N;
    if(400 <= N && N <= 599){
        ans = 8;
    }
    else if(600 <= N && N <= 799){
        ans = 7;
    }
    else if(800 <= N && N <= 999){
        ans = 6;
    }
    else if(1000 <= N && N <= 1199){
        ans = 5;
    }
    else if(1200 <= N && N <= 1399){
        ans = 4;
    }
    else if(1400 <= N && N <= 1599){
        ans = 3;
    }
    else if(1600 <= N && N <= 1799){
        ans = 2;
    }
    else{
        ans = 1;
    }

    cout << ans << endl;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a.begin(), a.end())

int main(){
    int n, taro = 0, hana = 0;
    cin >> n;
    rep(i,n){
        string t, h;
        cin >> t >> h;
        if(t == h){
            taro++;
            hana++;
        }

        else if(t < h)hana += 3;
        else if(t > h)taro += 3;
    }

    printf("%d %d\n", taro, hana);
    return 0;
}


Measured memory_bytes: 3248
#include<iostream>
#include<string>
#include<set>
using namespace std;
int main(){
int K,A,B;
cin >> K >> A >> B;
int C = A/K + 1;
if(B>=C*K || A%K == 0){
cout << "OK";
}
else{
cout << "NG";
}
  return 0;
}


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int n;
	int i, j;
	int sum;
	int tmp;
	int a[5000];

	while (1){
		scanf("%d", &n);

		if (n == 0){
			break;
		}

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

		sum = -100001;

		for (i = 0; i < n; i++){
			tmp = 0;
			for (j = i; j < n; j++){
				tmp += a[j];

				if (sum < tmp){
					sum = tmp;
				}
			}
		}

		printf("%d\n", sum);
	}

	return (0);
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

int main(){
	int N; cin >> N;
	string si[N];
	int s = 0;
	vector<P> ar2;
	vector<PP> ar1;
	rep(i, N){
		cin >> si[i];
		int n = 0, mi = 0;
		rep(j, si[i].size()){
			if(si[i][j] == '(') n++;
			else n--;
			chmin(mi, n);
		}
		mi = -mi;
		if(n < 0) ar1.pb({mi+n, {mi, n}});
		else ar2.pb(P(mi, n));
		s += n;
	}
	if(s != 0){
		cout << "No" << endl;
		return 0;
	}
	int ch = 0;
	sort(all(ar2));
	rep(i, ar2.size()){
		if(ch - ar2[i].first < 0){
			cout << "No" << endl;
			return 0;
		}else{
			ch += ar2[i].second;
		}
	}
	sort(all(ar1), greater<PP>() );
	rep(i, ar1.size()){
		if(ch - ar1[i].second.first < 0){
			cout << "No" << endl;
			return 0;
		}else{
			ch += ar1[i].second.second;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 54412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  std::string s;
  cin>>s;
  if((s[0]!=s[1])||(s[0]!=s[2])||(s[1]!=s[2])){
    cout<<"Yes"<<"\n";
  }
  else{
    cout<<"No"<<"\n";
  }
return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI p10;
in cnt(in dc, in d, bool fst){
  if(dc==0){
    if(d==0)
      return 1;
    return 0;
  }
  if(dc==1){
    if(d==0)
      return 10;
    return 0;
  }
  in wy=0;
  in vl=0;
  in gl;
  vl=p10[dc-1]-1;
  gl=d%10;
  gl+=10;
  gl%=10;
  VI cn;
  for(in c=-9;c<=9;++c){
    if((vl%10*c%10+10)%10==gl)
      cn.PB(-c);
  }
  if(cn.empty())
    return 0;
  in tw=0;
  forv(z,cn){
    in df=cn[z];
    tw=0;
    for(in v1=(fst?1:0);v1<=9;++v1){
      if(v1+df>=0 && v1+df<=9 &&(!fst || v1+df>0))
    	++tw;
    }
    wy+=tw*cnt(dc-2,(d+df*vl)/10,0);
  }
  return wy;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  p10.PB(1);
  forn(i,18)
    p10.PB(p10[i]*10);
  in d;
  cin>>d;
  in sm=0;
  for(in dc=2;dc<=18;++dc){
    sm+=cnt(dc,d,1);
  }
  cout<<sm<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <string>
#include<iomanip>
#include<limits>
using namespace std;
int main(void){
   int A,B;
   cin>>A>>B;
   int unuse=0;
   for(int i=0;i<30;i++){
       unuse=i*(A-1)+1;
       if(unuse>=B){
           cout<<i<<endl;
           return 0;
       }
   }
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

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

    int ans = 0;
    for (int i = a; i <= b; ++i) {
        int k = i % 10, l = i / 10 % 10, m = i / 1000 % 10, n = i / 10000;
        if(k == n && l == m) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let a: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let l = a.iter().fold(0, |res, &x| if x == res + 1 { x } else { res });
    let ans = if l == 0 { -1 } else { N - l };

    println!("{}", ans);
}

Measured memory_bytes: 10492
#include<iostream>
using namespace std;
int a[20],n=0,num;
int main(){
  cin>>num;
  for(int i=0;i<num;i++){
  	cin>>a[i];
  }
  
  for(int i=1;i<num-1;i++){
  	if(a[i]>a[i-1]&&a[i]<a[i+1]){
      n++;
    }else if(a[i]<a[i-1]&&a[i]>a[i+1]){
      n++;
    }
  }
  cout<<n;
}

Measured memory_bytes: 256
Matches = {num: c for num, c in zip([1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 5, 5, 4, 5, 6, 3, 7, 6])}


def solve(N, M, As):
    dp = [-1 for _ in range(N + 1)]
    dp[0] = 0
    for i in range(N):
        for a in sorted(As, reverse=True):
            c = Matches[a]
            if dp[i] == -1:
                continue
            if i + c <= N:
                dp[i + c] = max(dp[i+c],
                                dp[i] * 10 + a)
    return dp[N]

if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, M, As))


Measured memory_bytes: 52444
n=int(input())
a=[int(j) for j in input().split()]
a.sort()
ans=[]
p=a[0]
q=a[-1]
for i in a[1:-1]:
    if i<0:
        ans.append([q,i])
        q-=i
    else:
        ans.append([p,i])
        p-=i
ans.append([q,p])
print(q-p)
for i,j in ans:
    print(i,j)


Measured memory_bytes: 23108
import sys
#import copy
#import math
#import numpy as np
#import itertools
#import collections
#from collections import deque
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#import functools

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    # input
    N = int(input())
    A = list(map(int, readline().split()))

    buka = [[] for i in range(N-1)]
    for i in range(N-1):
        buka[A[i]-1].append(i)

    for p in buka:
        print(len(p))
    print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44068
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

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

  int a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	int N, K;
	cin >> N >> K;
	int V = 1;
	for (int i = 0; i < N; i++)
	{
		V = V * 2 > V + K ? V + K : V * 2;
	}

	cout << V << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int main()
{	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int t;
	t=1;
	while(t--)
	{
		LL n;
		cin>>n;
		string s;
		cin>>s;
		LL count1=0,count2=0,count3=0;
		for(LL i=0; i<s.length(); i++)
		{
			if(s[i]=='W')
			count1++;
		}
		for(LL i=s.length()-1; count1>0; i--,count1--)
		{
			if(s[i]=='R')
			count2++;
		}
		cout<<count2<<"\n";
		
	
	}
}

Measured memory_bytes: 3760
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){var t=e.split("\n")[0].split(" "),r=Number(t[0]),n=Number(t[1]),o=Number(t[2]),u=Math.max(0,o-r+n);console.log(u)}},function(e,t){e.exports=require("fs")}]);

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

int a,b,c;

int main(){
    cin>>a>>b>>c;
    if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&b!=a)){printf("Yes\n");
    }else {printf("No");}
    return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0509-input.txt"));

		int[] s = new int[2];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 4; j++) {
				int x = scan.nextInt();
				s[i] += x;
			}
		}
		int max = -1;
		for (int i = 0; i < 2; i++)
			if (s[i] > max)
				max = s[i];

		System.out.println(max);

		scan.close();
		System.exit(0);
	}
}

Measured memory_bytes: 26304
#include<iostream>
#include<algorithm>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

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

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}
	vector<vector<int>> cnt(h, vector<int>(w));
	rep(i, h) {
		vector<int> done(w);
		rep(j, w) {
			if (s[i][j] == '#')continue;
			if (done[j])continue;
			int l = 0;
			while (j + l < w) {
				if (s[i][j + l] == '#')break;
				l++;
			}
			rep(k, l) {
				cnt[i][j + k] += l;
				done[j + k] = 1;
			}
		}
	}
	rep(i, w) {
		vector<int> done(h);
		rep(j, h) {
			if (s[j][w] == '#')continue;
			if (done[j])continue;
			int l = 0;
			while (j + l < h) {
				if (s[j + l][i] == '#')break;
				l++;
			}
			rep(k, l) {
				cnt[j + k][i] += l;
				done[j + k] = 1;
			}
		}
	}
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			ans = max(ans, cnt[i][j]-1);
		}
	}
	cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	set<int> num;
	for(int bit = 0; bit < 1 << n; bit++){
		int sum = 0;
		rep(i, n) {
			if(bit & 1 << i) sum += a[i];
		}
		num.insert(sum);
	}
	
	int q;
	cin >> q;
	rep(query, q) {
		int m;
		cin >> m;
		if(num.count(m)) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <queue>
#include <cassert>
 
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::swap;
using std::sort;
using std::vector;
using std::string;
using std::min;
using std::max;
using std::pair;
using std::set;
using std::map;
 
 
typedef long long ll;
const int MAXN = 100005;
const int INF = 1000000009;
 
vector<vector<int>> g;
 
int main() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    int n, m;
    cin >> n >> m;
    g.resize(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v; --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
 
 
    vector<int> q;
    for (int i = 0; i < g[0].size(); ++i) {
        q.push_back(g[0][i]);
    }
 
    for (auto v: q) {
        for (int u: g[v]) {
            if (u == n - 1) {
                cout << "POSSIBLE";
                return 0;
            }
        }
    }
 
    cout << "IMPOSSIBLE";
    return 0;
}

Measured memory_bytes: 12784
let quick_search str pat =
  let n_str = String.length str in
  let n_pat = String.length pat in
  let tbl = Array.init 256 (fun _ -> n_pat + 1) in
  String.iteri (fun i c -> tbl.(Char.code c) <- n_pat - i) pat;
  let rec doit i =
    if i >= (n_str - n_pat) then None
    else
      let rec scan i j =
        if String.get str (i + j) <> String.get pat j then None
        else if j = (n_pat - 1) then Some i
        else scan i (j + 1)
      in
      match scan i 0 with
      | None -> doit (i + tbl.(Char.code (String.get str (i + n_pat))))
      | ret -> ret
  in
  doit 0

let () =
  let s = read_line () in
  let l = read_line () in
  match quick_search (s^s) l with
  | None -> Printf.printf "No\n"
  | Some _ -> Printf.printf "Yes\n"

Measured memory_bytes: 2156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {
        Stdin stdin = new Stdin();
        int n = stdin.nextInt();
        int k = stdin.nextInt();

        List<List<Integer>> g = new ArrayList<>();
        for (int i = 0; i < n; i++) g.add(new ArrayList<>());
        for (int i = 0; i < n - 1; i++) {
            int a = stdin.nextInt() - 1;
            int b = stdin.nextInt() - 1;
            g.get(a).add(b);
            g.get(b).add(a);
        }

        long[] ans = new long[n];
        ans[0] = k;
        Deque<Tuple> stack = new ArrayDeque<>();
        stack.add(new Tuple(0, 0, -1));
        while (!stack.isEmpty()) {
            Tuple current = stack.pollLast();
            int brother = 0;
            for (int child : g.get(current.node)) {
                if (child == current.parent) continue;

                ans[child] = (current.depth == 0) ? k - brother - 1 : k - brother - 2;
                stack.add(new Tuple(child, current.depth + 1, current.node));
                brother++;
            }
        }

        BigInteger mod = BigInteger.valueOf(1_000_000_007);
        long sum = Arrays.stream(ans).mapToObj(BigInteger::valueOf).reduce(BigInteger.ONE, (x, y) -> x.multiply(y).mod(mod)).longValue();
        System.out.println(sum);
    }

    private static final class Tuple {
        private int node;
        private int depth;
        private int parent;
        public Tuple(int node, int depth, int parent) {
            super();
            this.node = node;
            this.depth = depth;
            this.parent = parent;
        }
    }


    private static final class Stdin {
        private BufferedReader stdin;
        private ArrayDeque<String> tokens;

        public Stdin() {
            this.stdin = new BufferedReader(new InputStreamReader(System.in));
            this.tokens = new ArrayDeque<>();
        }

        public String nextToken() throws IOException {
            if (tokens.isEmpty()) {
                for (String token : stdin.readLine().split(" ")) {
                    tokens.add(token);
                }
            }
            return tokens.poll();
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(nextToken());
        }

        public int nextLong() throws NumberFormatException, IOException {
            return Integer.parseInt(nextToken());
        }
    }
}

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

int main()
{
    string a,b;
    cin>>a>>b;
    int c=0,i,l=a.length();
    for(i=0;i<l;i++)
    {
        if(a[i]!=b[i])
            c++;
    }
    cout<<c<<endl;

}


Measured memory_bytes: 3924
import sys
input=sys.stdin.readline
n,k,q=map(int,input().split())
a=list(int(input()) for _ in range(q))

times = list(q for _ in range(n))

for i in range(q):
    times[a[i] - 1] -= 1

for i in range(n):
    if k > times[i]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 10476
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

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

int main() {
    int R,C;
    cin >> R >> C;

    vector<string> G(R);
    REP(i,R) cin >> G[i];

    int ans = 0;

    REP(sy,R) REP(sx,C) {

        vecveci dist(R,veci(C,-1));
        if(G[sy][sx] == '#') continue;
        dist[sy][sx] = 0;
        queue<P> que;
        que.push(P(sy,sx));

        while(!que.empty()) {
            P p = que.front();
            que.pop();
            int y = p.first;
            int x = p.second;
            REP(dir,4) {
                int ny = y + dy[dir];
                int nx = x + dx[dir];
                if(ny < 0 || ny >= R || nx < 0 || nx >= C) continue;
                if(G[ny][nx] == '#') continue;
                if(dist[ny][nx] != -1) continue;
                dist[ny][nx] = dist[y][x] + 1;
                que.push(P(ny,nx));
            }
        }

        REP(gy,R) REP(gx,C) chmax(ans,dist[gy][gx]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<int,int> e;	//<end,start>

bool insert(int x){
	//  [0]
	if(e.find(0)!=e.end())return false;

	auto itr = e.lower_bound(x);
	bool touchleft = (e.find(x-1)!=e.end());

	if(itr==e.end()){
		//  [  ]X #
		if(touchleft){
			e[x]=e[x-1];
			e.erase(x-1);
		}
		//  __X__#
		else e[x]=x;
		return true;
	}
	
	//  [left    right]
	int left=itr->second, right=itr->first;

	//  0[__X__ ]  or  0[  X]  [  ]
	if(left==1 && (x<right || (int)e.size()>1)) return false;

	if(left<=x){
		//  [   X]
		if(x==right)e.erase(itr);
		//  [__X ]
		else e[right] = x+1;
		return insert(left-1);
	}

	// __X__[  ]
	e[x]=x;

	// [  ]X__[  ]
	if(touchleft){
		e[x]=e[x-1];
		e.erase(x-1);
	}	

	//  X[  ]
	if(x==left-1){
		e[right] = e[x];
		e.erase(x);
	}
	return true;
}

int main(void){
	int n,x;
	cin>>n;
	while(n--){
		cin>>x;
		if(insert(x))cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 9832
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    val pos = IntArray(n)
    val neg = IntArray(n)
    for ((index, ai) in a.withIndex()) {
        if (index - ai >= 0) {
            neg[(index - ai).toInt()]++
        }
        if (index + ai < n) {
            pos[(index + ai).toInt()]++
        }
    }
    var sum = 0L
    for (i in 0 until n) {
        sum += neg[i].toLong() * pos[i].toLong()
    }
    println(sum)
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int a, b;
    bool point[N] = {false};
    bool flight[N] = {false};
    for (int i = 0; i < M; ++i) {
        cin >> a >> b;
        if (b == N) point[a] = true;
        if (a == 1) flight[b] = true;
    }
    bool ans = false;
    for (int i = 0; i < N; ++i) {
        if (point[i] && flight[i]) ans = true;
    }
    if (ans) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 640
import numpy as np

S = raw_input()
K = int(raw_input())

S_twice = S + S

A = np.full(len(S_twice),0)
A_twice = np.full(len(S_twice),0)

count = 0
for i in range(1, len(S)):
    if S[i] == S[i-1]:
        count = count + 1
    else:
        A[count] = A[count] + 1
        count = 0

A[count] = A[count] + 1

count = 0
for i in range(1, len(S_twice)):
    if S_twice[i] == S_twice[i-1]:
        count = count + 1
    else:
        A_twice[count] = A_twice[count] + 1
        count = 0

A_twice[count] = A_twice[count] + 1

if count == len(S_twice)-1:
    print len(S)*K/2
    exit()

A_k = A + (K-1)*(A_twice-A)

ans = 0

for i in range(1, A_k.shape[0]):
    ans = ans + (i+1)/2*A_k[i]

print int(ans)


Measured memory_bytes: 18536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define md 100001
#define mod 1000000000
int p[md + 2];
int main()
{
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; ++i)
		{
			cin >> a[i] >> b[i];
		}
	fill(p, p + h + 2, mod);
	p[0] = 0;
	for (int i = 0; i <= h; i++)
		{
			for (int j = 0; j < n; j++)
				{
					p[min(h, i + a[j])] = min(p[min(h, i + a[j])], p[i] + b[j]);
				}
		}
	cout << p[h] << endl;
}

Measured memory_bytes: 256