akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var AB = ReadSplitInt();
            if (AB[0] >= 13)
                Println(AB[1]);
            else if (AB[0] >= 6)
                Println(AB[1] / 2);
            else if (AB[0] <= 5)
                Println(0);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}



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

const int MAX = 500005;

// structure to store queries
struct Query
{
    int l, r, idx;
};

// cmp function to sort queries according to r
bool cmp(Query x, Query y)
{
    return x.r < y.r;
}

// updating the bit array
void update(int idx, int val, int bit[], int n)
{
    for (; idx <= n; idx += idx&-idx)
        bit[idx] += val;
}

// querying the bit array
int query(int idx, int bit[], int n)
{
    int sum = 0;
    for (; idx>0; idx-=idx&-idx)
        sum += bit[idx];
    return sum;
}

void answeringQueries(int arr[], int n, Query queries[], int q)
{
    // initialising bit array
    int bit[n+1];
    memset(bit, 0, sizeof(bit));

    // holds the rightmost index of any number
    // as numbers of a[i] are less than or equal to 10^6
    int last_visit[MAX];
    memset(last_visit, -1, sizeof(last_visit));

    // answer for each query
    int ans[q];
    int query_counter = 0;
    for (int i=0; i<n; i++)
    {
        // If last visit is not -1 update -1 at the
        // idx equal to last_visit[arr[i]]
        if (last_visit[arr[i]] !=-1)
            update (last_visit[arr[i]] + 1, -1, bit, n);

        // Setting last_visit[arr[i]] as i and updating
        // the bit array accordingly
        last_visit[arr[i]] = i;
        update(i + 1, 1, bit, n);

        // If i is equal to r of any query  store answer
        // for that query in ans[]
        while (query_counter < q && queries[query_counter].r == i)
        {
            ans[queries[query_counter].idx] =
                     query(queries[query_counter].r + 1, bit, n)-
                     query(queries[query_counter].l, bit, n);
            query_counter++;
        }
    }

    // print answer for each query
    for (int i=0; i<q; i++)
        cout << ans[i] << endl;
}

// driver code
int main()
{
    int n,q;
	cin>>n>>q;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];

    Query queries[q];
    for(int i=0;i<q;i++)
    {
    	int l,r;
    	cin>>l>>r;
    	l--;
    	r--;
    queries[i].l = l;
    queries[i].r = r;
    queries[i].idx = i;
    }

    sort(queries, queries+q, cmp);
    answeringQueries(a, n, queries, q);
}


Measured memory_bytes: 17396
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long int;
using namespace std;

