akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std ;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
#include <bits/stdc++.h>
using namespace std;

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

bool kaibun( string s ){
    string t = s ;
    reverse(s.begin(),s.end()) ;
    if( s == t )return true ;
    else return false ;
}

int main(){
    string s ;
    cin >> s ;
    ll n = s.size() ;
  	//cout << s.substr(0,(n-1)/2 ) <<endl;
  	//cout << s.substr( (n+3)/2-1 , (n-3)/2+1 ) << endl;
  	if(kaibun(s)){
    	if( kaibun( s.substr(0,(n-1)/2) ) ){
        	if( kaibun( s.substr( (n+3)/2-1, (n-3)/2+1) ) ) {
            	cout << "Yes" << endl ;
            	return 0 ;
        	} 
    	}
  	}
    cout << "No" << endl ;    
}

Measured memory_bytes: 3628
n = int(input())

s = []
for i in range(n):
  s.append(int(input()))
  
s = sorted(s)

ans = sum(s)
if ans%10==0:
  for s_i in s:
    if s_i%10!=0:
      ans -= s_i
      print(ans)
      exit()
  print(0)
  exit()
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
const int MOD = 1e9+7;
using namespace std;

ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}

ll llmin(ll x, ll y){
	if (x > y) return y;
	return x;
}

bool is_prime(int x){
	for (int i = 2; i*i <= x; i++){
		if (!(x%i)) return false;
	}
	return true;
}


