akhauriyash/Code-Regression huggingface dataset:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n,m = map(int,input().split())
s = list(input())
t = list(input())

div = gcd(n,m)
length = div * (n//div) * (m//div)

difs = length // n
dift = length // m


g = gcd(difs,dift)
gd = g * (difs//g) * (dift//g)
moves = gd//difs
movet = gd//dift

check = True
i = 0
k = 0

while i < n and k < m and check:
    if s[i] != t[k]:
        check = False
    i += moves
    k += movet
if check:
    print(length)
else:
    print('-1')

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

namespace csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var csl = Console.ReadLine();
            var X = int.Parse(csl.Split(' ')[0]);
            var A = int.Parse(csl.Split(' ')[1]);
            var B = int.Parse(csl.Split(' ')[2]);
            if (A - B >= 0)
            {
                Console.WriteLine("delicious");
            }
            else
            {
                if(B-A <= X)
                {
                    Console.WriteLine("safe");
                }
                else
                {
                    Console.WriteLine("dangerous");
                }
            }
        }
    }
}


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

using namespace std;
const int N=2005;
int A[N],B[N],R[N],C[N];
pair<int,int> idx[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    memset(idx,-1,sizeof idx);
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
        {
            int x;cin>>x;
            idx[x]={i,j};
        }
    int n;cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;cin>>x;
        int r=idx[x].first;
        int c=idx[x].second;
        if(r==-1) continue;
        R[r]++;
        if(R[r]==3) return 0*puts("Yes");
        C[c]++;
        if(C[c]==3) return 0*puts("Yes");
        A[r+c]++;
        if(A[r+c]==3) return 0*puts("Yes");
        B[r-c+6]++;
        if(B[r-c+6]==3) return 0*puts("Yes");
    }
    puts("No");
    return 0;
}


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

using namespace std;
typedef long long ll;

const int N = int(1e5) + 7;

ll count(int n){
    ll ans = 0;
    while(n > 0){
        ans += n-1;
        n--;
    }
    return ans;
}


void solve(){
    vector<string> v;
    int n;
    string s;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s;
        sort(s.begin(), s.end());
        v.push_back(s);
    }
    ll ans = 0;
    sort(v.begin(), v.end());
    int mult = 1;
    for(int i = 1; i < n; i++){
        if(v[i] == v[i-1]) mult++;
        else{
            ans += count(mult);
            mult = 1;
        }
    }
    ans += count(mult);
    cout << ans;
}

int main(){
    int test_cases_number = 1;
//    scanf("%d", &test_cases_number);
    for(int i = 0; i < test_cases_number; i++)
        solve();
}


Measured memory_bytes: 5748
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int n , a;

int main(){
    cin >> n;
    map<int,int> f , g;
    f.clear();
    f[0] = 0;
    rep(i,0,n) {
        cin >> a;
        int k = 31 - __builtin_clz(a);
        g.clear();
        auto Update = [&](int a,int b){
            if(!g.count(a)) g[a] = b;
            else g[a] = min(g[a] , b);
        };
        for(auto e : f){
            if(a == (1 << k))
                Update(k , e.se + k - min(e.fi , k));
            else
                Update(k , e.se + k + 1 - min(e.fi , k + 1)),
                Update(k + 1 , e.se + k + 1 - min(e.fi , k));
        }
        f = g;
    }
    int ans = 1 << 30;
    for(auto e : f) ans = min(ans , e.se);
    cout << ans << endl;
    return 0;
}


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

