akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <time.h>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <bitset>
#include <algorithm>
using namespace std;
#define MP make_pair
#define PB push_back
#define ms(a,b) memset((a),(b),sizeof(a))
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<Pii> Vii;
const int inf = 0x3f3f3f3f;
const LL INF = (1uLL << 63) - 1;
const LL mod = 1000000007;
const int N = 150 + 5;
const double Pi = acos(-1.0);
const int maxn = 200005;
using namespace std;
int fa[maxn];
int fb[maxn];
int find(int *fa,int x) {
    return x == fa[x] ? x : fa[x] = find(fa,fa[x]);
}
void init() {
    for(int i = 0 ; i < maxn; i++) {
        fa[i] = fb[i] = i;
    }
}
set<int>S[2][maxn];
int ans[maxn];
int G[maxn];
bool vis[maxn];
map<pair<int,int> ,int>M;
int main() {
#ifdef local
    freopen("in","r",stdin);
#endif
    init();
    int n,k,l;
    scanf("%d%d%d",&n,&k,&l);
    for(int i = 0; i < k; i++) {
        int u,v;
        cin>>u>>v;
        u = find(fa,u);
        v = find(fa,v);
        fa[u] = v;
    }
    for(int i = 0; i < l; i++) {
        int u,v;
        cin>>u>>v;
        u = find(fb,u);
        v = find(fb,v);
        fb[u] = v;
    }
    for(int i = 1; i <= n; i++) {
        S[0][find(fa,i)].insert(i);
        S[1][find(fb,i)].insert(i);
    }
    for(int i = 1; i <= n; i++) {
        if(M[MP(fa[i],fb[i])]) {
            ans[i] = M[MP(fa[i],fb[i])];
            continue;
        }
        int sz = S[0][fa[i]].size();
        int bz = S[1][fb[i]].size();
        if(sz < bz)
        for(int it : S[0][fa[i]]) {
            if(S[1][fb[i]].count(it))ans[i]++;
        }
        else for(int it : S[1][fb[i]]) {
            if(S[0][fa[i]].count(it))ans[i]++;
        }
        M[MP(fa[i],fb[i])] = ans[i];
    }
    for(int i = 1; i <= n; i++) {
        printf("%d ",ans[i]);
    }
}


Measured memory_bytes: 51072
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, m, ans;
ll MOD = 1e9+7;

