akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
	int x,y;
	while(cin >> x >> y, x|y){
		vvi field(y,vi(x));
		REP(i,y){
			REP(j,x){
				cin >> field[i][j];
			}
		}
		vvi dp(y,vi(x,0));
		REP(i,y){
			REP(j,x){
				if(i==0&&field[i][j]==0){
					dp[i][j]=1;
				}
				if(i<y-1&&field[i][j]==0){
					if(j>0&&field[i+1][j-1]==0){
						dp[i+1][j-1]+=dp[i][j];
					}
					if(j<x-1&&field[i+1][j+1]==0){
						dp[i+1][j+1]+=dp[i][j];
					}
					if(field[i+1][j]!=1){
						dp[i+1][j]+=dp[i][j];
					}
				}
				if(i<y-2&&field[i][j]==2){
					if(field[i+2][j]!=1){
						dp[i+2][j]+=dp[i][j];
					}
				}
			}
		}
		int result=0;
		REP(i,x){
			result+=dp[y-1][i];
			if(y>=2&&field[y-2][i]==2){
				result+=dp[y-2][i];
			}
		}
		cout << result << endl;
	}
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N; cin >> N;
  int A[N]; rep(i,N) cin >> A[i];
  sort(A, A+N, greater<int>());

  ll l = 0, s = 0, r = 0;
  int cnt = 0;
  rep(i,N){
    if (i<N-1 && A[i]==A[i+1]){
      if (cnt==0) {
        cnt++;
        l=A[i];
        i++;
      }
      else {
        s=A[i];
        break;
      }
    }
    else if (i+3<N && A[i]==A[i+3] && r==0){
      r = A[i];
      i += 3;
    }
  }
  cout << max(l*s, r*r) << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 640
import math
from functools import reduce
import itertools

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k=int(input())

l=[]
for i in range(1,k+1):
    l.append(i)

c_list = list(itertools.combinations_with_replacement(l,3))

cnt=0
for l in c_list:
    a = l[0]
    b = l[1]
    c = l[2]
    if a == b == c:
        d = 1
    elif a == b or b == c or c == a:
        d = 3
    else:
        d = 6
    cnt += gcd(a,b,c)*d
print(cnt)

