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

int main(){
    int K,A,B;
    int ans ,i = 1;
    cin >> K >> A >> B;
    while(ans <= B){
        ans = K*i;
        if(A <= ans && ans <=B){
            cout << "OK" << endl;
            return 0;
        }
        i++;
    }
    cout << "NG" << endl;
}

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

int main() {

    int n, m;
    cin >> n >> m;

    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++) {
            //cout << i << " " << j << endl;
            ans++;
        }
    }
    for (int i = 0; i < m; i++){
        for (int j = i+1; j < m; j++) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;        
}

Measured memory_bytes: 3624
L, R = map(int, input().split())

ansL = []
for i in range(2019):
    if L + i > R:
        break

    ansL.append((L + i) % 2019)

ans = 999999
for i in range(len(ansL)):
    for j in range(i, len(ansL)):
        if i == j:
            continue
        
        ans = min([ans, ((ansL[i] * ansL[j] ) % 2019)])

print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	cnt := 0
	out := false
	for _, vv := range s {
		v := string(vv)
		cnt++
		if cnt % 2 == 0 {
			if v == "L" || v == "U" || v == "D" {
				continue
			}
			out = true
		} else {
			if v == "R" || v == "U" || v == "D" {
				continue
			}
			out = true
		}
	}

	if out {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}

Measured memory_bytes: 512
#!/usr/bin/env python3


def main():
    #N = map(int, open(0).read().split())
    N = input()
    ans = 0

    if N[0] == '1':
        ans += 1
    if N[1] == '1':
        ans += 1
    if N[2] == '1':
        ans += 1
    print(ans)

main()


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

using namespace std;
using ll = long long;

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll calc_num(ll N, ll C, ll D){
  ll G = gcd(C, D);
  ll L = C/G*D;
  return N - N/C - N/D + N/L;
}

int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  
  cout << calc_num(B, C, D)-calc_num(A-1, C, D) << endl;
  
  
  return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i <= (n); i++)