namespace AtCoderTemplate
{
    public class App
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            var p = Console.ReadLine().Split().Select(i=>int.Parse(i));
            int t = 0;
            Console.WriteLine(p.Skip(1).Zip(p,(a,b)=>a==b).Select(i=>{if(i) t++; else t=0;return t;}).Count(i=>i%2==1));
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second   
#define mit mii::iterator
#define vit vi::iterator
#define all(a) a.begin(),a.end()
#define min3(a, b, c) min(a, min(b, c))
#define mod 998244353
#define inf 100000000000000000
#define limit 200005
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 

void input()
{
 	str s;
 	cin >> s;

 	int n = s.length();
 	int i = 0;
 	int ans = 0;
 	while(i < n)
 	{
 		if(s[i] != 'R')
 		{
 			i++;
 			continue;
 		}
 		int j = i;
 		while(j < n && s[j] == 'R')
 			j++;
 		ans = max(ans, j-i);
 		i = j;
 	}
 	cout << ans << '\n';
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int h,w;
  cin >> h >> w;
  string s[h][w];
  rep(i,h){
    rep(j,w)cin >> s[i][j];
  }
  rep(i,h){
    rep(j,w){
      if(s[i][j]=="snuke"){
        int x=i+1;
        char y='A'+j;
        cout << y << x << endl;
      }
    }
  }
return 0;}

Measured memory_bytes: 256
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)
def solve(A):
    if(len(A)==0):
        return 0
    if(max(A)==min(A)):
        return min(A)
    if(0 not in A):
        x=min(A)
        A=[A[i]-x for i in range(len(A))]
        ans=x
        i=0
        while(i<len(A)):
            while(i<len(A) and A[i]==0):
                i+=1
            k=0
            while(i+k<len(A) and A[i+k]!=0):
                k+=1
            ans+=solve(A[i:i+k])
            i+=k
        return ans
    ans=0
    i=0
    while(i<len(A)):
        while(i<len(A) and A[i]==0):
            i+=1
        k=0
        while(i+k<len(A) and A[i+k]!=0):
            k+=1
        ans+=solve(A[i:i+k])
        i+=k
    return ans





n=l()
h=l()
ans=solve(h)
print(ans)






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

int main() {
    int n,i,j,temp,ans=0;
    char tempc;
    bool xchar[28];
    bool ychar[28];
    string s,t;
    cin >> n>>s;
    for(i=0;i<n;i++){
        /*for(bool c:xchar){
            c=false;
        }
        for(bool c:ychar){
            c=false;
        }*/
        for(j=0;j<28;j++){
            xchar[j]=false;
            ychar[j]=false;
        }
        temp=0;
       for(j=0;j<i;j++){
           xchar[s[j]-'a']=true;
       }
       for(j=i;j<n;j++){
           ychar[s[j]-'a']=true;
       }
       for(j=0;j<28;j++){
        if(xchar[j]&&ychar[j])temp++;
       }
       //cout<<temp<<endl;
       if(ans<temp)ans=temp;
    }

    cout<<ans<<endl;
    //std::cout << ans << std::endl;
    return 0;
}

void resetchar(){

}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll k, x;cin >> k >> x;
	for(int i = x - (k - 1);i <= x + (k - 1);i++){
		cout << i << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		int x2000 = sc.nextInt();
		int mo = x2000;
		
		for (int i = 0; i < 10; i++) {
			mo = mo * r - D;
			out.println(mo);
		}
		
	}
}

Measured memory_bytes: 21204
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
vector<int>adj[100009];
vector<int>tree;
bool vis[100009];
int main()
{
    int n,m;
    int x,y;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    queue<int>Q;
    Q.push(1);
    vis[1]=true;
    tree.assign(n+1,0);
    while(!Q.empty())
    {   int i=Q.front();
        Q.pop();
        for(int x : adj[i] ) if(!vis[x]){ tree[x] =  i ; vis[x] =true ; Q.push(x) ;}
    }
    for(int i=2;i<=n;i++) if(tree[i]==0) { cout<<"No\n" ; return 0;}
    cout<<"Yes\n";
    for( int i=2;i<=n;i++) cout<<tree[i]<<"\n";
}


Measured memory_bytes: 9820
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

void dijkstra(vector<vector<data>>& tree,vector<ll>& d,ll start){
  ll i,K=tree[start].size(),N=d.size(),cnt=1;
  data x;
  d[start]=0;
  priority_queue<data,vector<data>,greater<data>> que;
  rep(i,K){
    que.push(data(tree[start][i].second,tree[start][i].first));
  }
  while(cnt<N){
    x=que.top();que.pop();
    if(d[x.second]>0)continue;
    d[x.second]=x.first;
    cnt++;
    K=tree[x.second].size();
    rep(i,K){
      if(d[tree[x.second][i].first]<0){
        que.push(data(d[x.second]+tree[x.second][i].second,tree[x.second][i].first));
      }
    }
  }
}