int main(){
	cin >> n >> m;
	
	if(max(n, m) - min(n, m) > 1){ans = 0;}
	else{
		ans = 1;
		if(n == m){
			for(ll i = n; i >= 1; i--){
				ans *= i;
				ans %= MOD;
				ans *= i;
				ans %= MOD;
			}
			ans *= 2;
			ans %= MOD;
		}
		else{
			n = max(n, m);
			ans *= n;
			ans %= MOD;
			for(ll i = n-1; i >= 1; i--){
				ans *= i;
				ans %= MOD;
				ans *= i;
				ans %= MOD;
			}
		}
	}

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

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

inline ld dist(ld &x1, ld &y1, ld &x2, ld &y2)
{
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  vector<int> p(n);
  iota(all(p), 0);
  ld x[8], y[8];
  rep(i, n) cin >> x[i] >> y[i];
  ld sum = 0.0;
  do
  {
    rep(i, n - 1)
    {
      sum += dist(x[p[i]], y[p[i]], x[p[i + 1]], y[p[i + 1]]);
    }
  } while (NP(p));
  ld f = 1.0;
  REP(i, 1, n + 1)
  f *= i;
  cout << sum / f << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
#define ld long double
int main()
{
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll x1 = a*c;
  ll x2 = a*d;
  ll x3 = b*c;
  ll x4 = b*d;
  ll ans=max(x1, x2);
  ans=max(ans, x3);
  ans=max(ans, x4); 
  cout << ans << "\n";

}

Measured memory_bytes: 3636
import heapq
N = int(input()) 
V=list(map(int,input().split())) 
C= list(map(int,input().split())) 
a=[] 
for i in range(0,N): 
  if V[i]>=C[i]:
    heapq.heappush(a,(V[i]-C[i])) 
  else:
    continue 
print(sum(a))

Measured memory_bytes: 38384
# input
N = int(input())
S = input()

# check
if N < 2 or N % 2 != 0:
    print("No")
else:
    if N == 2:
        right = S[0]
        left = S[1]
    else:
        c = N // 2
        right = S[0:c]
        left = S[c:]

    if right == left:
        print("Yes")
    else:
        print("No")

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

#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define ll long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define PI 3.1415926535897932384626
#define inf 1e18
#define vll vector<ll>
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define flr(i,a,b) for(ll i=a;i>b;i--)
#define print(v) for(auto i=v.begin();i!=v.end();i++){cout<<*i<<" ";}cout<<"\n";
#define MOD 1000000007
const ll N = 2e5;

int main()
{
    speed;
    ll R,G,a,b,c; cin>>R>>G>>a>>b>>c;
    vll p(a),q(b),r(c);
    forn(i,a) cin>>p[i];
    forn(i,b) cin>>q[i];
    forn(i,c) cin>>r[i];
    sort(all(p)); sort(all(q)); sort(all(r),greater<int>());
    ll ans= 0 ;
    priority_queue<ll,vll,greater<ll>> pq;
    forn(i,R){
        pq.push(p[p.size()-1]);
        p.pop_back();
    }
    forn(i,G){
        pq.push(q[q.size()-1]);
        q.pop_back();
    }
    for(auto num: r){
        if(pq.top()<num){
            pq.pop();
            pq.push(num);
        }
    }
    while(!pq.empty()){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4852
#include<iostream>
using namespace std ;
int color( int a )
{
	a = a % 3 ;
	if( a == 0 )
	{
		a = 3 ;
	}
	return a ;
}
int main()
{
	int n ;
	int k ;
	int yoko ,tate ;
	int i ;
	cin >> n ;
	cin >> k ;
	for( i = 0 ; i < k ; i++ )
	{
		cin >> yoko >> tate ;
		if( yoko > tate )
		{
			if( yoko > n - tate )
			{
				yoko = ( n - yoko ) + 1 ;
				cout << color( yoko ) << endl ;
			}
			else
			{
				cout << color( tate ) << endl ;
			}
		}
		else
		{
			if( tate > n - yoko )
			{
				tate = ( n - tate ) + 1 ;
				cout << color( tate ) << endl ;
			}
			else
			{
				cout << color( yoko ) << endl ;
			}
		}
	}
	return 0 ;
}

Measured memory_bytes: 3088
table = input().split()
N,M = int(table[0]),int(table[1])
hyou = []
for i in range(M):
    ith = input().split()
    hyou += ith
hyou = list(map(int,hyou))
j = 1
while j <= N:
    print(hyou.count(j))
    j += 1


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();

		if (R < 1200) {
			System.out.println("ABC");
		} else if (R < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}

		System.out.println();

		sc.close();

	}

}

Measured memory_bytes: 22612
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    N,K = isRaw()
    As = isRaw()
    for k in range(K):
        nAs = [0]*(N+1)
        for aidx,a in enumerate(As):
            nAs[max(0, aidx-a)]+=1
            nAs[min(aidx+a+1,N)]-=1
        for aidx in range(1,N):
            nAs[aidx] += nAs[aidx-1]
        As = nAs[:N]
        if sum(As) == N*N:
            break
        
    print(" ".join([str(a) for a in As]))




main()


Measured memory_bytes: 169280
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int n,x[10],y[10];

inline double dist(int a,int b){
	return sqrt((x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]));
}

signed main(){
	cin >> n;
	for(int i = 0;i < n;i++) cin >> x[i] >> y[i];
	vector<int> vec(n);
	for(int i = 0;i < n;i++) vec[i] = i;
	double ans = 0;
	do{
		double sum = 0;
		for(int i = 0;i < n - 1;i++) sum += dist(vec[i],vec[i + 1]);
		ans += sum;
	}while(next_permutation(all(vec)));
	for(int i = 1;i <= n;i++) ans /= i;
	printf("%.12lf\n",ans);
}

Measured memory_bytes: 256
S = input()
for bit in range(1 << 4):
    template = ('A' if bit & 1 else '') + 'KIH' + ('A' if (bit >> 1) & 1 else '') + 'B' + ('A' if (bit >> 2) & 1 else '') + 'R' + ('A' if (bit >> 3) & 1 else '')
    if S == template:
        print('YES')
        break
else:
    print('NO')

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var nk = Reads();
            var n = nk[0];
            var k = nk[1];
            var a = Reads();
            var d = new Dictionary<long, long>();
            for (int i = 0; i < n; i++)
            {
                if (d.ContainsKey(a[i])) d[a[i]]++;
                else d.Add(a[i], 1);
            }
            var nd = d.OrderBy(x => x.Value);
            var c = 0;
            long ans = 0;
            var size = d.Count;
            foreach (var item in nd)
            {
                if (c < size-k) ans += item.Value;
                else break;
                c++;
            }
            WriteLine(ans);











          
            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 43492
A, B, X = map(int, raw_input().split())

def check(n):
    if n == 0:
        return True
    v = X - n * A + n * B
    return v - B >= 0

hi = 10**16
lo = 0

while hi - lo > 1:
    mid = (hi + lo) / 2
    if check(mid):
        lo = mid
    else:
        hi = mid

print (X + lo * B) % (10 ** 9 + 7)



Measured memory_bytes: 4660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007

ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}