int main(){
	int x;
	cin >> x;
	for (int i = x; ; i++){
		if (is_prime(i)){
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(N);
    rep(i, N) cin >> X[i];
    sort(All(X));
    vector<int> mod(M + 1);
    vector<int> hist(100010);
    vector<int> same(M + 1);
    rep(i, N) {
        mod[X[i] % M]++;
        hist[X[i]]++;
        if(hist[X[i]] % 2 == 0)
            same[X[i] % M]++;
    }
    int res = 0;
    rep(i, M / 2 + 1) {
        if(i == 0 || (M % 2 == 0 && i == M / 2))
            res += mod[i] / 2;
        else {
            int a = mod[i];
            int b = mod[M - i];
            int c = same[i];
            int d = same[M - i];
            if(a < b) {
                swap(a, b);
                swap(c, d);
            }
            res += min(a, b);
            a -= b;
            res += min(c, a / 2);
        }
    }
    cout << res << endl;
    return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define INF 1e9
#define MOD 1e9+7

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

//library----------------------------------------------



int main() {
    SCIN(s,t);CIN(a,b);SCIN(u);
    if(s==u) a--;
    else if(t==u) b--;
    printf("%d %d\n",a,b);
    return 0;
}

Measured memory_bytes: 256
str=list(input())
if str.count(str[0])==2 and str.count(str[1])==2 and str.count(str[3])==2 and str.count(str[2])==2:
    print("Yes")
elif str.count(str[0])==4 or str.count(str[2])==4 or str.count(str[1])==4 or str.count(str[3])==4:
    print("No")
else:
    print("No")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
// ll mod=1000000007;
// ld pi = 3.14159;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,t1,i,j,k,temp,temp2,n,m,x,y,z,sum=0,o;
    // cin >> t;
    // while(t--){
        cin >> x >> y;
        cout << x*y;
    // }

}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

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

        static void A()
        {
            var N = ReadInt();
            var ST = ReadSplit();
            var S = ST[0];
            var T = ST[1];

            var ans = "";
            for (int i = 0; i < N; i++)
            {
                ans += S[i];
                ans += T[i];
            }

            Println(ans);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

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

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

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

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

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

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

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

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

            return true;
        }

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

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

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

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

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



Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
using ll = long long;
using P = pair<ll,ll>;
#define PI 3.141592653589793238
 
int main (){
  ll n,k;cin>>n>>k;
  vector<ll> v(k);
  rep(i,k) cin>>v.at(i);
  rep(i,k){
    n-=v.at(i);
  }
  if(n<0){
    cout << -1 << endl;
  }
  else{
    cout << n << endl;
  }
}

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

int main() {
    int N;
    std::cin >> N;
    
    int p[N+1] = {0};
    for (int i = 1; i <= N; ++i) {
        std::cin >> p[i];
    }

    bool swap = false;
    for (int i = 1; i <= N; ++i) {
        if (i != p[i]) {
            if (swap) {
                std::cout << "NO\n";
                return 0;
            }
            else if (i == p[p[i]]) {
                int tmp = p[i];
                p[i] = p[p[i]];
                p[tmp] = tmp;
                swap = true;        
            }
            else {
                std::cout << "NO\n";
                return 0;
            }
        }
    }

    std::cout << "YES\n";

    return 0;
}


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

int n,k;
long long sum[100005],nsum[100005];
long long mul[100005];


int main()
{
    scanf("%d%d",&n,&k);

    int sq = sqrt(n);int bd;
   {
        bd = (sq-1)*2+2;
        if(n/sq!=sq)++bd;
        //cout << bd << endl;
        for(int i=1;i<sq;++i)
        {
            sum[i] = mul[i] = 1;
            sum[bd-i] = 1;
            mul[bd-i] = n/i-n/(i+1);
        }
        sum[sq] = 1; mul[sq] = 1;
        if(n/sq!=sq) {sum[sq+1]=1;mul[sq+1] = n/sq-sq;}
    }
    int cnt = 0;


    long long nnum = 0;
    for(int t=1;t<k;++t)
    {
        nnum = 0;
        for(int i=1;i<bd;++i) nsum[i]=0;
        for(int i=1;i<bd;++i)
        {
            nnum+=sum[i]*mul[i];
            nnum%=mod;
            nsum[bd-i] = nnum;
        }
        for(int i=1;i<bd;++i)
            sum[i]=nsum[i];
    }

    nnum = 0;
    for(int i=1;i<bd;++i){
        nnum += sum[i]*mul[i];
        nnum %= mod;
    }
    printf("%lld\n",nnum);
    return 0;
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  cout << a[n/2]-a[n/2-1] << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int a[9];
    int hole[9] = {0,0,0,0,0,0,0,0,0};
    int n;
    int b[11] = {0,0,0,0,0,0,0,0,0,0,0};
    
    for ( int i=0; i<9; i++ ){
        scanf("%d",&a[i]);
    }
    
    scanf("%d",&n);
    
    for ( int i=0; i<n; i++ ){
        scanf("%d", &b[i]);
    }
    
    for ( int i=0; i<9; i++){
        for ( int j=0; j<n; j++ ){
            if ( a[i] == b[j] ){
                hole[i] = 1;
            }
        }
    }
    
    int flag = 0;
    
    if ( hole[0] == 1 && hole[1] == 1 && hole[2] == 1 ){
        flag = 1;
    } else if ( hole[3] == 1 && hole[4] == 1 && hole[5] == 1 ){
        flag = 1;
    } else if ( hole[6] == 1 && hole[7] == 1 && hole[8] == 1 ){
        flag = 1;
    } else if ( hole[0] == 1 && hole[3] == 1 && hole[6] == 1 ){
        flag = 1;
    } else if ( hole[1] == 1 && hole[4] == 1 && hole[7] == 1 ){
        flag = 1;
    } else if ( hole[2] == 1 && hole[5] == 1 && hole[8] == 1 ){
        flag = 1;
    } else if ( hole[0] == 1 && hole[4] == 1 && hole[8] == 1 ){
        flag = 1;
    } else if ( hole[2] == 1 && hole[4] == 1 && hole[6] == 1 ){
        flag = 1;
    }
    
    if ( flag == 1 ) printf("Yes\n");
    else             printf("No\n");
}


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

aaa = list(map(int, input().split()))
ans = 1

if 0 in aaa:
    ans = 0
else:
    for i in range(N):
        if ans > 10 ** 18:
            ans = -1
            break
        else:
            ans = ans * aaa[i]


if ans > 10 ** 18:
    ans = -1


print(ans)

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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

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

    rep(i,k){
        if(i%2==0){
            if(a%2!=0){
            a--;
            }
            b+=a/2;
            a/=2;
        }
        else {
            if(b%2!=0){
                b--;
            }
            a+=b/2;
            b/=2;
        }
    }
    cout<<a<<" "<<b<<endl;
}



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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a>b){
    swap(a,b);
  }
  if(a>c){
    swap(a,c);
  }
  if(b>c){
    swap(b,c);
  }
  cout << c-a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string S;
    cin >> S;
    int bit = 0;
    REP(i, S.length()) {
        if(S[i] == 'N') {
            bit |= (1 << 0);
        } else if(S[i] == 'S') {
            bit |= (1 << 1);
        } else if(S[i] == 'W') {
            bit |= (1 << 2);
        } else if(S[i] == 'E') {
            bit |= (1 << 3);
        }
    }
    if(bit == 15 or bit == 3 or bit == 12) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <numeric>