int main(){
  ll i,j,N,M,K,ans=0;
  cin>>N>>M;
  vec a(5);
  For(i,N,M+1){
    K=i;
    rep(j,5){
      a[j]=K%10;
      K/=10;
    }
    if(a[0]==a[4]&&a[1]==a[3])ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    X = int(input())
    ans = INF
    for i in range(1,300):
        if 360*i%X == 0:
            ans = min(ans,360*i//X)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
# -*- coding: utf-8 -*-

import sys
from collections import deque

sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')

class BipartiteMatching:
    """
    XとYの二部グラフの最大マッチング X={0,1,2,...|X|-1} Y={0,1,2,...,|Y|-1}
    edges[x]: xとつながるYの頂点のset
    match1[x]: xとマッチングされたYの頂点
    match2[y]: yとマッチングされたXの頂点
    """

    def __init__(self, n, m):
        self.n = n
        self.m = m
        self.edges = [set() for _ in range(n)]
        self.match1 = [-1] * n
        self.match2 = [-1] * m
 
    def dfs(self, v, visited):
        """
        :param v: X側の未マッチングの頂点の1つ
        :param visited: 空のsetを渡す（外部からの呼び出し時）
        :return: 増大路が見つかればTrue
        """
        for u in self.edges[v]:
            if u in visited:
                continue
            visited.add(u)
            if self.match2[u] == -1 or self.dfs(self.match2[u], visited):
                self.match2[u] = v
                self.match1[v] = u
                return True
        return False
    
    def add(self, a, b):
        self.edges[a].add(b)

    def whois1(self, a):
        """ :param: グループ1の頂点 :return: ペアになるグループ2の頂点 """
        return self.match1[a]

    def whois2(self, a):
        """ :param: グループ2の頂点 :return: ペアになるグループ1の頂点 """
        return self.match2[a]

    def solve(self):
        # 増大路発見に成功したらTrue(=1)。合計することでマッチング数となる
        return sum(self.dfs(i, set()) for i in range(self.n))

N,M,E=MAP()
bm=BipartiteMatching(N, M)
for i in range(E):
    x,y=MAP()
    bm.add(x, y)

print(bm.solve())



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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 1e3 + 10;
const int maxK = 1e4+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1e9+7;


int main()
{
	int x;
	cin>>x;
	int y = (x-400)/200;
	
	int z = 8-y;
	cout<<z<<endl; 
		
	return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
     
using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 2;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, m;
    cin >> n >> m;
    int a[n];
    rep(i, 0, n)
    {
        cin >> a[i];
        a[i]--;
    }
    ll cnt = 0, cont = 0, ans;
    rep(i, 0, n - 1)
        if (a[i] <= a[i + 1])
        {
            if (a[i] < 0 && a[i + 1] >= 0)
                cnt += 1 + (a[i + 1] - 0), cont++;
            else
                cnt += (a[i + 1] - a[i]);
        }
        else
        {
            if (!(a[i] < 0 && a[i + 1] >= 0))
                cnt += 1 + (a[i + 1] + m - 0) % m, cont++;
            else
                cnt += (a[i + 1] + m - a[i]) % m;
        }
    ans = cnt;
    vector<pair<pair<int, int>, int> > b(n * 2 - 2);
    rep(i, 0, n - 1)
    {
        b[i * 2] = {{a[i], 1}, i};
        b[i * 2 + 1] = {{a[i + 1], -1}, i};
    }
    sort(b.begin(), b.end());
    int pos = 0;
    rep(x, 0, m - 1)
    {
        while (pos < sz(b) && b[pos].fi.fi == x && b[pos].fi.se == -1)
        {
            cnt--;
            cnt += (a[b[pos].se + 1] + m - a[b[pos].se]) % m;
            cont--;
            pos++;
        }
        cnt -= cont;
        while (pos < sz(b) && b[pos].fi.fi == x && b[pos].fi.se == 1)
        {
            cont++;
            pos++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int MAX_N=2005;
int n, m;
vector<string> grid;
int U[MAX_N][MAX_N], D[MAX_N][MAX_N], L[MAX_N][MAX_N], R[MAX_N][MAX_N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n >> m;
    grid.resize(n);
    REP(i, n) cin >> grid[i];

    // U,L
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            if(grid[i-1][j-1]=='.') {
                U[i][j]=U[i-1][j]+1;
                L[i][j]=L[i][j-1]+1;
            }
        }
    }    

    // D,R 
    for(int i=n; i>0; i--) {
        for(int j=m; j>0; j--) {
            if(grid[i-1][j-1]=='.') {
                D[i][j]=D[i+1][j]+1;
                R[i][j]=R[i][j+1]+1;
            }
        }
    }    

    int ans=0;
    REP1(i,1,n) {
        REP1(j,1,m) {
            if(grid[i-1][j-1]=='.') {
                chmax(ans, U[i-1][j]+D[i+1][j]+L[i][j]+R[i][j+1]);
            }
        }
    }

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

Measured memory_bytes: 67328
#include <stdio.h>
const int N=1e5+10;
const int N2=2e5+30;
int p[N2];
int find(int n){return p[n]==n?n:p[n]=find(p[n]);}
int main(){
    int n,m,k,t,a,b;
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<N2;i++)p[i]=i;
    for(int i=1;i<=k;i++){
        scanf("%d%d%d",&t,&a,&b);
        if(t==1){
            a=find(a);
            b=find(b);
            if(a!=b){
                if(a>N){
                    if(b>N){
                        printf("%d\n",i);
                        return 0;
                    }
                    else p[b]=a;
                }
                else p[a]=b;
            }
        }
        else{
            a=find(a);
            b+=N;
            if(a!=b){
                if(a>N){
                    printf("%d\n",i);
                    return 0;
                }
                else p[a]=b;
            }
        }
    }
    printf("0\n");
}


Measured memory_bytes: 3524
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace at
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(' ');

            if(int.Parse(x[0])==int.Parse(x[1]))
            {
                Console.WriteLine("a == b");
            }
            else if(int.Parse(x[0])<int.Parse(x[1]))
            {
                Console.WriteLine("a < b");
            }
            else if(int.Parse(x[0])>int.Parse(x[1]))
            {
                Console.WriteLine("a > b");
            }
        }
    }
}



Measured memory_bytes: 17904
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

int main() {
    int N,D;
    cin >> N >> D;
    cout << (N%(2*D+1) == 0 ? N/(2*D+1) : N/(2*D+1) + 1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int read() {
	int x=0, f=1; char ch=' ';
	while(!isdigit(ch)) {ch=getchar(); if(ch=='-') f=-1;}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x*f;
}
string s, t;
int len, ans;
int main() {
	cin>>s>>t;
	len=s.size();
	for(int i=0;i<len;i++) {
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3848
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list>
#include <unordered_set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n,cnt=0;
	cin >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	unordered_map<ll, ll>mp;
	for (ll i = 0; i < n; i++) {
		mp[a[i]]++;
	}
	for (auto itr = mp.begin(); itr != mp.end();itr++) {
		ll in = itr->first;
		ll out = itr->second;
		cnt += (out >= in ? abs(in - out) : out);
	}
	cout << cnt << endl;
}


Measured memory_bytes: 5028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s1s2s3;
  int a,b,c;
  cin >> s1s2s3;
  
  a=s1s2s3/100;
  b=(s1s2s3-100*a)/10;
  c=s1s2s3-100*a-10*b;
  
  cout << a+b+c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const long long INF = 1LL << 60;
const ll C = 1000000000+7;

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

int main() {
    int H, W;
    cin >> H >> W;
    string board[H];
    for(int i=0; i<H; i++) cin >> board[i];

    bool flg;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            int cnt = 0;
            for(int k=0; k<4; k++) {
                int x = dx[k] + j;
                int y = dy[k] + i;
                if(x >= 0 && y >= 0 && x < W && y < H) {
                    if(board[i][j] == '#' && board[y][x] != '#') cnt++;
                }
            }
            if(cnt == 4) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  queue<int> ans;
  int cnt = 0;
  int r_cnt = 0;

  rep(i, N){
    cnt++;
    if(S[i] == 'R') r_cnt++;
    if(S[i]=='L' && S[i+1]=='R'){
      //cout << cnt << endl;
      if(cnt % 2 == 0){
        ans.push(cnt/2);
        ans.push(cnt/2);
      }
      else{
        if(r_cnt%2){
          ans.push((cnt+1)/2);
          ans.push((cnt-1)/2);
        }
        else{
          ans.push((cnt-1)/2);
          ans.push((cnt+1)/2);
        }

      }
      cnt = 0;
      r_cnt = 0;
    }
  }

  if(cnt % 2 == 0){
    ans.push(cnt/2);
    ans.push(cnt/2);
  }
  else{
    if(r_cnt%2){
      ans.push((cnt+1)/2);
      ans.push((cnt-1)/2);
    }
    else{
      ans.push((cnt-1)/2);
      ans.push((cnt+1)/2);
    }

  }

  rep(i, N){
    if(S[i]=='R' && S[i+1]=='L'){
      cout << ans.front() << endl;
      ans.pop();
      i++;
      cout << ans.front() << endl;
      ans.pop();
    }
    else cout << 0 << endl;
  }

}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1e9;

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

    vector<pair<int, int>> key;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, b) {
            int c;
            cin >> c;
            c--;
            s |= 1<<c;
        }
        key.emplace_back(s, a);
    }

    vector<int> dp(1<<n, INF);
    dp[0] = 0;
    rep(s, 1<<n) {
        rep(i, m) {
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }

    int ans = dp[(1<<n)-1];
    if(ans == INF) {
        ans = -1;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10001];
void print(int n)
{
	for(int i=0;i<n;i++)
	{
		cout<<a[i];
		if(i!=n-1)
		cout<<' ';
		else
		cout<<endl;
	}
		
}
void insertsort(int n)
{
	int v,j;
	for(int i=0;i<n;i++)
	{
		v=a[i];
		j=i-1;
		while(j>=0&&a[j]>v)
		{
			a[j+1]=a[j];
			j--;
			a[j+1]=v;
		}	
		print(n);
	}
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	insertsort(n);
	
	
}


Measured memory_bytes: 3068
using System;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力受け取ってやる
            int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = input[0];int B = input[1];

            if (A <= 8 && B <= 8){//成立
                Console.WriteLine("Yay!");
            }else{
                Console.WriteLine(":(");
            }

        }
    }
}