Measured memory_bytes: 105876
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main(){
  int n,x,z,sum=0,ans=0;
  cin>>n>>x;
  int m[n+1]={};
  cin>>m[0];
  z=m[0];
  sum=m[0];
  for(int i=1;i<n;i++){
    cin>>m[i];
    z=min(z,m[i]);
    sum+=m[i];
  }
  ans=n;
  ans+=(x-sum)/z;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	ll N,K;
	scanf("%lld %lld",&N,&K);

	priority_queue<ll> Q;
	ll pre,current,first,last;

	scanf("%lld",&pre);
	first = pre;

	if(N == 1){
		printf("1\n");
		return 0;
	}



	for(int i = 1; i <= N-1; i++){
		scanf("%lld",&current);
		if(current != (pre+1)){
			Q.push(current-(pre+1));
		}
		if(i == N-1){
			last = current;
		}
		pre = current;
	}

	ll ans = (last+1-first);
	ll count = 1;

	while(Q.empty() == false && count < K){
		ans -= Q.top();
		Q.pop();
		count++;
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 3880
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
class Main{
    public static void main(String args[]){
	try{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String str;
	    ArrayList<Integer> in = new ArrayList<Integer>();
	    int out;
	    int n;
	    while(null != (str = br.readLine())){
		n = Integer.parseInt(str);
		if(n == 0){
		    System.out.println(in.get(in.size()-1));
		    in.remove(in.size()-1);
		}
		else
		    in.add(n);
	    }
	}
	catch(Exception e){
	    System.exit(0);
	}
    }
}

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

int main() {
  int s1s2s3;
  cin >> s1s2s3;
  cout << s1s2s3/100 + (s1s2s3-s1s2s3/100*100)/10 + s1s2s3-s1s2s3/100*100-(s1s2s3-s1s2s3/100*100)/10*10 << endl;
}
    

Measured memory_bytes: 256
s=input()
cnt=len(s)//2
i=0
if len(s)%2:
    while cnt+i<len(s) and s[cnt-i]==s[cnt+i]==s[cnt]:
        i+=1
else:
    while cnt+i<len(s) and s[cnt-i-1]==s[cnt+i]==s[cnt]:
        i+=1
print(cnt+i)

Measured memory_bytes: 39408
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define LL long long
#define endl "\n"

using namespace std ;

int main( void )
{

 
    ios_base::sync_with_stdio( false ) ;

    cin.tie( NULL ) ;

    cout.tie( NULL ) ;

    int n ;

    cin >> n ;

    if( n == 0 )  cout << 0 << endl ;

    else  {

        vector<int> v ;

        while( n )  {

            v.push_back( abs( n % -2 ) ) ;      // positive remainder neyar jonno abs value neya

            n = (n-abs(n%-2)) /-2 ;     // dividend = quotient*divisor + remainder
                                        // n /= -2 ke uporer sutro diye replace kora
                                        // jate -9 / -2 == 4 na hoye 5 hoy
        }

        for( auto i = v.rbegin() ; i != v.rend() ; i++ )  {

            cout << *i ;

        }

    }           

    return 0 ;

}


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

int main() {
  string s, t;
  cin >> s >> t;
  int n = sz(s), m = sz(t);
  vector<vector<int>> is(26);
  rep(i, n) is[s[i] - 'a'].push_back(i);
  rep(i, n) is[s[i] - 'a'].push_back(i + n);
  ll ans = 0;
  int p = 0;  // after p
  rep(i, m) {
    int c = t[i] - 'a';
    if (sz(is[c]) == 0) {
      puts("-1");
      return 0;
    }
    p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
    if (p >= n) {
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1724
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;

int n, t;
int a[200005];
int main()
{
	scanf("%d%d", &n, &t);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	long long sum = 0;
	for(int i = 2; i <= n; i++)
	{
		int ant = a[i] - a[i-1];
		if(ant < t) sum += ant;
		else sum += t;
	}
	printf("%lld\n", sum + t);
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	double n,m,d;
	scanf("%lf%lf%lf",&n,&m,&d);
	if(d == 0)	printf("%.8f\n", (m - 1) / n);
	else printf("%.8f\n", 2 * (m - 1) * (n - d) / (n * n));
  	return 0;
}



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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    vii card(3,vi(3));
    rep(i,3){
        rep(j,3){
            cin >> card[i][j];
        }   
    }
    int n;cin >> n;
    vi num(n);
    rep(i,n)cin >> num[i];

    vii bingo(3,vi(3));
    for(int i=0;i<n;i++){
        int target = num[i];
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(target == card[j][k])bingo[j][k] = 1;
            }
        }
    }

    string ans = "";
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if((bingo[i][0] == bingo[i][1]) && (bingo[i][1] == bingo[i][2]) && (bingo[i][2] == bingo[i][0]) && (bingo[i][0] != 0))ans = "Yes";
            if((bingo[0][j] == bingo[1][j]) && (bingo[1][j] == bingo[2][j]) && (bingo[2][j] == bingo[0][j]) && (bingo[0][j] != 0))ans = "Yes";
            if((bingo[0][0] == bingo[1][1]) && (bingo[1][1] == bingo[2][2]) && (bingo[2][2] == bingo[0][0]) && (bingo[0][0] != 0))ans = "Yes";
            if((bingo[0][2] == bingo[1][1]) && (bingo[1][1] == bingo[2][0]) && (bingo[2][0] == bingo[0][2]) && (bingo[0][2] != 0))ans = "Yes";
        }
    }
    if(ans == "")cout << "No" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int N;
  cin >> N;
  
  for (size_t i = N; i <= 100003; ++i) {
    bool find = false;
    for (size_t j = 2; j <= sqrt(i); ++j) {
      if (i % j == 0) {
        find = true;
        break;
      }
    }
    if (!find) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


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

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {

            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            int N = int.Parse(line[0]);
            int L = int.Parse(line[1]);
            int sum = 0;

            for(int i=0; i<N; i++)
            {
                sum = sum + (L + i);
            }

            if(L >= 0)
            {
                sum = sum - L;
            }
            else if(L < 0 && L + N - 1 <= 0)
            {
                sum = sum - (L + N - 1);
            }

            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
 
typedef struct Bomb
{
    int map[8][8];
    int x, y;
} BOMB;
 
int x_cnt, y_cnt;
 
Input(BOMB *);
BOMB *explode(BOMB *);  /*Recursion*/
 
int main()
{
    int input_times, input_cnt;
    BOMB Bomb[50];
     
    scanf("%d", &input_times);
    input_cnt = 0;
    while(input_cnt < input_times)
    {
        Input(&Bomb[input_cnt]);
        explode(&Bomb[input_cnt]);
        input_cnt++;
    }
     
    /*Output*/
    input_cnt = 0;
    while(input_cnt < input_times)
    {
        printf("Data %d:\n", input_cnt + 1);
        for(y_cnt = 0; y_cnt < 8; y_cnt++)
        {
            for(x_cnt = 0; x_cnt < 8; x_cnt++)
            {
                printf("%d", Bomb[input_cnt].map[x_cnt][y_cnt]);
            }
            printf("\n");
        }
        input_cnt++;
    }
     
 
     
    return 0;
} 
 
Input(BOMB *bomb)
{
    /*Read input map*/
    char dump;      /*Get rid of enter*/
    dump = getchar();
    for(y_cnt = 0; y_cnt < 8; y_cnt++)
    {
        dump = getchar();
        for(x_cnt = 0; x_cnt < 8; x_cnt++)
            bomb->map[x_cnt][y_cnt] = getchar() - 48;    /*ASCII table*/
    }
    /*Read first explosion*/
    scanf("%d", &(bomb->x));
    scanf("%d", &(bomb->y));
    bomb->map[(bomb->x) - 1][(bomb->y) - 1] = 2;
}
 
BOMB* explode(BOMB* bomb_map)
{
    int explode_cnt;
    for(y_cnt = 0; y_cnt < 8; y_cnt++)
        for(x_cnt = 0; x_cnt < 8; x_cnt++)
        {
            /*Find exploded bomb and process*/
            if(bomb_map->map[x_cnt][y_cnt] == 2)
            {
                bomb_map->map[x_cnt][y_cnt] = 0;
                /*Left*/
                explode_cnt = 1;
                while((x_cnt - explode_cnt) >= 0 && explode_cnt <= 3)
                {
                    if((bomb_map->map[x_cnt - explode_cnt][y_cnt]) == 1)
                        (bomb_map->map[x_cnt - explode_cnt][y_cnt]) = 2;
                    explode_cnt++;
                }
                /*Right*/
                explode_cnt = 1;
                while((x_cnt + explode_cnt) <= 7 && explode_cnt <= 3)
                {
                    if((bomb_map->map[x_cnt + explode_cnt][y_cnt]) == 1)
                        (bomb_map->map[x_cnt + explode_cnt][y_cnt]) = 2;
                    explode_cnt++;
                }
                /*Down*/
                explode_cnt = 1;
                while((y_cnt - explode_cnt) >= 0 && explode_cnt <= 3)
                {
                    if((bomb_map->map[x_cnt][y_cnt - explode_cnt]) == 1)
                        (bomb_map->map[x_cnt][y_cnt - explode_cnt]) = 2;
                    explode_cnt++;
                }
                /*Up*/
                explode_cnt = 1;
                while((y_cnt + explode_cnt) <= 7 && explode_cnt <= 3)
                {
                    if((bomb_map->map[x_cnt][y_cnt + explode_cnt]) == 1)
                        (bomb_map->map[x_cnt][y_cnt + explode_cnt]) = 2;
                    explode_cnt++;
                }
                return explode(bomb_map);
            }
        }
    return bomb_map;
}

Measured memory_bytes: 612
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;


inline int ceileing(int a, int b) {return a % b == 0 ? a / b : a / b + 1;}
int main() {
	int N;cin>>N;
	cout << 800 * N - (N / 15) * 200 << endl;
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

int main() {
    string s;
    cin >> s;

    int min = 10000;
    for(int i=0; i<s.size()-2; i++) {
        int cand = stoi(string(s.begin() + i, s.begin() + i + 3));
        if(abs(min-753) > abs(cand-753)) {
            min = cand;
        }
    }
    cout << abs(min - 753) << endl;

    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  long long int N,K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i=0;i<N;i++)
  {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end()); 
  long long int sum = 0;
  for(int i=0;i<N-K;i++)
  {
    sum += vec[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>

#define unsigned int long long
#define p(a, b) pair<a,b>

using namespace std;

//ifstream cin("Input.txt");
//ofstream cout("Output.txt");`

int main() {
    int n, k;
    cin >> n >> k;
    if(n%k){
        cout << 1;
    } else {
        cout << 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
    vector<int> vec;
    int n, k;
    REP(i,3){
        cin >> n;
        vec.push_back(n);
    }
    cin >> k;
    REP(i,k)*max_element(ALL(vec))*=2;
    cout << accumulate(ALL(vec),0)<<endl;

}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int A, B;
    cin >> A >> B;
    Vi anses;

    for (int p = 1; p <= 100000; p++) {
        if (p * 8 / 100 == A && p * 10 / 100 == B) {
            anses.push_back(p);
        }
    }


    if (anses.size()) {
        cout << anses[0] << endl;
    }
    else {
        cout << -1 << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int m, f, r, total;
  char grade[1000];
  int i = 0, n = 0;

  while(1) {
    scanf("%d %d %d", &m, &f, &r);
    total = m + f;
    if(total < 30)
      grade[i] = 'F';
    if(total >= 30) {
      if(r >= 50)
	grade[i] = 'C';
      else
	grade[i] = 'D';
    }
    if(total >= 50)
      grade[i] = 'C';
    if(total >= 65)
      grade[i] = 'B';
    if(total >= 80)
      grade[i] = 'A';
    if(m == -1 || f == -1)
      grade[i] = 'F';
    if(m == -1 && f == -1 && r == -1)
      break;
    i++;
  }

  n = i;
  for(i = 0; i < n; i++)
    printf("%c\n", grade[i]);

  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int num = partition(a, 0, n - 1);
		printArray(a, n, num);

	}

	public static int partition(int a[], int p, int r) {
		int j;
		int x = a[r];
		int i = p - 1;
		for (j = p; j < r; j++) {
			if (a[j] <= x) {
				i++;
				swap(a, i, j);
			}
		}
		swap(a, i + 1, r);
		return i + 1;
	}

	public static void printArray(int a[], int n, int num) {
		for (int i = 0; i < n - 1; i++) {
			if (i == num) {
				System.out.print("[" + a[i] + "] ");
			} else {
				System.out.print(a[i] + " ");
			}
		}
		System.out.println(a[n - 1]);
	}

	public static void swap(int array[], int a, int b) {
		int tmp = array[a];
		array[a] = array[b];
		array[b] = tmp;
	}
}



Measured memory_bytes: 68920
package main

import (
        "fmt"
)

func solution(n int, a []int) int {
        c := 0
        for i := range a {
                if i+1 > a[i] && a[a[i]-1] == i+1 {
                        c++
                }
        }
        return c
}

func main() {
        var n int
        fmt.Scan(&n)
        a := make([]int, n)
        for i := range a {
                fmt.Scan(&a[i])
        }
        fmt.Println(solution(n, a))
}

Measured memory_bytes: 6312
# D - Prediction and Restriction
def fight(i, win_t):
	global rsp
	global ans
	global track
	
	if past_t(i) != win_t:
		ans += rsp[win_t]
		track += win_t
	else:
		future_t_ = future_t(i)
	
		for t in rsp:
			if t != win_t and t != future_t_:
				track += t
				break


def past_t(count):
	# K回前の自分の手が何だったか確認する
	global k
	global track
	
	if count >= k:
		return track[count-k]
	else:
		return ''
		

def future_t(count):
	global k
	global cpu_t

	try:
		cpu = cpu_t[count+k]
		
		if cpu == 'r':
			return 'p'
		elif cpu == 's':
			return 'r'
		else:
			return 's'
	except:
		return ''
			

n, k = map(int, input().split())
r, s, p = map(int, input().split())

rsp = dict()
rsp['r'] = r
rsp['s'] = s
rsp['p'] = p

cpu_t = input()
track = ''
i = 0
ans = 0

for cpu in cpu_t:
	if cpu == 's':
		fight(i, 'r')
	elif cpu == 'p':
		fight(i, 's')
	else:
		fight(i, 'p')
										
	i += 1

	if i == 3:
		pass

print(ans)
#print(track)

Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
int main() {
  string N;
  cin >> N;
  if (N[0]==N[1] && N[1]==N[2] || N[1]==N[2] && N[2]==N[3]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> card(N);
    for(int i=0; i<N; i++) cin >> card.at(i);
    sort(card.begin(), card.end());
    reverse(card.begin(), card.end());
    int Al = 0;
    int Bo = 0;
    for(int i=0; i<N; i++){
        if(i % 2 == 0) Al += card.at(i);
        else Bo += card.at(i);
    }

    cout << Al - Bo << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct{
  int top;         // スタックポインタ(一番上の位置)
  int S[MAX];
}Stack;


// スタック st の初期化
void initialize(Stack *st)
{
  st->top = 0;
  st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
  return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{  
  return st->top >= MAX - 1;
}

// スタック st に要素 x をプッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
  if (isFull(st)) 
    exit(1);

  st->top++;
  st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
  if (isEmpty(st)) 
    exit(1);

  st->top--;
  return st->S[st->top+1];
}


int main(void)
{
  Stack st1;     // '\' の開始位置を格納するスタック
  Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
  Stack st2_a;   // 各水たまりの水量を格納するスタック

  // スタック初期化
  initialize(&st1);
  initialize(&st2_j);
  initialize(&st2_a);
  char c;
  int sum = 0;  // 水たまりの総水量

  // 地形を読み込み，各水たまりの水量を計算
  for (int i = 0; (c = getchar()) != EOF; i++) {
    if (c == '\\') {                                 // '\' が出た時の処理
      // 位置 i を st1 にプッシュ(write your code)
    	push(i,&st1);
    }else if (!isEmpty(&st1) && c == '/') {          // '/' が出た時の処理
      // 水たまりの総水量 sum を更新(write your code)
    	int j;
    	j = pop(&st1);
    	sum = sum + (i - j);
      // st2_j と st2_a を用いて水たまりの水量を更新 
      int a = i - j;   // 更新する水たまりの水量を a に格納していく
      while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  // 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
        // 水たまりの水量を求めていく (write your code)
      	int x;
      	pop(&st2_j);
      	x = pop(&st2_a);
      	a = a + x;
      }
      /* 更新した水たまりの「最も左の'\' の位置」および「水量」を更新 (write your code)*/		
    	push(j,&st2_j);
    	push(a,&st2_a);
    }
  }

  printf("%d\n", sum);       // 水たまりの総水量を出力
  printf("%d", st2_a.top);   // 水たまりの個数を出力

  // 各水たまりの水量を断面図の左から出力(スタックの底から出力)
  for (int i = 1; i <= st2_a.top; i++) 
    printf(" %d", st2_a.S[i]);  
  printf("\n");

  return 0;
}


Measured memory_bytes: 2144
#include <stdio.h>
#include <math.h>

int main(){
	int a, b, c;
	int tmp;
	scanf("%d %d %d", &a, &b, &c);
	if (a > b){ 
		tmp = a; 
		a = b;
		b = tmp;
	}
	if (a > c){
		tmp = a;
		a = c;
		c = tmp;
	}
	if (b > c){
		tmp = b;
		b = c;
		c = tmp;
	}
	
	printf("%d %d %d\n", a,b,c);
	return 0;
}

Measured memory_bytes: 596
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	N := ScanText(scanner)
	var M []byte
	for i := len(N) - 1; i >= 0; i-- {
	    M = append(M, N[i])
	}
	
	if string(M) == N {
	    fmt.Println("Yes")
	} else {
	    fmt.Println("No")
	}
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

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

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int n=sc.nextInt();
    int N[] =new int[n];
    int x=0;
    for(int i=0;i<n;i++){
      N[i]=sc.nextInt();}
    for(int j=1;j<n-1;j++){
      if((N[j-1]<N[j])&&(N[j]<N[j+1])){x=x+1;}
      else if((N[j-1]>N[j])&&(N[j]>N[j+1])){x=x+1;}}
    System.out.println(x);
  }
}

Measured memory_bytes: 22100
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
X=int(input())
c=0
n=100
while n<X:
    n+=n//100
    c+=1
print(c)


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

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> a(n);
	rep(i,n){
		cin>>a.at(i);
	}
	sort(a.begin(),a.end(),greater<int>());
	int sum=0;
	rep(i,n){
		sum+=a.at(i);
	}
	int ans=0;
	rep(i,m){
		if(a.at(i)>=sum/(4.0*m)){
			continue;
		}else{
			ans++;
		}
	}
	if(ans==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (ll i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main(void) {
	vec<int> A(3);
	REP(i, 3)cin >> A[i];
	sort(ALL(A));
	cout << abs(A[0] - A[1]) + abs(A[1] - A[2]) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

int main() {
  uint32_t N;
  cin >> N;
  vector<pair<uint32_t, uint32_t>> A(N);
  for (uint32_t i = 0; i < N; ++i) {
    uint32_t tmp;
    cin >> tmp;
    A[i] = make_pair(tmp, i + 1);
  }
  sort(A.begin(), A.end());
  for (uint32_t i = 0; i < N; ++i) {
    cout << A[i].second << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1664
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rep3(i,n,m) for(ll i=(n);i<(ll)(m);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int _stoi(string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double _stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}
template<typename T>string to_string(const T& n){
	std::ostringstream stm;
	stm << n;
	return stm.str();
}

// 降順ソート: sort(A, A+N, greater<>());
// min: *min_element(A, A+N)
// argmin: min_element(A, A+N)-A

ll gcd(ll a, ll b){
	if (a==0){
		return b;
	}else{
		return gcd(b%a, a);
	}
}


int main(){	
	// ll A; cin >> A;
	// cout << "hello" << _stoi("14") << max({1,3}) << endl;
	char b, ans;
	cin >> b;
	if (b=='A'){
		ans = 'T';
	}else if(b=='T'){
		ans = 'A';
	}else if(b=='G'){
		ans = 'C';
	}else{
		ans = 'G';
	}
	cout << ans << endl;

}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()





int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep (i, n) {
        cin >> a[i];
    }
    rep (i, k, n) {
        if (a[i] > a[i-k]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}



Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define min(a,b) a<b ? a:b
// #define max(a, b) a < b ? b : a
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define endl "\n"
#define pb push_back
#define pi 3.14159265358979323846

// int explore(vector<vector<int>> &adj,int x,int y,vector<int> &visited)
// {
//     if(x==y)
//     return 1;
//     visited[x]=1;
//     for(int i=0;i<adj[x].size();i++)
//     {
//         if(!visited[adj[x][i]])
//         {
//             if(explore(adj,adj[x][i],y,visited))
//             return 1;
//         }
//     }
//     return 0;
// }
bool valley(int p[], int k)
{
    if (p[k] < p[k - 1] && p[k] < p[k + 1])
        return true;
    return false;
}
bool peak(int p[], int k)
{
    if (p[k] > p[k - 1] && p[k] > p[k + 1])
        return true;
    return false;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int prime(int b)
{
    for (int i = 2; i < b; i++)
    {
        if (b % i == 0)
            return 0;
    }
    return 1;
}
int d[1000006]={0};

int32_t main()
{
    IOS;
    // int t;
    // cin>>t;
    // while(t--)
    // {
        int n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            for(int j=i;j<=n;j+=i)
            ++d[j];
        }
        int ans=0;
        for(int i=1;i<n;i++)
        {
            ans+=d[n-i];
        }
        cout<<ans<<endl;
    // }
}

Measured memory_bytes: 11432
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double



////////////////////////////////////////////////////////////////////

template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to) : from(-1), to(to), cost(-1) {}
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

vector<int> prevn(1100);

template<typename T>
vector<T> dijkstra(int s, graph<T> &g){
  vector<T> dist(g.size()+10, INF);dist[s] = 0;rep(i,1100)prevn[i] = -1;prevn[s] = INF;
  priority_queue<P, vector<P>, greater<P>> que;que.push(P(0,s));
  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge<T> e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        prevn[e.to] = v;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

#define dijkstra dijkstra<int>

////////////////////////////////////////////////////////////////////

int n, dp[5100][5100];string s;
signed main(){
  cin>>n>>s;s = '#'+s;
  repd(i,1,n+1){
    repd(j,1,n+1){
      dp[i][j] = (s[i] == s[j] ? dp[i-1][j-1]+1: 0);
      chmin(dp[i][j], j-i);
    }
  }
  int ans = 0;
  repd(i,1,n+1)repd(j,1,n+1)chmax(ans, dp[i][j]);
  cout << ans << endl;
}


Measured memory_bytes: 200960
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T> using V = vector<T>;

bool solve() {
    ll N, M;
    cin >> N >> M;
    if(!(N + M)) return false;
    V<ll> A(N);
    for(ll &e : A) cin >> e;
    ll ans = -1;
    for(ll i = 0; i < N; i++) {
        for(ll j = i + 1; j < N; j++) {
            if(A[i] + A[j] > M) continue;
            ans = max(ans, A[i] + A[j]);
        }
    }
    if(ans != -1) cout << ans;
    else cout << "NONE";
    cout << endl;
    return true;
}

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



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

int64_t abso(int64_t x) {
    return max(x, -x);
}

int64_t dp[2005][2005];

int main() {
  int64_t N;
  cin >> N;
  vector<pair<int64_t, int64_t>> v(N);
  for (int64_t i = 0; i < N; i++) {
    int64_t x;
    cin >> x;
    v.at(i).first=x;
    v.at(i).second=i;
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int64_t i = 0; i < N; i++) {
    for (int64_t j = 0; j < N-i; j++) {
      dp[i+1][j] = max(dp[i+1][j], dp[i][j] + v.at(i+j).first*(abso(v.at(i+j).second - i)));
      dp[i][j+1] = max(dp[i][j+1], dp[i][j] + v.at(i+j).first*(abso(N-j-1-v.at(i+j).second)));
    }
  }
  priority_queue<int64_t> q;
  for (int64_t i = 0; i <= N; i++) {
    q.push(dp[i][N-i]);
  }
  cout << q.top() << endl;
}
    

Measured memory_bytes: 26284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<vector<char>> g;
int main(){
    string s;   cin >> s;
    ll sc=0, tc=0, res=0;
    rep(i, s.size()){
        if(s[i]=='S'){
            if(!tc) sc += 1;
            else{
                sc = 1;
                tc = 0;
            }
        }else{
            if(0<sc){
                sc -= 1;
                res += 1;
            }else tc = 1;
        }
    }
    cout << s.size()-2*res << endl;
}


Measured memory_bytes: 3644
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    zero = s.count('0')
    one = s.count('1')
    print(min(zero*2,one*2))
if __name__ == '__main__':
  main()


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int n,m,a[11],max=0;
	unordered_set<int> st;
	cin>>n>>m;
	REP(i,m){
		cin>>a[i];
		st.insert(a[i]);
	}
	for(int i=n;;i++){
		bool f=true;
		string s=to_string(i);
		REP(j,s.size()){
			if(st.find(int(s[j]-'0'))!=st.end()){
				f=false;
			}
		}
		if(f){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N;
  cin >> N;
  unordered_map<int64_t, int64_t> A;
  int64_t SUM = 0;
  rep(i, N) {
    int64_t a;
    cin >> a;
    A[a]++;
    SUM += a;
  }

  int Q;
  cin >> Q;
  rep(i, Q) {
    int64_t B, C;
    cin >> B >> C;
    if (A.count(B)) {
      int64_t cnt = A[B];
      SUM -= B * cnt;
      SUM += C * cnt;
      A.erase(B);
      A[C] += cnt;
    }
    cout << SUM << endl;
  }
  return 0;
}


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

int main()
{
    int w, n;
    char c;

    cin >> w >> n;

    list<vector <int>> routes;

    for (vector<int> r(2); n-- && cin >> r[0] >> c >> r[1];)
        routes.push_front(r);

    for (int i = 1, pos = i; i <= w; pos = ++i) {
        for (auto r: routes)
            if (r[0] == pos)
                pos = r[1];
            else if(r[1] == pos)
                pos = r[0];

        cout << pos << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<string>
#include<sstream>
#include<queue>
#include<map>
#include<set>
using namespace std;
int main()
{
    int n,k;
    string s;
    cin>>n>>k;
    cin>>s;
    s[k-1]+=32;
    cout<<s;
    return 0;
}


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

using namespace std;

const int INF = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for(int i = 0; i < n; i++)
  {
    int l, r;
    cin >> l >> r;
    a[i] = {l, r};
  }
  sort(a.begin(), a.end());
  vector<pair<int, int>> pref(n, {0, INF}), suf(n, {0, INF});
  pref[0] = a[0];
  for(int i = 1; i < n; i++)
  {
    pref[i].first = max(a[i].first, pref[i - 1].first);
    pref[i].second =  min(a[i].second, pref[i - 1].second);
  }
  suf[n - 1] = a[n - 1];
  for(int i = n - 2; i >= 0; i--)
  {
    suf[i].first = max(a[i].first, suf[i + 1].first);
    suf[i].second = min(a[i].second, suf[i + 1].second);
  }
  int ans = 0;
  for(int i = 0; i < n - 1; i++)
  {
    ans = max(ans, max(0, pref[i].second - pref[i].first + 1) + max(0, suf[i + 1].second - suf[i + 1].first + 1));
  }
  int chans = 0;
  int mx = 0, mi = -1;
  for(int i = 0; i < n; i++)
  {
    int diff = a[i].second - a[i].first + 1;
    if(diff > mx)
    {
      mi = i;
      mx = diff;
    }
  }
  pair<int, int> ck = {0, INF};
  if(n == 1) ck = {0, 0};
  for(int i = 0; i < n; i++)
  {
    if(i != mi)
    {
      ck.first = max(ck.first, a[i].first);
      ck.second = min(ck.second, a[i].second);
    }
  }
  chans = mx + max(0, ck.second - ck.first + 1);
  ans = max(ans, chans);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <list>

using namespace std;



int main()
{
	ios_base::sync_with_stdio(false);

	long long n, k;
	cin >> n >> k;
	

	if (abs(abs(n % k) - k) < abs(n % k)) cout << abs(abs(n % k) - k);
	else cout << abs(n%-k);

	return 0;
}

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

int main()
{
	int i;
	char str[1000];
	scanf("%s",str);
	for(i=0;i<strlen(str);i++)
	{ str[i]=((str[i]-'A'+23)%26)+'A'; printf("%c",str[i]); }
	printf("\n");
	return 0;
}

Measured memory_bytes: 520
#include<stdio.h>
#define MAX 100
#define INFTY 2000000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[MAX][MAX];
int prim(){
    int i,j,v,u,minv,sum=0;
    int d[MAX],p[MAX],color[MAX];
    for(i=0;i<n;i++){
        d[i]=INFTY;
        p[i]=-1;
        color[i]=WHITE;
    }
    d[0]=0;
    
    while(1){
        minv=INFTY;
        u=-1;
        for(i=0;i<n;i++){
            if(minv>d[i] && color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1) break;
        color[u]=BLACK;
        for(v=0;v<n;v++){
            if(color[v]!=BLACK && M[u][v]!=INFTY){
                if(d[v]>M[u][v]){
                    d[v]=M[u][v];
                    p[v]=u;
                    color[v]=GRAY;
                }
            }
        }
    }
    sum=0;
    for(i=0;i<n;i++){
        if(p[i]!=-1)sum+=M[i][p[i]];
    }
    return sum;
}

int main(){
    int i,j,e;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            int e;
            scanf("%d",&e);
            M[i][j]=(e==-1)?INFTY:e;
        }
    }
    printf("%d\n",prim());
    return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N = 5e4 + 5;

int n,m,q,mod,s,t,r,u[N],v[N],c[N],g,fa[N * 6] , id[N][2][3] , icnt;
bool can[2][1000100];

int get(int x) {
	return fa[x]==x?x:fa[x]=get(fa[x]);
}

void link(int x,int y) {
	x=get(x);
	y=get(y);
	if (x==y) return;
	fa[x]=y;
}

int main() {
	scanf("%d%d%d%d",&n,&m,&q,&mod);
	fo(i,1,m) {
		scanf("%d%d%d",&u[i],&v[i],&c[i]);
		g=__gcd(g,abs(c[i]-c[1]));
	}
	if (!g) g=mod;
	mod=__gcd(mod,3*g);
	int z=c[1]%g;

	for (int i = 1; i <= n; i++)
		for (int j = 0; j < 2; j++)
			for (int k = 0; k < 3; k++)
				id[i][j][k] = ++icnt;

	fo(i,0,6*n) fa[i]=i;
	fo(i,1,m) {
		int w=(c[i]-z)/g;
		fo(p,0,1)
		fo(q,0,2) {
			link(id[u[i]][p][q],id[v[i]][1-p][(2*q+w)%3]);
			link(id[v[i]][p][q],id[u[i]][1-p][(2*q+w)%3]);
		}
	}
	for(int i=0,j=z; i<mod<<1; i++,(j<<=1)%=mod) {
		can[i&1][j]=1;
	}
	for(; q; q--) {
		scanf("%d%d%d",&s,&t,&r);
		int ret=0;
		fo(p,0,1) fo(q,0,2) if (get(id[t][0][0])==get(id[s][p][q])) {
			ret|=can[p][(r+z+(3-q)*g)%mod];
		}
		puts(ret?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 5248
#include <stdio.h>

int div2(int *a, int N) {
	for(int i=0; i<N; i++){
		if( a[i] % 2 ) {
			return 0;
		}
		a[i] /= 2;
	}
	return 1;
}

int main(void){
	int N;
	scanf("%d", &N);
	int a[N];
	for(int i=0; i<N; i++){
		scanf("%d", a+i);
	}
	int c=0;
	while(div2(a, N))c++;

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


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

struct task {
    intmax_t A;
    intmax_t B;
};

int compareB (const void *a, const void *b)
{
    if(((struct task *)a)->B - ((struct task *)b)->B < 0)
        return -1;
    if(((struct task *)a)->B - ((struct task *)b)->B > 0)
        return 1;
    return 0;
}

int main (int argc, char const *argv[])
{
    intmax_t N;
    struct task task[(int)2e5];
    intmax_t time = 0, ans = 0;

    scanf("%jd", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%jd%jd", &task[i].A, &task[i].B);
    }

    qsort(task, N, sizeof(struct task), compareB);

    for (size_t i = 0; i < N; i++) {
        time += task[i].A;
        if (time > task[i].B) {
            puts("No");
            return 0;
        }
    }

    puts("Yes");

    return 0;
}


Measured memory_bytes: 6396
#include<iostream>

using namespace std;

class node{
public:
  int parent, left, right;
};

node t[25];

void pre(int u){
  if(u == -1) return;
  cout << " " << u;
  pre(t[u].left);
  pre(t[u].right);
}

void in(int u){
  if(u == -1) return;
  in(t[u].left);
  cout << " " <<  u;
  in(t[u].right);
}

void po(int u){
  if(u == -1) return;
  po(t[u].left);
  po(t[u].right);
  cout << " " << u;
}

int s = 0;
int n;

void solve(int l, int r, int pre[], int in[]){
  if(l >= r) return;
  int m = pre[s], j;
  s++;
  for(j = l; j < r; j++){
    if(m == in[j]){
      break;
    }
  }
  solve(l, j, pre, in);
  solve(j + 1, r, pre, in);
  if(m == pre[0]) cout << m << endl;
  else cout << m << " ";
}

int main(){
  cin >> n;
  int pre[n], in[n];

  for(int i = 0; i < n; i++){
    cin >> pre[i];
  }
  for(int i = 0; i < n; i++){
    cin >> in[i];
  }



  solve(0, n, pre, in);

  return 0;
}


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

int main() {
    ll N;
    cin >> N;
    string res = "";

    while (N) {
        --N;
        res += (char)('a' + (N % 26));
        N = N/26;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3640
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
sc = [input().split() for i in range(m)]
ac = 0
pena = 0
stpe = [0] * (n+1)
prob = [False] * (n+1)
for s,c in sc:
    s = int(s)
    if prob[s]:
        continue
    else:
        if c == 'AC':
            prob[s] = True
            ac += 1
            pena += stpe[s]
            stpe[s] = 0
        else:
            stpe[s] += 1
print(ac,pena)

Measured memory_bytes: 93780
#include <iostream>
#include <math.h>
using namespace std;
int main(int argc, const char * argv[]) {
    short N;
    cin >> N;
    short* scores = new short[N];
    
    for (int i = 0; i < N; i++) {
        cin >> scores[i];
    }
    
    sort(scores, scores + N);
    
    long total = 0;
    
    for (int i = 0; i < N; i++) {
        total += scores[i];
    }
    
    if (total % 10 != 0) {
        cout << total << endl;
        delete[] scores;
        return 0;
    }
    
    for (int i = 0; i < N; i++) {
        if (scores[i] % 10 != 0){
            cout << total - scores[i] << endl;
            delete[] scores;
            return 0;
        }
    }
    
    delete[] scores;
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 888