akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
}

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

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int N, D;
vector<int> C;
vector<vector<int>> S;

int ans_score;
vector<int> ans;

void Read(bool local = false) {
  N = 26;
  if (local) {
    D = 365;
  } else {
    cin >> D;
  }
  C.resize(N);
  for (int i = 0; i < N; i++) {
    if (local) {
      C[i] = rnd() % 100;
    } else {
      cin >> C[i];
    }
  }
  S.resize(D);
  for (int i = 0; i < D; i++) {
    S[i].resize(N);
    for (int j = 0; j < N; j++) {
      if (local) {
        S[i][j] = rnd() % 20000;
      } else {
        cin >> S[i][j];
      }
    }
  }
  ans.assign(D, 0);
}

void Write() {
  for (auto i : ans) {
    cout << i + 1 << "\n";
  }
}

int Arithmetic(int n) {
  return n * (n - 1) / 2;
}

vector<set<int>> Build(vector<int> a) {
  vector<set<int>> occ(N);
  for (int i = 0; i < D; i++) {
    occ[a[i]].insert(i);
  }
  for (int i = 0; i < N; i++) {
    occ[i].insert(-1);
    occ[i].insert(D);
  }
  return occ;
}

int Evaluate(vector<int> a) {
  vector<int> last(N, -1);
  int score = 0;
  for (int i = 0; i < D; i++) {
    score += S[i][a[i]];
    last[a[i]] = i;
    for (int j = 0; j < 26; j++) {
      score -= C[j] * (i - last[j]);
    }
  }
  return score;
}

int Evaluate(int init_score, const vector<int> &a, const vector<set<int>> &occ, int d, int q) {
  if (a[d] == q) return init_score;
  const set<int> &cur = occ[a[d]];
  auto pos = cur.lower_bound(d);
  int lst = *prev(pos);
  int nxt = *next(pos);

  int score = init_score;
  score += C[a[d]] * (Arithmetic(nxt - d) + Arithmetic(d - lst) - Arithmetic(nxt - lst));

  pos = occ[q].upper_bound(d);
  lst = *prev(pos);
  nxt = *pos;
  score -= C[q] * (Arithmetic(nxt - d) + Arithmetic(d - lst) - Arithmetic(nxt - lst));

  score -= S[d][a[d]];
  score += S[d][q];

  return score;
}

void Change(int &init_score, vector<int> &a, vector<set<int>> &occ, int d, int q) {
  int new_score = Evaluate(init_score, a, occ, d, q);
  init_score = new_score;
  occ[a[d]].erase(d);
  a[d] = q;
  occ[a[d]].insert(d);
}

void Solve(int t) {
  ans_score = Evaluate(ans);

  vector<int> a(D);
  for (int i = 0; i < D; i++) {
    a[i] = (i + t) % N;
  }
  int score = Evaluate(a);
  vector<set<int>> occ = Build(a);

  double temp = 20000;
  double cooling_rate = 0.9997;
  double absolute_zero = 0.001;

  while (temp > absolute_zero) {
    int d = rnd() % D;
    int q = rnd() % N;
    int delta = Evaluate(score, a, occ, d, q) - score;
    if (temp <= 0.1) {
      for (int i = 0; i < N; i++) {
        int new_delt = Evaluate(score, a, occ, d, i) - score;
        if (delta < new_delt) {
          delta = new_delt;
          q = i;
        }
      }
    }
    if (delta > 0 || exp(delta / temp)) {
      Change(score, a, occ, d, q);
      if (t > 0 && score > ans_score) {
        ans = a;
        ans_score = score;
      }
    }
    temp *= cooling_rate;
  }
  if (ans_score < score) {
    ans = a;
  }
}

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

  Read();
  for (int rep = 0; rep < 26; rep++) {
    Solve(rep);
  }
  Write();
  // cerr << Evaluate(ans) << "\n";
  return 0;
}


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


int abs(int a){
  if(a<0){
    return -a;
  }else{
    return a;
  }
}