#include <string>
#include <cmath>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);

	int alicesum= 0,bobsum = 0;

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

	std::sort(a.begin(), a.end(), std::greater<int>());

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			alicesum += a[i];
		}
		else {
			bobsum += a[i];
		}
	}

	cout << alicesum - bobsum << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
an = list(map(int, input().split()))

def collect(a):
  adic = {}
  for ai in a:
    if ai in adic.keys():
      adic[ai] += 1
    else:
      adic[ai] = 1
  adic = sorted(adic.items(), key=lambda x:x[1])[::-1]
  adic.append((0, 0))
  return adic

od = collect(an[::2])
ev = collect(an[1::2])

if od[0][0] == ev[0][0]:
  maxi = max(od[0][1] + ev[1][1], od[1][1] + ev[0][1])
else:
  maxi = od[0][1] + ev[0][1]
print(str(n-maxi))

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

using namespace std;

set<long long> factorise(long long a)
{
    set<long long> s;
    long long t=a;
    for(long long i=2;i*i<=a;i++)
    {
        if((t%i)==0) s.insert(i);
        while((t%i)==0) t/=i;
    }
    if(t>1) s.insert(t);
    return s;
}

int main()
{
    long long a,b;
    cin >> a >> b;
    set<long long> one=factorise(a);
    set<long long> two=factorise(b);
    int res=1;
    for(long long t:one) res+=(two.find(t)!=two.end());
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

while True:
  n = int(input())
  if n == 0:
    break
  ins = {}
  outs = {}
  node = set()
  base = ord("a")
  edges = [[0] * 26 for _ in range(26)]
  for i in range(26):
    ins[i] = 0
    outs[i] = 0
  
  for _ in range(n):
    s = input()
    fr = ord(s[0]) - base
    to = ord(s[-1]) - base
    ins[to] += 1
    outs[fr] += 1
    edges[fr][to] = 1
    node.add(fr)
    node.add(to)
  
  for i in range(26):
    if ins[i] != outs[i]:
      print("NG")
      break
  else:
    node = sorted(list(node))
    visited = [False] * 26
    visited[node[0]] = True
    que = deque()
    que.append(node[0])
    while que:
      p = que.popleft()
      for i in range(26):
        if edges[p][i] and not visited[i]:
          visited[i] = True
          que.append(i)
    
    for p in node:
      if not visited[p]:
        print("NG")
        break
    else:
      print("OK")


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    cout << fixed << setprecision(15);
    int N;
    cin >> N;

    vector<int> W(N);

    REP(i, N){
        cin >> W[i];
    }
    
    ll S1, S2;
    S1 = 0;
    S2 = 0;
    ll ans = INF;
    REP(i, N){
        S2 += W[i];
    }
    REP(i, N){
        S1 += W[i];
        S2 -= W[i];
        ans = min(ans, abs(S2-S1));
    }
    cout << ans << endl;
    return 0;
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          
          if(a[0]+a[1]==15)
            Console.WriteLine("+");
          else if(a[0]*a[1]==15)
            Console.WriteLine("*");
          else
            Console.WriteLine("x");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11348
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
#define LocalTestAddress "test.txt"
//////////////////////////////////////////////////////////////////////////////
#define endl '\n'
void solve();
signed main(){
#ifdef Sprinkle
    clock_t clock_start=clock();assert(freopen(LocalTestAddress,"r",stdin));
#else
     ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#endif
    solve();
#ifdef Sprinkle
    cerr<<"Running Time: "<<((clock()-clock_start) *1.0 / CLOCKS_PER_SEC)<<"s\n";
#endif
    return 0;
}
#ifdef Sprinkle
void err(){cerr<<"\n";}template<typename T,typename...U>void err(const T&hd,const U&...tl){cerr<<hd<<(sizeof...(tl)?", ":"");err(tl...);}
#define debug(x...) cerr<<""#x" = ";err(x)
#else
#define debug(...) 0
#endif
//////////////////////////////////////////////////////////////////////////////
long long a[100005];
void solve(){
    int n;
    long long ans=1;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;++i){
        long long t=0,base=1;
        while(a[i]){
            t+=1ll*(a[i]%10)*base*ans;
            if(t>1000000000000000000){
                cout<<"-1"<<endl;
                return;
            }
            base*=10;
            a[i]/=10;
        }
        ans=t;
    }
    cout<<ans<<endl;
}

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

