akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<P>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


const int MOD=1000000007;
int INF=100100100100100;
Graph g(20);

int cnt=0;
int dfs(int n){
  if(n==1)return 0;
  int v=dfs(n/2)+1;
  g[v-1].pb(P(v,0));
  g[v-1].pb(P(v,n/2));
  cnt+=2;
  if(n%2){g[0].pb(P(v,n-1));cnt++;}
  return v;
}
signed main(){
  int n;cin>>n;
  int ko=dfs(n)+1;
  cout<<ko<<" "<<cnt<<endl;
  rep(i,20){
    for(auto p:g[i])cout<<i+1<<" "<<p.F+1<<" "<<p.S<<endl;
  }
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int k[n];
  rep(i,n){
    int a;
    cin >> a;
    k[i]=a;
  }
  int min=k[0];
  int ans=0;
  rep(i,n){
    if(min>=k[i]){
      ans++;
      min=k[i];
    }
  }
  cout << ans << endl;
}
                     


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

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


int main(){
    long long N,M;
    cin>>N>>M;
    
    string S,T;
    cin>>S>>T;
    
    long long g=gcd(N,M);
    long long L=N*M/g;
    
    bool judge=true;
    for(int i=0;i<g;i++){
        if(S[i*N/g]!=T[i*M/g]){
            judge=false;
            break;
        }
    }
    
    if(judge)cout<<L<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

double PI = acos((double)-1);
const ld eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
//const ll mod = 1e9 + 9;
const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

const int N = 2e5 + 7;

ll cnt[N];

void solve() {
	fill(cnt, cnt + N, -inf);
	int x, y;
	cin >> x >> y;
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> a1(a), b1(b), c1(c);
	for (int& i : a1) cin >> i;
	for (int& i : b1) cin >> i;
	for (int& i : c1) cin >> i;
	vector<pair<int ,int>> kek;
	for (int i : a1) kek.push_back({ i, 0 });
	for (int i : b1) kek.push_back({ i, 1 });
	sort(rall(kek));
	int c0 = x;
	int cc = y;
	int cn = 0;
	ll su = 0;
	cnt[0] = 0;
	for (auto u : kek) {
		if (u.second == 0) {
			if (c0) {
				c0--;
				su += u.first;
				cn++;
			}
		}
		else {
			if (cc) {
				cc--;
				su += u.first;
				cn++;
			}
		}
		cnt[cn] = su;
	}
	ll ans = cnt[x + y];
	sort(rall(c1));
	su = 0;
	for (int i = 0; i < c; i++) {;
		if ((i + 1) > x + y) break;
		su += c1[i];
		ans = max(ans, cnt[x + y - i - 1] + su);
	}
	cout << ans << endl;
	return;
}

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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  cout << (n - 1) * (m - 1) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        int[] num = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int q = int.Parse(Console.ReadLine());
        for(int i=0; i<q; i++){
            int[] line = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            if(line[0] == 0){
                Console.WriteLine(num.Skip(line[1]).Take(line[2]-line[1]).Min());
            }
            else{
                Console.WriteLine(num.Skip(line[1]).Take(line[2]-line[1]).Max());
            }
        }
    }
}



Measured memory_bytes: 18372
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	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]);
	}

	//自分のいるグループの頂点数を調べる
	int 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;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	char a[110], b[110];
	cin >> a >> b;
	if (strlen(a) == strlen(b)) {
		rep(i, strlen(a)) {
			if (a[i] < b[i]) {
				cout << "LESS" << endl;
				return 0;
			}
			if (a[i] > b[i]) {
				cout << "GREATER" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}
	if (strlen(a) > strlen(b)) {
		cout << "GREATER" << endl;
	}
	if (strlen(a) < strlen(b)) {
		cout << "LESS" << endl;
	}
	return 0;
}

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

namespace Cs
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] st = str.Split(' ');
            int[] ss = new int[4];
            for (int i = 0; i < 4; i++)
            {
                ss[i] = int.Parse(st[i]);
            }
            int sa1 = ss[2] - ss[0];
            int sa2 = ss[3] - ss[1];

            string kotae = kuri("R", sa1) + kuri("U", sa2) + kuri("L", sa1) + kuri("D", sa2) + "D" + kuri("R", sa1 + 1) + kuri("U", sa2 + 1) + "L" + "U" + kuri("L", sa1 + 1) + kuri("D", sa2 + 1) + "R";
            Console.WriteLine(kotae);
        }

        static string kuri(string a, int k)
        {
            string b = "";
            for (int i = 0; i < k; i++)
            {
                b += a;
            }
            return b;
        }
    }
}


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