Measured memory_bytes: 11348
# 直角三角形ABCがあります。∠ABC=90°です。三角形ABCの三辺の長さである|AB|,|BC|,|CA|が与えられるので、直角三角形ABCの面積を求めて下さい。
# ただし、三角形ABCの面積は整数となることが保証されています。

AB,BC,CA = map(int,input().split())
print((AB * BC) // 2)

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



int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  
  ll gcd = __gcd(C, D);
  
  ll ans = B - A + 1;
  ans -= (B / C - (A - 1) / C) + (B / D - (A - 1) / D) - (B / (C / gcd * D) - (A - 1) / (C / gcd * D));
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
fn main() {
    let (mut a, mut b, mut c): (usize, usize, usize) =
        (read::<usize>(), read::<usize>(), read::<usize>());
    let mut d: usize = read();
    loop {
        match c.checked_sub(b) {
            Some(l) if l > 0 => c -= b,
            _ => {
                println!("Yes");
                exit(0);
            }
        }
        match a.checked_sub(d) {
            Some(l) if l > 0 => a -= d,
            _ => {
                println!("No");
                exit(0);
            }
        }
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

template <class t, class u>
void chmax(t &a, u b)
{
  if (a < b)
    a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
  if (b < a)
    a = b;
}
const int mod = 1000000007;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll 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
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;
int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}
int fact(int n)
{
  if (n == 0)
    return 1;
  return n * fact(n - 1);
}

int main()
{
	int n;cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  set<int> s;
  rep(i,n)s.insert(a[i]);
  int ss=s.size();
  if(ss%2==0){
 	cout <<ss-1<<endl; 
 }else{
  	cout <<ss<<endl;
  }

}

Measured memory_bytes: 5376
module DoublyLinkedList = struct
  type t = {
    mutable data : int;
    mutable next : t;
    mutable prev : t;
  }

  let make () =
    let rec head = { data = 0; next = head; prev = head } in
    head

  let insert data head =
    let x = { data = data; next = head.next; prev = head } in
    head.next.prev <- x;
    head.next <- x

  let delete x =
    x.next.prev <- x.prev;
    x.prev.next <- x.next

  let delete_first head = delete head.next

  let delete_last head = delete head.prev

  let delete_node data head =
    let rec doit ite =
      if ite == head then None
      else if ite.data = data then Some ite
      else doit ite.next in
    match doit head.next with
    | None -> ()
    | Some ite -> delete ite

  let iteri f head =
    let rec doit i ite =
      if ite != head then begin
        f i ite.data;
        doit (i + 1) ite.next
      end in
    doit 0 head.next
end

module L = DoublyLinkedList

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let head = L.make () in
  let rec read i =
    if i < n then begin
      begin match split_on_char ' ' (read_line ()) with
      | ["insert"; n] -> L.insert (int_of_string n) head
      | ["delete"; n] -> L.delete_node (int_of_string n) head
      | ["deleteFirst"] -> L.delete_first head
      | _ -> L.delete_last head
      end;
      read (i + 1)
    end in
  read 0;
  L.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) head;
  print_newline ()

Measured memory_bytes: 41080
#include<bits/stdc++.h>
using namespace std;
int dp[2][1000];
int main()
{
    int i,j,n;
    cin>>n;
    int arr[2][1000];
    
    for(i=0;i<2;i++)
    {
        for(j=0;j<n;j++)
        {cin>>arr[i][j];}
    }
    dp[0][0]=arr[0][0];
    for(i=1;i<n;i++)
        dp[0][i]=dp[0][i-1]+arr[0][i];
        
        dp[1][0]=dp[0][0]+arr[1][0];
    
    for(i=1;i<2;i++)
    {
        for(j=1;j<n;j++)
        {
            dp[i][j]= max(dp[i-1][j],dp[i][j-1])+arr[i][j];
        }
    }
    cout<<dp[1][n-1];
    return 0;
}


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

using namespace std;

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

int H,W;
int D;
int A[300][300];
P coords[100000];

vector<vector<int> > sum;

int cost(int i,int j) {
  P a = coords[i],b=coords[j];
  return abs(a.first - b.first) + abs(a.second-b.second);
}
int main(int argc, char** argv, char** envp) {
  cin >> H >> W >> D;
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      int a;
      scanf("%d", &a);
      a--;
      A[i][j] = a;
      coords[a] = P(i,j);
    }
  }
  sum.resize(D);
  for(int i=0;i<H * W;++i) {
    int s = 0;
    if (i < D) {
      s = 0;
    } else {
      s = sum[i%D].back() + cost(i,i-D);
    }
    sum[i%D].push_back(s);
  }
  int Q;
  cin >> Q;
  for(int i=0;i<Q;++i) {
    int L,R;
    scanf("%d%d", &L, &R);
    --L;--R;
    int answer = sum[L%D][R/D] - sum[L%D][L/D];
    cout << answer << endl;
  }
  
  return 0;
}