namespace AtCoder.Contest.E
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int n = cin.nextInt();
			List<int> t = new List<int> { 0 }, x = new List<int> { 0 }, y = new List<int> { 0 };
			for (int i = 0; i < n; i++)
			{
				t.Add(cin.nextInt());
				x.Add(cin.nextInt());
				y.Add(cin.nextInt());
			}

			bool ok = true;
			for (int i = 0; i < n && ok; i++)
			{
				int s = (t[i + 1] - t[i]) - Math.Abs(x[i + 1] - x[i]) - Math.Abs(y[i + 1] - y[i]);
				if (!(s >= 0 && s % 2 == 0)) ok = false;
			}

			if (ok) Console.WriteLine("Yes");
			else Console.WriteLine("No");

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 18132
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

a,b,c,k = map(int,input().split())
ans = 0
if k>0:
    ans += min(k,a)
    k -= min(k,a)
if k>0:
    k-= min(k,b)
if k>0:
    d = min(c,k)
    ans += -1*d
print(ans)

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline void chmax(T1 &a, const T2 &b)
{
    if (a < b)
    {
        a = b;
    }
}
template <class T1, class T2>
inline void chmin(T1 &a, const T2 &b)
{
    if (a > b)
    {
        a = b;
    }
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

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

    ll ans = 0;
    ll sum = 0;
    for (int i = N - 1; i >= 0; --i)
    {
        ans += sum * A[i];
        ans %= mod;
        sum += A[i];
        sum %= mod;
    }
    cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> d(N, 0);
    for(int i = 0; i < N; i++){
        cin >> d.at(i);
    }

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

    int ans = 1;
    for(int i = 1; i < N; i++){
        if(d.at(i) != d.at(i - 1)) ans ++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

void minSelf(int &a, int b) {
  if (a > b)
    a = b;
}

int main() {
  int n;
  scanf("%d", &n);
  int h[n];
  int minCost[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
    minCost[i] = INT_MAX;
  }
  minCost[0] = 0;
  for (int i = 0; i < n; i++) {
    if (i + 1 < n)
      minSelf(minCost[i + 1], minCost[i] + abs(h[i] - h[i + 1]));
    if (i + 2 < n)
      minSelf(minCost[i + 2], minCost[i] + abs(h[i] - h[i + 2]));
  }
  printf("%d\n", minCost[n - 1]);
  return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			long a = sc.nextLong();
			long b = sc.nextLong();
			long k = sc.nextLong();

			if (a < k) {
				if (b < (k - a)) {
					b = 0;
				} else {
					b = b - (k - a);
				}
				a = 0;
			} else {
				a = a - k;
			}

			System.out.println(a + " " + b);
		}
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> 	pii;
typedef long long 		ll;
typedef vector<int> 	vi;
typedef long double ld;
#define PI 				3.14159265
#define int				long long
#define f 				first
#define s 				second
#define pb 				push_back
#define mtup 			make_tuple
#define nl 				'\n'
#define FLASH 			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define maxheap 		priority_queue<ll>
#define minheap 		priority_queue<ll,vector<ll> ,greater<ll>>
const ll inf = 1e18 + 1;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 55;
ll modpow(ll a,ll b,int mod = LLONG_MAX) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) {return __gcd(a,b);}
vi g[maxn];
map<pii, int> len;
int n, u, v, w, col[maxn], seen[maxn];

void dfs(int v, int numodd){
	if (numodd%2) col[v] = 1;
	else col[v] = 0;
	seen[v] = 1;
	for (int u : g[v]) if (!seen[u]){
		dfs(u, numodd + (len[{v,u}] % 2));
	}
}

signed main(){
	FLASH
	cin >> n;
	memset(seen, 0, sizeof(seen));
	for (int i = 1; i < n; i++){
		cin >> u >> v >> w;
		g[u].pb(v), g[v].pb(u);
		len[{u,v}] = w, len[{v,u}] = w;
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++)
		cout << col[i] << nl;
	return 0;
}


Measured memory_bytes: 55424
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;
typedef long long LL;

inline int read() {
    int x=0,f=1; char ch=getchar();
    while (!(ch>='0'&&ch<='9')) {if (ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9') {x=x*10+(ch-'0'); ch=getchar();}
    return x*f;
}

const int N = 105;

int n,h[N];
int ans;

bool check() {
	rep(i,1,n) if (h[i]) return false;
	return true;
}

int main() {

	n=read(); rep(i,1,n) h[i]=read();
	while (!check()) {
		int mn,last;
		rep(i,1,n) {
			if (h[i-1]==0&&h[i]!=0) {
				mn = h[i];
				last = i;
			}
			if (h[i-1]!=0&&h[i]==0) {
				rep(j,last,i-1) h[j]-=mn;
				ans+=mn;
			}
			mn = min(mn,h[i]);
		}
		if (h[n]) {rep(j,last,n) h[j]-=mn; ans+=mn;}
	}
	printf("%d\n",ans);

	return 0;
	
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String answer ="IMPOSSIBLE";
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int s =0;
      if((a+b)%2 == 0){
        System.out.println((a+b)/2);
        }else{
        System.out.println(answer);
      }
        
		
        
		
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <cmath>
#include <cstdio>
#include <stdio.h>
#include <algorithm>
using namespace std;

const double pi = acos(-1);

const int maxn = 200005;
int f[maxn];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm

    int n;
    cin >> n;

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

    for( int i = 1; i <= n; i++ )
        cout << f[i] << "\n";
    return 0;
}


Measured memory_bytes: 4396
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = 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")
}

use std::cmp::{max, min};

fn main() {
    let a: usize = read();
    let p: usize = read();
    println!("{}", (a * 3 + p) / 2)
}


Measured memory_bytes: 2076
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <unordered_map>
#include <map>
#include <cmath>

#define MP make_pair
#define F first
#define S second
#define PB push_back

using namespace std;

const int maxn = 1e5 + 100;
int p[maxn], mark[maxn], cnt[maxn];

int main(){
    ios_base::sync_with_stdio(false);
    mark[1] = 1;
    for (int i = 1; i < maxn; i++){
        if (!mark[i])
            for (int j = i + i; j < maxn; j += i)
                mark[j] = 1;   
    }    
    for (int i = 1; i < maxn; i++){
        if (!mark[i] and !mark[(i + 1) / 2])
            p[i] = 1;
    } 
    for (int i = 1; i < maxn; i++)
        cnt[i] = cnt[i - 1] + p[i];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int l, r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l - 1] << endl;
    }
} 

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,x,l,d = 0,count = 0;
    cin >> n >> x;
    if(d <= x) count++;
    for(int i = 0;i < n;i++){
        cin >> l;
        d +=l;
        if(d <= x) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define input_from_file  freopen("input.txt", "r", stdin);

int main()
{
  // input_from_file;
  ll n;cin>>n;
  vector< long double> vec(n+1,0);
  for(ll i=1;i<=n;i++)   cin>>vec[i];
  vector<vector<long double>> dp(n+1,vector< long double>(n+1,0.0));
  dp[0][0]=1;
  long double ans=0;
  for(ll i=1;i<=n;i++)  dp[i][0]=dp[i-1][0]*(1-vec[i]);
  for(ll i=1;i<=n;i++){
    for(ll j=1;j<=n;j++){
      if(i<j) continue;
      dp[i][j]=dp[i-1][j]*(1-vec[i])+dp[i-1][j-1]*(vec[i]);
      if(i==n && j>n/2)  ans+=dp[i][j];
    }
  }
  cout<<setprecision(9)<<ans;
  return 0;

}

Measured memory_bytes: 141056
import java.util.*;
import java.math.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    BigInteger total = new BigInteger(String.format("%d", n));
    BigInteger sum = new BigInteger("0");
    scanner.nextLine();
    for (int ii = 0; ii < n; ii++) {
      BigInteger pr = new BigInteger(scanner.nextLine());
      sum = sum.add(pr);
    }
    System.out.println(sum.divide(total));
  }
}

