akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
xy = Array.new(n)

n.times do |i|
  a = gets.to_i
  xy[i] = a.times.map { gets.split.map(&:to_i) }
end

ans = 0

(1 << n).times do |bit|
  flag = true
  n.times do |i|
    if bit[i] == 1
      xy[i].each do |x, y|
        flag = false if bit[x-1] != y
      end
    end
  end
  ans = [ans, bit.to_s(2).count("1")].max if flag 
end

puts ans

Measured memory_bytes: 1788
#include<iostream>
#include<fstream>

/*
int f(int n, int& cnt){
  if(n < 2){
    return 1;
  }else{
    if(n % 10 == 0){
      n = n / 10;
      cnt++;
      return n * f(n-2);
    }
  }
}
*/

int main(){
  //std::ifstream in("input.txt");
  //std::cin.rdbuf(in.rdbuf());

  long long int N, answer,  multiple;
  std::cin >> N;
  multiple = 10;
  answer = 0;
  
  if(N % 2 == 1){
    std::cout << 0 << std::endl;
    return 0;
  }

  while(1){
    if(multiple > N){
      break;
    }else{
      answer += (long long int)(N / multiple);
      multiple = multiple * 5;
    }
  }
  std::cout << answer << std::endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]

A_max = max(A)
A_second = A_max

if A.count(A_max) == 1:
  AA = []
  for a in A:
    if a != A_max:
      AA.append(a)
  A_second = max(AA)

for i in range(len(A)):
  if A[i] == A_max:
    print(A_second)
  else:
    print(A_max)


Measured memory_bytes: 14060
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
#if l[i] == l[j]: continue
d, t, s = map(int, input().split())

if t >= d / s:
    print("Yes")
else:
    print("No")


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