#define repr(i, a, n) for (int i = (a); i >= (n); i--)
#define repit(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define sortt(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define co(x) cout << (x);
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define mkp make_pair
#define mkt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/******* Variable ***********************************/
const int maxn = 1e6 * 50;
const double inf = 0x3f3f3f3f3f;
/******* Function ***********************************/
void out(auto &X) {
  rep(i, 0, X.size() - 1) CO(X[i]);
}
void outsp(const vector<int> X) {
  rep(i, 0, X.size() - 1) {
    cout << X[i] << (i != X.size() - 1 ? " " : "\n");
  }
}
/*****************************************************/
/******* Main ****************************************/
int main() {
  int s[100000];
  int n;
  scanf("%d", &n);
  rep(i, 0, n - 1) scanf("%d", &s[i]);
  int q;
  scanf("%d", &q);
  int cnt = 0;
  rep(i, 0, q - 1) {
    int t;
    scanf("%d", &t);
    if (binary_search(s, s + n, t))
      cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main(){
    int a, b, c; std::cin >> a >> b >> c;
    int A = std::min({ a, b, c });
    int C = std::max({ a, b, c });
    int B = a + b + c - A - C;
    if ((A % 2 == 0 && B % 2 == 0 && C % 2 == 0) || (A % 2 == 1 && B % 2 == 1 && C % 2 == 1))
        std::cout << ((C - A) / 2) + ((C - B) / 2) << std::endl;
    else if (A % 2 == 0 && B % 2 == 1 && C % 2 == 0) {
        int count = (C - A) / 2;
        while (true) {
            if (B > C)
                break;
            else {
                B += 2;
                ++count;
            }
        }
        std::cout << count + 1 << std::endl;
    }
    else if (A % 2 == 1 && B % 2 == 0 && C % 2 == 0) {
        int count = (C - B) / 2;
        while (true) {
            if (A > C)
                break;
            else {
                A += 2;
                ++count;
            }
        }
        std::cout << count + 1 << std::endl;
    }
    else if (A % 2 == 1 && B % 2 == 0 && C % 2 == 1) {
        int count = (C - A) / 2;
        while (true) {
            if (B > C)
                break;
            else {
                B += 2;
                ++count;
            }
        }
        std::cout << count + 1 << std::endl;
    }
    else if (A % 2 == 0 && B % 2 == 1 && C % 2 == 1) {
        int count = (C - B) / 2;
        while (true) {
            if (A > C)
                break;
            else {
                A += 2;
                ++count;
            }
        }
        std::cout << count + 1 << std::endl;
    }
    else if (A % 2 == 1 && B % 2 == 1 && C % 2 == 0) {
        int count = (((C - 1) - B) / 2) + ((B - A) / 2);
        std::cout << count + 1 << std::endl;
    }
    else if (A % 2 == 0 && B % 2 == 0 && C % 2 == 1) {
        int count = (((C - 1) - B) / 2) + ((B - A) / 2);
        std::cout << count + 1 << std::endl;
    }
}

Measured memory_bytes: 3596
#include <iostream>
#include <assert.h>
#include <cmath>

struct cell{
    int32_t x;
    int32_t y;
    cell() : x(0), y(0) {}
    cell(int32_t x,int32_t y) : x(x), y(y) {}
    int32_t dist(const cell& rhs){
        return std::abs(x - rhs.x) + std::abs(y - rhs.y);
    }
};

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int32_t H, W, D;
    std::cin >> H >> W >> D;
    cell cell_array[H*W];
    for(int32_t h = 0; h < H; h++){
        for(int32_t w = 0; w < W; w++){
            int32_t val = 0;
            std::cin >> val;
            cell_array[val - 1] = cell(h+1,w+1);
        }
    }

    int32_t dist_memo[D][H*W/D + 1] = {};
    for(int32_t mod = 0; mod < D; mod++){
        int32_t val = mod + D;
        for(int32_t i = 1; i < H*W/D + 1; i++){
            if(val >= H*W) break;
            dist_memo[mod][i] = dist_memo[mod][i-1] + cell_array[val].dist(cell_array[val-D]);
            val += D;
        }
    }

    int32_t Q, L, R;
    std::cin >> Q;
    for(int32_t i = 0; i < Q; i++){
        std::cin >> L >> R;
        int32_t mod = (L - 1) % D;
        int32_t idx_l = (L - 1) / D;
        int32_t idx_r = (R - 1) / D;
        int32_t cost = dist_memo[mod][idx_r] - dist_memo[mod][idx_l];
        std::cout << cost << std::endl;
    }
    return 0;
}


Measured memory_bytes: 2176
import java.util.*;

class Main{
	
	static int N;
	static int[] C ;
	static int[] S ;
	static int[] F ;
	static int[] G ;
	
	public static void main(String[] args){
		
		
		readInfo();
		
		for(int i = 0 ; i < N ; i++){
			int time = 0;
			for(int j = i ; j < N - 1; j++){
				time = arriveTime(j , time);
			}
			G[i] = time;
			System.out.println(G[i]);
		}
		
	}
	static int arriveTime(int trainNo , int startTime){
		
		int result = 0;
		if(startTime == 0 ){
			result = S[trainNo] + C[trainNo];
		}else if(startTime < S[trainNo]){
			result = S[trainNo] + C[trainNo];
		}else if( startTime % F[trainNo] == 0){
			result = startTime + C[trainNo];
		}else{
			result = F[trainNo] * ( startTime / F[trainNo]  + 1) + C[trainNo];
		}
		return result;
	}

	
	static void readInfo(){
		Scanner sc = new Scanner(System.in);
		
		N = sc.nextInt();
//		N = 3;
		
		C = new int[ N - 1];
		S = new int[ N - 1];
		F = new int[ N - 1];
		G = new int[ N ];
		
		
//		C[0] = 6 ; C[1] = 1 ;
//		S[0] = 5 ; S[1] = 10 ;
//		F[0] = 1 ; F[1] = 1 ;
//		G[0] = 0 ; G[1] = 0 ; G[2] = 0 ;
		
		for(int i = 0 ;i < N  ; i++){
			if(i < N - 1){
				C[i] = sc.nextInt();
				S[i] = sc.nextInt();
				F[i] = sc.nextInt();
			}
			G[i] = 0;
		}
	}
}


Measured memory_bytes: 26592
#include<iostream>
using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c;
	if (a == b && a == c)
		cout << 1;
	else if (a != b && a != c&&b!=c)
		cout << 3;
	else
		cout << 2;
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    int res=0;
    for(int i=1;i<=n;i++){
        int cnt=0;
        int ii=i;
        while(ii!=0){
            cnt++;
            ii/=10;
            //cout<<i<<endl;
        }
        if(cnt%2!=0){
            res++;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e9
using namespace std;

const int maxn = 110000;

int n;
struct edge{int y,c,nex;}a[maxn<<1]; int len,fir[maxn];
inline void ins(const int x,const int y,const int c){a[++len]=(edge){y,c,fir[x]};fir[x]=len;}

int dis[maxn];
struct node{int x,i;};
inline bool operator <(const node x,const node y){return x.x>y.x;}
priority_queue<node>q;
void search()
{
	for(int i=0;i<n;i++) dis[i]=inf;
	dis[1]=1; q.push((node){1,1});
	while(!q.empty())
	{
		const node now=q.top(); q.pop();
		int x=now.i;
		if(now.x>dis[x]) continue;
		for(int k=fir[x],y=a[k].y;k;k=a[k].nex,y=a[k].y)
			if(dis[y]>dis[x]+a[k].c) dis[y]=dis[x]+a[k].c,q.push((node){dis[y],y});
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		ins(i,(i+1)%n,1);
		ins(i,i*10%n,0);
	}
	search();
	printf("%d\n",dis[0]);
	
	return 0;
}


Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
#define fv            first
#define sv            second
#define ll            long long
#define pb            push_back
#define mp            make_pair
#define pll           pair<ll,ll>
#define pii           pair<int,int>
#define READ(x)       freopen(x,"r",stdin)
#define WRITE(x)      freopen(x,"w",stdout)
#define all(x)        (x).begin(),(x).end()
#define isWorking()   cout<<"Wroking"<<endl
#define FOR(i,x,y)    for(int i=x; i<y; i++)
#define SORT(x)       sort(x.begin(),x.end())
#define PRINT(ok)     cout<<(ok? "Yes":"No")<<endl
#define SetPrint(a,x) cout<<fixed<<setprecision(x)<<a<<endl
#define Fast_Input    ios_base :: sync_with_stdio(0),cin.tie(0);
typedef vector<int> VI;
const ll mod= 1e9+7,INF=1e18,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

int main() {

    Fast_Input

    //cin>>testCase;
    while(testCase--) {
        int n; cin>>n;
        int ok=0;
        for(int i=1; !ok && i<10; i++){
            for(int j=1; j<10; j++){
                if(i*j==n){
                    ok=1; break;
                }
            }
        }
        PRINT(ok);
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int inf = 1e9;
const int mod = 1e9+7;

int n;
ll a[100010];

ll solve () {
	ll now_sum = 0;;
	ll res = 0;

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			if (now_sum + a[i] <= 0) {
				res += abs(now_sum + a[i] - 1);
				now_sum = 1;
			} else {
				now_sum += a[i];
			}
		} else {
			if (now_sum + a[i] >= 0) {
				res += abs(now_sum + a[i] - (-1));
				now_sum = -1;
			} else {
				now_sum += a[i];
			}
		}
	}

	return res;
}

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

	ll ans = solve();

	for (int i = 0; i < n; i++) a[i] *= -1;
	ans = min(ans, solve());

	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>


#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))


typedef long long ll;

using namespace std;

int main(void){

    
    int N, K, V[55];
    cin >>N>>K;
    rep(i, N) cin >> V[i];
    int r;
    int count, repeat, Maxim=0;
    

    
    static priority_queue<int, vector<int>, greater<int> > qued;
    static priority_queue<int, vector<int>, greater<int> > que;
    rep(l, N+1){
        if(l > K) break;
        for(r = N+1; r > l; r--){
            que=qued;
            count = 0;
            repeat = N-r+l+1;
            //cout << "r: " << r << " l: " << l <<endl;
            if(repeat > K) break;
            for(int s= 1; s<= l; s++){
                //cout << s << endl;
                que.push(V[s-1]);
                count+=V[s-1];
            }
            for(int s= N; s>=r; s--){
                //cout << s << endl;
                que.push(V[s-1]);
                count+=V[s-1];
            }
            rep(s, K-repeat){
                //cout << que.size()<< endl;
                if(que.empty()) break;
                //cout << "(" << que.size() << ")" << endl;
                if(que.top() >= 0) break;
                else{
                    //cout << "[" <<count<<"]" << endl;
                    count -= que.top();
                    que.pop();
                }
            }
            Maxim = max(Maxim, count);
            //cout << count << endl;
        }
    }
    cout << Maxim <<endl;

    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
long long ans1, ans2;

int main()
{
    //freopen("lpl.in", "r", stdin);
    scanf("%d", &N);
    long long x, y, a, b, k;
    scanf("%lld%lld", &ans1, &ans2);
    for(int i = 2; i <= N; ++i){
        scanf("%lld%lld", &x, &y);
        a = ans1 / x; if(a * x < ans1) a++;
        b = ans2 / y; if(b * y < ans2) b++;
        k = max(a, b);
        if(k){ans1 = k * x; ans2 = k * y;}
    }
    cout << ans1 + ans2;
    return 0;
}

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

int main() {
    ios_base :: sync_with_stdio(0);
    int n ;cin >> n;
    int arr [n][3];
    int dp[n][3];
    for (int i = 0 ; i < n ; i++){
        cin >> arr[i][0]>>arr[i][1]>> arr[i][2];
    }
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    for (int i =1 ; i < n; i++){
        dp[i][0]= arr[i][0]+ max(dp[i-1][1] , dp[i-1][2]);
        dp[i][1]= arr[i][1]+ max(dp[i-1][0] , dp[i-1][2]);
        dp[i][2]= arr[i][2]+ max(dp[i-1][0] , dp[i-1][1]);
    }
    cout << max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
const int N = 2e5 + 40;
 
long long a[N], k, mn= 1e18, n;
 
int main ()
{
	cin >>k >>n;
	for (int i = 1; i <= n; i++)
	{
		cin >>a[i];
	}
	for (int i = 1; i <= n; i++)
	{
		if (i == n)
		{
			mn = min(mn, a[n] - a[1]);
		} else
		{
			mn = min(mn, k - (a[i + 1] - a[i]));
		}
	}
	cout <<mn;
	return 0;
}

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

int main(){
  int A, B;
  string S;
  cin >> A >> B >> S;
  vector<char> a = {'0','1','2','3','4','5','6','7','8','9'};
  int count = 0;
  if(S.at(A) != '-'){
    cout << "No" << endl;
    return 0;
  }
  for(int i = 0; i < A; i++){
    for(int j = 0; j < 10; j++){
      if(S.at(i) == a.at(j)){
        count++;
      }
    }
  }
  if(count != A){
    cout << "No" << endl;
    return 0;
  }
  count = 0;
  for(int i = A + 1; i < A + B + 1; i++){
    for(int j = 0; j < 10; j++){
      if(S.at(i) == a.at(j)){
        count++;
      }
    }
  }
  if(count != B){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;  
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int dp[50][50];
int a[50][50],b[50][50];

int dd(int w,int h){
	queue<tuple<int,int,int>> lis;
	lis.push(make_tuple(0,0,0));
	while(1){
		if(lis.empty()) break;
		tuple<int,int,int> memo=lis.front();
		lis.pop();
		int x,y,now;
		x=get<0>(memo);
		y=get<1>(memo);
		now=get<2>(memo);
		if(dp[x][y]<=now) continue;
		dp[x][y]=now;
		now++;
		if(a[x][y]==0&&x!=w-1) lis.push(make_tuple(x+1,y,now));
		if(b[x][y]==0&&y!=h-1) lis.push(make_tuple(x,y+1,now));
		if(x!=0){
			if(a[x-1][y]==0) lis.push(make_tuple(x-1,y,now));
		}
		if(y!=0){
			if(b[x][y-1]==0) lis.push(make_tuple(x,y-1,now));
		}
	}
	if(dp[w-1][h-1]==10000)
	return 0;
	else return dp[w-1][h-1]+1;
}

int main(){
	while(1){
		int w,h;
		cin>>w>>h;
		if(w==0&&h==0) break;
		lp(i,50){
			lp(j,50){
				a[i][j]=0;
				b[i][j]=0;
				dp[i][j]=10000;
			}
		}
		lp(i,h){
			lp(j,w-1){
				cin>>a[j][i];
			}
			if(i==h-1) break;
			lp(j,w){
				cin>>b[j][i];
			}
		}
		cout<<dd(w,h)<<endl;
	}
	return 0;
}


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


int main(){
    int n, m, c;    cin >> n >> m >> c;
    vector<int> b(m), a(m);
    for(int i=0; i<m; i++)  cin >> b.at(i);
    
    int cnt=0;
    for(int i=0; i<n; i++){
        ll sum = c;
        for(int j=0; j<m; j++)  cin >> a.at(j);
        for(int j=0; j<m; j++)
            sum += b.at(j)*a.at(j);
        if(0<sum)
            cnt += 1;   
    }
    cout << cnt << endl;

}
    

Measured memory_bytes: 256
MAX_NUM = 10 ** 18

def main():
    import math
    N = int(input())
    A = list(map(int, input().split()))
    A_set = set(A)
    log_sum = 0
    if(0 in A_set):
        print("0")
        return
    
    A_log = [0] * N
    ans = 1
    for i in range(N):
        log_sum += math.log10(A[i])
        if(log_sum > 18):
            ans = -1
            break
        else:
            ans = ans * A[i]
            if(ans > MAX_NUM):
                ans = -1
                break
    print(ans)



main()

Measured memory_bytes: 22540
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  vector<int64_t> a_array, b_array;
  vector<string> op_array;

  while (true) {
    int64_t a, b;
    string op;

    cin >> a >> op >> b;

    a_array.push_back(a);
    b_array.push_back(b);
    op_array.push_back(op);

    if (op == "?") {
      break;
    }
  }

  for (int i = 0; i < a_array.size(); i++) {
    if (op_array[i] == "+") {
      cout << a_array[i] + b_array[i] << endl;
    }
    else if (op_array[i] == "-") {
      cout << a_array[i] - b_array[i] << endl;
    }
    else if (op_array[i] == "*") {
      cout << a_array[i] * b_array[i] << endl;
    }
    else if (op_array[i] == "/") {
      cout << a_array[i] / b_array[i] << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3064
from bisect import bisect_left
n, q = map(int, input().split())
a = list(map(int, input().split()))

if n % 2:
    n += 1
    a.insert(0, 0)

border = [(a[2*i+1] + a[i+n//2])//2 for i in range(n//2-1)]

s = sum(a[n//2:])
ans = [s]
for i in range(n//2-1):
    s += -a[i+n//2] + a[2*i+1]
    ans.append(s)

for _ in range(q):
    x = int(input())
    i = bisect_left(border, x)
    print(ans[i])



Measured memory_bytes: 15100
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
      val n = readLine().split(" ").map(_.toInt)
      val (a,b,c) = (n(0),n(1),n(2))
      println( if(a<b && b<c) "Yes" else "No")
  }
}

Measured memory_bytes: 43528
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int count = scanner.nextInt();

        final List<Work> works = new ArrayList<>();

        for(int i = 0;i<count;i++){
            works.add(new Work(scanner.nextInt(), scanner.nextInt()));
        }

        works.sort(Comparator.comparing(Work::getDeadLine));

        int ruisekiL = 0;
        for (int i = 0; i < works.size(); i++) {
            final Work work = works.get(i);
            ruisekiL += work.getLength();

            if(ruisekiL > work.getDeadLine()){
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }

    static class Work {
        private final int length;
        private final int deadLine;

        public Work(final int length, final int deadLine) {
            this.length = length;
            this.deadLine = deadLine;
        }

        public int getLength() {
            return length;
        }

        public int getDeadLine() {
            return deadLine;
        }
    }
}


Measured memory_bytes: 160716
#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  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int H,W;cin >> H >> W;
    char e[51][51] = {'.'};
    rep(i,H) rep(j,W){
        cin >> e[i][j];
    }

    int dx[4] = {-1,0,1,0};
    int dy[4] = {0,-1,0,1};
    
    bool ans = true;
    rep(i,H) rep(j,W){
        if(e[i][j] == '#'){
            int ct = 0;
            rep(k,4){
                if(i+dy[k] < 0 || i+dy[k] >= H || j+dx[k] < 0 || j+dx[k] >= W){
                    ct++;
                }
                else if(e[dy[k]+i][dx[k]+j] == '.'){
                    ct++;
                }
            }
            if(ct == 4)ans = false;
        }
    }

/*    bool check = true;
    rep(i,H) rep(j,W){
        if(e[i][j] == '.' && check)continue;
        else check = false;
    }
    if(check)ans = true;
*/    
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;

    
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}
func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	q := nextInt(sc)
	ans := make([]int, 0)
	m := make(map[string]int)
	for i := 0; i < q; i++ {
		t := nextInt(sc)
		k := nextString(sc)
		if t == 0 {
			x := nextInt(sc)
			m[k] = x
		} else if t == 1 {
			var x int
			if v, ok := m[k]; ok {
				x = v
			}
			ans = append(ans, x)
		} else {
			delete(m, k)
		}
	}
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < len(ans); i++ {
		fmt.Fprintln(wtr, ans[i])
	}
	wtr.Flush()
}



Measured memory_bytes: 18700
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		string s; cin >> s;
		int n; n = 13;
		vector<int64> dp(n);
		dp[0] = 1;
		int mul = 1;
		for (int i = s.length() - 1; i >= 0; --i) {
			vector<int64> next_dp(n);
			char c = s[i];
			if (c  == '?') {
				for (int k = 0; k < 10; ++k) {
					for (int j = 0; j < n; ++j) {
						next_dp[(k * mul  + j) % n] += dp[j];
						next_dp[(k * mul  + j) % n] %= MOD;
					}
				}
			} else {
				int k = (int)(c  - '0');
				for (int j = 0; j < n; ++j) {
					next_dp[(k * mul  + j) % n] += dp[j];
					next_dp[(k * mul  + j) % n] %= MOD;
				}
			}
			mul *= 10;
			mul %= n;
			dp = next_dp;
		}
		cout << dp[5] << endl;
    return;
}

int main() {
    solve();
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

ll n, total = 0, arr[3005],dp[3005][3005][2];

ll ans(ll i = 0, ll j = n - 1,bool b=0) {
    ll &ret=dp[i][j][b];
    if(~ret)return ret;
    if(i>j)return 0;
    if(!b){
    return ret=max(arr[i]+ans(i+1,j,1),arr[j]+ans(i,j-1,1));
    }
    else{
    return ret=min(-arr[i]+ans(i+1,j,0),-arr[j]+ans(i,j-1,0));
    }


}


int main() {
    cin >> n;

    for (ll i = 0; i < n; ++i) {
        cin >> arr[i];
        total += arr[i];
    }
    clr(dp,-1);
    cout << ans();
}

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

using namespace std;

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

    int a[n];
    for(auto &it:a)
        cin>>it;

    cout<<((n-3+k)/(k-1))<<endl;

}

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

    solve();

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	string s; cin >> s;
	rep(i,s.size()-1){
		if(s.substr(i,2) == "AC"){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <functional>

#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

int main(){
    ll A,B,ans=0;
    char a =' ', b;
    cin >> A;
    for(int i=0; i< A;i++){
        cin >> b;
        if(a != b) ans++;
        a = b;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
import numpy as np
from collections import defaultdict
from math import gcd
import time
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
 
start = time.time()
# N, K = map(int, input().split(' '))
N = int(readline())
print(N*2*3.14)

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

bool solve() {
    string S, T;
    cin >> S >> T;
    vector<int> si(26,-1), ti(26,-1);
    for ( int i = 0; i < S.size(); i++ ) {
        int six = S[i] - 'a';
        int tix = T[i] - 'a';
        if ( si[six] == -1 ) {
            si[six] = i;
        }
        int ss = si[six];
        if ( ti[tix] == -1 ) {
            ti[tix] = i;
        }
        int tt = ti[tix];
        if ( ss != tt ) return false;
    }
    return true;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 776
import java.util.*;
 
public class Main {
    public static void main(String[] args){
      
      int cor = 0;
      int pen = 0;
      
      Scanner scan = new Scanner(System.in);
   	  int n = scan.nextInt();
      int m = scan.nextInt();
      
	  Hashtable<Integer, Integer> numbers = new Hashtable<Integer, Integer>();
      Hashtable<Integer, Boolean> first = new Hashtable<Integer, Boolean>();
      
      int i = 1;
      while(i<=n){
        numbers.put(i, 0);
        first.put(i, false);
        i++;
      }
      
      i = 0;
      while(i!=m){
        Integer p = scan.nextInt();
		Integer tmp = numbers.get(p);
        String s = scan.next();
        if(s.equals("WA")){
            numbers.put(p, tmp+1);
        } else {
            if(first.get(p) == false){
              cor++;
              pen += numbers.get(p);
              first.put(p, true);
            }
        }
        i++;
      }
         
      System.out.println(cor + " " + pen);
      
      return;
 
    }
}


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


    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846
    const int MOD=1e9+7;

    void solve(){
        int h1,h2,m1,m2,k;
        cin>>h1>>m1>>h2>>m2>>k;
        int total=(h2-h1)*60 + (m2-m1);
        cout<<max(0,total-k);
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3688
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a=0;
	string S;
	cin>>S;
	if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2])a++;
	else if(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1])a++;
	else if(S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[1])a++;
	if(a==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s;
    cin >> s;

    int q;
    cin >> q;

    int r = 0;
    string a[2];

    for (int h = 0; h < q; h++) {
        int t;
        cin >> t;

        if (t == 1) {
            r ^= 1;

        } else {
            int f;
            char c;
            cin >> f >> c;
            f--;

            a[f ^ r].push_back(c);
        }
    }

    reverse(a[0].begin(), a[0].end());
    s = a[0] + s + a[1];
    if (r) reverse(s.begin(), s.end());

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

vector<int> p;
int x;

int main() {
    cin >> x;
    if (x == 2) {
        cout << "2";
        return 0;
    }
    p.push_back(2);

    for (int i = 3; i < x; i += 2) {
        bool found = false;
        for (int j = 1; j < p.size() && p[j]*p[j] <= i; ++j) {
            if (i % p[j] == 0) {
                found = true;
                break;
            }
        }
        if (!found)
            p.push_back(i);
    }

    for (int i = x; ; ++i) {
        bool found = false;
        for (int j = 0; j < p.size() && p[j]*p[j] <= i; ++j) {
            if (i % p[j] == 0) {
                found = true;
                break;
            }
        }
        if (!found) {
            cout << i;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 384
import scala.io.StdIn._
object Main extends App {
  val sr = new StdinReader
  val n, m, q = sr.nextInt

  val arr = Array.ofDim[Int](n + 1, n + 1)
  (1 to m).foreach{i =>
    val l, r = sr.nextInt
    arr(l)(r) += 1
  }

  for {
    l <- (1 to n)
    r <- (2 to n)
  } {
    arr(l)(r) = arr(l)(r - 1) + arr(l)(r)
  }

  (1 to q).foreach{i =>
    val l, r = sr.nextInt
    println((l to r).map{i => arr(i)(r) - arr(i)(l - 1)}.sum)
  }
}




class StdinReader {
  val is = System.in
  val buffer = new Array[Byte](1024 * 1024)
  var size = 0
  var pos = 0

  private def readByte: Byte = {
    if (pos >= size) {
      pos = 0;
      size = is.read(buffer);
    }
    if (size < 0) -1
    else {
      val ret = buffer(pos)
      pos += 1
      ret
    }
  }

  // support single byte char only
  def next: String = {
    @scala.annotation.tailrec
    def r(sb: StringBuilder, reading: Boolean): String = {
      readByte match {
        case b if ('!' <= b && b <= '~') => r(sb.append(b.asInstanceOf[Char]), true)
        case _ => if (reading) sb.toString else r(sb, false)
      }
    }
    r(new StringBuilder, false)
  }

  def nextInt: Int = {
    @scala.annotation.tailrec
    def r(i: Int, reading: Boolean): Int = {
      readByte match {
        case '-' => r(i * -1, true)
        case b if '0' <= b && b <= '9' => r(i * 10 + (b - '0'), true)
        case _ => if (reading) i else r(i, false)
      }
    }
    r(0, false)
  }
}

Measured memory_bytes: 117404
from collections import Counter
n = int(input())
a = list(map(int ,input().split()))

cnt = Counter(a) # カードの値をカウント
ans = len(cnt) # 存在する値の数をカウント
if ans%2 == 0: print(ans-1) # 存在する値の数が偶数であれば1回取り除く必要があるため-1をする
else: print(ans) # 奇数の場合はそのまま

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

using namespace std;
using ll = long long;

int main() {

	int N, M;
	cin>>N>>M;
	ll x = 0, y = 0;
	if (N >= 2) {
		x = (N*(N-1))/2;
	}

	if (M >= 2) {
		y = (M*(M-1))/2;
	}

	cout<<x+y<<endl;
	
	return 0;
}


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

fn main() {
    let (H, W, N): (usize, usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (s_r, s_c): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };
    let T: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let (l, r) = (0..N).rev()
        .fold((0, W + 1), |(l, r), i| {
            let x = if S[i] != 'L' && l == 0 { 0 }
                else if S[i] == 'L' && l == 0 { 1 }
                else if S[i] != 'L' && T[i] == 'R' && 0 < l && l < r - 1 { l - 1 }
                else if (S[i] == 'L' && T[i] == 'R' && l > 0) ||
                        (S[i] != 'L' && T[i] != 'R') ||
                        (S[i] != 'L' && l == r - 1) { l }
                else { l + 1 };
            let y = if S[i] != 'R' && r == W + 1 { W + 1 }
                else if S[i] == 'R' && r == W + 1 { W }
                else if S[i] != 'R' && T[i] == 'L' && l + 1 < r && r < W + 1 { r + 1 }
                else if (S[i] == 'R' && T[i] == 'L' && r < W + 1) ||
                        (S[i] != 'R' && T[i] != 'L') ||
                        (S[i] != 'R' && r == l + 1) { r }
                else { r - 1 };
            (x, y)
        });
    let (u, d) = (0..N).rev()
        .fold((0, H + 1), |(u, d), i| {
            let x = if S[i] != 'U' && u == 0 { 0 }
                else if S[i] == 'U' && u == 0 { 1 }
                else if S[i] != 'U' && T[i] == 'D' && 0 < u && u < d - 1 { u - 1 }
                else if (S[i] == 'U' && T[i] == 'D' && u > 0) ||
                        (S[i] != 'U' && T[i] != 'D') ||
                        (S[i] != 'U' && u == d - 1) { u }
                else { u + 1 };
            let y = if S[i] != 'D' && d == H + 1 { H + 1 }
                else if S[i] == 'D' && d == H + 1 { H }
                else if S[i] != 'D' && T[i] == 'U' && u + 1 < d && d < H + 1 { d + 1 }
                else if (S[i] == 'D' && T[i] == 'U' && r < W + 1) ||
                        (S[i] != 'D' && T[i] != 'U') ||
                        (S[i] != 'D' && d == u + 1) { d }
                else { d - 1 };
            (x, y)
        });
    let ans = if l < s_c && s_c < r && u < s_r && s_r < d { "YES" } else { "NO" };
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define lf long double
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <pair <int,int> >vii;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
ll mod=1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,d;
    cin>>n>>d;
    ll num=ceil((lf)n/(2*d+1));
    cout<<num<<endl;
}


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

template <typename T>
struct Compress {
    vector<T> xs;

    Compress(const vector<T>& vs) : xs(vs) {
        sort(xs.begin(), xs.end());
        xs.erase(unique(xs.begin(), xs.end()), xs.end());
    }

    int compress(const T& x) {
        return lower_bound(xs.begin(), xs.end(), x) - xs.begin();
    }

    T decompress(int i) {
        return xs[i];
    }
};

vector<int> suffix_array(vector<int>& s) {
    int n = s.size();
    Compress<int> comp(s);
    vector<int> t(n);
    for (int i = 0; i < n; i++) t[i] = comp.compress(s[i]);
    vector<int> p(n), c(n), cnt(n);
    for (int i = 0; i < n; i++) cnt[t[i]]++;
    for (int i = 1; i < n; i++) cnt[i] += cnt[i-1];
    for (int i = 0; i < n; i++) p[--cnt[t[i]]] = i;
    int cl = 0;
    for (int i = 1; i < n; i++) {
        if (s[p[i]] != s[p[i-1]]) cl++;
        c[p[i]] = cl;
    }
    vector<int> pn(n), cn(n);
    for (int h = 0; (1 << h) < n; h++) {
        for (int i = 0; i < n; i++) {
            pn[i] = p[i] - (1 << h);
            if (pn[i] < 0) pn[i] += n;
        }
        fill(cnt.begin(), cnt.end(), 0);
        for (int i = 0; i < n; i++) cnt[c[pn[i]]]++;
        for (int i = 1; i < n; i++) cnt[i] += cnt[i-1];
        for (int i = n - 1; i >= 0; i--) {
            cnt[c[pn[i]]]--;
            p[cnt[c[pn[i]]]] = pn[i];
        }
        cn[p[0]] = 0;
        cl = 0;
        for (int i = 1; i < n; i++) {
            pair<int, int> cur(c[p[i]], c[(p[i] + (1 << h)) % n]);
            pair<int, int> prev(c[p[i-1]], c[(p[i-1] + (1 << h)) % n]);
            if (cur != prev) cl++;
            cn[p[i]] = cl;
        }
        swap(c, cn);
    }
    return p;
}

int bin_search(vector<int>& a, vector<int>& b, vector<int>& sa, bool lower) {
    int n = a.size();
    int lb = -1, ub = n;
    while (ub - lb > 1) {
        int m = (lb + ub) / 2;
        bool flag = false;
        for (int i = 0; i < n; i++) {
            int j = (sa[m] + i) % n;
            if (a[i] < b[j]) {
                ub = m;
                flag = true;
                break;
            }
            if (a[i] > b[j]) {
                lb = m;
                flag = true;
                break;
            }
        }
        if (!flag) {
            if (lower) ub = m;
            else lb = m;
        }
    }
    return ub;
}

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

    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];
    vector<int> c(N), d(N);
    for (int i = 0; i < N; i++) {
        c[i] = a[i] ^ a[(i+1) % N];
        d[i] = b[i] ^ b[(i+1) % N];
    }
    auto sa = suffix_array(d);
    int lb = bin_search(c, d, sa, true);
    int ub = bin_search(c, d, sa, false);
    vector<pair<int, int>> ans;
    for (int i = lb; i < ub; i++) {
        int k = (N - sa[i]) % N;
        int x = a[k] ^ b[0];
        ans.push_back({k, x});
    }
    sort(ans.begin(), ans.end());
    for (auto& p : ans) cout << p.first << " " << p.second << "\n";
}

Measured memory_bytes: 11892
n,m = map(int,input().split())

arr = [False]*n
warr = [0]*n

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if arr[p]:
        pass
    else:
        if s == "AC":
            arr[p] = True
        else:
            warr[p] += 1

warr = [warr[i] if arr[i] else 0 for i in range(n)]
answer = str(sum(arr)) + " " + str(sum(warr))
print(answer)

Measured memory_bytes: 51896
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> b(n - 1);
    for(int i = 0; i < n - 1; i++) cin >> b[i];

    int ans = b[0] + b[n - 2];
    for(int i = 1; i < n - 1; i++) {
        ans += min(b[i - 1], b[i]);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
N,K=map(int,input().split())
D=[int(i) for i in input().split()]
L=[0]*10
for i in range(K):
    L[D[i]]=1
for i in range(N,100001):
    x=str(i)
    flag=True
    for k in range(len(x)):
        y=int(x[k])
        if L[y]==1:
            flag=False
    if flag:
        print(i)
        sys.exit()

Measured memory_bytes: 40944
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin>>n;
 int a[n];
 for(int i=0;i<n;i++)
 {
     cin>>a[i];
 }
 int cnt=0;
 for(int i=0;i<n;i++)
 {
     for(int j=i+1;j<n;j++)
     {
        for(int k=j+1;k<n;k++)
        {
            if(a[i]==a[j] || a[i]==a[k]||a[j]==a[k])
            {
                continue;
            }
            else if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i])
            {
              //   cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<'\n';
                cnt++;
            }

        }
     }
 }
 cout<<cnt;
}


Measured memory_bytes: 3644
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from itertools import combinations_with_replacement, combinations
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
A = LI()
G = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = LI()
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]

depth = [0] * n
def euler_tour():
    euler = []
    dq = deque([0])
    dq2 = deque()
    visited = [0] * n
    while dq:
        u = dq.pop()
        euler += [u]
        if visited[u]:
            continue
        for v in G[u]:
            if visited[v]:
                dq += [v]
            # [親頂点、子頂点、子頂点、。。。]と入れていく.その後連結
            else:
                depth[v] = depth[u] + 1
                dq2 += [v]
        dq.extend(dq2)
        dq2 = deque()
        visited[u] = 1
    return euler


order = euler_tour()
ans = [1] * n
P = [0] * n
LIS = [A[0]]
pre = 0
ret = 1
for j in range(1, len(order)):
    i = order[j]
    if depth[i] > depth[pre]:
        if A[i] > LIS[-1]:
            LIS += [A[i]]
            ret += 1
            P[i] = (-1, 0)
        else:
            idx = bisect_left(LIS, A[i])
            P[i] = (idx, LIS[idx])
            LIS[idx] = A[i]
        ans[i] = ret
    else:
        idx, e = P[pre]
        if idx == -1:
            LIS.pop()
            ret -= 1
        else:
            LIS[idx] = e
    pre = i

print(*ans, sep='\n')

Measured memory_bytes: 169504
#include<stdio.h>
int main(){
int a[10001],b[10001],c,i,j,n=0,x[10001];
while(1){
scanf("%d,%d\n",&a[n],&b[n]);
if(a[n]==0 && b[n]==0){
break;
}
n++;
}
for(i=0;i<n;i++){
for(j=n-1;j>i;j--){
if(b[j-1]<b[j]){
c=b[j-1];
b[j-1]=b[j];
b[j]=c;
c=a[j-1];
a[j-1]=a[j];
a[j]=c;
}
}
}
x[0]=1;
for(i=1;i<n;i++){
if(b[i-1]==b[i]){
x[i]=x[i-1];
}
else{
x[i]=x[i-1]+1;
}
}
while(scanf("%d\n",&c)!=EOF){
for(i=0;i<n;i++){
if(a[i]==c){
printf("%d\n",x[i]);
break;
}
}
}
return 0;
}


Measured memory_bytes: 2032
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n; int a[20],cnt,ans,now;
int main(){
	scanf("%lld",&n);
	for(;n;n/=10) a[++cnt]=n%10;
	for(int i=cnt;i>=1;--i){
		if(a[i]) ans=max(ans,now+a[i]-1+(i-1)*9);
		now+=a[i];
	}
	ans=max(ans,now);
	printf("%d",ans);
}

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

int main(){
    int S,h,m,s;
    cin>>S;
    h=(S-(S%3600))/3600;
    S-=h*3600;
    m=(S-(S%60))/60;
    S-=m*60;
    s=S;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
const ll MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3652