Measured memory_bytes: 51528
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    string s; cin >> s;
    int n = s.length();
    set<char> c;
    REP(i,n) c.emplace(s[i]);
    bool ans = (c.size()%2); ans = !ans;
    if(ans) ans = ((c.find('N')!=c.end() && c.find('S')!=c.end()) || (c.find('E')!=c.end() && c.find('W')!=c.end()));
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

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

n, k = na()
r, s, p = na()
t = input()
ans = 0
for i in range(k):
    #print(t[0+i::k])
    li = t[0+i::k]
    li  = 'x' + li
    flg = False
    for j in range(1, len(li)):
        if li[j] != li[j-1] or flg:
            flg = False
            if li[j] == 'r':
                ans += p
            if li[j] == 's':
                ans += r
            if li[j] == 'p':
                ans += s
        else:
            flg = True
        #print(ans)
print(ans)

    

Measured memory_bytes: 3316
#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 int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int dp[100005][2];

int main() {
  string s;
  cin >> s;
  dp[0][0] = 1;
  int n = s.size();
  rep(i, n) {
    {
      if (s[i] == '0') {
        dp[i + 1][0] = dp[i][0];
        dp[i + 1][1] = dp[i][1];
      } else {
        dp[i + 1][1] = (dp[i][0] + dp[i][1]) % mod;
      }
    }
    {
      if (s[i] == '0') {
        (dp[i + 1][1] += dp[i][1] * 2 % mod) %= mod;
      } else {
        (dp[i + 1][0] += dp[i][0] * 2 % mod) %= mod;
        (dp[i + 1][1] += dp[i][1] * 2 % mod) %= mod;
      }
    }
  }
  int ans = (dp[n][0] + dp[n][1]) % mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int a,b,c;
	cin >>a >> b >> c;
	
	if(c >= a && c <= b)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N,A,B,C,D,E;
    cin >> N >> A >> B >> C >> D >> E;

    //本文
    ll ans = N/min(A,min(B,min(C,min(D,E))));
    if(N%min(A,min(B,min(C,min(D,E))))!=0)ans ++;
    //出力
    cout << ans+4 << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3660
n, m = map(int, input().split())
AB = []
import collections
d = collections.defaultdict(list)
for i in range(m):
    a,b = map(int, input().split())
    #AB.append(ab)
    d[a].append(b)
    d[b].append(a)
for k in d.keys():
    if 1 in d[k] and n in d[k]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 51200
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N, X; cin >> N >> X;
    vector<int> L(N);
    for(int i=0; i<N; i++){
        cin >> L[i];
    }
    int cur = 0;
    int cnt = 1;
    for(int i=0; i<N; i++){
        cur += L[i];
        if(cur > X) break;
        cnt++;
    }

    cout << cnt << endl;
    
    return 0;
}



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

