akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans;
    int dx = tx - sx, dy = ty - sy;
    ans += string(dx, 'R') + string(dy, 'U') + string(dx, 'L') + string(dy, 'D');
    ans += 'D';
    ans += string(dx+1, 'R') + string(dy+1, 'U');
    ans += "LU";
    ans += string(dx+1, 'L') + string(dy+1, 'D');
    ans += 'R';
    cout << ans << endl;
}


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

using namespace std;

int main()
{
    int a, b, c, temp;

    scanf("%d %d %d", &a, &b, &c);

    if(a>b)
    {
        temp=a;
        a=b;
        b=temp;
    }
    if(a>c)
    {
        temp=a;
        a=c;
        c=temp;
    }
    if(b>c)
    {
        temp=b;
        b=c;
        c=temp;
    }

    printf("%d\n", (b-a)+(c-b) );


    return 0;
}



Measured memory_bytes: 256
n = gets.to_i
f = []
n.times {f << gets.split.map(&:to_i)}
pp = []
n.times {pp << gets.split.map(&:to_i)}

ans = -(10 ** 9)

1.upto(1023) do |i|
    s = i.to_s(2).reverse
    c = Array.new(n,0)
    q = 0

    s.length.times do |j|
        if s[j] == '1'
            f.each_with_index {|e,index| c[index] += e[j]}
        end
    end

    n.times {|k| q += pp[k][c[k]]}
    ans = q if ans < q
end

puts ans

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int A;
  int B;
  cin>>N>>A>>B;
  if (A*N>=B){
    cout<<B<<endl;
  }
   else if (A*N<B){
    cout<<N*A<<endl;
   }
}
     

Measured memory_bytes: 256
function main(arg) {
  const inputs = arg.split("\n");
  const x = inputs[0];
  
  const rate = 1.01;
  
  let counter = 0;
  let credit = 100;
  
  while( credit < x ) {
    credit = Math.floor(credit * rate);
    counter++;
  }
  
  console.log(counter);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29776
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static final List<String> LIST = Arrays.asList("AAA", "BBB");

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			System.out.println(LIST.contains(scanner.next()) ? "No" : "Yes");
		}
	}
}


Measured memory_bytes: 21844
# cook your dish here
n=int(input())
if(n>=400 and n<=599):
    print(8)
elif(n>=600 and n<=799):
    print(7)
elif(n>=800 and n<=999):
    print(6)
elif(n>=1000 and n<=1199):
    print(5)
elif(n>=1200 and n<=1399):
    print(4)
elif(n>=1400 and n<=1599):
    print(3)
elif(n>=1600 and n<=1799):
    print(2)
elif(n>=1800 and n<=1999):
    print(1)