int main(){

  int x, a, b;
  cin >> x >> a >> b;
  if (b - a <= 0){
    cout << "delicious" << endl;
  }
  else if (b - a <= x){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
import os

s = list(map(str,input()))
t = list(map(str,input()))

m = len(s)
n = len(t)
ans = 0

if m<n:
    print("UNRESTORABLE")
    exit()
for i in range(m-n+1):
    s2 = s.copy()
    s1 = s2[i:i+n]
    flag = True
    for j in range(n):
        if s1[j]!="?" and s1[j]!=t[j]:
            flag = False
            break
        else:
            s1[j] = t[j]
    if flag:
        s2[i:i+n] = s1
        s2 = "".join(s2)
        a = s2.replace("?","a")
        if ans==0:
            ans = a
        elif ans > a:
            ans = a
if ans==0:
    print("UNRESTORABLE")
else:
    print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

main(){
  int dp[2][11];
  char c;
  while(scanf("%c", &c) != EOF && c != '0'){
    fill(dp[0], dp[2], 0);
    //cout << "c = " << c << endl;
    int ans = 0;
    dp[0][c-'0'] = 1;
    for(int i=0;scanf("%c", &c)&&c!='\n';++i){
      int ct = i%2, nt = (i+1)%2;
      /*
      for(int j=0;j<11;j++) cout << j << ' '; cout << endl;
      for(int j=0;j<11;j++) cout << dp[ct][j] << ' '; cout << endl;
      cout << "c' = " << c << endl;
      */
      for(int j=0;j<11;++j) dp[nt][j] = 0;
      if(c != '0') dp[nt][c-'0'] += 1;
      for(int j=0;j<11;++j) dp[nt][(j*10+c-'0')%11] += dp[ct][j];
      ans += dp[nt][0];
    }
    /*
    for(int j=0;j<11;j++) cout << j << ' '; cout << endl;
    for(int j=0;j<11;j++) cout << dp[0][j] << ' '; cout << endl;
    */
    cout << ans << endl;
  }
}

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

int main() {
	
	int H, W;

	for (int k = 0;; k++) {

		cin >> H >> W;

		if (H == 0 || W == 0)break;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if((i+j)%2==0){
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << "\n";
		}
		cout << "\n";
	}

	return 0;

}

Measured memory_bytes: 1120
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

constexpr unsigned Mod = 1000000007;

constexpr unsigned Add(unsigned a, unsigned b) { return (a + b) % Mod; }

int main() {
  int N;
  scanf("%d", &N);
  static char S[3000];
  scanf("%s", S);
  static unsigned F[3000][3000];
  for (auto i = 0; i < N; ++i)
    F[0][i] = 1;
  for (auto i = 1; i < N; ++i) {
    if (S[i - 1] == '<') {
      F[i][0] = F[i - 1][0];
      for (auto j = 1; j < N - i; ++j)
        F[i][j] = Add(F[i][j - 1], F[i - 1][j]);
    }
    else {
      F[i][N - i - 1] = F[i - 1][N - i];
      for (auto j = N - i - 2; j >= 0; --j)
        F[i][j] = Add(F[i][j + 1], F[i - 1][j + 1]);
    }
  }
  printf("%u\n", accumulate(F[N - 1], F[N - 1] + N, 0u, Add));
  return 0;
}


Measured memory_bytes: 35200
#
# abc051 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """0 0 1 2"""
        output = """UURDDLLUUURRDRDDDLLU"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """-2 -2 1 1"""
        output = """UURRURRDDDLLDLLULUUURRURRDDDLLDL"""
        self.assertIO(input, output)


def resolve():
    sx, sy, tx, ty = map(int, input().split())

    ans = "U"*(ty-sy) + "R"*(tx-sx)
    ans += "D"*(ty-sy) + "L"*(tx-sx)
    ans += "L" + "U"*(ty-sy+1) + "R"*(tx-sx+1) + "D"
    ans += "R" + "D"*(ty-sy+1) + "L"*(tx-sx+1) + "U"

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

int main(){
  long long X;
  cin >> X;
  
  long long money = 100;
  for (int i=1 ; ; i++){
    money += money/100;
    if (money >= X){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define int long long int
#define modulo 1000000007
using namespace std;

int32_t main(){
    int n,k,x;
    cin>>n>>k;
    priority_queue<int> Q;
    for(int i=0;i<n;i++){
        cin>>x;
        Q.push(x);
    }
    for(int i=0;i<k;i++){
        x=Q.top();
        Q.pop();
        Q.push(x/2);
    }
    int ans=0;
    while(!Q.empty()){
        ans+=Q.top();
        Q.pop();
    }
    cout<<ans;
}


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

using namespace std;

int H, W;
vector<string> s(20);
int dp[20][20][20][20];

int grundy(int sx, int sy, int gx, int gy)
{
    if (gx < sx || gy < sy)
        return 0;
    if (dp[sx][sy][gx][gy] >= 0)
        return dp[sx][sy][gx][gy];

    set<int> st;
    for (int i = sx; i <= gx; i++)
    {
        for (int j = sy; j <= gy; j++)
        {
            if (s[i][j] == '.')
            {
                st.insert(grundy(sx, sy, i - 1, j - 1) ^ grundy(i + 1, sy, gx, j - 1) ^ grundy(sx, j + 1, i - 1, gy) ^ grundy(i + 1, j + 1, gx, gy));
            }
        }
    }
    int res = 0;
    while (st.find(res) != st.end())
        res++;
    return dp[sx][sy][gx][gy] = res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> H >> W;
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < H; i++)
        cin >> s[i];
    cout << (grundy(0, 0, H - 1, W - 1) ? "First" : "Second") << endl;
}



Measured memory_bytes: 3852
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if(a<=0 and b>=0){
        cout<<"Zero";
    }else if(a>0 or (b<0 and (b-a)%2==1)){
        cout<<"Positive";
    }else{
        cout<<"Negative";
    }
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll N, K; cin >> N >> K;
    vector<bool> undone(N + 1, false);
    vector<ll> undonec(N + 1, 0);
    vector<ll>t(N + 1);
    vector<ll>ans;
    REP(i, N) {
        ll a; cin >> a;
        t[i] = a;
    }
    ll a = t[1];
    ll roopc = 0;
    undone[1] = true;
    ans.push_back(1);
    REP(i, N) {
        if (undone[a] != true) {
            undone[a] = true;
            roopc++;
            ans.push_back(a);
            undonec[a] = roopc;
            a = t[a];
        }
        else {
            roopc -= undonec[a];
            break;

        }

    }
    if (K <= undonec[a]) {
        cout << ans[K];
    }
    else {
        cout << ans[(K - undonec[a]) % (roopc + 1) + undonec[a]] << endl;
    }



}











Measured memory_bytes: 8524
#include<stdio.h>
int main(){
  int A[2] ,i ,j[2] ,m[2] ,s[2] ,e[2];
  for ( i = 0 ; i < 2 ; i++ ){
    scanf ( "%d %d %d %d" ,&j[i] ,&m[i] ,&s[i] ,&e[i]);
    A[i] = j[i] + m[i] + s[i] + e[i];
  }

  if ( A[1] > A[2] ){
    printf ( "%d\n" ,A[1] );
  }

  else{
    printf ( "%d\n" ,A[2] );
  }

  return 0;
}

Measured memory_bytes: 592
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll D, T, S;

int main() {
  std::cin >> D >> T >> S;

  if( D <= T*S ) {
    std::cout << "Yes" << endl;
  } else {
    std::cout << "No" << endl;
  }

  return 0;
}

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

using namespace std;

int main(void){
    int a;
    cin >> a;
    int temp = 1;
    int ans = 0;
    for(int i = 0;i < 3;i++){
          temp *= a;
          ans += temp;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
 int i,j,n,S[10000],q,T[500],ans=0;

 scanf("%d",&n);

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

 scanf("%d",&q);

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

 for(i=0;i<q;i++){
  j=0;
  while(T[i]!=S[j]){
   j++;
   if(j==n) break;
  }
  if(j!=n) ans++;
 }

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

 return 0;
}  

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    string s; cin >> s;

    ll ans = 0, b = 0;
    for (char c : s) {
        if (c == 'B') b++;
        else ans += b;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    string N_str;
    cin >> N_str;
    int N = atoi(N_str.c_str());

    int sum = 0;
    rep(i, (int)(N_str.length())) {
        sum += (int)(N_str[i] - '0');
    }
    
    if (N % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
string S;
int memo[10005][105][2];
const int MOD=1e9+7;
int m;
int solve(int ix, int sisa, bool con)
{
	if(ix==S.size())
	{
		if(sisa%m==0) return 1;
		return 0;
	}
	if(memo[ix][sisa][con]!=-1) return memo[ix][sisa][con];
	int ret=0;
	if(!con)
	{
		for(int z=0;z<10;z++)
		{
			int tmp=(sisa+z)%m;
			ret+=solve(ix+1, tmp, con);
			ret%=MOD;
		}
	}
	else
	{
		int tr=S[ix]-'0';
		for(int z=0;z<=tr;z++)
		{
			int tmp=(sisa+z)%m;
			if(z==tr) ret+=solve(ix+1, tmp, 1);
			else ret+=solve(ix+1, tmp, 0);
			ret%=MOD;
		}
	}
	return memo[ix][sisa][con]=ret;
}

int main()
{
	cin>>S;
	cin>>m;
	memset(memo, -1, sizeof(memo));
	printf("%d\n", (solve(0, 0, 1)-1+MOD)%MOD);
	return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

char shift(char c, int n) {
	int k = c - 'A';
	k = (k + n) % 26;
	return 'A' + k;
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	int m = s.length();
	for (int i = 0; i < m; i++)
		s[i] = shift(s[i], n);
	cout << s << endl;
}


Measured memory_bytes: 256
import numpy as np

n, d = map(int, input().split())

ps = []
for i in range(n):
    p = np.array(list(map(int, input().split())))
    ps.append(p)

count = 0
for i, pi in enumerate(ps):
    for pj in ps[i+1:]:
        d = np.sum((pi-pj)**2)
        sq = np.sqrt(d)
        if sq%1 < 1e-6:
            count += 1
print(count)

Measured memory_bytes: 12488
import heapq

A = []
heapq.heapify(A)

while True:
    tmp = input()
    if tmp == "end":
        break
    elif tmp[0] == "i":
        heapq.heappush(A, int(tmp[7:])*(-1))
    else:
        print(heapq.heappop(A)*(-1))


Measured memory_bytes: 45312
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    l,r=map(int, input().split())
    if r-l>=2019:
        print(0)
    else:
        ans=2019
        for i in range(l,r):
            for j in range(i+1,r+1):
                ans=min(ans,(i*j)%2019)
        print(ans)
resolve()

Measured memory_bytes: 38896
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }




int main() {
	char S[11], f[11];
	int len, len2 = 0;
	scanf("%s", S);
	len = strlen(S);
	int j = -1;
	for (int i = 0; i < len; i++) {
		if (S[i] == '0') {
			j++;
			len2++;
			f[j] = '0';

		}
		if (S[i] == '1') {
			j++;
			len2++;
			f[j] = '1';
		}
		if (S[i] == 'B'&& len2 > 0) {
			j--;
			len2 --;

		}
	}

	for (int i = 0; i < len2; i++) {
		printf("%c", f[i]);
	}
	printf("\n");


#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var X = input[0];
            var Y = input[1];
            var Z = input[2];
            var ans = 0;
            X -= Z;
            while (X >= Y + Z)
            {
                X -= Y + Z;
                ans++;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13268
x1,y1,x2,y2 = map(int,input().split())
x3 = x2 + y1 - y2
y3 = y2 + x2 - x1 
x4 = x3 + y2 - y3
y4 = y3 + x3 - x2 

print(str(x3)+ ' ' + str(y3)+ ' ' + str(x4) +  ' ' + str(y4))

Measured memory_bytes: 2940
N,Q = list(map(int,input().split()))
S = list(input())
l = [0 for i in range(Q)]
r = [0 for i in range(Q)]
for i in range(Q):
    l[i],r[i] = list(map(int,input().split()))
L = [0,0]
for i in range(2,N+1):
    if S[i-1]=='C' and S[i-2]=='A':
        L.append(L[i-1] + 1)
    else:
        L.append(L[i-1])

for i in range(Q):
    print(L[r[i]]-L[l[i]])

Measured memory_bytes: 14932
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;

int a[200001];
int d[200001];
int n;
vector<int> v[200001];
vector<int> tmp;

void go(int x, int p) {
	for (int next : v[x]) {
		if (next == p)continue;
		if (tmp.back() < a[next]) {
			tmp.push_back(a[next]);
			d[next] = tmp.size();
			go(next, x);
			tmp.pop_back();
		}
		else {
			auto p = lower_bound(tmp.begin(), tmp.end(), a[next]);
			int l = 0;
			int r = tmp.size() - 1;
			while (l <= r) {
				int mid = (l + r) / 2;
				if (tmp[mid] >= a[next]) {
					r = mid - 1;
				}
				else l = mid + 1;
			}
			int tt = tmp[l];
			tmp[l] = a[next];
			d[next] = tmp.size();
			go(next, x);
			tmp[l] = tt;
		}

	}
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		int x, y; cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	tmp.push_back(a[1]);
	d[1] = 1;
	go(1 , 0);
	for (int i = 1; i <= n; i++) {
		cout << d[i] << '\n';
	}

}

Measured memory_bytes: 32812
#include <iostream>
#include <map>
#include <vector>
 
using namespace std;
 
int main( void )
{
  /* ボール数入力 */
  int n;
  cin >> n;
  
  /* ボールの番号と番号の数を入力 */
  map<long long, long long>	mpNum;
  vector<int>	v;
  for ( int i = 0; i < n; i++ ) {
    int a;
    cin >> a;
    
    v.push_back(a);
    mpNum[a]++;
  }
  
  /* コンビネーション計算 */
  long long	combi = 0;
  for ( auto itr = mpNum.begin(); itr != mpNum.end(); itr++ ) {
    combi += ((itr->second * (itr->second - 1)) >> 1);
  }

  /* 方法の数計算 */
  for ( auto itrV = v.begin(); itrV != v.end(); itrV++ ) {
    cout << (combi - mpNum[*itrV] + 1) << endl;
  }
  
  return 0;
}

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

using namespace std;

int main(){
    int A, B; cin >> A >> B;
    int ans = 0;
    int X = ceil((double)B / (double)(A-1));
    if (B%(A-1) == 1 || A == 2) ans = X-1;
    else ans = X;
    
    cout << ans << endl;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


int N, M;

signed main(){
    cin >> N >> M;
    vector<int> divisor;
    for(int i = 1; i * i <= M; i++){
        if(M % i == 0){
            divisor.push_back(i);
            divisor.push_back(M / i);
        }
    }
    sort(ALL(divisor), greater<int>());
    for(int i : divisor){
        if(N <= M / i){
            PRINT(i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b, ans = -1000000;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    ans = max(ans, a + b);
    ans = max(ans, a - b);
    ans = max(ans, a*b);
    cout << ans << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int max_value(int maxv, int max){
    if(maxv > max){
        return maxv;
    }
    else {
        return max;
    }
}

int min_value(int minv, int min){
    if(minv < min){
        return minv;
    }
    else {
        return min;
    }
}

int main() {
    int i,n,r[200000];

    cin >> n;

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

    int maxv = -2000000000;
    int minv = r[0];

    for(i = 1;i < n;i++){
        maxv = max_value(maxv, r[i] - minv);
        minv = min_value(minv, r[i]);
    }
    
    cout << maxv << endl;
   
    return 0;
}

Measured memory_bytes: 1940
function Main(s){
  const n = s.length;
  const a = "a".charCodeAt();
  var b = Array(26).fill(1);
  var i;
  if(n < 26){
    for(i = 0; i < n; i++){
      b[s.charCodeAt(i) - a] = 0;
    }
    for(i = 0; i < 26; i++){
      if(b[i]){
        s += String.fromCharCode(a + i);
        break;
      }
    }
  }else{
    if(s === "zyxwvutsrqponmlkjihgfedcba"){
      console.log(-1); return;
    }
    b[s.charCodeAt(25) - a] = 0;
    loop:
    for(i = 24; i >= 0; i--){
      for(var j = s.charCodeAt(i) - a; j < 26; j++){
        if(b[j] === 0){
          s = s.slice(0,i);
          s += String.fromCharCode(a + j);
          break loop;
        }
        b[s.charCodeAt(i) - a] = 0;
      }
    }
  }
  console.log(s);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7372
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
A = LIST()

cnt = 0
now = 0

visited = [0]*N
while not visited[now]:
	visited[now] = cnt
	cnt += 1
	now = A[now]-1
	if cnt == K:
		print(now+1)
		exit()

K -= visited[now]
K = K%(cnt-visited[now])
visited = [0]*N
for i in range(K):
	now = A[now]-1
print(now+1)


Measured memory_bytes: 101024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <stack>

using namespace std;

int main() {

	stack<int> st;
	int a, ans[100]={0},i = 0;

	while (cin >> a) {
		if (a == 0) {
			cout << st.top() << endl;
			st.pop();
		}
		else {
			st.push(a);
		}
	}

	
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
ll gcd(ll a,ll b)
{
	return (!b)?a:gcd(b,a%b);
}
ll f(ll n,ll k)
{
	ll count=0;
	 for(ll i=n;i>=1;i--)
	 {
	 	if(n%i==0)
	 	{count++;
	 	//	cout<<i<<endl;
	 	if(count==k)return i;
		 }
	 	
	 }
}
int main()
{
ll a,b,k;
cin>>a>>b>>k;
printf("%lld\n",f(gcd(a,b),k));

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		char[] wk;

		try {
			scanner = new Scanner(System.in);
			wk = scanner.nextLine().toCharArray();

			int res = 0;
			for (int i = 0; i < wk.length; i++) {
				if (wk[i] == '1') {
					res++;
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int divide(int[] wk) {
		boolean divide = true;
		int res = 0;
		for (int i = 0; i < wk.length && divide; i++) {
			if (wk[i] % 2 == 0 && wk[i] > 0) {
				wk[i] = wk[i] / 2;
			} else {
				divide = false;
			}
		}
		if (divide) {
			res = divide(wk) + 1;
		}
		return res;
	}

	private void solveB() {
		Scanner scanner = null;
		int n = 0;

		try {
			scanner = new Scanner(System.in);
			n = scanner.nextInt();

			int[] wk = new int[n];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}

			System.out.println(divide(wk));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

int main() {
    int a,b,c;
    int k;
    cin >> a >> b >> c;
    cin >> k;
    int cnt = 0;

    while(cnt != k) {
        if(a >= b) {b *= 2; cnt++; continue;}
        if(b >= c) {c *= 2; cnt++; continue;}
        cnt++;
    }

    if(a < b and b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		Integer[] Ints = new Integer[3];
		for (int i=0; i<3; i++) {
			Ints[i] = sc.nextInt();
		}
		Arrays.sort(Ints,Comparator.naturalOrder());
		System.out.println(Ints[0]+" "+Ints[1]+" "+Ints[2]);
	}
}



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

int main()
{
    int N,M; cin >> N >> M;

    vector<int> a(N);

    rep(i,M) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int s;
            cin >> s;
            s--;
            a[s] |= 1 << i;
        }
    }

    int p = 0;
    rep(i,M) {
        int x; cin >> x;
        p |= x << i;
    }

    int ans = 0;
    for (int s = 0; s < (1 << N); s++) {
        int t = 0;
        for (int i = 0; i < N; i++) {
            if (s >> i & 1) t ^= a[i];
        }
        if (t == p) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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 double PI=(acos(-1));

int main(){
    int a,b,c;
    cin>>c>>a>>b;
    cout<<a*c/2<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

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

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

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

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

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

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

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

int main(void){
	ll N, T, Q;
	ll A[100000], D[100000];
	ll X[100000];
	vector<ll> p;
	cin >> N >> T >> Q;
	REP(i, N){
		cin >> A[i] >> D[i];
	}
	REP(i, Q){
		cin >> X[i];
	}
	p.push_back(-1*INF_LL);

	REP(i, N-1){
		if(D[i] == 1 && D[i+1] == 2){
			p.push_back((A[i]+A[i+1])/2);
		}
	}
	p.push_back(INF_LL);
	REP(i, Q){
		if(D[X[i]-1] == 1){
			REP(j, p.size()){
				if(p[j] >= A[X[i]-1]){
					if(abs(p[j] - A[X[i]-1]) <= T){
						cout << p[j] << endl;
					}else{
						cout << A[X[i]-1] + T << endl;
					}
					j = p.size();
				}
			}
		}else{
			REP(j, p.size()){
				if(p[j] > A[X[i]-1]){
					if(abs(A[X[i]-1] - p[j-1]) <= T){
						cout << p[j-1] << endl;
					}else{
						cout << A[X[i]-1] - T << endl;
					}
					j = p.size();
				}
			}
		}
	}
}

Measured memory_bytes: 4780
fn main() {
  let n = read::<i64>()[0];
  
  let mut sum = 0;
  for k in 1..=n {
    sum += k*(1+n/k)*(n/k)/2;
  };
  
  println!("{}", sum);
}

fn read<T: std::str::FromStr>() -> Vec<T> {
  gets().split_whitespace().filter_map(|s|s.parse().ok()).collect()
}

fn gets() -> String {
  let mut line = String::new();
  std::io::stdin().read_line(&mut line).ok();
  line.trim().to_string()
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,j,n) for(int i = (int)(j); i < (int)(n); i++)
#define mrep(i,n) for (int i = (int)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20)
ll INF = 1LL << 60;
ll mod = 1e9 + 7;
ll modn = 998244353;

int main() {
	int l,r,d; cin >> l >> r >> d;
	int ans=0;
	for(int i=l;i<=r;i++) {
		if(i%d==0) ans++;
	}
	cout << ans << endl;
}

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

int main()
{
    int i = 1;
    int j = 1;

    while (i < 10){
        while (j <= 9){
            cout << i << 'x' << j << '=' << i*j << endl;
            j ++ ;
        }
        if (j == 10){
            j = 1;
            i ++ ;
            }
    }
    return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  long long N, K;
  cin >> N >> K;
  
  long long answer = K;
  
  if(N != 1){
  for(int i = 0; i < N - 1; i++){
    answer *= (K - 1);
  }
  }
  else{
    answer = K;
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val l1 = readLine()!!.split(" ").map{it.toInt()}
    val l2 = readLine()!!.split(" ").map{it.toInt()}

    var l1sum = 0
    var l2sum = 0

    for (i in 0 until n) {
        l1sum += l1[i]
        l2sum = Math.max(l1sum + l2[i], l2sum + l2[i])
    }
    println(l2sum)
}

Measured memory_bytes: 36076
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
//[int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 }; int dy[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }

/*--------------------template--------------------*/
int n;
int hs(int x, int y) { return x*n + y; }
vector<bool> st;
int main()
{
	int w, h;
	while (cin >> w >> h, w)
	{
		vs fldl(h), fldr(h);
		REP(i, h) cin >> fldl[i] >> fldr[i];
		n = w*h;
		st.clear();
		st.resize(n*n);
		int rx, ry, lx, ly;
		REP(i, h)REP(j, w)
		{
			if (fldl[i][j] == 'L')
			{
				fldl[i][j] = '.';
				lx = i, ly = j;
			}
			if (fldr[i][j] == 'R')
			{
				fldr[i][j] = '.';
				rx = i, ry = j;
			}
		}
		queue<int> que;
		st[hs(place(lx, ly, w), place(rx, ry, w))] = true;
		que.push(hs(place(lx, ly, w), place(rx, ry, w)));
		bool ans = false;
		while (que.size())
		{
			int tmp = que.front();
			que.pop();
			int tl = tmp / n, tr = tmp%n;
			int lx = tl / w, ly = tl%w;
			int rx = tr / w, ry = tr%w;
			if (fldl[lx][ly] == '%' || fldr[rx][ry] == '%')
			{
				if (fldl[lx][ly] == '%' && fldr[rx][ry] == '%')
				{
					ans = true;
					break;
				}
				else continue;
			}
			REP(i, 4)
			{
				int lnx, lny, rnx, rny;
				if (valid(lx + dx[i], ly + dy[i], h, w) && fldl[lx + dx[i]][ly + dy[i]] != '#')
				{
					lnx = lx + dx[i], lny = ly + dy[i];
				}
				else
				{
					lnx = lx, lny = ly;
				}
				if (valid(rx + dx[i], ry - dy[i], h, w) && fldr[rx + dx[i]][ry - dy[i]] != '#')
				{
					rnx = rx + dx[i], rny = ry - dy[i];
				}
				else
				{
					rnx = rx, rny = ry;
				}
				int next = hs(place(lnx, lny, w), place(rnx, rny, w));
				if (!st[next])
				{
					st[next] = true;
					que.push(next);
				}
			}
		}
		puts(ans ? "Yes" : "No");
	}
	return 0;
}

Measured memory_bytes: 3876
fun main(args: Array<String>) {

    val pairList = arrayListOf<Pair<Int, Int>>()

    while (true) {

        val input = readLine()?.split(" ") ?: return
        val list = arrayListOf<Int>()
        input.forEach { list.add(it.toInt()) }

        if (list[0] == 0 && list[1] == 0) break
        pairList.add(Pair(list[0], list[1]))
    }

    for (pair in pairList) {
        for (h in 0 until pair.first) {
            for (w in 0 until pair.second) {
                if (h != 0 && h != pair.first - 1 &&
                    w != 0 && w != pair.second - 1) print(".")
                else print("#")
            }
            println()
        }
        println()
    }
}



Measured memory_bytes: 40652
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll INF = 1001001001001001001;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<ll>> cost(10, vector<ll>(10, INF));
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            ll a;
            cin >> a;
            cost[i][j] = a;
        }
    }
    for (int i = 0; i < 10; ++i) {
        cost[i][i] = 0;
    }
    for (int k = 0; k < 10; ++k) {
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < 10; ++j) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ll x;
            cin >> x;
            if (x == -1) continue;
            ans += cost[x][1];
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main(){
string se,moto;
int a=0,i=0;
cin>> moto;
for(i=0;i<moto.size();++i){
if(isupper(moto[i])){
moto[i]=tolower(moto[i]);
}
}
while(1){
cin >> se;
int j=0;
if (se == "END_OF_TEXT"){
 break;
}
for(j=0;j<se.size();++j){
if(isupper(se[j])){
se[j]=tolower(se[j]);
}
}
if(se==moto){
a=a+1;

}
}
cout << a << endl;
    return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		String str = sc.next();
		int ans = 0;
		for (int i = 0; i < str.length() / 2; ++i) {
			if (!syn(str.charAt(i), str.charAt(str.length() - 1 - i))) {
				++ans;
			}
		}
		if (str.length() % 2 == 1) {
			char center = str.charAt(str.length() / 2);
			if (center == '(' || center == ')') {
				++ans;
			}
		}
		System.out.println(ans);
	}

	static boolean syn(char c1, char c2) {
		if (c1 == 'i' && c2 == 'i') {
			return true;
		}
		if (c1 == 'w' && c2 == 'w') {
			return true;
		}
		if (c1 == '(' && c2 == ')') {
			return true;
		}
		if (c1 == ')' && c2 == '(') {
			return true;
		}
		return false;
	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

ll values[1001][3];

int main() {
    int N, M;
    ll max_count = -(1ll << 60);
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) cin >> values[i][j];
    }
    for (int i = 0; i < 8; i++) {
        vector<ll> v;
        for (int j = 0; j < N; j++) {
            ll sum = 0;
            for (int k = 0; k < 3; k++) {
                if ((i >> k) & 1) sum -= values[j][k];
                else sum += values[j][k];
            }
            v.push_back(sum);
        }
        sort(v.begin(), v.end());
        reverse(v.begin(), v.end());
        ll count = 0;
        for (int j = 0; j < M; j++) {
            count += v[j];
        }
        max_count = max(max_count, count);
    }
    cout << max_count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
	int n;
	priority_queue<int,vector<int>,greater<int> >q;
	int s=0;
	cin>>n;
	vector<P>v;
	r(i,n){
		int a,b;
		cin>>a>>b;
		v.push_back(P(a,b));
	}
	sort(v.begin(),v.end());
	r(i,n){
		int p=v[i].first;
		int x=v[i].second;

		while(!q.empty() && q.top()<p)q.pop();
		q.push(x);

		s=max(s,(int)q.size());
	}
	cout<<s<<endl;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using v = vector<T>;
template <class T>
using vv = v<v<T>>;
#define ALL(c) (c).begin(), (c).end()

int main()
{
    int N;
    cin >> N;
    unordered_map<int, bool> A;
    for (int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        A[a] = !A[a];
    }

    int ans = 0;
    for (auto itr = A.begin(); itr != A.end(); itr++)
    {
        if(itr->second){
            ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

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

int f(int N,int a){
  int x=0;
  while(N>0){
    N /= a;
    x += N;
  }
  return x;
}

int main(){
  int N;
  cin >>N;
  vector<int> sosu = {1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
  int a=0,b=0,c=0,d=0,e=0;
  for(int i=1;i<16;i++){
    if(f( N , sosu.at(i) ) > 73){
      a=i;
    }
    if(f( N , sosu.at(i) ) > 23){
      b=i;
    }
    if(f( N , sosu.at(i) ) > 13){
      c=i;
    }
    if(f( N , sosu.at(i) ) > 3){
      d=i;
    }
    if(f( N , sosu.at(i) ) > 1){
      e=i;
    }
  }
  if(e < 2){
    cout << 0 << endl;
    return 0;
  }
  int ans_75=a;
  int ans_25=b*(b-1)+b*(e-b);
  int ans_15=c*(c-1)+c*(d-c);
  int ans_5=d*(d-1)*(d-2)/2+d*(d-1)*(e-d)/2;
  int ans = ans_75+ans_25+ans_15+ans_5;
  cout <<ans<< endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        int x;
        cin>>x;
        int ans=0;
      if(x==1){cout<<1<<endl;}
      else{
        for(int i=2;i<33;i++){
            int A=i;
            while(A<=x){
                A*=i;
                if(A<=x){
                    ans = max(ans, A);
                }

            }
        }
       
        
        
        cout<<ans<<endl;
      }
    }

Measured memory_bytes: 256
import sys

def solve():
    n, q = map(int, sys.stdin.readline().split())
    uf = UnionFind(n)
    ans = []
    
    for lp in range(q):
        c, x, y = map(int, sys.stdin.readline().split())

        if c == 0:
            uf.unite(x, y)
        else:
            ans.append(1 if uf.same(x, y) else 0)

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


class UnionFind:

    def __init__(self, n):
        self.ds = [i for i in range(n)]
        self.root = [i for i in range(n)]
        self.rank = [0] * n

    def find_root(self, x):
        if self.root[x] == x:
            return x

        res = self.root[x]

        while res != self.root[res]:
            res = self.root[res]

        return res

    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def unite(self, x, y):
        p = self.find_root(x)
        q = self.find_root(y)

        if p == q:
            return None

        if self.rank[p] < self.rank[q]:
            self.root[p] = q
        elif self.rank[q] < self.rank[p]:
            self.root[q] = p
        else:
            self.root[q] = p
            self.rank[p] += 1

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

Measured memory_bytes: 10400
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
ll llmax(ll a,ll b,ll c,ll d,ll e,ll f,ll g,ll h){
    if(a<b)a=b;
    if(a<c)a=c;
    if(a<d)a=d;
    if(a<e)a=e;
    if(a<f)a=f;
    if(a<g)a=g;
    if(a<h)a=h;
    return a;
}
int main(){
    ll n,m,x,y,z;
    cin>>n>>m;
    if(m==0){
        cout<<0;
        return 0;
    }
    ll a[n],b[n],c[n],d[n];
    rep(i,0,n){
        cin>>x>>y>>z;
        a[i]=x+y+z;
        b[i]=x+y-z;
        c[i]=x-y+z;
        d[i]=x-y-z;
    }
    if(n==m){
        rep(i,1,n){
            a[0]+=a[i];
            b[0]+=b[i];
            c[0]+=c[i];
            d[0]+=d[i];
        }
        cout<<llmax(a[0],b[0],c[0],d[0],-a[0],-b[0],-c[0],-d[0]);
        return 0;
    }
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    sort(d,d+n);
    rep(i,1,m){
        a[0]+=a[i];
        b[0]+=b[i];
        c[0]+=c[i];
        d[0]+=d[i];
        a[n-1]+=a[n-1-i];
        b[n-1]+=b[n-1-i];
        c[n-1]+=c[n-1-i];
        d[n-1]+=d[n-1-i];
    }
    cout<<llmax(-a[0], -b[0], -c[0], -d[0], a[n-1], b[n-1], c[n-1], d[n-1]);
}

Measured memory_bytes: 256