#define SQ(x) (x)*(x)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

int main(void){

  double x[4],y[4],S,s,a,b,c,sum;

  while(~scanf("%lf %lf %lf %lf %lf %lf %lf %lf"
	      ,&x[1],&y[1],&x[2],&y[2],&x[3],&y[3],&x[0],&y[0])){
    
    sum=0;

    a=sqrt(SQ(x[1]-x[2])+SQ(y[1]-y[2]));
    b=sqrt(SQ(x[3]-x[2])+SQ(y[3]-y[2]));
    c=sqrt(SQ(x[1]-x[3])+SQ(y[1]-y[3]));

    s=(a+b+c)/2;
    S=sqrt(s*(s-a)*(s-b)*(s-c));

    a=sqrt(SQ(x[0]-x[2])+SQ(y[0]-y[2]));
    b=sqrt(SQ(x[3]-x[2])+SQ(y[3]-y[2]));
    c=sqrt(SQ(x[0]-x[3])+SQ(y[0]-y[3]));

    s=(a+b+c)/2;
    sum+=sqrt(s*(s-a)*(s-b)*(s-c));

    a=sqrt(SQ(x[1]-x[0])+SQ(y[1]-y[0]));
    b=sqrt(SQ(x[3]-x[0])+SQ(y[3]-y[0]));
    c=sqrt(SQ(x[1]-x[3])+SQ(y[1]-y[3]));

    s=(a+b+c)/2;
    sum+=sqrt(s*(s-a)*(s-b)*(s-c));

    a=sqrt(SQ(x[1]-x[2])+SQ(y[1]-y[2]));
    b=sqrt(SQ(x[0]-x[2])+SQ(y[0]-y[2]));
    c=sqrt(SQ(x[1]-x[0])+SQ(y[1]-y[0]));

    s=(a+b+c)/2;
    sum+=sqrt(s*(s-a)*(s-b)*(s-c));

    if(EQ(S,sum))printf("YES\n");
    else printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cassert>
#include <string>
#include <cstring>
#include <bitset>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, 30, +31, +30, +31, +31, +30, +31, +30, +31};

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int dp [N][2];
vvi g (N);

int add (int a, int b) {
  a += b;
  while (a >= MOD) a -= MOD;
  return a;
}

int mult (int a, int b) {
  i64 res = 1LL * a * b;
  if (res >= MOD) res %= MOD;
  return res;
}

void dfs (int node = 0, int p = -1) {
  bool is_leaf = true;
  GO (to, g[node]) {
    if (to != p) {
      dfs (to, node);
      is_leaf = false;
    }
  }
  if (is_leaf) {
    dp[node][0] = dp[node][1] = 1;
  } else {
    // Paint our current node white
    i64 res = 1;
    GO (to, g[node]) {
      if (to == p) continue;
      res = mult (res, dp[to][0] + dp[to][1]);
    }
    dp[node][0] = add (dp[node][0], res);
    // Paint our current node black
    res = 1;
    GO (to, g[node]) {
      if (to == p) continue;
      res = mult (res, dp[to][0]);
    }
    dp[node][1] = add (dp[node][1], res);
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  F0R (i, n - 1) {
    int st, et;
    cin >> st >> et;
    --st; --et;
    g[st].eb(et);
    g[et].eb(st);
  }
  dfs ();
  int res = add (0, dp[0][0] + dp[0][1]);
  cout << res << '\n';
  return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

const string yesno[2] = {"No", "Yes"};

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

    int A[3];
    for(int i=0;i<3;++i){
        std::cin >> A[i];        
    }
    sort(A, A+3);
    
    std::cout << yesno[A[0] + A[1] == A[2]] << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}

ll n,m;
string s,t;
map<ll,char> mp;

int main(){
	cin>>n>>m>>s>>t;
	ll L=lcm(n,m);
	for(int i=0;i<n;i++) mp[L/n*i]=s[i];
	for(int i=0;i<m;i++) if(mp.find(L/m*i)!=mp.end()&&mp[L/m*i]!=t[i]) L=-1;
	cout<<L<<endl;
}

Measured memory_bytes: 6144
import java.util.*;

class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      String T = sc.next();
      String str = "No";
      
     if(T.length() == S.length()+1){
      for(int i=0; i<S.length(); i++){
        if(S.charAt(i) == T.charAt(i)){
          if(i == S.length()-1){
            str = "Yes";
          }
        }else{
          break;
        }
      }
     }
        
      System.out.println(str);
   }
}

Measured memory_bytes: 35400
import queue
h, w = map(int, input().split())
masu = [input() for _ in range(h)]
dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]
INF = 100000
cood = (0, 0)
d = [[INF for _ in range(w)] for _ in range(h)]
d[0][0] = 0