int main(){
    ll D;
    cin >> D;
    vector<ll> c(26), t(D), last(26, -1);
    vector< vector<ll> > s(365, vector<ll> (26));
    rep(i, 0, 26) cin >> c[i];
    rep(i, 0, D){
        rep(j, 0, 26) cin >> s[i][j];
    }
    srand((unsigned int)time(NULL));
    rep(i, 0, D){
        t[i] = (ll) (rand() % 26);
    }
    ll M = 1e6;
    vector<ll> d(M), q(M), rec(26, 0);
    rep(i, 0, M){
        d[i] = (ll) (rand() % D);
        q[i] = (ll) (rand() % 26);
    }
    ll res = 0;
    rep(d, 0, D){
        res += s[d][t[d]];
        last[t[d]] = d;
        rep(j, 0, 26) {
            res -= c[j] * (d - last[j]);
            rec[j] += c[j] * (d - last[j]);
        }
    }
    // t[d[m]] := 0 - 25
    rep(m, 0, M){
        ll prev_res = res;
        res -= s[d[m]][t[d[m]]];
        res += s[d[m]][q[m]];
        res += rec[t[d[m]]];
        res += rec[q[m]];
        ll tdrec = 0, qrec = 0;
        ll lst = -1;
        rep(i, 0, D){
            if(i != d[m] && t[i] == t[d[m]]){
                lst = i;
            }
            res -= c[t[d[m]]] * (i - lst);
            // rec[t[d[m]]] +=  c[t[d[m]]] * (i - lst);
            tdrec +=  c[t[d[m]]] * (i - lst);
        }
        lst = -1;
        rep(i, 0, D){
            if(i == d[m] || t[i] == q[m]){
                lst = i;
            }
            res -= c[q[m]] * (i - lst);
            // rec[q[m]] += c[q[m]] * (i - lst);
            qrec += c[q[m]] * (i - lst);
        }
        if(res > prev_res){
            rec[t[d[m]]] = tdrec;
            rec[q[m]] = qrec;
            t[d[m]] = q[m];
        }else{
            res = prev_res;
        }
        // cout << res << endl;
    }
    rep(i, 0, D) cout << t[i]+1 << endl;
    return 0;
}