int main(){
  int t[100005],x[100005],y[100005];
  int n,i=0,s=0;
  int xd,yd,td;
  scanf("%d",&n);
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for(i=1;i<n+1;i++){
    scanf("%d %d %d",&t[i],&x[i],&y[i]);
  }
  for(i=0;i<n;i++){
    xd = abs(x[i+1] - x[i]);
    yd = abs(y[i+1] - y[i]);
    td = t[i+1] - t[i];
    if(td >= xd + yd && (td - xd - yd)%2==0){
      s += 1;
    }else{
      i = n;
    }
  }
  if(s==n){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1280
class SegmentTree:
    def __init__(self, a, mode='min'):
        if mode == 'min':
            self.padding = float('inf')
            self.func = min
        elif mode == 'max':
            self.padding = -float('inf')
            self.func = max
        elif mode == 'sum':
            self.padding = 0
            self.func = sum
        
        n = len(a)
        self.N = 2 ** (n-1).bit_length()
        self.data = [self.padding]*(self.N-1) + a + [self.padding]*(self.N-n)
        for i in range(2*self.N-2, 0, -2):
            self.data[(i-1)//2] = self.func([self.data[i], self.data[i-1]])
    
    def update(self, i, x):
        idx = self.N - 1 + i
        self.data[idx] = x
        while idx:
            idx = (idx-1) // 2
            self.data[idx] = self.func([self.data[2*idx+1], self.data[2*idx+2]])
    
    def search(self, i, j):
        # [i, j)
        if i == j:
            return self.data[self.N - 1 + i]
        else:
            idx1 = self.N - 1 + i
            idx2 = self.N - 2 + j # 閉区間にする
            result = self.padding
            while idx1 + 1 < idx2:
                if idx1&1 == 0: # idx1が偶数
                    result = self.func([result, self.data[idx1]])
                if idx2&1 == 1: # idx2が奇数
                    result = self.func([result, self.data[idx2]])
                    idx2 -= 1
                
                idx1 //= 2
                idx2 = (idx2 - 1)//2
            
            if idx1 == idx2:
                result = self.func([result, self.data[idx1]])
            else: # idx1 + 1 == idx2
                result = self.func([result, self.data[idx1], self.data[idx2]])
            
            return result


N = int(input())
H = list(map(int, input().split()))
A = list(map(int, input().split()))

dp = [0] * (N+1)
st = SegmentTree(dp, 'max')

ans = 0
for h, a in zip(H, A):
  M = st.search(0, h)
  st.update(h, M + a)

print(st.search(0, N+1))

Measured memory_bytes: 121596
read n
F=(1 1 2 6 24 120 720 5040)
f(){
	read d
	ex=(0 0 0 0 0 0 0 0)
	a=0
	i=$1
	for d in $d;do
		c=0
		for((j=1;j<d;j++));do
			if [ ${ex[j-1]} -eq 0 ];then
				c=$[c+1]
			fi
		done
		a=$[a+c*F[--i]]
		ex[d-1]=1
	done
	echo $a
}
s=$(f $n)
t=$(f $n)
echo $[s>t?s-t:t-s]


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

int main(){
    int n;
    
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    sort(a.begin(),a.end());
    int flag=0;
    for(int i=0;i<n;i++){
        if(i-1>=0&&a[i]==a[i-1]){
            flag++;
        }
    }
    if(flag>0){
        cout << "NO";
    }else{
        cout << "YES";
    }

}

Measured memory_bytes: 1024
'''
「文字列」S を「文字列」X と 「文字列」Y に分割、X と Y 両方に含む文字種類数最大化

「文字列」S を 各位置 で 分割して、「集合」X と 「集合」Y に格納する。
「集合」X と 「集合」Y の 論理積(AND) の 要素数 を 最大化することで求めることができる。
「集合」X と 「集合」Y の 論理積(AND) は X & Y で求めることができる。
'''

N = int(input())
S = input()

answer = 0
for L in range(N):
  left = S[:L]
  right = S[L:]
  both = set(left) & set(right)
  answer = max(answer, len(both))

print(answer)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    set<char> acgt = {'A', 'C', 'G', 'T'};
    string S;
    cin >> S;

    int ans = 0;

    int len = S.size();
    for (int i = 0; i < len; ++i) {
        for (int j = i; j < len; ++j) {
            int l = j - i + 1;
            for (int k = i; k <= j; ++k) {
                if (acgt.count(S[k]) == 0) {
                    l = 0;
                    break;
                }
            
            }
            ans = max(ans, l);
        }
    }

    cout << ans << "\n";

    return 0;
}

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

#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define str string
#define vint vector<int>
#define vchar vector<char>
#define vool vector<bool>
#define pb() pushback()

main(){
    int a,b,c,count=0,count2=0;
    double d;
    str S;
    vint fivr={64,32,16,8,4,2,1};
    cin>>d;
    rep(0,7){
      if(count==0&&fivr[i]<=d)count=fivr[i];
    }
    cout<<count<<endl;
}


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

int main() {
  
  string s, t;
  cin >> s >> t;
  
  int n = 0;
  
  if (s[0] == t[0]) n += 1;
  if (s[1] == t[1]) n += 1;
  if (s[2] == t[2]) n += 1;
  
  cout << n;
  
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HossamDoma
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {


            int n = in.nextInt();
            int m = in.nextInt();

            Set<Integer>[] arr = new TreeSet[n + 1];


            for (int i = 1; i <= n; ++i)
                arr[i] = new TreeSet<>();

            for (int i = 0; i < m; ++i) {

                int x = in.nextInt();
                int y = in.nextInt();

                arr[x].add(y);
                arr[y].add(x);
            }

            for (int e : arr[1]) {
                if (arr[n].contains(e)) {
                    out.println("POSSIBLE");
                    return;
                }
            }

            out.println("IMPOSSIBLE");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 104864
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Set<Integer> set = new HashSet<Integer>();
		set.add(1);
		int[] count = new int[n+1];
		for(int i=1; i<=n; i++) count[i] = 1;

		for(int i=0; i<m; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(set.contains(x)) set.add(y);
			count[x] --;
			count[y] ++;
			if(count[x]==0) set.remove(x);
		}
		System.out.println(set.size());
	}
}

Measured memory_bytes: 27776
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

const int N=1e6+10;
ll a[N];
int sum[11];
main(){
    ios
    int h,w,n;cin>>h>>w>>n;
    if(w==1000000000 && h==1000000000){
        h-=2,w-=2;
    int x,y;
    int cnt=0;
    ll m=(ll)h*w;
    rep(iii,n){
        cin>>x>>y;
        rep(i,3)if(x-i>=1 && x-i<=h){
            rep(j,3)if(y-j<=w){
            a[cnt++]=((ll)(x-i)<<32)+(y-j);
            }
        }
    }
    sort(a,a+cnt);
    ll t=1;
    rep(i,cnt){
        if(a[i]==a[i+1])t++;
        else sum[t]++,t=1,m--;
    }
    cout<<m<<" ";
    rep2(i,1,9)cout<<sum[i]<<" ";
    }
    else{
    h-=2,w-=2;
    int x,y;
    int cnt=0;
    ll m=(ll)h*w;
    rep(iii,n){
        cin>>x>>y;
        rep(i,3)if( x-i>=1 && x-i<=h){
            rep(j,3)if(y-j>=1 && y-j<=w){
            a[cnt++]=((ll)(x-i)<<32)+(y-j);
            }
        }
    }
    sort(a,a+cnt);
    ll t=1;
    rep(i,cnt){
        if(a[i]==a[i+1])t++;
        else sum[t]++,t=1,m--;
    }
    cout<<m<<" ";
    rep2(i,1,9)cout<<sum[i]<<" ";
    }
}



Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#include<functional>
#include<vector>
#include<map>
#include<set>
#pragma warning(disable:4996)；
int gcd(int a, int b)
{
	return b == 0 ? a : gcd(b, a%b);
}



using namespace std;
#define ll long long
int za[100005]; int sa[100005];
int main() {
	int n,x;
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &za[i]);
	}
	za[n] = x;
	sort(za, za + n + 1);
	for (int i = 0; i < n; i++)
	{
		sa[i] = za[i + 1] - za[i];
	}
	for (int i = 1; i < n; i++)
	{
		sa[i] = gcd(sa[i], sa[i-1]);
	}
	cout << sa[n - 1];



	system("pause");
	return 0;
}


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