black_num = 0
for i in range(h):
    black_num += masu[i].count('#')

que = queue.Queue()
que.put((0, 0))
while not que.empty():
    cood = que.get()
    if cood[0] == h-1 and cood[1] == w-1:
        break
    for i in range(4):
        ncood = (cood[0] + dy[i], cood[1] + dx[i])
        if 0 <= ncood[0] and ncood[0] < h and 0 <= ncood[1] and ncood[1] < w and masu[ncood[0]][ncood[1]] != '#' and d[ncood[0]][ncood[1]] == INF:
            que.put(ncood)
            d[ncood[0]][ncood[1]] = d[cood[0]][cood[1]] + 1


if d[h-1][w-1] == INF:
    print(-1)
else:
    print(h*w - d[h-1][w-1] - 1 - black_num)


Measured memory_bytes: 4080
S = input()

mi = 1e10
for c in [chr(ord('a') + i) for i in range(26)]:
    count = 0
    T = S[:]
    while len(T) > T.count(c):
        U = ""
        for i in range(len(T) - 1):
            if c in T[i:i+2]:
                U += c
            else:
                U += T[i]
        T = U
        count += 1
    mi = min(mi, count)

print(mi)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> P;
 
int main(){
  int N;
  cin >> N;
  int A[N+1],B[N+1],c=0,a;
  for(int i=1; i<N+1; i++){
    cin >> a;
    A[i] = a;
  }
  for(int i=N; i>0; i--){
    B[i] = A[i];
    for(int j=i+i; j<=N; j+=i){
      B[i] ^= B[j];
    }
    c+=B[i];
  }
  cout << c << endl;
  for(int i=1; i<=N; i++){
    if(B[i]==1) cout << i << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>

int main(void){
    int x,y;

    while(1){
        scanf("%d%d",&x,&y);
        if(x==0&&y==0) break;

        if(x>y) printf("%d %d\n",y,x);
        else printf("%d %d\n",x,y);
    }

    return 0;
}


Measured memory_bytes: 2032
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String text = sc.next();
		String b = text.substring(0, 2);
		String a = text.substring(2,4);
		
		int before = Integer.parseInt(b);
		int after = Integer.parseInt(a);
		
		if(before > 0 && before <= 12) {
			
			if (after > 0 && after <= 12) {
				System.out.println("AMBIGUOUS");
			} else {
				System.out.println("MMYY");
			}
		}else {
			if (after > 0 && after <= 12) {
				System.out.println("YYMM");
			} else {
				System.out.println("NA");
			}
		}
		
		
//		long n= sc.nextLong();
	}
}

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