Measured memory_bytes: 9204
#include<iostream>
#include<vector>
#include<algorithm>
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());

    if(a[n-1] == 0){
        cout << "Yes" << endl;
    }else if(n%3){
        cout << "No" << endl;
    }else{
        int k = n/3;
        if(a[0]==a[k-1]&&a[k]==a[2*k-1]&&a[2*k]==a[3*k-1]&&(a[0]^a[k]^a[2*k])==0)
            cout << "Yes" << endl;
        else 
            cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
a,b,h,m = gets.split.map(&:to_i)

d = (h * 30 + 0.5 * m - m * 6).abs
s = [d, 360-d].min

puts Math.sqrt(a**2 + b**2 + (-2 * a * b * Math.cos(s * (Math::PI / 180))))


Measured memory_bytes: 14596
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#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 Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int keta(int n) {
    int res = 0;
    while(n > 0) {
        res ++;//res ++にすると桁数
        n /= 10;//10を変えるとn進数(上のも)
    }
    return res;
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n;
    cin>>n;
    vector<in> a(n);
        rep(i,n) cin>>a.at(i);
    sort(all(a));
    if(a[0]==0ll){
        cout<<0<<endl;
        return 0;
    }
    in ans=1ll;
    rep(i,n){
        in oans=ans;
        ans *=a[i];
        if(ans<oans ||ans>1000000000000000000ll){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3988
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int N,K,C;
ll A[200001];
int B[200001];
vector<int> ans;
 
 
 
int main(){
    cin >> N >> K;
    ll sum = 0;
    for (int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    for (int i=0;i<N-K;i++){
        sum += A[i];
    }
    cout << sum << endl;
    
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int i = 0;
        while ((i + 1) * (i + 1) <= N) {
            i++;
        }
        System.out.println(i*i);
    }

}

Measured memory_bytes: 22740
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
int test[213456], uiop[213456];
signed main() {
	int n, m, a, b = 0, ans = 0; string s, t; cin >> n >> m;
	for (int h = 0; h < m; h++) {
		cin >> a >> s;
		if (s == "AC") {
			test[a] = 1;
		}
		else {
			if (test[a] == 0) { uiop[a]++; }
		}
	}
	for (int h = 0; h <= n; h++) {
		if (test[h] == 1) {
			b++; ans += uiop[h];
		}
	}
	cout << b << ' ' << ans << endl;
}

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

int main(){

  int n, k;
  while(cin >> n >> k){
    vector<int> v;

    if(n == 0 && k == 0)break;

    int s;
    for(int i = 0; i < k; i++){
      cin >> s;
      if(s != 0)
      v.push_back(s);
    }
    sort(v.begin(),v.end());
    // for(int i = 0; i < v.size(); i++){
    //   cout << v[i] << endl;
    // }
    int used[v.size()];
    memset(used,-1,sizeof(used));
    int cnt = 1;
    // cout << v.size() << endl;

    int ans = INT_MIN;
    if(v.size() < k){
      for(int i = 0; i < v.size(); i++){
        cnt = 1;
        int judge = 0;
        int tmp = v[i];
        // cout << v[i] << endl;
        for(int j = i+1; j < v.size(); j++){
          // cout << v[j] << "w" << endl;
          if(v[j] == tmp+1){
            tmp = v[j];
            cnt++;
          }
          else if(v[j] == tmp+2){
            // cout << v[j];
            if(judge == 1) break;
            judge = 1;
            tmp = v[j];
            cnt= cnt + 2;
          }
        }
        judge = 0;
        ans = max(ans,cnt);
      }
    }else {
      // cout << "hoge" << endl;
      for(int i = 0; i < v.size(); i++){
        cnt = 1;
        int tmp = v[i];
        if(used[i] == -1){
          used[i] = 1;
          for(int j = i+1; j < v.size(); j++){
            // cout << "hoge" << endl;
            if(v[j] == tmp+1){
              cnt++;
              tmp = v[j];
              used[j] = 1;
            }else {
              break;
            }
          }
        }
        ans = max(ans,cnt);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1864
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

N = I()
A = LI()
ans = [0]*N
dis = [0]*N
dis[0] = (A[1]-A[0])*2
for i in range(N-1):
    dis[i+1] = dis[i]+2*(A[-N+2*i+3]-A[-N+2*i+2])
#print(dis)

basic = (sum(A) - sum(dis))//N
ans[0] = basic
for i in range(1,N):
    ans[2*i-N] = basic + dis[i-1]

print((' '.join(map(str, ans))))

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

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

int H,W;
int fld[10][10];
int lim;
bool change(int y,int x,int c,int f){
    fld[y][x]=c;
    for(int d=0;d<4;d++){
        int ny=y+dy[d],nx=x+dx[d];
        if(ny<0||ny>=H||nx<0||nx>=W||fld[ny][nx]!=f)continue;
        change(ny,nx,c,f);
    }

}

bool dfs(int t=0){
    bool ok=true;
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        if(fld[0][0]!=fld[i][j])ok=false;
    }
    if(ok)return true;
    if(t==lim)return false;

    int _fld[10][10];
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        _fld[i][j]=fld[i][j];
    }

    bool ret=false;
    for(int k=0;k<3;k++)if(k!=fld[0][0]){
        change(0,0,k,fld[0][0]);
        ret|=dfs(t+1);
        for(int i=0;i<H;i++)for(int j=0;j<W;j++){
            fld[i][j]=_fld[i][j];
        }
    }

    return ret;
}
int main(){
    while(cin>>W>>H,W||H){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                char c;
                cin>>c;
                switch(c){
                case 'R':fld[i][j]=0;break;
                case 'G':fld[i][j]=1;break;
                case 'B':fld[i][j]=2;break;
                }
            }
        }

        for(lim=0;;lim++)if(dfs())break;
        cout<<lim<<endl;
    }

    return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int A, B, C;

    cin >> A >> B >> C;

    if ((C >= A) && (C <= B)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
知らなかったこと

「Ax + Ay + Zi は偶数であること」を
「各カードの値が偶数なのか奇数なのかだけわかれば良い」
と言いかえられなかった.

こういうときは, 本質的に知りたいことは「偶奇」だけである
だから, mod 2をとることでparityに着目する

Ax + Ay mod2が表す意味がわからなかった
・・・「一方の偶奇がわかれば他方の偶奇」もわかる
２つの関係式があったら？？
・・・一つでも偶奇がわかれば他の２つについても偶奇がわかる
・・・ノード x とノード y との間に辺を張ったグラフを用意することで処理できる

・・・そう考えることで
「グラフの各連結成分について、どれか 1 個でも偶奇がわかれば、
連結成分内のすべてのノードの偶奇がわかる」ことになる


・・・よって求める試行回数は, 「グラフの連結成分の個数」である

・・・グラフの連結成分の個数を求めるためには
UnionFindにより「root」の個数が何通りあるか？調べれば良い

重複を許さず, 集合の要素がいくつ存在するかを知りたいときは
要素を全てstd::setへ入れ込んで, .size()によりsetの大きさを求めれば良い

*/


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

class UnionFind{
public:

    //親の番号を格納する. Parentだった場合は−(the size)とする
    vector<int> Parent;
    
    //作るときはParentの値を全て-1にする
    //こうすると, すべての頂点が根となる
    UnionFind(int N){
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A){
        if (Parent[A] < 0) return A; //自分のグループにいる
        return Parent[A] = root(Parent[A]); //親をつなぎ替える
    }
    
    //size関数を作る
    //自分の所属するグループの頂点数を調べる
    long long size(int A){
        return -Parent[root(A)]; //親をとりたい
    }
    
    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接繋がない
        //root(A) に root(B)をくっつける　
        //リーダー同士をくっつける
        
        A = root(A);
        B = root(B);
        
        if (A == B){
            return false; //すでにくっついてる
        }
            
        //大きい方に小さい方をくっつけたい
        //大小が逆だったらひっくり返す
            
        if(size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        
        //BのParentをAに変更する
        Parent[B] = A;
        
        return true; //くっついた
    }
    
};

int main(void){
    
    int n, m;
    cin >> n >> m;
    
    UnionFind uni(n);
    
    for (int i = 0; i < m; i++){
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        
        uni.connect(x,y);
    }
    
    set<int> st;
    
    for (int i = 0; i < n; i++){
        st.insert(uni.root(i));
    }
    
    cout << st.size() << endl;
}


Measured memory_bytes: 5376
#include <stdio.h>

////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int main(void){
	int s;
	int hh;
	int mm;
	int ss;

	scanf("%d", &s);

	hh  = s/3600;
	mm  = (s/60)%60;
	ss  = s%60;

	printf("%d:%d:%d\n", hh, mm, ss);
		
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll k = accumulate(all(b), 0LL) - accumulate(all(a), 0LL);
    ll na = 0, nb = 0;
    rep(i, n) {
        if (a[i] < b[i]) {
            int d = b[i] - a[i];
            if (d % 2 == 0) {
                na += d/2;
            } else {
                na += (d+1)/2; nb++;
            }
        } else if (a[i] > b[i]) {
            nb += a[i] - b[i];
        }
    }
    if (k >= 0 && na <= k && nb <= k && (k - na) * 2 == k - nb) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
typedef long long     ll;
using namespace std;
int main()
{
    ll n,sum=0;
    cin>>n;
    if(n==360)
        cout << 2 << endl;
    else
    {
        for(int i=1;i<=100000;i++)
        {
             sum+=n;
             if(sum%360==0)
             {
                  cout << i << endl;
                  break;
             }
        }
    }
}


Measured memory_bytes: 3632
import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    class Reader {
        BufferedReader in;

        Reader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
        }

        Reader(String name) throws IOException {
            in = new BufferedReader(new FileReader(name));
        }

        StringTokenizer tokin = new StringTokenizer("");

        String next() throws IOException {
            if (!tokin.hasMoreTokens()) {
                tokin = new StringTokenizer(in.readLine());
            }
            return tokin.nextToken();
        }

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

        boolean hasNext() throws IOException {
            if (tokin.hasMoreTokens()) {
                return true;
            } else {
                String s = in.readLine();
                while (s != null && s.length() == 0) {
                    s = in.readLine();
                }
                if (s == null) {
                    return false;
                } else {
                    tokin = new StringTokenizer(s);
                    return true;
                }
            }
        }
    }

    class Writer {
        PrintWriter cout;

        Writer() throws IOException {
            cout = new PrintWriter(System.out);
        }

        Writer(String name) throws IOException {
            cout = new PrintWriter(new FileWriter(name));
        }

        StringBuilder out = new StringBuilder();

        void print(Object a) {
            out.append(a);
        }

        void close() {
            cout.print(out.toString());
            cout.close();
        }
    }

    void run() throws Exception {
        Reader in = new Reader();
        Writer out = new Writer();
        String s = in.next();
        if (s.charAt(s.length() - 1) == 's') {
            out.print(s + "es");
        } else {
            out.print(s + "s");
        }
        out.close();
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  int32 ans = 1;
  while((ans + 1) * (ans + 1) <= n)++ans;
  ANS(ans * ans);
  return 0;
}

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

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

const int N = 2e5+10 , mod = 1e9+7;

int ans[2 * N] , a[N] , t = 0 , mark[N] , lst;

void dfs(int v , int num){
   if(mark[v] == 2)
      return;
   lst = num;
   ans[num] = v;
   if(mark[v] == 1){
      mark[v]++;
      t++;
   }
   if(mark[v] == 0)
      mark[v]++;
   dfs(a[v] , num + 1);
}

int dfs2(int v , int num , int des){
   if(num == des)
      return v;
   return dfs2(a[v] , num + 1 , des);
}

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n;
   ll k;
   cin >> n >> k;
   k++;
   for(int i = 0 ; i < n ; i++){
      cin >> a[i];
      a[i]--;
   }
   dfs(0 , 1);
   if(k <= lst)
      cout << ans[k] + 1;
   else
      cout << dfs2(0 , 1 , (k - lst) % t + lst) + 1;
   return 0;
}


Measured memory_bytes: 6580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Let's Solve Geometric Problems
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		long p, q;
		p = parseInt(line.substring(0, line.indexOf(' ')));
		q = parseInt(line.substring(line.indexOf(' ') + 1));

		//reduce
		q /= gcd(p, q);

		//is prime?
		if (!isPrime(q)) {

			//factorize
			List<Long> f = factors(q);
			if (f.size() != 1) {
				Map<Long, Integer> map = new HashMap<>();
				for (long l : f) {
					map.putIfAbsent(l, 0);
					map.put(l, map.get(l) + 1);
				}
				if (map.size() != 1) {
					boolean multi = true;
					int _c = -1;
					for (int c : map.values()) {
						if (_c == -1) {
							_c = c;
							continue;
						} else {
							if (c != _c) {
								multi = false;
								break;
							}
						}
					}
					q = 1;
					for (long l : map.keySet()) {
						q *= l;
					}
				} else {
					q = f.get(0);
				}
			}
		}
		System.out.println(q);

	}//end main

	static long gcd(long a, long b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	static boolean isPrime(long n) {
		if (n == 2) return true;
		if (n < 2 || n % 2 == 0) return false;

		int i = 3;
		while (i <= Math.sqrt(n)) {
			if (n % i == 0) return false;
			else i += 2;
		}
		return true;
	}

	static List<Long> factors(long n) {
		if (n == 0) return new ArrayList<Long>() {
			{
				add(1L);
			}
		};
		List<Long> fs = new ArrayList<>();
		long p = 2;
		for (long i = p; i <= n; i++) {
			while (n % i == 0) {
				fs.add(i);
				n /= i;
			}
		}
		return fs;
	}
}

Measured memory_bytes: 24740
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

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

const long long INF = 1LL << 60;

int N;
long long h[100010];
long long dp[100010];

int main(void){
    int N,K; 
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> h[i];
    
    for(int i=0; i<100010; i++) dp[i] = INF;
    dp[0] = 0;
    
    for(int i=0; i<N; i++){
        for(int j=1; j<=K; j++){
            chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[N-1] << endl;
    
}


Measured memory_bytes: 1792
import java.util.*;
import java.awt.geom.*;
import java.io.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int dataset = sc.nextInt();
		while(dataset-- > 0){
			String a = sc.next();
			String b = sc.next();
			int anum = solve(a);
			int bnum = solve(b);
			String c = tostr(anum + bnum);
			System.out.println(c);
		}
	}
	
	private int solve(String a) {
		int mul = 1;
		int res = 0;
		int [] value = new int[26];
		value['m' - 'a'] = 1000;
		value['c' - 'a'] = 100;
		value['x' - 'a'] = 10;
		value['i' - 'a'] = 1;
		for(int i = 0; i < a.length(); i++){
			if(Character.isDigit(a.charAt(i))){
				mul = a.charAt(i) - '0';
			}
			else{
				res += value[a.charAt(i) - 'a'] * mul;
				mul = 1;
			}
		}
		return res;
	}
	
	private String tostr(int num) {
		StringBuilder sb = new StringBuilder();
		String [] c = {"m", "c", "x" , "i"};
		for(int i = 1000, count = 0;i != 0; i = i / 10, count++){
			if(num / i == 0){
				continue;
			}
			int temp = num / i;
			if(temp != 1){
				sb.append(num / i);
			}
			sb.append(c[count]);
			num = num % i;
		}
		return sb.toString();
	}
	
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 25268
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int mod=1e9+7;
const double eps=1e-8;
const LL inf=0x3f3f3f3f;
const double pi=acos(-1.0);
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main(){
    int n,a;
    cin>>n;
    LL ans = 0;
    int mx=1;
    for(int i = 1; i <= n; i++)
    {
        cin>>a;
        int m= a/mx;
        if(a%mx==0)m--;
        if(a>=mx)
        {
            ans+=m;
            if(a==mx||i==1) mx++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    vector<i64> A(N);
    i64 s = 0;
    REP(i, N) {
        cin >> A[i];
        s += A[i];
    }

    auto f = [&](i64 x) {
        i64 res = 0;
        REP(i, N) res += (A[i] - x) * (A[i] - x);
        return res;
    };

    i64 ans = min(f(s / N), f(s / N + 1));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        long ans = 0;
        for (int i = 0; i < (1 << (n - 1)); i++) {
            int l = 0;
            for (int j = 0; j < n - 1; j++) {
                if ((i & (1 << j)) == 0) continue;
                String sub = s.substring(l, j + 1);
                long add = Long.parseLong(sub);
                ans += add;
                l = j + 1;
            }
            String f = s.substring(l, s.length());
            long a = Long.parseLong(f);
            ans += a;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] a) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		StringBuffer sb = new StringBuffer(str);
		str = sb.reverse().toString();
		System.out.println(str);
	}
}

Measured memory_bytes: 24124
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
def cmb(n,r):
    return factorial(n) // factorial(r) // factorial(n - r)

n,m=mii()
ans=0
if n<2 and m<2:
    print(0)
elif n>=2 and m<2:
    print(cmb(n,2))
elif n<2 and m>=2:
    print(cmb(m,2))
else:
    print(cmb(n,2)+cmb(m,2))






Measured memory_bytes: 65516
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std;


 
int main() 
{
	string s;
	long long k;
	cin >> s >> k;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'a')
		{
			continue;
		}
		long long tmp = 'z' - s[i] + 1;
		if (k >= tmp)
		{
			k -= tmp;
			s[i] = 'a';
		}
	}
	s[s.size() - 1] += (k % 26);
	cout << s << endl;



}

 

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

int main(){
    int K;
    cin>>K;
    vector<int> vec={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<vec.at(K-1)<<endl;
}

Measured memory_bytes: 256
// @Problem https://atcoder.jp/contests/abc121/tasks/abc121_b
use proconio::input;

fn main() {
    input!{
        n: u32,
        m: u32,
        c: i32,
        br: [i32; m],
        ar: [[i32; m]; n],
    }

    let mut count = 0;

    for row in ar.iter() {
        let mut sum = c;
        for (a_row_j, b_row_j) in row.iter().zip(br.iter()) {
            sum += a_row_j * b_row_j
        }
        if sum > 0 {
            count += 1;
        }
    }

    println!("{}", count);

}


Measured memory_bytes: 2136
#include <iostream>
#include <climits>
#include <vector>

using namespace std;

#define lsb(i) ((i)&(-i))

int N;
vector <long long> h;	//heights
vector <long long> a;	//beauties
vector <long long> bit; //Binary Indexed Tree/Fenwick Tree

void update(int j,long long value){
	for(int i=j;i<=N;i+=lsb(i)){
		 bit[i] = max(value,bit[i]);
	}
}

long long getMax(int j){
	long long Max = 0;
	for(int i=j;i>0;i-=lsb(i)){
		Max = max(Max,bit[i]);
	}
	return Max;
}

int main(){
	cin>>N;

	h.resize(N+1);
	a.resize(N+1);
	bit.resize(N+1,0);

	for(int i=1;i<=N;i++)
		cin>>h[i];

	for(int i=1;i<=N;i++){
		cin>>a[i];
	}

	/*
	vector <long long> BestTill(N+1);
	long long best = 0;
	for(int i=2;i<=N;i++){
		best = a[i];
		for(int j=1;j<i;j++)
			if(h[j]<h[i])
				best = max(best,BestTill[j]);
		BestTill[i] = best + a[i];
	}
	This aproach is O(n²)
	TLE
	*/

	for(int i=1;i<=N;i++){
		update(h[i],getMax(h[i]-1)+a[i]);
	}
	// O(n*logn) 
	// From previous flowers we are getting
	// Max-beauty from flowers which have h[j]<h[i]
	// And Update Corresponding beauty h[i]
	// For Stricty increasing?
	// update(h[i], max(getMax(h[i]-1),a[i]) );

	cout<<getMax(N)<<endl;
}


Measured memory_bytes: 7996
import math

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

thetaA =  math.radians(0.5*(60*H+M))
thetaB = math.radians(6*M)

Ax = A*math.cos(thetaA)
Ay = A*math.sin(thetaA)

Bx = B*math.cos(thetaB)
By = B*math.sin(thetaB)

dis = math.sqrt(pow(Ax-Bx,2) + pow(Ay-By,2))
print(dis)

Measured memory_bytes: 9580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
 
int main(){
    char s[1000];
    cin >> s;
  	int len = strlen(s);
  	if(s[len-1] != 's')cout<<s<<"s";
  	else if(s[len-1] == 's')cout<<s<<"es";
    return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

string s;


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>s;
    if(s=="ABC"){
        print("ARC");
    }else{
        print("ABC");
    }
    return 0;
}

Measured memory_bytes: 3640
n = int(input())
digit = len(str(n))
if digit%2 != 0:
    if digit == 1:
        print(n)
    elif digit == 3:
        print(n-90)
    else:
        print(n-10000+900+10)
else:
    if digit == 2:
        print(9)
    elif digit == 4:
        print(909)
    else:
        print(90909)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 
 
int main() {
    string S; cin >> S;
    ll Q; cin >> Q;
    bool flag = true;
    for(int i = 0; i < Q; i++){
        int T; cin >> T;
        if(T == 1){
            if(flag) flag = false;
            else if(!flag)flag = true;
            //reverse(S.begin(), S.end());
        }
        else if (T == 2){
            int f;cin >> f;
            string ch; cin >> ch;
            if(f == 1){
                if(flag) S.insert(0, ch);
                else if(!flag)S += ch;
            }
            else if(f == 2){
                if(flag) S += ch;
                else if(!flag)S.insert(0, ch);
            }
        }
    }
    if(flag) cout << S << endl;
    else if(!flag){
        reverse(S.begin(), S.end());
        cout << S << endl;
    }
}

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

long long int mem[100006];


long long int frog_dp(long long int i,long long int n,long long int ht[],int k)
{
    int j;
    if(i>=n)return 0;
    if(mem[i]!=-1)return mem[i];
    if(k==1)
    mem[i]=frog_dp(i+1,n,ht,k)+abs(ht[i+1]-ht[i]);

    if(k!=1)
    mem[i]=min(frog_dp(i+1,n,ht,k)+abs(ht[i+1]-ht[i]),frog_dp(i+2,n,ht,k)+abs(ht[i+2]-ht[i]));

    for(j=3; j<=k; j++)
    {
        mem[i]=min(mem[i],frog_dp(i+j,n,ht,k)+abs(ht[i+j]-ht[i]));
    }

    return mem[i];
}

int main()
{
    long long int n,i,k;
    cin>>n>>k;
    long long int ht[n+k+3];
    for(i=1; i<=n; i++)
        cin>>ht[i];
        for(i=1; i<=k+2; i++ )
        ht[n+i]=9999999999999;

        memset(mem,-1,sizeof(mem));
    cout<<frog_dp(1,n,ht,k)<<endl;


    return 0;
}



Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int INF=100000000;

int gcd(int x, int y){
  if(x==INF)return y;
  if(y==INF)return x;
  int r;
  while((r= x % y)!=0){x=y; y=r;}
  return y;
}

struct SegmentTree{
  private:
  int n;
  vector<int> node;
  
  public:
  SegmentTree(vector<int> v){
    int sz=v.size();
    n=1; while(n<sz)n*=2;
    node.resize(2*n-1,INF);
    for(int i=0;i<sz;i++)node[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)node[i]=gcd(node[2*i+1],node[2*i+2]);
  }
  
  void update(int x,int val){
    x+=(n-1);
    node[x]=val;
    while(x>0){
      x=(x-1)/2;
      node[x]=gcd(node[2*x+1],node[2*x+2]);
    }
  }
    
  int getmin(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    if(r<=a || b<=l)return INF;
    if(a<=l && r<=b)return node[k];
      
    int vl=getmin(a,b,2*k+1,l,(l+r)/2);
    int vr=getmin(a,b,2*k+2,(l+r)/2,r);
    return gcd(vl,vr);
  }
};

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++)cin >> A[i];
  int ans=1;
  SegmentTree seg(A);
  for(int i=0;i<N;i++){
    int q=gcd(seg.getmin(0,i),seg.getmin(i+1,N));
    ans=max(ans,q);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int l,r;
    cin >> l >> r;
    ll ans = 2019;
    if(l - r >= 2019){
        cout << 0 << endl;
    }
    repi(i,r + 1,l){
        repi(j,r + 1,i+1){
            ans = min(ans,((i%2019) * (j%2019))%2019);
            if(ans == 0){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
    ll n;
    cin>>n;
    double dp[n+1][n+1],a[n+1];
    memset(dp,0,sizeof(dp));
    a[0]=0.000;
    for(ll i=0;i<n;i++)cin>>a[i+1];
    dp[1][0]=1-a[1];
    dp[1][1]=a[1];
    for(ll i=2;i<=n;i++){
        for(ll j=0;j<=n;j++){
            dp[i][j]=dp[i-1][j]*(1-a[i]);
            if(j)dp[i][j]+=dp[i-1][j-1]*(a[i]);
        }
    }
    double ans=0;
    for(ll i=n/2+1;i<=n;i++)ans+=dp[n][i];
    cout<<fixed<<setprecision(12)<<ans<<endl;


return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
const int mod = 1e9 + 7;
typedef pair<lint, lint> pi;

lint d;
lint p[20];
int dx1[20], dx2[20];
vector<lint> v;

void dfs(int s, int e, vector<pi> &w, lint val, lint cnt){
	if(s == e){
		w.push_back(pi(val, cnt));
		return;
	}
	for(int i=-9; i<=9; i++){
		dfs(s+1, e, w, val + i * v[s], cnt * (s == 0 ? dx2[i + 10] : dx1[i + 10]));
	}
}

lint solve(int l){
	v.clear();
	for(int i=0; l-1-i > i; i++){
		v.push_back(p[l-1-i] - p[i]);
	}
	vector<pi> v1, v2;
	dfs(0, (v.size() + 1) / 2, v1, 0, 1);
	dfs((v.size() + 1) / 2, v.size(), v2, 0, 1);
	lint ans = 0;
	map<lint, lint> mp;
	for(auto &i : v2) mp[i.first] += i.second;
	for(auto &i : v1){
		ans += mp[i.first + d] * i.second;
	}	
	if(l % 2 == 1) ans *= 10;
	return ans;
}

int main(){
	p[0] = 1;
	for(int i=1; i<20; i++) p[i] = p[i-1] * 10;
	for(int i=0; i<10; i++){
		for(int j=0; j<10; j++){
			dx1[i-j+10]++;
		}
	}
	for(int i=1; i<10; i++){
		for(int j=0; j<10; j++){
			dx2[i-j+10]++;
		}
	}
	cin >> d;
	lint ans = 0;
	for(int i=2; i<=18; i++) ans += solve(i);
	cout << ans << endl;
}


Measured memory_bytes: 205936
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		int a,b,c;
		Scanner br =new Scanner(System.in);
		a=br.nextInt();
		b=br.nextInt();
		c=br.nextInt();
		int s_1=0,s_2=0,s_3=0;
		if(a<b){
			s_1=a;
			s_2=b;
		}else{
			s_1=b;
			s_2=a;
		}
		if(s_1<c && s_2<c){
			s_3=c;
		}else if(c<=s_2 && c>=s_1){
			s_3=s_2;
			s_2=c;
		}else if(s_1>c && s_2>c){
			s_3=s_2;
			s_2=s_1;
			s_1=c;
		}
		System.out.println(s_1+" "+s_2+" "+s_3);
	}
}

Measured memory_bytes: 26060
n = int(input())
count = list()
for b in range(4):
    count.append(list())
    for f in range(3):
        count[b].append(list())
        for r in range(10):
            count[b][f].append(0)

read = 0
while read < n:
    b,f,r,v = [int(x) for x in input().split(" ")]
    count[b-1][f-1][r-1] += v
    read += 1

for b in range(len(count)):
    for f in range(len(count[b])):
        for r in range(len(count[b][f])):
            print("", count[b][f][r], end="")
        print()
    if b < len(count) - 1:
        print("####################")

Measured memory_bytes: 7696
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::{BTreeMap,BTreeSet};
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! tf {
    ($c:expr, $t:expr, $f:expr) => {{
        if $c { $t } else { $f }
    }};
}

fn main() {
    let n = read_i64();
    let mut res = 0;
    for i in 1..n+1 {
        if i % 2 == 0 {
            continue;
        }
        let mut count = 0;
        for k in 1..i+1 {
            if i % k == 0 {
                count += 1;
            }
        }
        if count == 8 {
            res += 1;
        }
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    //ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <array>
#include <stdlib.h>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main() {
	int n;
	int a[100000];
	cin >> n;
	rep(i, 0, n)
		cin >> a[i];
	set<int> s;
	int ans = 0;
	int c;
	rep(i, 0, n) {
		c = s.erase(a[i]);
		if (c == 0) {
			s.insert(a[i]);
			ans++;
		}
		else {
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5376
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
const int N = (int) 1e6 + 6, mod = (int) 0;
vector<int> ord;
int markn[N], a[N], cnt[N], pl[N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    for (int i = 0; i < q; ++i) {
        cin >> a[i];
        a[i]--;
    }
    cnt[0] = n;
    for (int i = q - 1; i >= 0; --i) {
        if (!markn[a[i]]++) {
            ord.push_back(a[i]);
        }
    }
    for (int i = 0; i < m; ++i)
        if (!markn[i]++) {
            ord.push_back(i);
        }
    for (int i = 0; i < m; ++i)
        pl[ord[i]] = i;
    for (int i = q - 1; i >= 0; --i) {
        if (cnt[pl[a[i]]] == 0) continue;
        cnt[pl[a[i]]]--;
        cnt[pl[a[i]] + 1]++;
    }
    int sr = 0;
    for (int i = m - 2; i >= 0; --i) {
        if (ord[i + 1] < ord[i]) {
            sr = i + 1;
            break;
        }
    }
    for (int i = 0; i < sr; ++i) {
        if (cnt[i] > 0) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";


}





Measured memory_bytes: 2296
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Int
getInt = (\a -> read a :: Int) <$> getLine

getIntArray :: IO [Int]
getIntArray = ((map (\a -> read a :: Int)) . words) <$> getLine

getStrArray :: Int -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

countTop :: String -> Int
countTop "" = 700
countTop ('o':rst) = 100 + countTop rst
countTop ('x':rst) = countTop rst

main = do
    print =<< countTop <$> getLine


Measured memory_bytes: 380
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws Exception
    {
        Scanner sc = new Scanner(System.in);
        int V = sc.nextInt();
        int E = sc.nextInt();
        int [][]dist = new int [V][V];
//        int [][]path = new int [V][V];


        for(int i=0;i<V;i++){
            for(int j=0;j<V;j++){
                dist[i][j] = -1;
//                path[i][j] = j;
            }
        }

        int a[] = new int[E];
        int b[] = new int[E];
        int c[] = new int[E];

        for(int i=0;i<E;i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            a[i]=x-1;
            b[i]=y-1;
            dist[x-1][y-1] = sc.nextInt();
            dist[y-1][x-1] = dist[x-1][y-1];
            c[i] = dist[x-1][y-1];
        }

        for(int i = 0;i< V;i++)
        {
            for(int j = 0;j< V;j++)
            {
                for(int k = 0;k< V;k++)
                {
                    int tmp = dist[j][i]+dist[i][k];
                    if(dist[j][i]>=0&&dist[i][k]>=0) {
                        if (tmp < dist[j][k]||dist[j][k]==-1) {
                            dist[j][k] = tmp;
//                            path[j][k] = path[j][i];
                        }
                    }

                }
            }
        }

        int ans = 0;

        for(int i=0;i<E;i++){
            if(dist[a[i]][b[i]]<c[i]){
                ans++;
            }
        }

//        StringBuilder sb = new StringBuilder();
//        for(int i=0;i<V;i++)
//        {
//            for(int j=0;j<V;j++)
//            {
////               sb.append("("+i+","+j+"):");
////                sb.append(i);
//                int tmp = i;
//                while (tmp!=j){
//
//                    tmp = path[tmp][j];
////                    sb.append(tmp);
//
//                }
////                System.out.println(sb.toString());
////                sb = new StringBuilder();
//            }
//        }

        System.out.println(ans);
        sc.close();
    }



}

Measured memory_bytes: 14600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> request(M);
    rep(i, M)
    {
        cin >> request[i].second >> request[i].first;
    }
    sort(request.begin(), request.end());
    int ans = 0;
    int break_bridge = -1;
    rep(i, M)
    {
        int a = request[i].second;
        int b = request[i].first;
        //cout << a << "->" << b << endl;
        if (a <= break_bridge && break_bridge < b)
        {
            continue;
        }
        else
        {
            break_bridge = b - 1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
def main():
    n = int(input())
    a = list(map(int,input().split()))
    Ilis = {}
    Jlis = {}
    for i in range(n):
        k = a[i]+i+1
        l = i-a[i]+1
        if k not in Ilis.keys():
            Ilis[k] = 1
        else:
            Ilis[k]+=1
        if l not in Jlis.keys():
            Jlis[l]=1
        else:
            Jlis[l]+=1
    ans = 0
    for i in Ilis.keys():
        if i in Jlis.keys():
            ans += Ilis[i]*Jlis[i]
    print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

int main(){

    int x;
     cin>>x;
     if(x/10==x/1000*111)cout<<"Yes\n";
     else if(x%1000==x%10*111)cout<<"Yes\n";
     else cout<<"No\n";
     return 0;

 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char b;
	cin>>b;
	if(b=='A')
	{
		cout<<'T'<<endl;
		return 0;
	}
	if(b=='T')
	{
		cout<<'A'<<endl;
		return 0;
	}if(b=='G')
	{
		cout<<'C'<<endl;
		return 0;
	}
	if(b=='C')
	{
		cout<<'G'<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int count=0, N;
  cin >> S;
  N = S.size();
  for (int i=0; i<N; i++){
    if (S.at(i) != S.at(N-1-i)){
      S.at(i) = S.at(N-1-i);
      count++;
    }
    else
      continue;
  }
  cout << count << endl;
}

Measured memory_bytes: 256