int main(){
  uint32_t K;
  string S;
  cin >> K;
  cin >> S;

  if( S.size() <= K ){
    cout << S << endl;
  }else{
    cout << S.substr(0,K) << "..." << endl;
  }
}

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

int main() {
  int n;
  cin>>n;
  ll a[n],b[n];
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  for (int i=0; i<n; i++) {
    cin>>b[i];
  }
  ll ans=0;
  for (ll bit=0; bit<30; bit++) {
    ll cnt=0;
    ll t=1ll<<bit;
    int tmpa[n],tmpb[n];
    for (int i=0; i<n; i++) {
      tmpa[i]=a[i]%(2*t);
      tmpb[i]=b[i]%(2*t);
    }
    sort(tmpb,tmpb+n);
    for (int j=0; j<n; j++) {
      cnt+=lower_bound(tmpb,tmpb+n,2*t-tmpa[j])-lower_bound(tmpb,tmpb+n,t-tmpa[j]);
      cnt+=lower_bound(tmpb,tmpb+n,4*t-tmpa[j])-lower_bound(tmpb,tmpb+n,3*t-tmpa[j]);
    }
    ans+=(cnt%2)*t;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4992
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

def count(k, bins, N):
    current = 0
    for i in range(2, N+1):
        if k * i <=N:
            if bins[k*i] == -1:raise ValueError(f'bins{i} is not filled yet')
            current += bins[k*i]
        else:
            break
    return current % 2

def check(bins):
    for b in bins[1:]:
        if b == -1:
            return False
    return True

def run():
    N = int(sysread())
    A = list(map(int, sysread().split()))
    A = [-1] + A
    bins = [-1] * (N+1)

    for i in range(N, 0, -1):
        tmp =(A[i] - count(i, bins, N)) % 2
        if bins[i] == -1 or bins[i] == tmp:
            bins[i] = tmp
        else:
            print(-1)
            return

    if check(bins):
        print(sum(bins) + 1)
        ans = []
        for i, b in enumerate(bins):
            if b == 1:
                ans.append(str(i))
        print(' '.join(ans))

    else:
        print(-1)

if __name__ == "__main__":
    run()

Measured memory_bytes: 22724
def main(points):
    points.insert(0, [0, 0, 0])
    for i in range(len(points) - 1):
        p1 = points[i]
        p2 = points[i + 1]
        t = p2[0] - p1[0]
        if not can_reach(p1[1:], p2[1:], t):
            print('No')
            return
    print('Yes')


def can_reach(p1, p2, t):
    length = abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])
    return length <= t and (length - t) % 2 == 0


if __name__ == "__main__":
    points = []
    n = int(input())
    for i in range(n):
        points.append([int(x) for x in input().split(' ')])
    main(points)


Measured memory_bytes: 25720
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,d;
    cin>>n>>d;
    int x,y,cnt=0,flag=0;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
    long long m=pow(x,2);
    long long  p=pow(y,2);
        long long z=m+p;
        double r=sqrt(z );
        if(r<=d)
        {
            cnt++;
            
        }
        else 
        {
            continue;
        }
    }
   
        
    
    cout<<cnt<<endl;
    
    
    return 0;
}

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

int main(){
    int n,arr[1000],sum=0;
    double fl,cl;
    int mn1=0,mn2=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
        sum+=arr[i];
    }
    fl=floor((double)sum/n);
    cl=ceil((double)sum/n);

    for(int i=0;i<n;i++){
        mn1+=((arr[i]-fl)*(arr[i]-fl));
        mn2+=((arr[i]-cl)*(arr[i]-cl));
    }
    cout<<min(mn1,mn2);
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{

 int a, b, c;

 scanf("%d", &a);

 scanf("%d", &b);

 scanf("%d", &c);

 if(a < b && a < c && b < c){

 printf("Yes\n");

 }

 else{

 printf("No\n");

 }

 return 0;

}