int main(){
  
    priority_queue<int> PQ;
    while(1){
        char com[20];
        scanf("%s",com);
        if(com[0]=='i'){
            int N;cin>>N;
            PQ.push(N);
        }
        else if(com[1]=='x'){
            printf("%d\n",PQ.top());
            PQ.pop();
        }
        else break;
    }
    }



Measured memory_bytes: 7008
from sys import setrecursionlimit


def dfs(i, j, c):
    visited[i][j] = 1
    current.append((i, j))
    for di, dj in (1, 0), (-1, 0), (0, 1), (0, -1):
        ni, nj = i + di, j + dj
        if not (0 <= ni < H and 0 <= nj < W and not visited[ni][nj]):
            continue
        if S[ni][nj] == c:
            continue
        dfs(ni, nj, not c)


setrecursionlimit(2 * 10 ** 5)
H, W = map(int, input().split())
S = [[c == "#" for c in input()] for _ in range(H)]

ans = 0
visited = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] and not visited[i][j]:
            current = []
            dfs(i, j, True)
            b, w = 0, 0
            for k, l in current:
                if S[k][l]:
                    b += 1
                else:
                    w += 1
            ans += b * w
print(ans)


Measured memory_bytes: 168968
import kotlin.comparisons.compareBy
fun main(args: Array<String>) {
    val N = nextInt()
    val S = Array(N) { next() }
    val M = S.groupBy { it }.map { it.key to it.value.size }.sortedWith(compareBy({ -it.second }, { it.first }))
    val max = M[0].second
    println(M.filter { it.second == max }.map { it.first }.sorted().joinToString(separator="\n"))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun printErr(value: Any) = System.err.println(value)


Measured memory_bytes: 123248