Measured memory_bytes: 6400
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	l := 0
	count := N
	P := A[0]
	j := 1
	for l < N {
		for ; j < N; j++ {
			if P&A[j] > 0 {
				break
			}
			count += j - l
			P |= A[j]
		}
		P -= A[l]
		l++
	}
	fmt.Println(count)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	
	int k,a,b;
	cin>>k;
	cin>>a>>b;

	if(a%k == 0)
	cout<<"OK";

	else if(b%k==0)
	cout<<"OK";

	else if(a/k != b/k)
	cout<<"OK";

	else
	cout<<"NG";

	return 0;
}

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

// int 3E4
// long 2E9
// long long 9E18

struct lunlun
{
  long v;
  vector<long> children;
  lunlun(long v) : v(v)
  {
    int x = v % 10;
    for (int i = max(0, x - 1); i <= min(9, x + 1); i++)
      children.emplace_back(v * 10 + i);
  };
};

int main() {
  long K;
  cin >> K;

  if (K <= 9)
    {
      cout << K << endl;
      return 0;
    }
  
  queue<lunlun> open;
  for (int i = 1; i <= 9; i++)
    open.emplace(i);

  long k = 9;
  while (true)
    {
      lunlun n = open.front();
      open.pop();
      for (const auto& child : n.children)
	{
	  // cout << k << "," << child << endl;
	  if (++k >= K)
	    {
	      cout << child << endl;
	      return 0;
	    }
	  open.emplace(child);
	}
    }

}


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

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    f = list(map(int, input().split()))
    a = sorted(a)
    f = sorted(f)
    f = f[::-1]
    mi = -1  # Impossible
    ma = 10 ** 12  # Possible
    for i in range(100):
        md = mi + (ma - mi) // 2
        if can_achieve(md, a, f, k, n):
            ma = md
        else:
            mi = md
        if ma - mi <= 1:
            break
    print(ma)