Measured memory_bytes: 1676
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll nr,dulc,i,j;
    cin >> nr >>dulc;
    ll arr[1001];
    for(i = 0; i!= nr; i++){
        cin>>arr[i];
    }
    sort(arr,arr+nr);
    ll aux =0;
    for( i = 0; i!=nr;i++){
        aux+=arr[i];
        if(aux > dulc)break;
    }
    if(aux < dulc)i--;
    cout<<i<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int maxCount = 0;
        int maxNum = 0;
        for (int i = 0; i < n; i++) {
            int count = 0;
            int num = i + 1;
            while (true) {
                if (num % 2 != 0) {
                    break;
                }
                num /= 2;
                count++;
            }
            if (i == 0 || count > maxCount) {
                maxCount = count;
                maxNum = i + 1;
            }
        }
        System.out.println(maxNum);
    }

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    int H, W, K; cin >> H >> W >> K;
    vector<vector<bool>> v(H);
    for (int i = 0; i < H; ++i) {
        v[i].assign(W, 0);
        for (int j = 0; j < W; ++j) {
            char c; cin >> c;
            if (c == '.') v[i][j] = 1;
            // black
            else v[i][j] = 0;
        }
    }

    ll ans = 0;
    for (int hbit = 0; hbit < (1 << H); ++hbit) {
        vector<vector<bool>> copy = v;
        for (int i = 0; i < H; ++i) {
            if (hbit & (1 << i)) {
                for (int j = 0; j < W; ++j) {
                    copy[i][j] = 1;
                }
            }
        }

        for (int wbit = 0; wbit < (1 << W); ++wbit) {
            vector<vector<bool>> copy2 = copy;
            for (int j = 0; j < W; ++j) {
                if (wbit & (1 << j)) {
                    for (int i = 0; i < H; ++i) {
                        copy2[i][j] = 1;
                    }
                }
            }
            ll count = 0;
            for (int i = 0; i < H; ++i) {
                for (int j = 0; j < W; ++j) {
                    if (copy2[i][j] == 0) count ++;
                }
            }
            if (count == K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;

class Solver extends Main{
	Solver(){
	}
}//Solver_end

class Main{
	static int imax=Integer.MAX_VALUE;
	static long lmax=Long.MAX_VALUE;
	public static void main(String[] args) throws FileNotFoundException{
		
		Scanner sc=new Scanner(System.in);
		int n=readI(sc);
		int[] scr=new int[n];
		for(int i=0; i<n; i++){
			scr[i]=readI(sc);
		}
		
		int[][] dpt=new int[n+1][10001];
		dpt[0][0]=1;
		
		for(int i=0; i<n; i++){
			for(int j=0; j<10000; j++){
				if(dpt[i][j]>0 && j+scr[i]<=10000){
					dpt[i+1][j+scr[i]]=1;
					dpt[i+1][j]=1;
				}
			}
		}
		
		int ans=0;
		
		for(int i=0; i<dpt[0].length; i++){
			if(dpt[n][i]>0 && i%10!=0 && ans<i){
				ans=i;
			}
		}
		
		puts(ans);
		
		new Solver();		
	}//main_end
	
	//utility
	static int readI(Scanner sc){
		return Integer.parseInt(sc.nextLine().trim());
	}
	static long readL(Scanner sc){
		return Long.parseLong(sc.nextLine().trim());
	}
	static String readS(Scanner sc){
		return sc.nextLine().trim();
	}
	static int[] readlnI(Scanner sc, String dl){
		return Arrays.stream(sc.nextLine().trim().split(dl)).mapToInt(Integer::parseInt).toArray();
	}
	static long[] readlnL(Scanner sc, String dl){
		return Arrays.stream(sc.nextLine().trim().split(dl)).mapToLong(Long::parseLong).toArray();
	}
	static String[] readlnS(Scanner sc, String dl){
		return sc.nextLine().trim().split(dl);
	}
	@SuppressWarnings("unchecked")
	static <T> void puts(T... args){
		for(int i=0; i<args.length-1; i++){
			System.out.printf("%s ",args[i]);
		}
		System.out.println(args[args.length-1]);
	}
	static void puts(int[] ary){
		for(int i=0; i<ary.length-1; i++){
			System.out.printf("%d ",ary[i]);
		}
		System.out.println(ary[ary.length-1]);
	}
	static void puts(long[] ary){
		for(int i=0; i<ary.length-1; i++){
			System.out.printf("%d ",ary[i]);
		}
		System.out.println(ary[ary.length-1]);
	}
	static void bs(){
		System.out.println("");
	}
	static void tblSort(int[][] tbl){
		Arrays.sort(tbl, new Comparator<int[]>(){
			@Override
			public int compare(int[] a, int[] b){
				if(a[0]==b[0]){
					return b[1]-a[1];
				}else{
					return b[0]-a[0];
				}
			}
		});
	}
}

Measured memory_bytes: 26452
n,d = map(int,input().split())
data = [input().split() for i in range(n)]
ans = 0
for i in range(n - 1):
    for j in range(i+1 , n):
        sum = 0
        for k in range(d):
            sum += (int(data[i][k]) - int(data[j][k])) **2
        temp = sum ** 0.5
        if  temp.is_integer() == True:
            ans += 1
print(ans)

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


using vi = vector<int>;
#define rng(i, a, b) for(int i = (a); i < (b); ++i)
#define FOR(x, cont) for (auto &x: cont)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pq(T,COMP) priority_queue<T, vector<T>, COMP>
#define eb emplace_back
#define SZ(x) (int)(x).size()
#define rep(n) for(int _ = 0, __ = (int)n; _ < __; _++)
using pii = pair<int,int>;

using vb = vector<bool>;
using ll = long long;

vi get_prime(int n) {
    vi minp(n+1);
    vi p;
    for (int i = 2; i <= n; i++) {
        if (!minp[i]) {
            minp[i] = i;
            p.pb(i);
        }
        FOR(x, p) {
            if (x <= minp[i] && x * i <= n)
                minp[x * i] = x;
        }
    }
    return p;
}

const int mod = 1e9 + 7;



int main() {
#ifdef LOCAL
    freopen("main.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<pii> x;
    ll sa = 0, sb = 0;
    rng(i, 1, n+1) {
        int a, b;
        cin >> a >> b;
        sa += a, sb += b;
        x.eb(a, i), x.eb(b, -i);
    }



    sort(all(x));

    vi posa(n+1), posb(n+1);
    rng(i, 0, 2*n) {
        if (x[i].second > 0) posa[x[i].second] = i;
        else posb[-x[i].second] = i;
    }

    ll ans = min(sa, sb);

    ll sum = 0;
    rng(i, 0, n - 1) {
        sum += x[i].first;
    }

    rng (i, 1, n + 1) {
        if (posa[i] < n -1 && posb[i] < n - 1) {
            ans = min(ans, sum + x[n-1].first);
            break;
        }
        if (posa[i] < n - 1) {
            ans = min(ans, sum + x[posb[i]].first);
        }
        else if (posb[i] < n - 1) {
            ans = min(ans, sum + x[posa[i]].first);
        }
        else {
            ans = min(ans, sum - x[n - 2].first + x[posa[i]].first + x[posb[i]].first);
        }
    }

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

Measured memory_bytes: 2672
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import bisect



def main():
    num = int(input())
    data_a = list(map(int, input().split()))
    data_a.sort()
    data_b = list(map(int, input().split()))
    data_b.sort()
    data_c = list(map(int, input().split()))
    data_c.sort()

    ans = 0
    for ele in data_b:
        aaa = bisect.bisect_left(data_a, ele)
        bbb = bisect.bisect_right(data_c, ele)
        bbb = num - bbb
        ans += aaa * bbb
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 105444
/*input
abracadabra
avadakedavra
*/
#include<bits/stdc++.h>
/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 
#define ff(n) for(int i=0;i<n;i++)

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs(string X, string Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
std::vector<char> lcs(index+1);
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
ff(lcs.size()-1) cout<<lcs[i];
} 

/* Driver program to test above function */
int main() 
{ 
string X,Y;
cin>>X>>Y; 
int m = (X.size()); 
int n = Y.size(); 
lcs(X, Y, m, n); 
return 0; 
} 



Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": " << a << ENDL
#define all(a) begin(a),end(a)
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;

bool cmp(pair<ii, lli> u, pair<ii, lli> v) {
    return (u.f.f + u.f.s) < (v.f.f + v.f.s);
}

const int MAX = 2e4 + 5;

int main()
{   _
    lli n; cin >> n;
    vector<pair<ii, lli>> t(n);
    fore(i, 0, n) cin >> t[i].f.f >> t[i].f.s >> t[i].s;
    vector<lli> dp(MAX, 0);
    sort(all(t), cmp);
    fore(i, 0, n) {
        ///cout << "---" << t[i].f.f << ' ' << t[i].f.s << ' ' << t[i].s << ENDL;
        for(int j = t[i].f.s; j >= 0; --j) {
            if(j + t[i].f.f < MAX) {
                dp[j + t[i].f.f] = max(dp[j + t[i].f.f], dp[j] + t[i].s);
           ///     cout << j + t[i].f.f << ' ' << t[i].s << ' ' << dp[j + t[i].f.f] << ENDL;
            }
        }
    }
    lli ans = 0;
    for(auto it : dp) ans = max(ans, it);
    cout << ans << ENDL;
    return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
#include <unistd.h>
using namespace std;

#define int long long

signed main(){
	int sum = 0;
	for(int i = 0; i < 5; i++){
		int a;
		cin >> a;
		sum += a;
		//sum = sum + a;
	}
	cout << 15 - sum << endl;
	return 0;
}

Measured memory_bytes: 3552
n = int(input())
a = sorted(list(map(int, input().split())))
ans = 0
cnt = 1
prev = a[0]
#print(a)

for i in range(1, n):
    # print('\n# i: ' + str(i))
    # print('# a[i]: ' + str(a[i]))
    if a[i] == prev:
#        print('same!')
        cnt += 1
    else:
        if cnt > prev:
#            print('cnt is larger!')
            ans += cnt - prev
        elif cnt < prev:
#            print('cnt is smaller!')
            ans += cnt
#        print('ans: ' + str(ans))
        prev = a[i]
        cnt = 1

if cnt > prev:
    ans += cnt - prev
elif cnt < prev:
    ans += cnt

print(ans)



Measured memory_bytes: 63984
//c problem
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
ll n,m,a,b;
ll quick(ll a,ll b,ll mod){
	ll res=1,t=a;
	while(b){
		if(b&1)res=(res*t)%mod;
		t=(t*t)%mod;
		b>>=1;
	}
	return res;
}
ll jie[N],inv[N];
void chu(){
	jie[0]=inv[0]=1;
	for(int i=1;i<N;i++)jie[i]=(jie[i-1]*i)%mod,inv[i]=quick(jie[i],mod-2,mod);
}
ll c(ll a,ll b){
	return ((jie[b]*inv[a])%mod*inv[b-a])%mod;
}
int main()
{
	chu(); 
	ll a,b,n,m;
	cin>>n>>m>>a>>b; 
	ll ans=0;
	for(int i=1;i<=n-a;i++){
		ll ans1=c(b-1,b+i-2); 
		ll ans2=c(m-b-1,n-i+m-b-1);
		ans=(ans+ans1*ans2)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6752
N = int(input())
A = list(map(int, input().split()))
 
import collections
import copy

tot = 0
c = collections.Counter(copy.copy(A))
for v in c.values():
  tot += (v*(v-1)/2)

for n in A:
  ans = tot
  ans -= c[n]*(c[n]-1)/2
  ans += (c[n]-1)*(c[n]-2) / 2 
  print(int(ans))

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

const int MAX_SIZE  = 7368791;
bool b[MAX_SIZE+1];

int main()
{
  int m, n;
  while(1){
    cin >> m >> n;
    if(m == 0 && n == 0) break;
    fill(b,b+MAX_SIZE+1,false);
    int c = 0;
    for(int i = m; i <= MAX_SIZE; i++){
      if(!b[i]){
        c++;
        for(int j = i; j <= MAX_SIZE; j += i){
          b[j] = true;
        }
      }
      if(c == n) break;
    }
    for(int i = m; i <= MAX_SIZE; i++){
      if(!b[i]){
        cout << i << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 10272
N = int(input())
L = list(map(int, input().split()))
L_sorted = sorted(L, reverse=False)
subtract = [x - y for (x, y) in zip(L, L_sorted)]
if subtract.count(0) == N-2 or subtract.count(0) == N:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n,d,a;
pair<int,int> mon[200010];
int m, ind=0;
pair<int,int> smanji[200010];
ll sum=0;
ll sol=0;

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

    cin>>n>>d>>a;
    d=d*2+1;
    for(int i=0;i<n;i++)
        cin>>mon[i].first>>mon[i].second;
    sort(mon,mon+n);
    ind=0;
    m=0;
    for(int i=0;i<n;i++)
    {
        int ti=mon[i].first;
        while(ind<m && smanji[ind].first<=ti)
            sum-=a*smanji[ind].second, ind++;
        int th=mon[i].second;
        th-=sum;
        if(th<=0)
            continue;
        int tmp=(th+a-1)/a;
        sum+=tmp*a;
        sol+=tmp;
        smanji[m++]=make_pair(ti+d,tmp);
    }
    cout<<sol;

	return 0;
}


Measured memory_bytes: 3328
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

def dfs(s,Map,H,W,c):
    dxdy = [(1,0),(-1,0),(0,1),(0,-1),(1,1),(-1,-1),(-1,1),(1,-1)]
    for i in range(len(dxdy)):
        Map[s[0]][s[1]] = c
        nextPos = (s[0]+dxdy[i][0],s[1]+dxdy[i][1])
        if nextPos[0] >= 0 and nextPos[1] >= 0 and nextPos[0] < H and nextPos[1] < W:
            if Map[nextPos[0]][nextPos[1]] == 1:
                dfs(nextPos,Map,H,W,c)

while True:
    W,H = map(int,input().split(" "))
    if W == 0 and H == 0:
        break
    Map = [list(map(int,input().split())) for i in range(0,H)]
    c = 1
    for i in range(H):
        for j in range(W):
            if Map[i][j] == 1:
                c += 1
                dfs((i,j),Map,H,W,c)
    print(c-1)

Measured memory_bytes: 9648
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;

ll p = 1e9 + 7; //this value must be prime
ll fact(ll x, ll y) {
	/*
		return x * (x-1) * (x-2) * .... * (y+1) * y;
	*/
	ll ans = 1;
	while (y <= x) {
		ans *= y;
		ans %= p;
		y++;
	}
	return ans;
}
ll trans(ll x) {
	/*
		return x's multiplicative inverse in p's modular state space
		that is x^(p-2);
	*/
	ll y = p - 2;
	ll ans = 1;
	for (int i = 0; y >> i; i++) {
		if ((y >> i) & 1) {
			ans *= x;
			ans %= p;
		}
		x *= x;
		x %= p;
	}
	return ans;
}
ll comb(ll x, ll y) {
	ll up, down;
	if (x < 2 * y) {
		up = fact(x, y + 1);
		down = fact(x - y, 1);
	}
	else {
		up = fact(x, x - y + 1);
		down = fact(y, 1);
	}
	return (up * trans(down))%p;
}
int main(void) {
	ll n, k; scanf("%lld %lld", &n, &k);
	for (int i = 1; i <= k; i++) {
		if (n - k < i - 1) {
			printf("%lld\n", 0);
		}
		else {
			ll ans1 = comb(k - 1, i - 1);
			ll ans2 = comb(n - k + 1, i);
			printf("%lld\n", ans1 * ans2 % p);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const int MAX_V = 50;
const int MAX_S = MAX_V * 50 + 5;
const ll INF = 1e18;

struct Edge {
	int to, a, b;
	Edge(int to, int a, int b): to(to), a(a), b(b) {}
};

struct Data {
	int v, s;
	ll x;
	Data(int v, int s, ll x): v(v), s(s), x(x) {}
	bool operator<(const Data &a) const {
		return x > a.x;
	}
};

vector<Edge> g[MAX_V];
ll dist[MAX_V][MAX_S+5];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, s;
	cin >> n >> m >> s;
	rep(i,m){
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		--u; --v;
		g[u].emplace_back(v, a, b);
		g[v].emplace_back(u, a, b);
	}
	rep(i,n)rep(j,MAX_S+5) dist[i][j] = INF;
	chmin(s, MAX_S);
	priority_queue<Data> q;
	auto push = [&](int v, int s, ll x){
		if(s < 0) return;
		if(dist[v][s] <= x) return;
		dist[v][s] = x;
		q.emplace(v, s, x);
	};
	vector<int> c(n), d(n);
	rep(i,n) cin >> c[i] >> d[i];
	push(0, s, 0);
	while(!q.empty()){
		Data cur = q.top();
		q.pop();
		int v = cur.v;
		int s = cur.s;
		ll x = cur.x;
		if(dist[v][s] != x) continue;
		int ns = min(s + c[v], MAX_S);
		push(v, ns, x + d[v]);
		for(Edge e : g[v]){
			push(e.to, s - e.a, x + e.b);
		}
	}
	for(int i = 1; i < n; ++i){
		ll ans = INF;
		rep(j,MAX_S+5) chmin(ans, dist[i][j]);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 6148
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mxN=1e6;
 vector<int >v[mxN];
int dp[mxN];
int vis[mxN];
int n,m;
void solve(int i){
	vis[i]=1;
	for(auto t:v[i]){
		if(!vis[t]){
			solve(t);
			}
		dp[i]=max(dp[i],dp[t]+1);
		}
	}
int main(){
	
	cin>>n>>m;
	memset(dp,0,sizeof(dp));
	memset(vis,0,sizeof(vis));
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		}
	
	for(int i=1;i<=n;i++){
		if(!vis[i]){
		solve(i);
		}
	
	}
	cout<<*max_element(dp,dp+n+1);
	return 0;
	}


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {	
	int N;
	int d[100];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> d[i];
	}
	sort(d,d+N);
	reverse(d,d+N);
	int cnt = 1;
	int last = d[0];
	for (int i = 1; i < N; ++i) {
		if (d[i] < last) {
			++cnt;
			last = d[i];
		}
	}

	cout << cnt << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

//RMQ
struct SegTree {
    int N;
    vector<int> dat;
    SegTree() {}
    SegTree(int n) {
        N = 1;
        while(N < n) N *= 2;
        dat.resize(2 * N, -1);
        // for(int i = 0; i < 2*N-1; i++)
        //     dat[i] = INF;
    }
    // update k th element
    void update(int k, int a) {
        k += N-1; // leaf
        dat[k] = a; 
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = max(dat[k*2+1], dat[k*2+2]);
        }
    }
    // min [a, b)
    int query(int a, int b) { return query(a, b, 0, 0, N); }
    int query(int a, int b, int k, int l, int r) {
        if(r <= a or b <= l) return -1;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        return max(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, c;
    cin >> n >> c;
    vector<int> x(n), v(n);
    rep(i, 0, n){
        cin >> x[i] >> v[i];
    }
    vector<int> rx = x;
    vector<int> rv = v;
    reverse(all(rx));
    reverse(all(rv));
    rep(i, 0, n){
        rx[i] = c - rx[i];
    }
    rep(i, 1, n){
        v[i] += v[i - 1];
        rv[i] += rv[i - 1];
    }
    int ans = 0;
    SegTree s1(n), s2(n);
    rep(i, 0, n){
        int tmp = v[i] - x[i];
        chmax(ans, tmp);
        s1.update(i, tmp);
    }
    rep(i, 0, n){
        int tmp = rv[i] - rx[i];
        chmax(ans, tmp);
        s2.update(i, tmp);
    }
    rep(i, 0, n){
        int tmp = v[i] - x[i] * 2 + s2.query(0, n - 1 - i);
        chmax(ans, tmp);
    }
    rep(i, 0, n){
        int tmp = rv[i] - rx[i] * 2 + s1.query(0, n - 1 - i);
        chmax(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7552
#include <iostream>
#include <cstdlib>
#include <vector>
#include <stack>
#include <string>
#include <climits>
#include <algorithm>
#include <functional>
#include <string.h>
#include <numeric>
#include <math.h>

#define LOOP(N) for(int i=0; i<(N); ++i)
#define REP(i, N) for(int i=0; i<(N); ++i)
#define FOR(i, start, end) for(int i=(start); i<(end); ++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using Graph = vector< vector<int> >;

const ll MOD = 1000000007;

void sayYes() {cout << "Yes" << endl;}
void sayNo() {cout << "No" << endl;}


int main() {
    int N; cin >> N;
    string s; cin >> s;
    if (s[0] == 'W') {
        cout << 0;
        return 0;
    }
    
    vector<bool> is_L(2*N);
    is_L[0] = true;
    int l_num = 1;
    // cout << 'L';
    FOR(i, 1, 2*N) {
        is_L[i] = (s[i-1]==s[i]) ? !is_L[i-1] : is_L[i-1];
        l_num += is_L[i] ? 1 : 0;
        // cout << (is_L[i] ? 'L' : 'R');
    }
    // cout << endl;
    if (l_num != N) {
        cout << 0;
        return 0;
    }
    
    int l_count = 0;
    int r_count = 0;
    ll result = 1;
    REP(i, 2*N) {
        if (is_L[i]) {
            ++l_count;
        }
        else {
            result *= l_count - r_count;
            result %= MOD;
            ++r_count;
        }
        // cout << i << " " << (is_L[i] ? 'L' : 'R') << " " << l_count << " " << r_count << endl;
    }
    
    FOR(i, 1, N+1) {
        result *= i;
        result %= MOD;
    }
    cout << result;
}

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

string s;
string t = "keyence";

int main() {
	cin >> s;

	int ans = 0;
	for( int i = 0; i < t.size(); i++ ) {
		if( s.substr( 0, i ) == t.substr( 0, i )  && s.substr( s.size() - (t.size() - i), t.size() - i ) == t.substr( i, t.size() - i ) ) {
			ans = 1;
		}
	}

	if( ans ) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

int main(){
    while(1){
        string s, d;
        cin >> s >> d;
        if(s==".") break;
        string ans = "IDENTICAL";
        if(s == d){
            cout << ans << endl;
        }
        else{
            int len_s = s.length(), count_s = 0;
            int len_d = d.length(), count_d = 0;
            vector<int> flag_s(len_s+1);
            vector<int> flag_d(len_d+1);
            rep(i, len_s){
                if(s.at(i) == '"'){
                    count_s++;
                    flag_s.at(count_s) = i;
                }
            }
            rep(i, len_d){
                if(d.at(i) == '"'){
                    count_d++;
                    flag_d.at(count_d) = i;
                }
            }
            
            if(count_s != count_d){
                ans = "DIFFERENT";
                cout << ans << endl;
            }
            else{
                ans = "CLOSE";
                string a, b;
                int count = 0;
                //最初の部分文字列の比較
                a = s.substr(0, flag_s.at(0));
                b = d.substr(0, flag_d.at(0));
                if(a!=b){
                    ans = "DIFFERENT";
                }
                //最後の部分文字列の比較
                a = s.substr(flag_s.at(count_s), len_s-flag_s.at(count_s));
                b = d.substr(flag_d.at(count_d), len_d-flag_d.at(count_d));
                if(a!=b){
                    ans = "DIFFERENT";
                }
                rep(i, count_s){//部分文字列の比較
                    a = s.substr(flag_s.at(i), flag_s.at(i+1)-flag_s.at(i));
                    b = d.substr(flag_d.at(i), flag_d.at(i+1)-flag_d.at(i));
                    if(i%2 == 0){
                        if(a!=b){
                            ans = "DIFFERENT";
                        }
                    }
                    else{
                        if(a!=b){
                            count++;
                            if(count > 1){
                                ans = "DIFFERENT";
                            }
                        }
                    }
                }
                cout << ans << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
using namespace std;
int main(){
    int n,m,l;
    long A[101][101]={},B[101][101]={},c[101][101]={};
    cin>>n>>m>>l;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>B[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                c[i][j]=c[i][j]+A[i][k]*B[k][j];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j==l-1){
                cout<<c[i][j];
            }
            else{
            cout<<c[i][j]<<" ";
            }
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3360
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
a,b,c=[input() for i in range(3)]
for i in range(n):
  ans += len(set((a[i],b[i],c[i]))) - 1
print(ans)

Measured memory_bytes: 40336
// Lets go to the next level 
// AIM Expert at CF *__* asap 
// Hit A,B,C and if possible D faster and reach Expert
// Remember you were also a novice when you started, 
// hence never be rude to anyone who wants to learn something
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure.  
#include "bits/stdc++.h"
//#include <algorithm>
#define ll long long 
#define mod 1000000007
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define umap unordered_map
#define uset unordered_set
#define lb lower_bound
#define ub upper_bound
#define endll "\n";
#define all(x) (x).begin(), (x).end()
#define forr(it,x) for(auto it=x.begin();it!=x.end();it++)
#define for1(i,a,b) for(int i=a;i<b;i++)
#define for2(i,a,b) for(int i=a;i>=b;i--)
#define for3(i,a,b) for(long long int i=a;i<b;i++)
#define for4(i,a,b) for(long long int i=a;i>=b;i--)
#define pp pair<int,int>
#define ld long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpp vector<pp>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvpp vector<vpp>
#define I insert
#define mem(a,x) memset(a,x,sizeof(a))
#define p_queue(a) priority_queue<a,vector<a>,greater<a>>
using namespace std;
//const int dx[8]={1,0,-1,0,1,1,-1,-1},dy[8]={0,1,0,-1,-1,1,-1,1};
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1}; 
const int N=2e5+5;
/*vector<bool> p(N+1, true);
void sieve()
{
  p[0] = p[1] = false;
  int i,j;
  for (i = 2; i*i <= N; i++) 
  {
      if (p[i]) 
      {
          for (j = i * i; j <=N; j += i)
            {
        p[j] =false;
        }
      }
  }
}*/
/*int power(int a, int b){
    int res = 1;
    while(b > 0){
        if(b % 2){
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
        b /= 2;
    }
    return res;
}*/
/*int gcd(int a,int b){
    if(a<b) swap(a,b);
    a%=b;
    if(a==0) return b;
    return gcd(b,a);
}*/
/*int lcm(int a,int b){
   return (a*1LL*b)/gcd(a,b);
}*/
ll a[N];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll x,k,d;cin>>x>>k>>d;
    x=abs(x);
    if(k<(x/d)){
      cout<<x-k*d<<endll;
    }
    else{
       ll extra=k-x/d;
       if(extra&1LL){
         cout<<(d-(x%d))<<endll;
       }
       else{
          cout<<x%d<<endll;
       }
    }
    return 0;
}

/*

*/




Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int mn = 1001;

  rep(i, N)
  {
    int c, t;
    cin >> c >> t;
    if (t <= T && mn > c)
    {
      mn = c;
    }
  }

  if (mn == 1001)
  {
    cout << "TLE" << endl;
  }
  else
  {
    cout << mn << endl;
  }

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	if strings.Contains(s, "a") && strings.Contains(s, "b") && strings.Contains(s, "c") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<int, int, int> tp;
///-------------------------

int main()
{
    Phuong_; /// <3333
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=1; i<=n; ++i){
        ll num = n/i;
        ans += i*((num+1)*num)/2;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3596