int main(){
    ll n;cin>>n;
    vector<ll> vec(n+1);
    vec.at(0)=-1;
    For1(i,n+1){
        cin>>vec.at(i);
    }
    vector<ll> ans(n+1);
    ans.at(0)=-1;
    for(ll i=n;i>n/2;i--){
        ans.at(i)=vec.at(i);
    }
    for(ll i=n/2;i>0;i--){
        ll module=100;
        ll j=i;
        while(j<=n){
            module+=ans.at(j);
            j+=i;
        }
        ans.at(i)=(module-vec.at(i))%2;
    }
    ll m=0;
    vector<ll> b;
    For1(i,n+1){
        //cout<<ans.at(i)<<endl;
        if(ans.at(i)==1){
            m++;
            b.push_back(i);
        }
    }
    cout<<m<<endl;
    For(i,b.size()){
        cout<<b.at(i)<<" ";
    }
}


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

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

    int M, K; cin >> M >> K;

    int val = 1; F0R(i, M) val = val * 2;
    if (val <= K) {
        cout << -1 << endl;
        return 0;
    }

    if (M == 1) {
        if (K == 1) {
            cout << -1 << endl;
        } else {
            cout << "0 0 1 1" << endl;
        }
        return 0;
    }

    F0R(i, val) {
        if (i != K) {
            cout << i << " ";
        }
    }

    cout << K << " ";
    F0Rd(i, val) {
        if (i != K) {
            cout << i << " ";
        }
    }
    cout << K << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 1792
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    if(a<b && b<c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "Yes" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL--------------------------------- 

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    string S; cin>>S;
    vector<ll> A[N];
    rep(i,M){
        ll a,b; cin>>a>>b; --a,--b;
        A[a].emplace_back(b);
        A[b].emplace_back(a);
    }
    deque<ll> qu;
    bool se[N]={};
    vector<ll> a(N);
    vector<ll> b(N);
    rep(i,N){
        for(auto x: A[i]){
            if(S[x]=='A') ++a[i];
            if(S[x]=='B') ++b[i];
        }
        if(a[i]==0 or b[i]==0) qu.emplace_back(i);
        else se[i]=true;
    }
    while(!qu.empty()){
        ll saku=qu.front(); qu.pop_front();
        for(auto x: A[saku]){
            if(se[x]==false) continue;
            if(S[saku]=='A') --a[x];
            if(S[saku]=='B') --b[x];
            if(a[x]==0 or b[x]==0){
                se[x]=false;
                qu.emplace_back(x);
            }
        }
    }
    rep(i,N) if(se[i]) dame;
    cout<< "No" <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 15696
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
int main(){
    vl v(7);rep(i,7)cin >> v[i];
    ll ans=0;
    ans+=(v[0]/2+v[3]/2+v[4]/2)*4;
    ll res=0;
    if(v[0]&&v[3]&&v[4]){
        res+=6;v[0]--;v[3]--;v[4]--;
        res+=(v[0]/2+v[3]/2+v[4]/2)*4;
    }
    cout << v[1]+max(ans,res)/2 <<endl;
} 

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> par(n), a(n, -1);
    vector<vector<int>> g(n);
    for (int i = 0; i < n; i++) {
        cin >> par[i], par[i]--;
        g[par[i]].emplace_back(i);
    }
    queue<int> que;
    for (int i = 0; i < n; i++) if (g[i].size() == 0) que.emplace(i);   // 葉
    while (!que.empty()) {
        int u = que.front(); que.pop();
        if (a[u] >= 0) continue;
        set<int> s;
        bool on_cycle = false;
        for (int v: g[u]) {
            if (a[v] == -1) on_cycle = true;
            s.emplace(a[v]);
        }
        if (on_cycle) continue;
        int g = 0; while (s.count(g)) g++;
        a[u] = g;
        que.emplace(par[u]);
    }
    auto check = [&](int st, int val) {
        int u = par[st];
        int prev = val;
        while (u != st) {
            set<int> s; s.insert(prev);
            for (int v: g[u]) s.insert(a[v]);
            int g = 0; while (s.count(g)) g++;
            prev = a[u] = g;
            u = par[u];
        }
        set<int> s; s.insert(prev);
        for (int v: g[u]) s.insert(a[v]);
        int g = 0; while (s.count(g)) g++;
        a[st] = g;
        return g == val;
    };
    int u;
    for (int i = 0; i < n; i++) if (a[i] == -1) u = i;
    set<int> s;
    for (int v: g[u]) s.emplace(a[v]);
    int g1 = 0;         while (s.count(g1)) g1++;
    int g2 = g1 + 1;    while (s.count(g2)) g2++;
    if (check(u, g1) || check(u, g2)) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 11776
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

typedef long double ld;

int main() {
	ios::sync_with_stdio(0);
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	ld best = 0.0;
	int bw = 100*a, bs = 0;
	for(int i = 0; i<=f; i+=(100*a)){
		for(int j = 0; i+j<=f; j+=(100*b)){
			int water = i + j;
			for(int x=0; water+x<=f; x+=c){
				int reqx = (water*e) / 100;
				if (reqx < x)
					break;
				int maxlim = reqx - x;
				int flim = f - water - x;
				int lim = min(maxlim, flim);
				int y = (lim / d)*d;
				int sugar = x + y;
				ld pct = (100.0*(sugar)) / (sugar + water);
				if(pct>best){
					best = pct;
					bw = water;
					bs = sugar;
				}
			}
		}
	}
	cout << bw + bs << " " << bs;
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
  int n,a[100001]={},b,cnt=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&b);
    a[b]++;
  }
  for(int i=1;i<=100000;i++)
    if(a[i])
      cnt++;
  if(cnt%2==1)
    printf("%d\n",cnt);
  else
    printf("%d\n",cnt-1);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