def can_achieve(score, a, f, k, n):
    sumb = 0
    for i in range(n):
        b = a[i] - score // f[i]
        b = max(b, 0)
        sumb += b
    return k >= sumb

if __name__ == "__main__":
    main()


Measured memory_bytes: 122572
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int ans = 0;
		if(B <= C || D <= A) {
			ans = 0;
		} else if(C <= A && A <= D && D <= B){
			ans = D - A;
		} else if(C <= A && B <= D) {
			ans = B - A;
		} else if(A <= C && C <= B && D <= B) {
			ans = D - C;
		} else if(A <= C && C <= B && B <= D) {
			ans = B - C;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
	map<int,int> mp;
	int n;
	cin >> n;

	string ans="YES";
	for(int i=0; i<n; ++i){
		int a; cin >> a;
		++mp[a];
		if(mp[a]==2){
			ans="NO";
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 9600
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ll factorial(ll x){
  if(x==0)return 1;
  return x*factorial(x-1)%MOD;
}
int main(){
  ll n;cin>>n;
  cout<<factorial(n)<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main(){
  int n,num,i,j,flag,count = 0;
  
  scanf("%d",&n);
  
  for(i = 0 ; i < n ; i++){
    flag = 0;
    scanf("%d",&num);
    if(num == 2){
      count++;
      continue;
    }
    for(j = 2 ; j <= sqrt(num) ; j++){
      if(num%j == 0){
	flag = 1;
	break;
      }
    }
    if(flag == 0) count++;
  }
  
  printf("%d\n",count);
  
  return 0;
}


  
    



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;

int n, ans[100050] = {0};
string s;

signed main() {

	cin >> s;
	n = s.length();

	vector<int> l, r;

	for(int i = 0; i < n; i++){
		if(s[i] == 'L') l.push_back(i);
		else r.push_back(i);
	}

	/*for(int i = 0; i < l.size(); i++){
		cout << l[i] << " " ;
	}return 0;*/

	for(int i = 0; i < (int) r.size(); i++){
		vector<int>::iterator up;
  		up = std::upper_bound (l.begin(), l.end(), r[i]);
  		//cout << "up = " << up - l.begin() << endl;
  		if(up - l.begin() == (int) l.size()) ans[n-2]++;
  		else{
  			//cout << l[up - l.begin()] << " ";
  			if( ( l[up - l.begin()] - r[i]) % 2 == 0){
  				ans[l[up - l.begin()]]++;
  				//cout << l[up - l.begin()] << " ";
  			}
  			else{
  				ans[l[up - l.begin()] - 1]++;
  				//cout << l[up - l.begin() - 1] << " ";
  			}
  		}
	} //return 0;

	/*for(int i = 0; i < n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;*/

	//return 0;

	string ns;
	for(int i = n-1; i >= 0; i--) {
		ns += s[i];
	}

	for(int i = 0; i < n; i++){
		if(ns[i] == 'L') ns[i] = 'R';
		else ns[i] = 'L';
	}

	vector<int> nl, nr;

	for(int i = 0; i < n; i++){
		if(ns[i] == 'L') nl.push_back(i);
		else nr.push_back(i);
	}

	/*for(int i = 0; i < l.size(); i++){
		cout << l[i] << " " ;
	}return 0;*/

	for(int i = 0; i < (int) nr.size(); i++){
		vector<int>::iterator nup;
  		nup = std::upper_bound (nl.begin(), nl.end(), nr[i]);
  		//cout << "up = " << up - l.begin() << endl;
  		if(nup - nl.begin() == (int) nl.size()) ans[n-2]++;
  		else{
  			//cout << l[up - l.begin()] << " ";
  			if( ( nl[nup - nl.begin()] - nr[i]) % 2 == 0){
  				ans[(n-1) - (nl[nup - nl.begin()])]++;
  				//cout << l[up - l.begin()] << " ";
  			}
  			else{
  				ans[(n-1) - (nl[nup - nl.begin()] - 1)]++;
  				//cout << l[up - l.begin() - 1] << " ";
  			}
  		}
	} 

	for(int i = 0; i < n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;


	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n;
	int count=1;
	vector<int> d;

	cin>> n;
	d.resize(n);

	for(int i=0;i<n;i++) cin>> d[i];

	sort(d.begin(), d.end());

	for(int i=1;i<n;i++) if(d[i]!=d[i-1]) count++;

	cout<< count << endl;


}

Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

my_hand = []
ans = 0
point = {'r':P, 's':R, 'p':S}
win = {'r':'p', 's':'r', 'p':'s'}

for i, t in enumerate(T):
    if i >= K:
        if my_hand[i - K] == win[t]:
            my_hand.append('z')
        else:
            ans += point[t]
            my_hand.append(win[t])
    else:
        ans += point[t]
        my_hand.append(win[t])
print(ans)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(), .end());
int main(){
  ll n, k, z;
  cin >> n >> k;
  vll x(n+1);
  for (ll i = 1; i <= n; i++) cin >> x[i];
  for (ll i = 1; i <= n-k+1; i++) {
    if (x[i]*x[i+k-1] >= 0) z = max(abs(x[i]),abs(x[i+k-1]));
    else z = x[i+k-1] - x[i] + min(-x[i],x[i+k-1]);
    if (INF > z) INF = z;
  }
  cout << INF << endl;
}

Measured memory_bytes: 1024
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		System.out.printf("ABC%03d\n", sc.nextInt());
	}
}

Measured memory_bytes: 21844
l_a  = list(input())
l_b = [l_a[0],0,l_a[1],0,l_a[2],0,l_a[3]]
l_c = []
for i in range (2**3):
    for k in range(3):
        if i & (1<<k):
            l_b[2*k+1] = '+'
        else:
            l_b[2*k+1] = '-'
    d =''.join(l_b)
    if eval(d) == 7:
        print(d + '=7')
        exit()

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

li solve(li x,const vector<li>& bgr,const vector<li>& pty,int n){
  if(x<=n) return 0;
  else if(x==bgr[n]){
    return pty[n];
  }else if(x>=bgr[n-1]+2){
    return pty[n-1]+solve(x-bgr[n-1]-2,bgr,pty,n-1)+1;
  }else if(x==bgr[n-1]+1){
    return pty[n-1];
  }else{
    return solve(x-1,bgr,pty,n-1);
  }
}

int main(){
  int n; li x; cin >>n >>x;
  vector<li> bgr(n+1,0),pty(n+1,0);
  bgr[0]=1;pty[0]=1;
  rep(i,n){
    bgr[i+1]=bgr[i]*2+3;
    pty[i+1]=pty[i]*2+1;
  }
  print(solve(x,bgr,pty,n));
}


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

int main() {
  int n; cin >> n;
  bool ans = false;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if (i * j == n) {
        ans = true;
      }
    }
  }
  if (ans){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256