int main() {
    fastio;
    int a, b, x;
    cin >> a >> b >> x;
    for (int i = a; i <= a + b; i++) {
        if (x == i) {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
}

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N;
ll pw[100];

ll i, j, k;



ll calc(ll n,string& s){
    if(n<26){
        s += ('a' + n);
        return 1;
    }
    ll c = calc(n / 26 - 1, s) * 26;
    s += n % 26 + 'a';
    return c;
}

int main(){
    scanf("%lld", &N);
    string s;
    calc(N - 1, s);

    cout << s;
    return 0;
}

Measured memory_bytes: 3688
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<bitset>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const ll base = 999983;
const int maxn = 1e5+5;
int n,ind[maxn];
vector<ll> htable;
vector<int> G[maxn];

ll dfs(int u)
{
    ll temp = 0;
    for(int i=0;i<G[u].size();++i){
        temp += dfs(G[u][i]);
    }
    htable.push_back(temp*base+G[u].size());
    return temp*base+G[u].size();
}

inline ll work(ll m)
{
    return m*(m-1)>>1;
}

int main()
{
    while(~scanf("%d",&n)){
        htable.clear();
        memset(ind,0,sizeof ind);
        for(int i=0;i<=n;++i) G[i].clear();
        for(int i=0;i<n-1;++i){
            int u,v; scanf("%d%d",&u,&v);
            G[u].push_back(v);
            ++ind[v];
        }
        int s = 0;
        for(int i=1;i<=n && !s;++i){
            if(ind[i] == 0) s = i;
        }
        dfs(s);
        sort(htable.begin(),htable.end());
        ll num = 1;
        ll ans = 0;
        for(int i=1;i<htable.size();++i){
            if(htable[i] != htable[i-1]){
                ans += work(num);
                num = 1;
            }
            else ++num;
        }
        if(htable.size() > 1 && htable[htable.size()-1] == htable[htable.size()-2]) ans += work(num);
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 15992
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define LLIandI pair<long long int , int>
#define ll long long

int main(){
    while(1){
        //ここで、ある桁まで(a)みて次の桁(b)までを見るとき、
        //(a*10+b)%11=(a*(-1)+b )%11= (-(a%11)+b%11)%11 (modで計算すればわかる)なので、ここから漸化式で求めていくことができる。
        //答えはdp[whatever][0]
        char S[80005];
        int a[80005];//<10^5
        scanf("%s",S);
        int lenS=strlen(S);
        if(lenS==1 && S[0]=='0')break;
        int dp[80005][12];//i番が最後の数列で、あまりがj(0~10)になるもの
        rep(i,lenS){
            a[i]=S[i]-'0';
            if(i==0){
                rep(j,11){
                    if(j==a[i])dp[i][j]=1;
                    else dp[i][j]=0;
                }
            }else{
                rep(j,11){
                    //j=-k+a[i]
                    int k=(a[i]-j)%11;
                    if(k<0)k+=11;
                    dp[i][j]=dp[i-1][k];
                    if(j!=0&&j==a[i]%11)dp[i][j]+=1;
                }
            }
        }
        int ans=0;
        rep(i,lenS){
            ans+=dp[i][0];
        }
        
        printf("%d\n",ans);
    }
}



Measured memory_bytes: 6416
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		String s = scan.next();

		int en = 700;
		for (char c : s.toCharArray()) {
			if (c == 'o') {
				en += 100;
			}
		}
		System.out.println(en);
	}

}


Measured memory_bytes: 21716
#include <iostream>

int main(){
  
  
 int a,b,c,x;
  
  std::cin>>a>>b>>c>>x;
  int ans=0;
  int count=0;
  for(int i=0;i<=a;i++){
    
   for(int j=0;j<=b;j++){
    
     for(int k=0;k<=c;k++){
       
       ans=i*500+j*100+k*50;
    
      if( ans==x) count++;
     }
   }
    
  }
  
  std::cout<<count;
  
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,d,x;cin>>n>>d>>x;
    vector<int>a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++){
        int j=0;
        int tmp=1;
        while(tmp!=d+1){
            if(tmp==j*a[i]+1){
                j++;
                x++;
            }
            tmp++;
        }
    }
    cout<<x<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

class Dice {
public:

  int a1, a2, a3, a4, a5, a6, q1, q2;

  Dice(int x) {

    a1 = a2 = a3 = a4 = a5 = a6 = q1 = q2 = x;

  }

  void rotateFront() {
    int newa1 = a5;
    a5 = a6;
    a6 = a2;
    a2 = a1;
    a1 = newa1;

  }

  void rotateLeft() {
    int newa1 = a3;
    a3 = a6;
    a6 = a4;
    a4 = a1;
    a1 = newa1;

  }

  void rotateSpin() {

    int newa2 = a3;
    a3 = a5;
    a5 = a4;
    a4 = a2;
    a2 = newa2;

  }

};

int main(void) {

  Dice d1(0);
  int i , Q;

  cin >> d1.a1 >> d1.a2 >> d1.a3 >> d1.a4 >> d1.a5 >> d1.a6;
  cin >> Q;

  for(i = 0; i < Q; i++) {

    cin >> d1.q1 >> d1.q2;

      if(d1.a3 == d1.q1) {

	d1.rotateLeft();

      } else if(d1.a4 == d1.q1) {

	d1.rotateLeft();
	d1.rotateLeft();
	d1.rotateLeft();

      } else {

	while(1) {

	  if(d1.a1 == d1.q1) break;

	  d1.rotateFront();

	}

      }

    while(1) {

      if(d1.a2 == d1.q2) break;

      d1.rotateSpin();

    }


    cout << d1.a3 << endl;

  }

  return 0;

}

Measured memory_bytes: 1160
#include <cstdio>

int cnt[35];

int main() {
	int n, m;
	int ans = 0;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		int k;
		scanf("%d", &k);
		for (int j = 0; j < k; j++) {
			int l;
			scanf("%d", &l);
			cnt[l]++;
			if (cnt[l] == n) ans++;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long N){
	cout << N*N*N << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	solve(N);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,k;
	cin>>n>>k;
	
	vi p(n);
	REP(i,n) cin>>p[i];
	sort(ALL(p));
	
	int ans=0;
	REP(i,k) ans+=p[i];
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder {
  class Program {
    static void Main(string[] args) {
      var first = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(s => ulong.Parse(s)).ToArray();
      var N = first[0];
      var K = first[1];
      var A = new ulong[N];
      A = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(s => ulong.Parse(s)).ToArray();

      var f = new Func<ulong, ulong>(x => A[x-1]);
      var connectionP = connection_point(1, f);
      ulong count = 0;
      ulong distConnectionP, loop;
      ulong pos = 1;
      while (true) {
        if (pos == connectionP) {
          distConnectionP = count;
          pos = f(pos);
          count++;
          break;
        }
        pos = f(pos);
        count++;
      }
      while (true) {
        if (pos == connectionP) {
          loop = count - distConnectionP;
          break;
        }
        pos = f(pos);
        count++;
      }
      if ((long)K - (long)distConnectionP > 0) {
        K -= distConnectionP;
        K %= loop;
        pos = connectionP;
      } else {
        pos = 1;
      }
      for (ulong i = 0; i < K; i++) {
        pos = f(pos);
      }
      Console.WriteLine(pos);
    }

    static ulong collision_point(in ulong x, Func<ulong, ulong> f) {
      ulong slow = x;
      ulong fast = f(x);

      while (fast != slow) {
        slow = f(slow);
        fast = f(fast);
        fast = f(fast);
      }
      return fast;
    }

    static ulong convergent_point(ulong x0, ulong x1, Func<ulong, ulong> f) {
      while (x0 != x1) {
        x0 = f(x0);
        x1 = f(x1);
      }
      return x0;
    }

    static ulong connection_point(in ulong x, Func<ulong, ulong> f) {
      ulong y = collision_point(x, f);
      return convergent_point(x, f(y), f);
    }
  }
}


Measured memory_bytes: 43700
N = int(input())
C = 10**9+7
A = list(map(int, input().split()))
ans = 0
for i in range(60):
    L = [(A[j] >> i) & 1 for j in range(N)]
    # print(L)
    a = L.count(0)
    b = L.count(1)
    ans += a*b*pow(2, i, C)
print(ans % C)


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


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  int ans=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      ans += a.at(i)*a.at(j);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
//K-th Common Divisor
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<(x)<<endl
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){//階乗の計算
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}
ll gcd(ll a ,ll b){return b ? gcd(b,a%b) : a;}//最大公約数
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}//最小公倍数
int num_digit(ll a){//桁数を求める
    int num_dig = 0;
    while(a!=0){
        a /= 10;
        ++num_dig;
    }
    return num_dig;
}
vector<ll> digit(ll a){//桁の数字を求める
    vector<ll> dig(num_digit(a));
    for(int i=num_digit(a)-1; i>=0; --i){
        dig[i] = a%10;
        a /= 10; 
    }
    return dig;
}

int main(){
    int a,b,k;
    cin >> a >> b >> k;

    int n = min(a,b);
    vector<int> div;
    for(int i=1; i<=n; ++i){
        if(a%i==0&&b%i==0){
            div.push_back(i);
        }
    }
    cout(div.at((int)div.size() -1 -(k-1)));


    return 0;
}

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

#define sign(x) (x ? '+' : '-')

int main()
{
	int abcd;
	cin>>abcd;
	int a, b, c, d;
	a = abcd / 1000;
	b = abcd / 100 % 10;
	c = abcd / 10 % 10;
	d = abcd % 10;
	for(bool sa=false;;sa++)
	{
		for(bool sb=false;;sb++)
		{
			for(bool sc=false;;sc++)
			{
				int sum = 0;
				sum += a;
				sum += (sa ? b : -b);
				sum += (sb ? c : -c);
				sum += (sc ? d : -d);
				if(sum == 7)
				{
					cout<<a<<sign(sa)<<b<<sign(sb)<<c<<sign(sc)<<d<<"=7"<<endl;
					return 0;
				}
				if(sc) break;
			}
			if(sb) break;
		}
		if(sa) break;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
int k,n;
std::vector<int>A[555];
int main(){
	scanf("%d",&k);
	if(k<=500){
		printf("%d\n",k);
		for(int i=1;i<=k;++i)
		for(int j=1;j<=k;++j)
		printf("%d%c",i," \n"[j==k]);
	}else{
		n=k+1>>1;
		if(n&1)++n;
		for(int i=1;i<=n;++i)
		A[0].push_back(i);
		for(int i=n+2;i<=2*n;++i)
		A[1].push_back(i);
		A[1].push_back(n+1);
		for(int i=2;i<n;++i){
			A[i]=A[i-2];
			A[i].push_back(A[i][0]),A[i].push_back(A[i][1]);
			A[i].erase(A[i].begin());
			A[i].erase(A[i].begin());
		}
		for(int i=0;i<n*2-k;++i){
			for(int x=0;x<n;++x)
			for(int y=0;y<n;++y)
			if(A[x][y]==2*n-i)A[x][y]-=n;
		}
		printf("%d\n",n);
		for(int i=0;i<n;++i){
			for(int j:A[i])printf("%d ",j);
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>

using namespace std;

int a,b,c,d,e;

int main(){
	cin >> e;
	a = e /1000;
	b = e%1000/100;
	c = e%100/10;
	d = e%10;
	
	int x,y,z;
	for(int i = 0; i < 8; i++){
		if(i < 4) x = b; else x = -b;
		if(i == 2 || i == 3 || i == 6 || i == 7) y = c; else y = -c;
		if(i % 2) z = d; else z = -d;
		if(a + x + y + z == 7){
			cout << a;
			if(x >= 0) cout << '+' << x;
			else cout << x;
			if(y >= 0) cout << '+' << y;
			else cout << y;
			if(z >= 0) cout << '+' << z;
			else cout << z;
			cout << '=' << 7 << endl;
			break;
		}
	}
	
	return 0;
}

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

using namespace std;

int main()
{
	string a;
	int n, m;
	stack<int> s;
	while (cin>>a)
	{
		if (a == "+")
		{
			m = s.top(); s.pop();
			n = s.top(); s.pop();
			s.push(n + m);
		}
		else if (a == "-")
		{
			m = s.top(); s.pop();
			n = s.top(); s.pop();
			s.push(n - m);
		}
		else if (a == "*")
		{
			m = s.top(); s.pop();
			n = s.top(); s.pop();
			s.push(n*m);
		}
		else
		{
			s.push(stoi(a));
		}
	}
	cout << s.top() << endl;
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define dump(x)  cerr << #x << " = " << (x) << endl;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

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


//ここから書き始める
int main(int argc, char const *argv[])
{
	LL N, M;
	cin >> N >> M;
	string S, T;
	cin >> S >> T;

	auto nmgcd = gcd(N,M);
	LL n = N / nmgcd;
	LL m = M/ nmgcd;

	int loop = nmgcd;
	int flag = 0;


	FOR(i, 0, loop)
	{
		if(S[i * n] != T[i * m])
		{
			cout << -1 << endl;
			flag = 1;
			break;
		}

	}
	if(flag == 0)
	{
		cout <<  LL(N * m) << endl;
	}



}


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	string s;
	cin >> s;

	int n = s.size();
	if(s[0] == s[n-1]){
		if(n % 2 == 1)cout << "Second" << endl;
		else cout << "First" << endl;
	}
	else{
		if(n % 2 == 1)cout << "First" << endl;
		else cout << "Second" << endl;
	}
}


Measured memory_bytes: 512
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
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; }


// E - Knapsack 2
ll N, W;
ll w[110];
ll v[110];
ll ans = 0;
const int MAX_N = 110;
const int MAX_V = 110000;
const ll INF = 10000000000000;
ll dp[MAX_N][MAX_V];

int main(){
    cin >> N >> W;
    rep(i, 0, N){
        cin >> w[i] >> v[i];
    }

    rep(i, 0, MAX_N){
        rep(j, 0, MAX_V){
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;
    rep(i, 0, N){
        repeq(j, 0, MAX_V){
            if(j>=v[i]){
                chmin(dp[i+1][j], dp[i][j-v[i]] + w[i]);
            }
            chmin(dp[i+1][j], dp[i][j]);
        }
    }

    rep(i, 0, MAX_V){
        if(dp[N][i] <= W){
            ans = i;
        }
    }

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




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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

LL N;
const int maxn = 1e5+5;
LL A[maxn];

int main()
{
    cin >> N;
    LL res = 0;
    _for(i,0,N){
        cin >> A[i];
        if(i&1) res-= A[i];
        else res += A[i];
    }
    printf("%lld",res);
    _for(i,0,N-1){
        res = (A[i] - res/2)*2;
        printf(" %lld",res);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class SA{
public:
  string S;
  int n;
  vector<int> sa;
  
  SA():n(-1){}
  SA(string S):S(S),n(S.size()),sa(n){  
    vector<int> rnk(n);
    vector<int> tmp(n);
    for(int i=0;i<n;i++) sa[i]=i;
    for(int i=0;i<n;i++) rnk[i] = S[i];
    
    //k文字についてソートされているところから、2k文字でソート
    for(int Len=1;Len<=n;Len*=2){
      
      //(rnk[i],rnk[i+k])と(rnk[j],rnk[j+k])を比較
      auto compare_sa=[&](const int &i,const int &j){
        if(rnk[i]!=rnk[j])return rnk[i]<rnk[j];
        int ri=i+Len<n?rnk[i+Len]:-1;
        int rj=j+Len<n?rnk[j+Len]:-1;
        return ri<rj;
      };
      
      sort(sa.begin(),sa.end(),compare_sa);

      //いったんtmpに次のランクを計算して、rnkに代入
      for(int i=1;i<n;i++)
        tmp[sa[i]] = tmp[sa[i-1]] + compare_sa(sa[i-1],sa[i]);
      rnk = tmp;
    }
  }

  int lower_bound(string T){
    assert(n >= 0);
    int L=-1,R=S.length();
    while(L+1<R){
      int M = (L+R)/2;
      S.compare(sa[M],T.size(),T)<0? L = M:R = M;
    }
    return R;
  } 

  int upper_bound(string T){return lower_bound(T+char('z'+ 1));} 
  int count(string T){return upper_bound(T) - lower_bound(T);};
};




signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin>>s;
  int K; 
  cin>>K;

  int n = s.size();

  typedef pair<string,int> P;
  priority_queue<P,vector<P>,greater<P> > Q;
  
  set<string> S;
  for(int i=0;i<n;i++) Q.push(P(string(1,s[i]),i));
  
  while((int)S.size() < K){
    auto t = Q.top(); Q.pop();
    string str = t.first;
    int idx = t.second;
    
    S.insert(str);
    if(idx == n-1) continue;
    str += s[idx+1];
    Q.push(P(str, idx+1));
  }
  
  auto ans = *(--S.end());
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,X1[100],X2[100],Y1[100],Y2[100];
int nx,ny;
double xv[200],yv[200];
bool v[200][200];

int main()
{
	int cs=1;
	while(scanf("%d",&n),n)
	{
		double x[200],y[200],r[200];
		rep(i,n)
		{
			scanf("%lf%lf%lf",x+i,y+i,r+i);
			xv[i*2]=x[i]-r[i]; xv[i*2+1]=x[i]+r[i];
			yv[i*2]=y[i]-r[i]; yv[i*2+1]=y[i]+r[i];
		}
		rep(i,2*n)x[i]=xv[i],y[i]=yv[i];
		sort(xv,xv+2*n); sort(yv,yv+2*n);
		nx=unique(xv,xv+2*n)-xv; ny=unique(yv,yv+2*n)-yv;
		rep(i,n)
		{
			X1[i]=lower_bound(xv,xv+nx,x[i*2])-xv;
			X2[i]=lower_bound(xv,xv+nx,x[i*2+1])-xv;
			Y1[i]=lower_bound(yv,yv+ny,y[i*2])-yv;
			Y2[i]=lower_bound(yv,yv+ny,y[i*2+1])-yv;
		}
		
		double ans=0;
		rep(i,ny)rep(j,nx)v[i][j]=0;
		rep(i,n)
		{
			for(int y=Y1[i];y<Y2[i];y++)for(int x=X1[i];x<X2[i];x++)
			if(!v[y][x])
			{
				ans+=(yv[y+1]-yv[y])*(xv[x+1]-xv[x]);
				v[y][x]=1;
			}
		}
		printf("%d %.2f\n",cs++,ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
#include <list>
using namespace std;

int n;
struct node
{
    int parent, depth;
    vector<int> child;
};
node nd[100000];

void CalcDepth(int r)
{
    if (nd[r].child.size() != 0)
    {
        for (int i = 0; i < nd[r].child.size(); i++)
        {
            nd[nd[r].child[i]].depth = nd[r].depth + 1;
            CalcDepth(nd[r].child[i]);
        }
    }

    return;
}

int main()
{
    cin >> n;
    int x, y, k;
    for (int i = 0; i < n; i++)
    {
        nd[i].parent = -1;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> x >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> y;
            nd[x].child.push_back(y);
            nd[y].parent = x;
        }
    }

    int r = 0;
    while (nd[r].parent > -1)
    {
        r = nd[r].parent;
    }
    nd[r].depth = 0;
    CalcDepth(r);

    for (int i = 0; i < n; i++)
    {
        printf("node %d: parent = %d, depth = %d,", i, nd[i].parent, nd[i].depth);
        if (nd[i].parent == -1)
            printf(" root,");
        else if (nd[i].child.size() == 0)
            printf(" leaf,");
        else
            printf(" internal node,");

        printf(" [");
        for (int j = 0; j < nd[i].child.size(); j++)
        {
            if (j)
                printf(" ");
            printf("%d", nd[i].child[j]);
            if (j != nd[i].child.size() - 1)
                printf(",");
        }
        printf("]\n");
    }

    return 0;
}


Measured memory_bytes: 7104
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

const int mod = 1000000007; // 998244353;
struct mint {
  long long x;
  mint(long long x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    return mint(*this) += a;
  }
  mint operator-(const mint& a) const {
    return mint(*this) -= a;
  }
  mint operator*(const mint& a) const {
    return mint(*this) *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint& a) { return *this *= a.inv(); }
  mint operator/(const mint& a) const {
    return mint(*this) /= a;
  }
};
istream& operator>>(istream& is, const mint& a) {
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
  return os << a.x;
}

int main(){
  int n,k;
  cin>>n>>k;
  vector<mint>x(k+1);
  mint ans=0;
  for(int i=k;i>0;i--){
    x[i]=mint(k/i).pow(n);
    for(int j=i*2;j<=k;j+=i){
      x[i]-=x[j];
    }
    ans+=x[i]*i;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 4028
#include <iostream>
using namespace std;
int main(){
    int d;
    cin>>d;
    if(d==25){
        cout<<"Christmas"<<endl;
    }
    else if(d==24){
        cout<<"Christmas Eve"<<endl;
    }
    else if(d==23){
        cout<<"Christmas Eve Eve"<<endl;
    }
    else{
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int N, T;
  ci(N, T);
  int a = 1001;
  rep(i, N){
    int c, t;
    ci(c, t);
    if(t <= T){
      a = min(c, a);
    }
  }
  if(a == 1001){
    co("TLE");
  }
  else{
    co(a);
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
f = defaultdict(int)
f1 = defaultdict(int)
ans1 = 0
ans2 = 0
for _ in range(m):
    p,s = input().split()
    if f1[p] == 1:
        continue
    if s == 'WA':
        f[p] += 1
    else:
        f1[p] = 1
        ans1 += f[p]
        ans2 += 1
print(ans2,ans1)
        
        

Measured memory_bytes: 68952
import           Control.Monad
import           Data.Array.Unboxed
import qualified Data.ByteString.Char8 as BS
main :: IO ()
type Pos = (Int,Int)
main = do
    [h,w] <- map read . words <$> getLine :: IO [Int]
    s <- concat <$> replicateM h (map BS.unpack . BS.words <$> BS.getLine)
    let idxs = (\x y -> (x,y)) <$> [0..h-1] <*> [0..w-1]
        arr :: Array Pos Char
        arr = array ((0,0),(h-1,w-1)) (zip idxs (concat s))
        ms = [bfs arr p | p <- idxs,arr ! p == '.']
        next :: Array Pos Char -> Pos ->  [Pos]
        next s (y,x) = [(ny,nx) | (dy,dx) <- zip [1,0,-1,0] [0,1,0,-1],let (ny,nx) = (y+dy,x+dx),0 <= nx,nx < w,0 <= ny,ny < h,s ! (ny,nx) == '.']

        walk ::Array Pos Char -> Int -> [(Pos,Int)] -> [(Pos,Int)]
        walk _ 0 _ = []
        walk s n ((p,d):ps) = zip ne (repeat (d+1)) ++ walk k (n-1+len) ps
            where   ne = next s p
                    len = length ne
                    k = s // zip ne (repeat '#')

        bfs :: Array Pos Char -> Pos -> Int
        bfs s start = postProcess queue
            where   queue = (start,0) : walk s' 1 queue
                    postProcess = maximum . map snd
                    s' = s // [(start,'#')]
    print $ maximum ms

Measured memory_bytes: 4960
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
int main()
  {
  	long long int n;
  	cin >> n;
  	static long long int date[1000000 + 110];
  	for (long long int i = 1;i <= n;i++)
  	  cin >> date[i];
  	sort(date + 1,date + 1 + n);
    if (date[1] == 0)
  	  return puts("0") * 0;
  	  
  	ll ret = 1;
  	ll base = 1000000000ull * 1000000000ull;
  	for (ll i = 1;i <= n;i++)
  	  {
  	  	ll t = date[i];
  	  /*	print(ret * t);
  	  	puts("");*/
  	  	if (t * ret > base or t * ret / ret != t)
  	  	  return puts("-1") * 0;
  	  	else
  	  	  ret = ret * t;
		}
	cout << ret;
  }

Measured memory_bytes: 4436
#include <stdio.h>
int n, m, g;
int h[100000];
int main() {
	scanf("%d", &n);
	if (n == 1) {
		printf("Yes\n");
		return 0;
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", h + i);
	}
	for (int i = 0; i < n - 1; i++) {
		m = n - 2 - i;
		if (h[m] > h[m + 1] + 1) {
			h[m] = h[m + 1];
			g = 1;
		}
		if (h[m] == h[m + 1] + 1)h[m]--;
	}
	if (g)printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 512
x1,y1,x2,y2 = (int(i) for i in input().split())
a = x2 - x1
b = y2 - y1
x3 = x2 - b
y3 = y2 + a
x4 = x1 - b
y4 = y1 + a
print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1000010

bool prime[SIZE];

void initPrime(int n){
  for(int i=2;i<=n;i++){
    prime[i] = true;
  }

  for(int i=2;i*i<=n;i++){
    if(!prime[i]) continue;
    for(int j=2;j*i<=n;j++){
      prime[j*i] = false;
    }
  }
}

int counter[SIZE], calc[SIZE];

int main(){
  int l,r;

  cin >> l >> r;

  for(int i=0;i<r-l+1;i++){
    counter[i] = 0;
    calc[i] = 1;
  }

  initPrime(200000);
  
  for(int i=2;i*i<=r;i++){
    if(!prime[i]) continue;
    
    int start = (l + i - 1)/i * i;
    
    for(int j=start;j<=r;j+=i){
      int cc = 0, v = j;
      int t = 1;
      while(v%i==0){
        v /= i;
        cc++;
        t *= i;
      }

      counter[j-l] += cc;
      calc[j-l] *= t;
    }
  }

  int ans = 0;
  
  for(int i=0;i<(r-l+1);i++){
    ans += prime[counter[i] + (calc[i] != (i+l))];
  }

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

Measured memory_bytes: 11204
chomp($x=<>);
($n,$m) = split/ /,$x;
%hash=();
for($i=0;$i<$m;$i++){
	$val=<>;
    chomp($val);
    ($a,$b)=split/ /,$val;
    $hash{$a}++;
    $hash{$b}++;
}
for($i=0;$i<$n;$i++){
	if(defined $hash{$i+1}){
		print "$hash{$i+1}"."\n";
    }else{
    	print "0"."\n";
    }
}

Measured memory_bytes: 512
let reverse_string s =
    let length = String.length s in
    let t      = Buffer.create length in
    let last   = length - 1 in
    for i = 0 to last do
        Buffer.add_char t s.[last-i]
    done ;
    Buffer.contents t

let () =
    let s = read_line () in
    Printf.printf "%s\n" (reverse_string s)

Measured memory_bytes: 2044
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n , k;
    cin >> n >> k;

    int hash[n+1] = {0};
    for(int i = 0 ; i < k ; i++){
        int num;
        cin >> num;
        for(int j = 0 ; j < num ; j++){
            int x;
            cin >> x;
            hash[x]++;
        }
    }

    int cnt = 0;
    for(int i = 1 ; i <= n ; i++){
        if(!hash[i])cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
      ios::sync_with_stdio(0);
    
      ll a, b, c, x, y;
      cin >> a >> b >> c >> x >> y;
      
      ll ans1 = max(x, y)*c*2;
      ll ans2 = min(x, y)*c*2;
      if (x > y) {
            ans2 += (x - y)*a;
      } else {
            ans2 += (y - x)*b;
      }
      ll ans3 = a*x + b*y;
      cout << min(ans1, min(ans3, ans2));
    
      return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    VL a(n),b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    LL add = 0;
    for (int i = n-1; i >= 0; i--) {
        if ((a[i] + add) % b[i] != 0) {
            add += (b[i] - (a[i] + add) % b[i]);
        }
    }
    cout << add << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

int process(int a)
{
	int cnt = 0;
	while (a % 2 == 0)
	{
		a /= 2;
		cnt++;
	}

	return cnt;
}

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

	int N;
	cin >> N;

	int result = 0;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;

		result += process(a);
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 256
/// @pSaurabh

#include <bits/stdc++.h>

using namespace std;

#define read(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define print(a, n) for(int i = 0; i < n; i++) cout << a[i] << " ";

typedef long long ll;
const ll mod = 1e9 + 7;

void fast(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout .tie(0);
}

int main(){
	// fast();

	int h, w;
	cin >> h >> w;

	string mat[h];

	for(int i = 0; i < h; i++){
		cin >> mat[i];
	}

	ll dp[h][w];
	int c = 1;

	for(int i = 0; i < h; i++){
		if(mat[i][0] == '#') c = 0;
		dp[i][0] = c;
	}

	c = 1;
	for(int i = 0; i < w; i++){
		if(mat[0][i] == '#') c = 0;
		dp[0][i] = c;
	}



	for(int i = 1; i < h; i++){
		for(int j = 1; j < w; j++){
			if(mat[i][j] == '#'){
				dp[i][j] = 0;
				continue;
			}
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}

	// for(int i = 0; i < h; i++){
	// 	for(int j = 0; j < w; j++){
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }

	cout << dp[h - 1][w - 1];

	return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    long double a,b,c;
    cin >> a >> b >> c;

    long double ra = sqrt(a) , rb = sqrt(b) , rc = sqrt(c);
    long double e = 0.00000000000001;

    if((4 * a * b < (c-a-b)*(c-a-b))&&((c-a-b)>0)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while (x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  while (u != NIL && k !=  u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;

}

/*Node treeSuccessor(Node x){
  

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 20608
#!/bin/env python3
def judge_dist(i,j,P,D):
    dist = 0
    for k in range(D):
        dist += (P[i][k] - P[j][k])**2
    square = dist**(1/2)
    if square - int(square) == 0:
        return 1
    else:
        return 0 

def main():
    n,D=map(int,input().split())
    P=[list(map(int,input().split())) for _ in range(n)]
    res = 0
    for i in range(n):
        for j in range(n):
            if i < j:
                res += judge_dist(i,j,P,D)  
    print(res)

main()


Measured memory_bytes: 3316