#define ll              long long int
#define vll             vector<ll>
#define vs              vector <string>                                    
#define mll             map<ll,ll>
#define pll             pair<ll, ll>
#define vpll            vector < pair<ll,ll> >
#define itr             vll::iterator
#define all(c)          c.begin(),c.end()
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define pb              push_back
#define mb              make_pair
#define ff              first
#define ss              second
#define max3(a,b,c)     max(max(a,b),c)                                    
#define min3(a,b,c)     min(min(a,b),c)  
#define mod             1000000007
#define inf             1000000000000000001
#define from(i, n)      for(__typeof(n) i = 0; i <  n; ++i)
#define fromj(i, j, n)  for(__typeof(n) i = j; i <  n; ++i)
#define printv(v)       from(i,v.size())cout<<v[i]<<" ";cout<<"\n";
#define w(x)            int x; cin>>x; while(x--)
 
using namespace std;
using namespace __gnu_pbds; 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
}
 
bool func(const pll &a, const pll &b){
    if(a.ss==b.ss)return a.ff<b.ff;
    return a.ss < b.ss;
}
 
typedef tree<int, null_type, less<int >, rb_tree_tag, 
             tree_order_statistics_node_update> pbds; 
 
int main(){
    c_p_c();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll h,w;
    cin>>h>>w;
    char a[h][w];
    from(i,h){
    	from(j,w)cin>>a[i][j];
    }
    vector<vll >v(h,vll(w,0));
    from(i,h){
    	if(a[i][0]=='.')v[i][0]=1;
    	else break;
    }
    from(i,w){
    	if(a[0][i]=='.')v[0][i]=1;
    	else break;
    }	
    fromj(i,1,h){
    	fromj(j,1,w){
    		if(a[i][j]=='#')v[i][j]=0;
    		else v[i][j]=(v[i-1][j]+v[i][j-1])%mod;
    	}
    }
    cout<<v[h-1][w-1];
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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 ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll ans=0;
  rep(i,s.size()){
    if(s[i]=='+')ans++;
    else ans--;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int r;

void rec(int n, int s, int x) {
  if (!n && !s) {
    r++;
    return;
  }
  for (; x >= 0; x--)
    if (x <= s)
      rec(n-1, s-x, x-1);
}

int main() {
  for (;;) {
    int n, s;
    cin >> n >> s;
    if (!n && !s) return 0;
    r = 0;
    rec(n, s, 9);
    cout << r << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);
//桁数に注意 long long　にする

int main() {
  int n;
  cin >> n;
  
  cout << 1000*(n/500)+5*(n%500/5);
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> A;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    A.push_back(0);
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;A.push_back(a);
    }
    A.push_back(0);
}

int solve(){
    ll ans=0;
    // N = A.size();
    for (int i = 0; i < A.size()-1; i++)
    {
        ans += abs(A[i+1]-A[i]);
    }
    for (int i = 1; i <= N; i++)
    {
        ll tmp = ans;
        tmp -= abs(A[i]-A[i-1]);
        tmp -= abs(A[i+1]-A[i]);
        tmp += abs(A[i+1]-A[i-1]);
        cout << tmp << endl;
    }
    
    
    return 0;
}   

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


Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<pair<char, int>> cnt;
    cnt.push_back(make_pair(s[0], 1));
    rep1(i, n){
        if(s[i] == cnt.back().first) ++cnt.back().second;
        else cnt.push_back(make_pair(s[i], 1));
    }

    int res = 0;
    rep(i, cnt.size()) res += cnt[i].second - 1;

    cout << min(n-1, res + 2*k) << endl;

    return 0;
}

Measured memory_bytes: 4444
N, P = map(int, input().split())
S = input()
total = 0
if P == 2:
  for idx, right_value in enumerate(S, 1):
    if int(int(right_value)%2==0):
      total += idx
elif P == 5:
  valid_options = (0, 5)
  for idx, right_value in enumerate(S, 1):
    if int(int(right_value) in valid_options):
      total += idx
else:
  histo_modsuffix = [0]*P
  previous = 0
  for i, val in enumerate(reversed(S)):
    scale = pow(10, i, P)
    new_val = (previous + scale*int(val))%P
    histo_modsuffix[new_val] += 1
    previous = new_val
  for val in histo_modsuffix:
    total += val*(val-1)//2
  total += histo_modsuffix[0] # when right hand side is at far end
print(total)

Measured memory_bytes: 68496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;
template<typename T> T factorial(T n){
    if(n==1) return 1;
    else return n*factorial(n-1)%MOD;
}
template<typename T> T Pow(T x, T n, T m){
    if(n == 0) return 1;
    if(n % 2 == 0) return Pow(x * x % m, n / 2, m);
    else return x * Pow(x, n - 1, m) % m;
}
template<typename T> T combination(T n, T k, T m){
    return factorial<T>(n) * Pow<T>(factorial(k), m-2, m) % m * Pow<T>(factorial(n-k), m-2, m) % m;
}
struct edge{
    int to; // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using graph = vector<vector<edge>>;
using Graph = vector<vector<int>>;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n; cin >> n;
    str s; cin >> s;
    int first_digit, second_digit, third_digit;
    bool first, second, third;
    int num = 0;
    int ans = 0;
    while(num <= 999){
        first_digit = num / 100;
        second_digit = (num - (first_digit * 100)) / 10;
        third_digit = num % 10;
        first = false;
        second = false;
        third = false;
        rep(j, n){
            char letter = ctoi(s[j]);
            if(first == false){
                if(letter == first_digit) first = true;
            }
            else if(first == true && second == false){
                if(letter == second_digit) second = true;
            }
            else if(first == true && second == true && third == false){
                if(letter == third_digit) third = true;
            }
            if(first == true && second == true && third == true){
                ans++;
                break;
            }
        }
        num++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
flag = True
for i in range(N//2):
    if S[i] == S[-1-i]:
        continue
    flag = False
    break

if S[:(N-1)//2] != S[(N+1)//2:]:
    flag = False

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n, k;
    cin >> n >> k;
    
    int ans = n;
    rep(i,n) {
        int a;
        cin >> a;
        if(a<k) {
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
} /*atcoder*/



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
int main(){
    ll a,b,c;cin >> a >> b >> c;
    if(c<a+b){
        cout << "No" << endl;
        return 0;
    }
    if(4*a*b<(c-a-b)*(c-a-b)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, AB):

    in_n = [0] * (N+1)
    g = defaultdict(list)
    rg = defaultdict(list)
    for a, b in AB:
        in_n[b] += 1
        g[a].append(b)
        rg[b].append(a)

    r = []
    for i, n in enumerate(in_n):
        if i != 0 and n == 0:
            r.append(i)

    sv = []
    while r:
        u = r.pop()
        sv.append(u)
        for v in g[u]:
            in_n[v] -= 1
            if in_n[v] == 0:
                r.append(v)

    svd = {}
    for i, v in enumerate(sv):
        svd[v] = i
    for i in range(1, N+1):
        mi = 0
        if len(rg[i]) == 0:
            print(0)
        else:
            for j in rg[i]:
                mi = max(mi, svd[j])
            print(sv[mi])
    return


def main():
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(N+M-1)]
    slv(N, M, AB)


if __name__ == '__main__':
    main()


Measured memory_bytes: 76008
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		boolean f = false;
		if(a < 10 && b < 10) {
			f = true;
		}
		if(f) {
			System.out.println(a * b);
		}else {
			System.out.println(-1);
		}
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll cache[55][55][105];
ll a[60];
ll dp(ll i,ll j,ll k)
{
	if(k<0)
	return -1e18;
	if(i>j||k==0)
	return 0;
	if(cache[i][j][k]!=-1)
	return cache[i][j][k];
	ll ans=0;
	ans=max(ans,a[i]+dp(i+1,j,k-1));
	ans=max(ans,a[j]+dp(i,j-1,k-1));
	ans=max(ans,dp(i+1,j,k-2));
	ans=max(ans,dp(i,j-1,k-2));
	return cache[i][j][k]=ans;
}
int main()
{
	memset(cache,-1,sizeof(cache));
	ll n,k;
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	cin>>a[i];
	ll ans=dp(0,n-1,k);
	cout<<ans;
}

Measured memory_bytes: 2688
n, k = map(int, input().split())
s = [False] * n
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        s[a[j]-1] = True

cnt = 0
for sn in s:
    if not sn:
        cnt += 1

print(cnt)


Measured memory_bytes: 9176
#include<stdio.h>


int main(void){

  int num[13];
  int card[5];
  int i;

  int one, three, straight, four;
  int count;

  while(scanf("%d,%d,%d,%d,%d", &card[0], &card[1], &card[2], &card[3], &card[4])!=EOF){
    for(i=0; i<13; i++){
      num[i]=0;
    }

    for(i=0; i<5; i++){
      num[card[i]-1]++;
    }
    

    one=three=straight=four=0;
  
    for(i=0; i<13; i++){
      if(num[i]==2){
	one++;
      }
      else if(num[i]==3){
	three++;
      }
      else if(num[i]==4){
	four++;
      }
    }

    count=0;
    i=0;
    while(num[i]!=1){
      i++;
    }


    count++;
    for(i=i+1; i<13; i++){
      if(num[i]!=1){
	break;
      }
      count++;
    }

    if(count==5){
      straight++;
    }

    if(num[9]==1 && num[10]==1 && num[11]==1 && num[12]==1 && num[0]==1){
      straight++;
    }


    if(four==1){
      printf("four card\n");
    }
    else if(one==1 && three==1){
      printf("full house\n");
    }
    else if(straight==1){
      printf("straight\n");
    }
    else if(three==1){
      printf("three card\n");
    }
    else if(one==2){
      printf("two pair\n");
    }
    else if(one==1){
      printf("one pair\n");
    }
    else{
      printf("null\n");
    }

  }


  return(0);
}



Measured memory_bytes: 2032
import math
l = raw_input().split()
N=int(l[0]+l[1])
ans=0;
i=1;
flag=0;
while ans<=N:
    ans=i*i;
    i+=1;
    if ans==N:
        print "Yes"
        flag=1;
        break
if flag==0:
    print "No"


Measured memory_bytes: 2568
#include <cctype>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int count = 0;
	string word;
	cin >> word;
	string line;
	while (getline(cin,line)) {
		if (line == "END_OF_TEXT") {
			break;
		}
		istringstream stream(line);
		string piece;
		while (stream >> piece) {
			if (!isalpha(piece.front())) {
				piece.erase(0,1);
			}
			if (!isalpha(piece.back())) {
				piece.pop_back();
			}
			transform(piece.begin(),piece.end(),piece.begin(),::tolower);
			if (piece == word) {
				++count;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3188
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
	
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		sc.close();
		if(S.length() < 4) {
			System.out.println("No");
			return;
		}
		if(S.substring(0, 4).equals("YAKI")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>

using namespace std;

int main() {

	int r, D,x;

	cin >> r >> D >>x;

	for (int i = 0; i < 10; i++) {
		int ans;

		ans = r * x - D;

		cout << ans << endl;

		x = ans;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int x = 0;
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != T[i])
			x += 1;
	}
	cout << x << "\n";
}

Measured memory_bytes: 3820
#include<iostream>
#include<cstdlib>
#include <cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include <bits/stdc++.h>
using namespace std;

#define INF 10000000
int main()
{ 
    long x;
    cin >> x;

    if(x>=30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

        
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    string S;
    cin >> S;
    bool flag=true;
    REP(i,0,S.size()){
        if(i%2==1){
            if(S[i]=='R'){
                flag=false;
            }
        }else{
            if(S[i]=='L'){
                flag=false;
            }
        }
    }

    if(flag){
        P("Yes");
    }else{
        P("No");
    }
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

def main():
    n,k = na()
    ans = 0
    mod = pow(10,9)+7
    for i in range(k,n+2):
        sum_min = i*(i-1)//2
        sum_max = i*(2*n-i+1)//2
        #print(sum_min,sum_max)
        ans += (sum_max - sum_min + 1)
        ans %= mod
    print(ans%mod)
    return
if __name__ == '__main__':
    main()



Measured memory_bytes: 63420
n,m = map(int,input().split(" "))
X = list(map(int,input().split(" ")))
Y = list(map(int,input().split(" ")))
mod = (10 ** 9) + 7

sum_x = sum_y = 0

l = 0
r = (n-1)

while l < r:
	sum_x += ((r-l) * abs(X[r] - X[l]))
	r -= 1
	l += 1

l = 0
r = (m-1)
while l < r:
	sum_y += ((r-l) * abs(Y[r] - Y[l]))
	r -= 1
	l += 1

print((sum_x*sum_y) % mod)


Measured memory_bytes: 18556
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int A,B,C;
    cin>>A>>B>>C;
    if(A<=C&&C<=B) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for (int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        }
        else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
int main(){
  int N,M;cin>>N>>M;
  UnionFind Onion(N);
  for(int i=0;i<M;i++){
    int a,b,c;cin>>a>>b>>c;
    if(a==0)Onion.unite(b,c);
    else cout<<(Onion.same(b,c)? 1:0)<<endl;
  }
}

Measured memory_bytes: 4720
l,r = map(int,input().split())

if r-l >= 2019:
    print(0)
    exit()
mod = 2019

if r//mod != l//mod:
    print(0)
    exit()

li = []

for i in range(l,r+1):
    li.append(i%mod)

ans = mod
for i in range(len(li)-1):
    for j in range(i+1,len(li)):
        ans = min(ans,(li[i]*li[j])%2019)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

void sieve(int n,vector<bool> &expo){
    for(int i=2;i<=n;i++){
        for(int j=i*i;j<=n;j*=i){
            expo[j]=1;
        }
    }
}
int _find(int n,vector<bool> &expo){
    for(int i=n;i>=1;i--){
        if(expo[i]){
            return i;
        }
    }
    return 1;
}
void solve(){
    int n;
    cin>>n;
    vector<bool> expo(n+1,false);
    sieve(n,expo);
    cout<<_find(n,expo);
}





int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INF 999999999
using namespace std;

int main(){
      int sx,tx,sy,ty;
      cin >> sx >> sy >> tx >> ty;
      const int dx=tx-sx;
      const int dy=ty-sy;

      cout << string(dy,'U') << string(dx,'R');

      cout << string(dy,'D') << string(dx,'L');

      cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';

      cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U' << endl;


      return 0;
}


Measured memory_bytes: 256