Measured memory_bytes: 19096
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  map<int,int> m;
  REP(i,N){
    int a;
    cin>>a;
    m[a]+=1;
  }
  int ans=0;
  for(auto i:m){
    if(i.second%2==1)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <utility>
#include <string>
#include <vector>
#include <map>

using std::cin;
using std::cout;
using std::endl;

const int N_MAX = 100;

long long n;

const std::string c = "ACGT";

std::map<std::pair<int, std::string>, long long> dp;

bool slv_ok(std::string s) {

    if(s.size() < 3) return true;

    std::string ngs;

    ngs = "AGAC";
    for(int i = 0; i < c.size(); i++) {
        ngs[2] = c[i];
        if(ngs == s) return false;
    }

    ngs = "AAGC";
    for(int i = 0; i < c.size(); i++) {
        ngs[1] = c[i];
        if(ngs == s) return false;
    }

    ngs = "AGC";
    if(s.substr(0, 3) == ngs || s.substr(1, 3) == ngs) return false;

    ngs = "ACG";
    if(s.substr(0, 3) == ngs || s.substr(1, 3) == ngs) return false;

    ngs = "GAC";
    if(s.substr(0, 3) == ngs || s.substr(1, 3) == ngs) return false;

    return true;
}

long long slv(int now, std::string s) {

    if(!slv_ok(s)) return 0;    

    if(now == 0) return 1;
    if(dp.find(std::make_pair(now, s)) != dp.end()) return dp[std::make_pair(now, s)];

    long long ret = 0;

    std::string mem = s;

    if(s.size() > 3) {
        for(int i = 0; i < 3; i++) {
            s[i] = s[i+1];
        }
        s.pop_back();
    }

    for(int i = 0; i < c.size(); i++) {
        ret = (ret + slv(now-1, s+c[i])) % 1000000007;
    }

    return dp[std::make_pair(now, mem)] = ret % 1000000007;
}

int main(){

    cin >> n;

    cout << slv(n, "") << endl;

    return 0;
}

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


int main(){
  string s,t,ans="";
  bool f[3010][3010]={};
  cin>>s>>t;
  int n=s.length(),m=t.length(),dp[3010][3010];
  fr(p,n+m+1){
    for(int i=max(0,p-m);i<=min(p,n);i++){
      int j=p-i;
      if(i==0||j==0) dp[i][j]=0;
      else if(s[i-1]==t[j-1]){dp[i][j]=dp[i-1][j-1]+1;f[i][j]=1;}
      else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  while(dp[n][m]>0){
    if(f[n][m]){n--;m--;ans=s[n]+ans;continue;}
    if(dp[n-1][m]>dp[n][m-1]) n--;
    else m--;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 44416
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    R = int(input())
    G = int(input())
    print(G*2-R)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,a=4,b=7,n,sum=0;
	cin>>n;
	for(i=0;i*4<=n;i++)
	{
		if(n-a*i!=0)
		{
			if((n-a*i)%b==0)
			sum++;
		}
		else
		{
			sum++;
		}	
	}
	if(sum>=1)
	cout<<"Yes";
	else
	cout<<"No";
    return 0;
}

Measured memory_bytes: 256
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
$ans=30;
$i=0;
while($i<$n){
    $c=$a[$i];
    $ans_i=0;
    while($c%2==0){
        ++$ans_i;
        $c/=2;
    }
    $ans=min($ans,$ans_i);
    if($ans==0){
        break;
    }
    ++$i;
}
echo $ans;

Measured memory_bytes: 4856
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  int n, d;
  cin >> n >> d;
  int range = 2*d+1;
  if (n % range == 0) {
    cout << n / range << '\n';
  } else {
    cout << n / range + 1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;

	//water + suger, suger
	PII ans = mp(-1, -1);
	for (int w1 = 0; w1 <= f; w1 += 100 * a)for (int w2 = 0; w2 <= f; w2 += 100 * b) {
		if (w1 + w2 > f)continue;

		for (int s1 = 0; s1 <= f - w1 - w2; s1 += c)for (int s2 = 0; s2 <= f - w1 - w2; s2 += d) {
			if (w1 + w2 + s1 + s2 > f || w1 + w2 == 0)continue;

			int wa = w1 + w2, su = s1 + s2;
			if (wa / 100 * e >= su) {
				if (ans == mp(-1, -1))ans = mp(wa + su, su);
				else if ((double)(ans.second * 100) / (double)(ans.first) < (double)(su * 100) / (double)(wa + su))ans = mp(wa + su, su);
			}
		}
	}
	cout << ans.first << " " << ans.second << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>
using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int h,w,k;
    cin >> h >> w >> k;
    vs s(h);
    rep(i,h)cin >> s[i];
    vvi ans(h,vi(w,0));
    int cnt = 1;
    rep(i,h)rep(j,w)if(s[i][j] == '#'){
        rep(x,i+1)if(ans[x][j] == 0)ans[x][j] = cnt;
        cnt++;
    }
    rep(j,w)if(ans[h-1][j] == 0){
        int i = h-1;
        while(i >= 0 && ans[i][j] == 0)i--;
        //cout << i << endl;
        if(i != -1){
            i++;
            while(i < h)ans[i][j] = ans[i-1][j],i++;
        }
    }
    loop(j,1,w)if(ans[0][j-1] != 0 && ans[0][j] == 0){
        rep(i,h)ans[i][j] = ans[i][j-1];
    }

    for(int j = w-2; j >= 0; j--)if(ans[h-1][j] == 0){
        rep(i,h)ans[i][j] = ans[i][j+1];
    }
    rep(i,h){
        rep(j,w){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(15);
	ll n;
	cin>>n;
	string s;
	ll x,y,z;
	while(n>0)
	{
		x=n%26;
		if(x==0)
		x=26;
		s.push_back('a'+x-1);
		n-=x;
		n/=26;
	}
	reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define Pi pair<int,int>
#define IINF 1e9
#define LINF 1e18
#define vi vector<int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, 0,-1,0 };
int dy[] = { 0, 1,0,-1 };

void solve() {
	int n;
	cin >> n;
	ll A, B;
	rep(i, n) {
		ll t, a;
		cin >> t >> a;
		if (i == 0) {
			A = t;
			B = a;
		}
		else {
			if (A > t || B > a) {
				ll x, y;
				x = A / t;
				y = B / a;
				if (t*x < A) {
					x++;
				}
				if (a*y < B) {
					y++;
				}
				A = t * max(x, y);
				B = a * max(x, y);
			}
			else if (A <= t && B <= a) {
				A = t;
				B = a;
			}
		}
	}
	P(A + B);
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	long long int a;
	cin>>a;
	long long int x=100,ct=0;
	while(x!=a)
	{
		x+=(x*1)/100;
		ct++;
		if(x>=a)
			break;
	}
	cout<<ct;
	return 0;
}


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

using namespace std;
int bit[100005],n,m,maxt=0;

struct test
{
	int st,et,ch;
}a[100005];

void update(int pos,int x)
{
	while(pos<=maxt)
	{
		bit[pos]+=x;
		pos+= pos&(-pos);
	}
}

long long sum(int pos)
{
	long long ret=0;
	while(pos)
	{
		ret+=bit[pos];
		pos-= pos&(-pos);
	}
	return ret;
}

bool cmp(test x,test y)
{
	if(x.ch!=y.ch) return x.ch<y.ch;
	if(x.st!=y.st) return x.st<y.st;
	return x.et<y.et;
}

int main()
{
	cin >> n >> m;
	
	for(int i=1;i<=n;i++)
	{
		cin >> a[i].st >> a[i].et >> a[i].ch;
		maxt=max(maxt,a[i].et);
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		if(a[i].ch==a[i-1].ch && a[i].st==a[i-1].et) update(a[i].st+1,1);
		else update(a[i].st,1);		
		update(a[i].et+1,-1);
	}
	
	long long res=0;
	for(int i=1;i<=maxt;i++) res=max(res,sum(i));
	cout << res;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin>>N;
    vl A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));

    ll tmp = A[0];
    bool ok = true;
    repe(i,1,N){
        if(A[i]==tmp){
            ok = false;
            break;
        }
        tmp = A[i];
    }

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

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

ll a, b, c;
int main() {
    cin>>a>>b>>c;

    if(a%2==1 && b%2==1 && c%2==1) cout<<min(a*b, min(b*c, c*a))<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

const size_t V_MAX = 100000;

std::vector<std::pair<size_t, int>> edges[V_MAX];
int ds[V_MAX];
size_t paeh[V_MAX];
std::vector<size_t> heap;

void bubble_up(size_t i) {
  while (i) {
    auto j = (i - 1) / 2;
    if (ds[heap[j]] <= ds[heap[i]])
      break;
    std::swap(paeh[heap[i]], paeh[heap[j]]);
    std::swap(heap[i], heap[j]);
    i = j;
  }
}

void bubble_down(size_t i) {
  for (;;) {
    auto j = 2 * i + 1, k = 2 * i + 2;
    if (k < heap.size() && ds[heap[k]] < ds[heap[i]]) {
      if (ds[heap[j]] < ds[heap[k]]) {
        std::swap(paeh[heap[i]], paeh[heap[j]]);
        std::swap(heap[i], heap[j]);
        i = j;
      } else {
        std::swap(paeh[heap[i]], paeh[heap[k]]);
        std::swap(heap[i], heap[k]);
        i = k;
      }
    } else if (j < heap.size() && ds[heap[j]] < ds[heap[i]]) {
      std::swap(paeh[heap[i]], paeh[heap[j]]);
      std::swap(heap[i], heap[j]);
      i = j;
    } else
      break;
  }
}

int main() {
  size_t V, E, r;
  scanf("%zd%zd%zd", &V, &E, &r);
  for (size_t i = 0; i < E; i++) {
    size_t s, t;
    int d;
    scanf("%zd%zd%d", &s, &t, &d);
    edges[s].push_back(std::make_pair(t, d));
  }
  std::fill(ds, ds + V, -1);
  ds[r] = 0;
  heap.push_back(r);
  while (heap.size()) {
    size_t s = heap.front();
    if (heap.size() == 1)
      heap.pop_back();
    else {
      paeh[heap.front() = heap.back()] = 0;
      heap.pop_back();
      bubble_down(0);
    }
    for (auto&& p : edges[s]) {
      auto t = p.first;
      auto d = ds[s] + p.second;
      if (ds[t] < 0) {
        ds[t] = d;
        heap.push_back(t);
        paeh[t] = heap.size()-1;
        bubble_up(heap.size()-1);
      } else if (ds[t] > d) {
        ds[t] = d;
        bubble_up(paeh[t]);
      }
    }
  }
  for (size_t s = 0; s < V; s++)
    if (ds[s] < 0)
      puts("INF");
    else
      printf("%d\n", ds[s]);
  return 0;
}

Measured memory_bytes: 17944
#include <stdio.h>
int main(void){
    int S,h,m,s,base=0;
    scanf("%d",&S);
    base+=S;
    h=base/3600;
    m=(base%3600)/60;
    s=(base%3600)%60;
    printf("%d:%d:%d\n",h,m,s);
    
    
}


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

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

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

  if (n == m) cout << "Yes\n";
  else cout << "No\n";

  return (0);
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main{
    public static void swap(int[] a, int n, int m){
        int temp = a[n];
        a[n] = a[m];
        a[m] = temp;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] sum = new int[w];
        for(int i=0; i<w; i++){
            sum[i] = i+1;
        }
        for(int i=0; i<n; i++){
            String[] s = sc.next().split(",");
            int a = Integer.parseInt(s[0]);
            int b = Integer.parseInt(s[1]);
            swap(sum, a-1, b-1);
        }

        for(int i=0; i<w; i++){
            System.out.println(sum[i]);
        }
    }
}


Measured memory_bytes: 26280
#include<cstdlib>
#include<vector>
#include<string>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<cstdio>
#include<iostream>
#include<vector>
#define MAXN 1000
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	//freopen("../in", "r", stdin);
//	freopen("../out", "w", stdout);
	ll m, n;
	cin>>m>>n;
	ll sum=0;
	for(ll i=0;i<m;i++) {
		ll temp;
		cin >> temp;
		if (temp >= n)
			sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 99999999
#define N 3000003
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
ll n , r[N] , g[N] , b[N] , ans , ok ;
string s;
string check = "RGB";
char check1(char fr , char sc){
	char ch = 'X';
	for(int q = 0 ; q < check.size() ; q++){
		if(check[q]!=fr && check[q]!=sc) {
		ch = check[q];
		break;
		}
	}
	return ch;
}
int main(){
fcin;
	cin >> n;
	cin >> s;
	for(int i = 0 ; i < n ; i++){
		if(s[i]=='R') {
		r[i] = r[i-1] + 1;
		g[i] = g[i-1];
		b[i] = b[i-1];
		}
		else if(s[i] == 'G'){
		r[i] = r[i-1];
		g[i] = g[i-1] + 1;
		b[i] = b[i-1];
		}
		else{
		r[i] = r[i-1];
		g[i] = g[i-1];
		b[i] = b[i-1] + 1;
		}
	}
	for(int i = 0 ;i < n ; i++){
		for(int k = i + 1 ; k < n ; k++){
			if(s[i]!=s[k]){
				char ch = check1(s[i],s[k]);
				if( (i + k) % 2 == 0 && s[(i+k)/2] == ch) ok = -1;
				else ok = 0;
				if(ch == 'B'){
					ans += (b[k] - b[i - 1] + ok );
				}
				else if(ch == 'R'){
					ans += (r[k] - r[i - 1] + ok );
				}
				else if(ch == 'G'){
					ans += (g[k] - g[i - 1] + ok );
				}
			}
		}
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 3748
#include <iostream>
using namespace std;
int min(int a, int b){
  return a < b ? a : b;
}
int main(void){
  int n, k;
  int ans = 0;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    ans += 2*min(x, k-x);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	int A, B, C, K, cnt = 0;
	cin >> A >> B >> C >> K;
	while (A >= B) {
		cnt += 1;
		B *= 2;
	}
	while (B >= C) {
		cnt += 1;
		C *= 2;
	}

	if (cnt <= K) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>

using namespace std;
using ll = long long;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    if (N < 1000) {
        cout << "ABC\n";
    }
    else {
        cout << "ABD\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
long long i[300000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b=0,c=0,d=0,e=1,f=0;
  cin >>a>>b>>c;
  i[a]++,i[b]++,i[c]++;
  for(int n=1;n<=100;n++){
    if(i[n]>0) d++;
  }
  cout <<d<<'\n';
  return (0);
}



Measured memory_bytes: 256
N=int(input())
if (N*100)%108==0:
  print(int(N/1.08))
else:
  X=int((N+1)/1.08)
  if int(X*1.08)==N:
    print(X)
  elif int((X-1)*1.08)==N:
    print(X-1)
  else:
    print(":(")

Measured memory_bytes: 3060
N, A, B, C = gets.split.map(&:to_i)
INF = 10 ** 9

L = []
N.times do
  l = gets.to_i
  L << l
end

def dfs(n, a, b, c)
  if N == n
    if [a, b, c].min > 0
      return (A - a).abs + (B - b).abs + (C - c).abs - 30
    else
      return INF
    end
  end

  mp0 = dfs(n + 1, a, b, c)
  mp1 = dfs(n + 1, a + L[n], b, c) + 10
  mp2 = dfs(n + 1, a, b + L[n], c) + 10
  mp3 = dfs(n + 1, a, b, c + L[n]) + 10

  return [mp0, mp1, mp2, mp3].min
end


puts dfs(0, 0, 0, 0)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  string s;
  cin >> n >> s;
  rep(i,0,len(s)){
    if (s[i]+n > 'Z'){
      cout << (char)(s[i] + 'A' + n - 'Z' - 1);
    }
    else cout << (char)(s[i]+n);
  }
  cout << endl;
}

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	// Atcoder用のサンプルプログラム
	public static void main(String[] args) {
		String line = "";
		try {
			line = readLine();

			StringTokenizer st = new StringTokenizer(line, " ");
			String s = st.nextToken();
			//String tempS = st.nextToken();

			//int k = Integer.parseInt(tempK);
			//int s = Integer.parseInt(tempS);
			
			//String result="";
            StringBuffer sb = new StringBuffer();
            
			for (int i =0;i<s.length();i++) {
				if (i % 2 == 0) {
					//result = result + s.charAt(i);
                    sb.append(s.charAt(i));
				}
			}
			
			System.out.println(sb.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}

}


Measured memory_bytes: 23752
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll n,m;
  cin>>n>>m;
  ll a[m],s=0;
  fo(i,m)
  {
    cin>>a[i];
    s=s+a[i];
  }
  ll r=-1;
  ll p=max(r,n-s);
  cout<<p;
  return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 2 * 105000;

class Fenwick {
private:
  vector <long long> f;
public:
  void init(int n) {
    f.assign(n, 0);
  }
  void update(int pos, int delta) {
    for (; pos < sz(f); pos = (pos | (pos + 1))) {
      f[pos] += delta;
    }
  }
  long long sum(int pos) {
    long long res = 0;
    for (; pos >= 0; pos = (pos & (pos + 1)) - 1) {
      res += f[pos];
    }
    return res;
  }
  long long sum(int l, int r) {
    return sum(r) - sum(l - 1);
  }
};

int n;
string s;
deque <int> d[200];
long long ans;
Fenwick l, r;

int main() { 

  getline(cin, s);
  n = sz(s);

  for (int i = 0; i < sz(s); i++) {
    d[s[i] - 'a'].push_back(i);
  }

  l.init(n); r.init(n);

  int from = 0, to = n - 1;
  while (from < to) {
    int best = -1, bestCost = (int) 1e9;
    int bestMn, bestMx;
    for (int i = 0; i < 26; i++) {
      if (sz(d[i]) < 2) {
        continue;
      }
      int mn = d[i].front(), mx = d[i].back();
      int newMn = mn + l.sum(mn + 1, n - 1) - r.sum(0, mn - 1);
      int newMx = mx + l.sum(mx + 1, n - 1) - r.sum(0, mx - 1);
      int curCost = newMn - from + to - newMx;
      if (best == -1 || curCost < bestCost) {
        best = i; bestCost = curCost;
        bestMn = mn, bestMx = mx;
      }
    }
    if (best == -1) {
      puts("-1");
      return 0;
    }
    ans += bestCost;
    l.update(bestMn, 1);
    r.update(bestMx, 1);
    d[best].pop_front(); d[best].pop_back();
    from++; to--;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4612
use std::io::*;
use std::str::*;
use std::process;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main(){
    let s = read_str();
    let mut sum:i32 = 0;
    let mut ans:i32 = s.len() as i32;

    for i in 0 .. s.len(){
        if(s[i]=='S'){
            sum += 1
        }
        if(s[i]=='T'){
            if(sum > 0){
                sum -=1;
                ans -=2;
            }
        }
    }
    println!("{}",ans);
}
fn read_str() -> Vec<char>{
    let s :String = read();
    s.chars().collect::<Vec<char>>()
}
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(|_| panic!("Faild to parse {}", s))
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  string s,t;
  cin >> s >> t;

  ll ans = 0;
  REP(i,s.size()) {
    ans += t[i] != s[i];
  }
  COUT(ans);

  return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;
#define endl '\n'
const ld PI=3.14159265358979;
#define w(x) int x;cin>>x;while(x--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define mset multiset
#define uset unordered_set
#define umap unordered_map
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll binpow(ll x, ll y, ll p){  ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  { if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}  
ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a % b); } 
bool parity(ll x,ll y){ bool f = ((x ^ y) < 0);return !f;}

ll dp[101][100002];
int main()
{
    IOS
    
    ll n,W;
    cin>>n>>W;
    vll wt(n+1,0);
    vll v(n+1,0);
    for(int i=1;i<=n;i++)
        cin>>wt[i]>>v[i];

    dp[0][0]=0;

    for(int i=1;i<=100000;i++)
        dp[0][i]=1e14;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=100000;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j>=v[i])
                dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+wt[i]);
        }
    }
    ll ans=0;
    for(int i=0;i<=100000;i++)
    {
        if(dp[n][i]<=W)
            ans=i;
    }
    cout<<ans<<endl;
    return 0;  
}

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

int main(){
	string w;
	cin >> w;
	vector<int> v(26,0);
	for (char c: w){
		v[c-'a'] ++;
	}
	for (int x: v){
		if (x%2==1) {cout << "No"; return 0;}
	}
	cout << "Yes";
}


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

int main() {
int A,B,C;
string S;
cin>>A>>B>>C;

  if(A+B+C==17 && max(max(A,B),C)==7 && min(min(A,B),C)==5) S="YES";
  else S="NO";
  cout<<S;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

i64 dp[200001][3][2];

int main() {
    i64 n;
    cin >> n;
    vector<i64> a(n);
    int k = 1 + (n % 2 == 1);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i <= n; ++i) {
        for (int t = 0; t <= 1; ++t) {
            for (int s = 0; s <= k; ++s) {
                if (i != 0 || t != 0 || s != 0) {
                    dp[i][s][t] = -1e15;
                }
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int t = 0; t <= 1; ++t) {
            for (int s = 0; s <= k; ++s) {
                if (t) {
                    dp[i][s][1] = max(dp[i][s][1], dp[i - 1][s][0] + a[i - 1]);
                } else {
                    dp[i][s][0] = max(dp[i][s][0], dp[i - 1][s][1]);
                    if (s > 0) {
                        dp[i][s][0] = max(dp[i][s][0], dp[i - 1][s - 1][0]);
                        if (i == 1 && s == 1) {
                            dp[i][s][0] = max(dp[i][s][0], i64(0));
                        }
                    }
                }
            }
        }
    }
    i64 ans = max(dp[n][k - 1][0], dp[n][k][1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(ll a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define dbg(x) cout<<#x<<" = "<<x<<endl;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);	cout.tie(NULL);
const ll M = 1e9+7 , INF = 1e16;


// 														MAIN
int32_t main()
{ 
    FASTIO
    read(n) 
    n/= __gcd(n,7LL);
    set<ll> already_visited;
    ll curram = 1;
    ll ans = 1;
    while(1)
    {
      already_visited.insert(curram);
      if(curram%n == 0){cout<<ans; return 0;}
      ans++;
      curram =curram*10;
      curram%=n;
      curram++;
      curram%=n;
      if(already_visited.find(curram)!=already_visited.end())return cout<<-1 , 0;
    }
}



Measured memory_bytes: 50492
#include<iostream>
using namespace std;
int main()
{
          long long int a,b,c,d;
          while(cin>>a)
          {
                    d=0;
                    b=600/a;
                    int i=0;
                    while(b--)
                    {
                              c=(a*a)*(i*i);
                              d+=(c*a);
                              ++i;
                    }
                    cout<<d<<endl;
          }
return 0;
}



Measured memory_bytes: 3004
import java.util.Scanner;

public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
double r = sc.nextDouble();
double pi = Math.PI;
double area = pi*r*r;
double length = 2*pi*r;
System.out.printf("%f %f",area,length);
sc.close();
}
}


Measured memory_bytes: 28100
# include <bits/stdc++.h>
using namespace std;
# define lli long long int
# define MOD 1000000007

int mat[22][22];
int dp[22][(1<<22)];

lli findAll(int x, int w, int n){
    if(x == n){
        return 1;
    }

    if(dp[x][w] != -1){
        return dp[x][w];
    }

    lli ans = 0;
    for(int i = 0; i < n; i++){
        bool avail = (((1<<i)&w) == 0) ? false : true;
        if(avail and mat[x][i]){
            ans += findAll(x + 1, (w^(1<<i)), n);
            ans %= MOD;
        }
    }

    return dp[x][w] = ans;
}

void solve(){
    int n;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> mat[i][j];
        }
    }

    cout << findAll(0, ((1<<n) - 1),n);
}


int main(){
   solve();
}


Measured memory_bytes: 364080
#include<cstdio>
#include<algorithm>
using namespace std;
#define mod 1000000007
int main(){
    int n;
    long t[100000],a[100000],ans=1;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%ld",&t[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%ld",&a[i]);
    }
    if(t[0]>a[0]||t[n-1]<a[n-1]||t[n-1]!=a[0]){
        ans*=0;
    }
    for(int i=1;i<n-1;i++){
        if(t[i]==t[i-1]&&a[i]==a[i+1]){
            ans*=min(a[i],t[i]);
            ans%=mod;
        }
        else if(a[i]!=t[i]&&t[i]>t[i-1]&&a[i]>a[i+1]){
            ans*=0;
        }
        else if(a[i]>t[i]&&a[i]>a[i+1]){
            ans*=0;
        }
        else if(a[i]<t[i]&&t[i]>t[i-1]){
            ans*=0;
        }
    }
    printf("%ld\n",ans);
}

Measured memory_bytes: 1664
// Comment
// easy

#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 100;

int N, K;
int Nr[MAX_N];
int main() {
	cin >> N >> K;
	for(int i=1; i<=N; i++) scanf("%d", &Nr[i]);
	int ans = INF * 2;
	for(int i=1; i<=N-K+1; i++) {
		int now = min(abs(Nr[i]), abs(Nr[i+K-1])) + abs(Nr[i+K-1] - Nr[i]);
		ans = min(ans, now);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4048
n, m, k = gets.chomp.split.map(&:to_i)
table = Array.new(1000000,false)
(n+1).times do |i|
  (m+1).times do |j|
    table[m * i + j * (n - i) - j * i]  = true
  end
end
puts (table[k])? "Yes" : "No"

Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
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; }
const long long INF = 1LL<<60;

const int MAX_N = 110;
const int MAX_V = 100100;

// 入力
int N;
long long W, weight[MAX_N], value[MAX_N]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // 初期化
    for (int i = 0; i < MAX_N; ++i) for (int j = 0; j < MAX_V; ++j) dp[i][j] = INF;

    // 初期条件
    dp[0][0] = 0;

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {

            // i 番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);

            // i 番目の品物を選ばない場合
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
        if (dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}

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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

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

int sgn(int x) {
	return x >= 0;
}

int divide(int a, int b) {
	if (a >= 0) {
		return a/b;
	} else {
		if (a%b==0) {
			return a/b;
		} else {
			return a/b + (sgn(a) == sgn(b) ? 1 : -1);
		}
	}
}

int mod(int a, int b) {
	return (a%b+b)%b;
}

void solve() {
	vector<int> vec;
	int n;
	cin >> n;

	if (n==0) {
		cout << 0 << '\n';
		return;
	}

	while (n) {
		if (mod(n,-2)) {
			vec.pb(1);
		} else {
			vec.pb(0);
		}
		n = divide(n,-2);
	}

	reverse(vec.begin(),vec.end());
	for (auto x : vec)
		cout << x;
	cout << '\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,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  cout << n*n*n << endl;
  return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int n, k;
    cin >> n >> k;

    vector<int> a(n);

    for (int i=0; i<k; i++) {
        int x, y;
        cin >> x;
        for (int j=0; j<x; j++) {
            cin >> y;
            a[y-1]++;
        }
    }

    int cnt = 0;
    for (int e : a) cnt += e == 0;
    cout << cnt << "\n";
}


Measured memory_bytes: 3620
N = int(input())

primelist = []
isprime = [True]*55555
for i in range(55555):
    if isprime[i] and i != 0 and i != 1:
        primelist.append(i)
        for j in range(i,55555,i):
            isprime[j] = False

anslist = []
for i in primelist:
    if i % 10 == 1:
        anslist.append(i)

ans = anslist[:N]
ans = map(str,ans)

print(" ".join(ans))


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005
using namespace std;
const int maxn = 1e5 + 100;
int dp[maxn], h[maxn];
inline int abs(int a)
{
	return a > 0 ? a : -a;
}
int32_t main() 
{
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
//#ifndef ONLINE_JUDGE
//	ifstream cin("input.txt");
//#endif
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++)cin >> h[i];
	dp[1] = 0;
	for (int i = 2; i <= N; i++)
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), 
			i == 2 ? INF : dp[i - 2] + abs(h[i] - h[i - 2]));
	cout << dp[N] << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'
typedef long long ll;

int main(){

   string s1, s2;
   cin>>s1>>s2;
   for (int i = 0; i < s1.length(); ++i)
   {
      if(s1[i]!=s2[i]){
         cout<<"No\n";
         return 0;
      }
   }
   if(s1.length()+1 == s2.length()) cout<<"Yes\n";
   else cout<<"No\n"; 
   return 0;
}

Measured memory_bytes: 3600