akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;
int a[N], ri[N];
char b[N];
LL sum[N];

int main() {
    int n;
    scanf("%d", &n);
    scanf("%d", &a[1]);
    for (int i = 2; i <= n; i++) scanf(" %c %d", b + i, a + i);
    for (int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i];
    ri[n + 1] = n + 1;
    for (int i = n; i >= 2; i--) {
        ri[i] = ri[i+1];
        if (b[i+1] == '-') ri[i] = i + 1;
    }
    LL ans = -1e18;
    LL tmp = a[1];
    for (int i = 2; i <= n; i++) {
        if (b[i] == '-') {
            LL ans1 = tmp - a[i] - (sum[ri[i]-1]-sum[i]) + (sum[n] - sum[ri[i]-1]);
            ans = max(ans1, ans);
        }
        if (b[i] == '-') tmp -= a[i];
        else tmp += a[i];
    }
    ans = max(ans, tmp);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

long a[100010];
long b[100010];

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

  long n, m;
  cin >> n >> m;

  fillLong(a, m);
  sort(a, a+m);

  rep(i, m-1) {
    b[i] = a[i+1] - a[i];
  }
  sort(b, b+m-1, greater<long>());

  if (m == 1) {
    cout << 0 << endl;
  } else {
    long res = a[m-1]-a[0];
    long j = 0;
    while(j < min(m-1,n-1)) {
      res -= b[j];
      j++;
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n,k; cin >> n >> k;
    double ans = 0;
    for (int i = 1; i<=n;i++){
        double tmp = 1.0/n;
        int now = i;
        while(now < k){
            now*=2;
            tmp/=2;
        }
        ans += tmp;
    }
    cout << fixed << setprecision(9);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] str_as = br.readLine().split(" ");
        int[] as = new int[n];
        long m=1;
        long ans = 0;
        for (int i = 0; i < n; i++) {
            as[i] = Integer.parseInt(str_as[i]);
            ans += as[i]-1;
        }
        //Arrays.sort(as);
        /*m -= 1;
        
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += m%as[i];
        }*/
        System.out.println(ans);
    }
}


Measured memory_bytes: 20820
def insertionSort(lst, n):
    print(" ".join([str(n) for n in lst]))
    for i in range(1, n):
        v = lst[i]
        for j in range(0, i):
            if lst[j] > v:
                lst.insert(j, lst.pop(i))
                break

        print(" ".join([str(n) for n in lst]))

    return lst


if __name__ == "__main__":
    n = int(input())
    lst = [int(n) for n in input().split()]
    insertionSort(lst, n)

Measured memory_bytes: 7808
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        s=list(input())
        ls=len(s)
        for i in range(ls-1):
            for j in range(i+1,ls):
                if s[i]=='C' and s[j]=='F':
                    return 'Yes'
        return 'No'
    print(main())
    
resolve()

Measured memory_bytes: 38640
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int mp[2][101],n,l;

void solve(){
  int sec=0,ant;
  while(1){
    sec++;
    for(int i=l;i>0;i--)mp[0][i]=mp[0][i-1]; //to right
    for(int i=0;i<l;i++)mp[1][i]=mp[1][i+1]; //to left
    for(int i=1;i<=l;i++)if((mp[0][i]>0&&mp[1][i]>0)) swap(mp[0][i],mp[1][i]); //turn
    int flg;
    for(flg=1;flg<l&&mp[0][flg]+mp[1][flg]==0;flg++);
    if(flg==l)break;
  }
  if(mp[0][l]>0)ant=mp[0][l];
  if(mp[1][0]>0)ant=mp[1][0];
  cout << sec <<" "<<ant<<endl;
}

int main(){
  while(1){
    cin >>n>>l;
    if(n==0&&l==0)break;
    memset(mp,0,sizeof(mp));
    for(int i=1;i<=n;i++){
      char c;
      int a,flg=0;
      cin >>c>>a;
      if(c=='L') flg=1;
      mp[flg][a]=i;
    }
    solve();
  }
  return 0;
}

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

typedef long long ll;
typedef pair<ll,ll>pll;
#define fore(i,ii,iii) for(ll i=ii;i<iii;i++)
#define X first
#define Y second
const ll N=2e5+15,MOD=1e9+7;

ll n,h,w,x,y,f[N],inv[N],dp[N];
pll a[N];
ll qpow(ll base,ll exp) { // base^exp in O(log(n))
	ll result=1;
	while (exp) {
		if (exp&1)result=(result*base)%MOD;
		exp>>=1;
		base=(base*base)%MOD;
	}
	return result%MOD;
}
ll comb(ll n,ll k){return (f[n]*((inv[k]*inv[n-k])%MOD))%MOD;}
int main() {
  ios::sync_with_stdio(false);
  f[0]=inv[0]=1;
  fore(i,1,N){
    f[i]=(f[i-1]*i)%MOD;
    inv[i]=qpow(f[i],MOD-2);
  }
  cin>>h>>w>>n;h--,w--;
  fore(i,0,n){
    cin>>a[i].X>>a[i].Y;
    a[i].X--;
    a[i].Y--;
  }
  sort(a,a+n);
  a[n]={h,w};
  fore(i,0,n+1) {
    dp[i]=comb(a[i].X+a[i].Y,a[i].X);
    fore(j,0,i) {
      if(a[j].X>a[i].X || a[j].Y>a[i].Y)continue;
      ll dX=a[i].X-a[j].X;
      ll dY=a[i].Y-a[j].Y;
      dp[i]=(dp[i]+MOD-((dp[j]*comb(dX+dY,dX))%MOD))%MOD;
    }
  }
  cout<<dp[n]<<endl;
  
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

struct state{
  int li,lj,ri,rj,f;
  int dist;
};
bool operator<(const state& a,const state& b){ return a.dist > b.dist; }

int h,w;
char s[111][111];
int dist[111][111][10];

int main(){
  while(1){
    cin>>w>>h;
    if(h==0&&w==0)break;
    rep(i,h)rep(j,w)cin>>s[i][j];
    priority_queue<state> que;
    rep(i,111)rep(j,111)rep(k,10)dist[i][j][k]=INF;
    rep(i,h)rep(j,w){
      if(s[i][j]=='S'){
        que.push((state){i,j,-1,-1,0,0});
        que.push((state){-1,-1,i,j,1,0});
      }
    }
    while(que.size()){
      state ns=que.top(); que.pop();
      int li=ns.li,lj=ns.lj,ri=ns.ri,rj=ns.rj,f=ns.f,nd=ns.dist;
      if((f==0&&dist[li][lj][0]!=INF)||(f==1&&dist[ri][rj][1]!=INF))continue;
      if(f==0){
        //dbg(li); dbg(lj);
        dist[li][lj][f]=nd;
        repl(ni,li-2,li+3)repl(nj,lj+1,lj+4){
          if(ni>=0&&ni<h&&nj>=0&&nj<w&&abs(ni-li)+abs(nj-lj)<=3&&s[ni][nj]!='X'&&s[ni][nj]!='S'){
            que.push((state){li,lj,ni,nj,1-f,nd+(s[ni][nj]=='T'?0:(s[ni][nj]-'0'))});
          }
        }
      }else{
        dist[ri][rj][f]=nd;
        repl(ni,ri-2,ri+3)repl(nj,rj-3,rj){
          if(ni>=0&&ni<h&&nj>=0&&nj<w&&abs(ni-ri)+abs(nj-rj)<=3&&s[ni][nj]!='X'&&s[ni][nj]!='S'){
            que.push((state){ni,nj,ri,rj,1-f,nd+(s[ni][nj]=='T'?0:(s[ni][nj]-'0'))});
          }
        }
      }
    }
    int res=INF;
    rep(i,h)rep(j,w){
      if(s[i][j]=='T')minch(res,min(dist[i][j][0],dist[i][j][1]));
    }
    if(res==INF)cout<<-1<<endl;
    else cout<<res<<endl;
  }
	return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i=1; i<10; ++i){
        for(int j=1; j<10; ++j){
            if(n == i*j){
                cout << "Yes" << "\n";
                return 0;
            }
        }
    }
    cout << "No" << "\n";
}

Measured memory_bytes: 256
fun main(args: Array<String>) = IO().exec {
    val n = long()
    val p = long()
    val factors = primeFactors(p)
    var ret = 1L
    for ((key, value) in factors) {
        ret *= key.pow(value / n)
    }
    println(ret)
}

fun Long.pow(k: Long) = Math.pow(this.toDouble(), k.toDouble()).toLong()

fun primeFactors(n_: Long): MutableMap<Long, Long> {
    val ret = mutableMapOf<Long, Long>()
    var n = n_
    var i = 2L
    while (i * i <= n) {
        while (n % i == 0L) {
            ret[i] = (ret[i] ?: 0) + 1
            n /= i
        }
        i++
    }
    if (n != 1L) {
        ret[n] = 1
    }
    return ret
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 31384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    cin>>n;
    string ans = "";
    ll s = 0;
    ll t = 0;
    while(t<n)
    {
        t = 26 + t*26;
        s++;
    }
    ll b = t - pow(26, s) + 1;
    ll e  = t;
    // cout<<s<<'\n';
    ll val = n - b;
    // cout<<val<<'\n';
    ll d = s;
    ll rem;
    while(d>0)
    {
        // cout<<val<<'\n';
        ans = ans + (char)(val%26 + 97);
        rem = val;
        val = val/26;
        // cout<<val<<'\n';
        d--;
    }
    // cout<<ans<<'\n';
    // ans = ans + (char)(rem+97);
    reverse(ans.begin(), ans.end());
    cout<<ans<<'\n';
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  string s;
  cin>>s;
  int ans=0;
  int temp=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G') temp++;
    else temp=0;
    ans=max(ans,temp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int X,Y,Z,temp1,temp2;
    scanf("%d %d %d",&X,&Y,&Z);
    temp1=X;
    X=Y;
    Y=temp1;
    temp2=X;
    X=Z;
    Z=temp2;
    printf("%d %d %d\n",X,Y,Z);
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		String N = in.readLine();


		String str[] = N.split(" ");
		String ans = "No";
		if(str[0].equals(str[1]) && str[1].equals(str[2])){
			ans = "Yes";
		}

		System.out.println(ans);
	}


}


Measured memory_bytes: 22228
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let n = read int
    let ps = reada int
    let qs = reada int
    let rs = reada int

    let mutable ans = 0
    let mutable last = -2
    for i in ps do
        let a = qs.[i-1]
        let b = if i = last + 1 && i - 2 >= 0 then rs.[i-2] else 0
        ans <- ans + a + b
        last <- i

    printfn "%i" ans
    0

Measured memory_bytes: 14044
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll ans, x, y, n, m;
ll u[111111], v[111111];

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>m; int i;
	for(i=1 ; i<=n ; i++) cin>>u[i];
	for(i=1 ; i<=m ; i++) cin>>v[i];
	for(i=1 ; i<=n ; i++) x+=((mod+2LL*i-n-1)*(mod+u[i]))%mod;
	for(i=1 ; i<=m ; i++) y+=((mod+2LL*i-m-1)*(mod+v[i]))%mod;
	x%=mod; y%=mod; cout<<(x*y)%mod; return 0;
}

// it may be easier than you think
// it may be harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

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

int main(){

   int N,A; cin >> N;
   map<string,int> mp{};
   
   for(int i=0;i<N;i++){
       cin >> A;
       if(A <= 399){mp["gray"]++;}
       else if(A <= 799){mp["brown"]++;}
       else if(A <= 1199){mp["green"]++;}
       else if(A <= 1599){mp["light_blue"]++;}
       else if(A <= 1999){mp["blue"]++;}
       else if(A <= 2399){mp["yellow"]++;}
       else if(A <= 2799){mp["orange"]++;}
       else if(A <= 3199){mp["red"]++;}
       else{mp["rainbow"]++;}
   }
   
   int color = mp.size(); if(mp["rainbow"] > 0) color--;
   int minv = color; if(minv < 1) minv = 1;
   int maxv = color + mp["rainbow"];
   cout << minv << " " << maxv << endl;
}

Measured memory_bytes: 3640
import sys

s = input()

former = int(s[:2])
latter = int(s[2:])

##YYMM
if ((former > 12 or former==0) and (latter <= 12 and latter > 0)):
    print('YYMM')
    sys.exit()

##MMYY
if ((former <= 12 and former > 0) and (latter > 12 or latter==0)):
    print('MMYY')
    sys.exit()

##AMBIGUOUS
if ((former <= 12 and former > 0) and (latter <= 12 and latter > 0)):
    print('AMBIGUOUS')
    sys.exit()

##NA
print('NA')

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

using namespace std;

queue<long long int> lunlun;

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

    for(int i=1;i<=9;i++)
    {
        lunlun.push(i);
    }

    for(int i=0;i<K;i++)
    {
        temp=lunlun.front();
        lunlun.pop();

        if(temp%10!=0)
        {
            lunlun.push(10*temp+(temp%10)-1);
        }
        lunlun.push(10*temp+(temp%10));

        if(temp%10!=9)
        {
            lunlun.push(10*temp+(temp%10)+1);
        }
    }
    cout << temp;

}


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

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

int op[8][3] = {
                {0, 0, 0},
                {0, 0, 1},
                {0, 1, 0},
                {0, 1, 1},
                {1, 0, 0},
                {1, 0, 1},
                {1, 1, 0},
                {1, 1, 1}
                };

int func(string s){
    int num[3] = {ctoi(s[1]), ctoi(s[2]), ctoi(s[3])};
    for (int i = 0; i < 8; i++)
    {
        int ans = ctoi(s[0]);
        for (int j = 0; j < 3; j++)
        {
            if(op[i][j]) ans += num[j];
            else ans -= num[j];
        }
        if (ans == 7) return i;
    }
 return -1;   
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    
	string S;
    cin >> S;

    int n = func(S);
    string ans = "";
    ans += S[0];
	for (int i = 0; i < 3; i++)
    {
        ans += (op[n][i])? "+" : "-";
        ans += S[i+1];
    }
    ans += "=7";
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

ll N; ll K;
ll A[MAX_N];

ll ans[MAX_N][2];

void solve() {
	cin >> N >> K;
	if(N - K < N / 2) {
		cout << -1 << "\n";
		return;
	}
	if(N % 2 == 0) {
		rep(i, 0, N / 2) {
			ans[i][0] = 0 + i * 2; ans[i][1] = N / 2 - i;
		}
		rep(i, 0, N / 2 - 1) {
			ans[N / 2 + i][0] = i * 2 + 1; ans[N / 2 + i][1] = N - 1 - i;
		}
		ans[N - 1][0] = N - 1; ans[N - 1][1] = 0;
	}
	else {
		rep(i, 0, N / 2 + 1) {
			ans[i][0] = 0 + i * 2; ans[i][1] = N / 2 - i;
		}
		rep(i, 0, N / 2) {
			ans[N / 2 + 1 + i][0] = i * 2 + 1; ans[N / 2 + 1 + i][1] = N - 1 - i;
		}
	}
	rep(i, 0, N) {
		cout << ans[i][0] + K << " " << ans[i][1] + N + K << " " << 2 * N + i + K << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 3840
class Node(object):
    def __init__(self, num, prv = None, nxt = None):
        self.num = num
        self.prv = prv
        self.nxt = nxt
 
 
class DoublyLinkedList(object):
    def __init__(self):
        self.start = self.last = None
 
    def insert(self, num):
        new_elem = Node(num)
 
        if self.start is None:
            self.start = self.last = new_elem
        else:
            new_elem.nxt = self.start
            self.start.prv = new_elem
            self.start = new_elem
 
    def delete_num(self, target):
        it = self.start
        while it is not None:
            if it.num == target:
                if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
 
                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                break
            it = it.nxt
 
    def delete_start(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.start.nxt.prv = None
            self.start = self.start.nxt
 
    def delete_last(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.last.prv.nxt = None
            self.last = self.last.prv
 
    def get_content(self):
        ret = []
        it = self.start
 
        while it is not None:
            ret.append(it.num)
            it = it.nxt
 
        return ' '.join(ret)
 
 
def _main():
    from sys import stdin
 
    n = int(input())
 
    lst = DoublyLinkedList()
     
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            lst.insert(cmd[1])
        elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.delete_start()
        elif cmd[0] == 'deleteLast':
            lst.delete_last()
 
    print(lst.get_content())
 
 
if __name__ == '__main__':
    _main()


Measured memory_bytes: 227604
import sys
sys.setrecursionlimit(2 ** 30)

def fact(n):
    if n == 0: return 1
    return n * fact(n-1)%1000000007

N, M=map(int,input().split())
if(abs(N%1000000007-M%1000000007)>1):
    i=0
else:
    i=fact(M%1000000007)*fact(N%1000000007)
if(N==M):
    i=i*2
ans=i%1000000007
print(ans)

Measured memory_bytes: 126448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m;
int main()
{
	scanf("%lld%lld", &n, &m);
	ll p = pow(2, m);
	ll ans = p*(n-m)*100+p*m*1900;
	printf("%lld\n", ans);
}

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

int main() {
    string S;
    cin >> S;
    int ans =9999999;
    for(int i=0;i<S.size()-2;i++){
        int num=0;
        for(int j=0;j<3;j++){
            num *= 10;
            num += (S[i+j]-'0');
        }
        num = abs(753-num);
        ans = min(ans,num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string s, t; cin >> s >> t;
    int n = s.size();

    rep(i,n){

        if (s == t){
            cout << "Yes" << endl;
            return 0;
        }

        s = s.back() + s.substr(0, s.size()-1);
    }
    

    cout << "No" << endl;
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut map = std::collections::HashMap::new();
    let mut ans = 0;
    let mut now = 0;
    map.insert(0usize, 1usize);
    for i in 0..n {
        now = (now + a[i]) % m;
        let p = map.entry(now).or_insert(0);
        ans += *p;
        *p += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 14588
//**KEEP IT SHORT AND SIMPLE**

#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef set <long long> sll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
double pi = 2 * acos(0.0);
int OO = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
const int NMAX = 100010;
ll n, A[NMAX], B[NMAX], C[NMAX], dp[NMAX][5];
ll solve(ll i, int last)
{
    if(i == n)          return 0;
    if(~dp[i][last])    return dp[i][last];
    ll ans = 0;
    if(last == 0)       ans = max(solve(i + 1, 1) + B[i], solve(i + 1, 2) + C[i]);
    else if(last == 1)  ans = max(solve(i + 1, 0) + A[i], solve(i + 1, 2) + C[i]);
    else if(last == 2)  ans = max(solve(i + 1, 0) + A[i], solve(i + 1, 1) + B[i]);
    else                ans = max(solve(i + 1, 0) + A[i], max(solve(i + 1, 1) + B[i], solve(i + 1, 2) + C[i]));
    return dp[i][last] = ans;
}
int main()
{
    IO
    cin >> n;
    REP(i, 0, n)
        cin >> A[i] >> B[i] >> C[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0, 3);
    return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;
  
  cin >> n;
  for (int i = 0; i < n; i++) cin >> R[i];

  int maxv =  -2000000000;
  int minv = R[0];

  for (int i = 1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}


Measured memory_bytes: 3876
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; 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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

class Point {
  public:
  long double x, y;

  Point(long double x = 0, long double y = 0): x(x), y(y) {}

  Point operator + (Point &p) {
    return Point(x + p.x, y + p.y);
  }

  Point operator - (Point &p) {
    return Point(x - p.x, y - p.y);
  }

  Point operator * (long double k) {
    return Point(x * k, y * k);
  }

  Point operator / (long double k) {
    return Point(x / k, y / k);
  }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};

long double norm(Point p) {
  return p.x * p.x + p.y * p.y;
}

long double abs(Point p) {
  return sqrt(norm(p));
}

long double dot(Point p1, Point p2) {
  return p1.x * p2.x + p1.y * p2.y;
}

long double cross(Point p1, Point p2) {
  return p1.x * p2.y - p1.y * p2.x;
}

int main() {
  Point p0, p1, p2, v01, v02, ans;
  int q;
  cin >> p0.x >> p0.y >> p1.x >> p1.y;
  v01 = p1 - p0;
  cin >> q;
  rep(i, q) {
    cin >> p2.x >> p2.y;
    v02 = p2 - p0;
    ans = (v01 * dot(v01, v02) / norm(v01) + p0) * 2 - p2;
    if (equals(ans.x, EPS)) ans.x = 0;
    if (equals(ans.y, EPS)) ans.y = 0;
    cout << setprecision(15) << ans.x << " " << ans.y << endl;
  }

  
  return 0;
}


Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin>>n;
 int a[n];
 int i;
  int f=0;
  map<int,int> m;
 for(i=0;i<n;i++)
 {
 	cin>>a[i];
 	if(m[a[i]]!=0)
   {
   	f=1;
   }
   m[a[i]]++;
 }
  if(f==0)
 cout<<"YES"<<endl;
 else
 cout<<"NO"<<endl;
 return 0;
}


Measured memory_bytes: 10368
if __name__ == '__main__':
    N = int(input())
    C = [0]*(N-1)
    S = [0]*(N-1)
    F = [0]*(N-1)
    for i in range(N-1):
        C[i], S[i], F[i] = map(int, input().split())
    
    for i in range(N):
        if i == N-1:
            print(0)
            break
        count = S[i]
        count += C[i]
        for j in range(i+1, N-1):
            if count < S[j]:
                count = S[j]
            elif count%F[j] != 0:
                count += F[j] - count%F[j]
            count += C[j]
        print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<limits.h>
#include<utility>
#include<cstdlib>
#define LP(i,n) for(int i=0;i<n;i++)
#define LPIN(n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >>c;
  long long int ans;
  ans = c;
  for(int i=0;i<10;i++){
ans = ans * a -b;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
dp = [None]*(N+1)
a = 1
while a <= N:
    dp[a] = 1
    a *= 6
a = 1
while a <= N:
    dp[a] = 1
    a *= 9

def f(n):
    if dp[n]:
        return dp[n]
    a = 6
    while a <= n:
        a *= 6
    a //= 6
    b = 9
    while b <= n:
        b *= 9
    b //= 9
    ans = min([f(n-a), f(n-b)])+1
    dp[n] = ans
    return ans
print(f(N))

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<(c<=a+b ? "Yes" : "No")<<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input().strip())
s=[]
su=0
for i in range(n):
    a=int(input().strip())
    s.append(a)
    su+=a
s.sort()

if su%10==0:
    fl=False
    for i in s:
        tm=su-i
        if tm%10!=0:
            su=tm
            fl=True
            break
else:
    fl=True

if fl:
    print(su)
else:
    print(0)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int a,b,c,n,i;
    while(scanf("%d",&n)!=EOF)
        {
       for(i=0;i<n;i++)
          {
            scanf("%d %d %d", &a, &b, &c);
            if((a*a)+(b*b)==(c*c))
            printf("YES\n");
             else if((b*b)+(c*c)==(a*a))
              printf("YES\n");
             else if((a*a)+(c*c)==(b*b))
                printf("YES\n");
            else
            printf("NO\n");
           }
        }
    return 0;
}

Measured memory_bytes: 576
def main():
    A = [int(i) for i in input().split()]
    A.sort()
    B = [A[2]-A[0], A[2]-A[1]]
    B.sort(key=lambda p: p % 2)
    ans = 0
    if B[0] % 2 == B[1] % 2:
        ans += B[0]//2 + B[1]//2
        if B[0] % 2 == 1:
            ans += 1
    else:
        ans += B[0]//2 + (B[1]+1)//2 + 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			if (n == 1)
				continue;
			Set<Integer> set = new HashSet<Integer>();
			for (int i = 1; i < n; i++) {
				set.add(i * i % n);
			}
			Integer[] sqmod = new Integer[set.size()];
			set.toArray(sqmod);
			int[] f = new int[(n - 1) / 2 + 1];
			for (int i = 0; i < sqmod.length; i++) {
				for (int j = 0; j < sqmod.length; j++) {
					if (i == j)
						continue;
					int diff = sqmod[i] - sqmod[j];
					if (diff < 0)
						diff += n;
					if (diff > (n - 1) / 2)
						diff = n - diff;
					f[diff]++;
				}
			}
			for (int i = 1; i <= (n - 1) / 2; i++) {
				System.out.println(f[i]);
			}
		}
	}
}

Measured memory_bytes: 13000
from collections import defaultdict
H, W, N, *L = map(int, open(0).read().split())
dic = defaultdict(int)
for a, b in zip(*[iter(L)]*2):
  for i in range(a-2,a+1):
    for j in range(b-2,b+1):
      if 0<i and i+2<=H and 0<j and j+2<=W:
        dic[(i,j)] += 1
ans = [0]*10
ans[0] = (W-2)*(H-2)
for k in dic.keys():
  ans[dic[k]] += 1
  ans[0] -= 1
print(*ans,sep='\n')

Measured memory_bytes: 163508
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=2e5+100;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int L[N],R[N],x[N];
int e[N<<2];
LL f[N],g[N];
#define lc (i<<1)
#define rc (lc|1)
inline void build(int i,int l,int r,int t) {
	e[i]=t;
	if (l!=r) {
		int mid=(l+r)>>1;
		build(lc,l,mid,t);
		build(rc,mid+1,r,t);
	}
}
inline void modify(int i,int l,int r,int L,int R,int k) {
	if (L<=l&&r<=R) e[i]=k;
	else {
		int mid=(l+r)>>1;
		if (L<=mid) modify(lc,l,mid,L,R,k);
		if (mid<R) modify(rc,mid+1,r,L,R,k);
	}
}
inline int query(int i,int l,int r,int k) {
	if (l==r) return e[i];
	int mid=(l+r)>>1;
	return min(e[i],k<=mid?query(lc,l,mid,k):query(rc,mid+1,r,k));
}
inline void add(int i,int l,int r,int L,int R) {
	if (L<=l&&r<=R) e[i]++;
	else {
		int mid=(l+r)>>1;
		if (L<=mid) add(lc,l,mid,L,R);
		if (mid<R) add(rc,mid+1,r,L,R);
	}
}
inline int Sum(int i,int l,int r,int k) {
	if (l==r) return e[i];
	int mid=(l+r)>>1;
	return e[i]+(k<=mid?Sum(lc,l,mid,k):Sum(rc,mid+1,r,k));
}
int main()
{
	int n=gi(),m=gi(),i,a,k,tp,sum=0,len=0;
	LL ans=1LL<<60,S=0;
	for (i=1;i<=n;i++) {
		a=gi(),tp=gi();S+=a<<1;
		if (tp==1&&a*2>m) return puts("-1"),0;
		if (tp==2) L[i]=0,R[i]=m-1;
		else L[i]=sum,R[i]=(sum-a*2%m+m)%m;
		sum=(sum-a*2%m+m)%m;
		x[++len]=L[i];
		x[++len]=R[i];
	}
	sort(x+1,x+1+len);
	len=unique(x+1,x+1+len)-x-1;
	build(1,1,len,n+1);
	for (i=n;i;i--) {
		L[i]=lower_bound(x+1,x+1+len,L[i])-x;
		R[i]=lower_bound(x+1,x+1+len,R[i])-x;

		k=query(1,1,len,L[i]);
		if (k!=n+1) f[i]=f[k]+(x[L[k]]-x[L[i]]+m)%m;
		k=query(1,1,len,R[i]);
		if (k!=n+1) g[i]=f[k]+(x[L[k]]-x[R[i]]+m)%m;

		if (L[i]<=R[i]) {
			if (R[i]<len) modify(1,1,len,R[i]+1,len,i);
			if (L[i]>1) modify(1,1,len,1,L[i]-1,i);
		} else if (R[i]+1<L[i]) modify(1,1,len,R[i]+1,L[i]-1,i);
	}
	build(1,1,len,0);
	for (i=1;i<=n;i++) {
		if (Sum(1,1,len,L[i])==i-1)
			ans=min(ans,f[i]);
		if (Sum(1,1,len,R[i])==i-1)
			ans=min(ans,g[i]);
		if (L[i]<=R[i]) add(1,1,len,L[i],R[i]);
		else add(1,1,len,L[i],len),add(1,1,len,1,R[i]);
	}
	cout<<ans+S<<endl;
	return 0;
}


Measured memory_bytes: 7680
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        if ( (a * b) % 2 == 0 ) {
            System.out.print("Even");
        } else {
            System.out.print("Odd");
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

bool used[100001];
Int a[100001];
Int cnt;

void f(Int x) {
    if (used[x]) return;
    used[x] = true;    
    if (x == 2) return;
    cnt++;
    f(a[x]);
}

int main() {
    ios::sync_with_stdio(false);
    Int n;
    cin >> n;
    for (Int i = 1; i <= n; i++) cin >> a[i];
    f(1);
    dump(used[2] ? cnt : -1);
    return 0;
} 


Measured memory_bytes: 1152
n = int(input())
ab = [ list(map(int, input().split())) for _ in range(n) ]
cd = [ list(map(int, input().split())) for _ in range(n) ]
ab = sorted(ab, key=lambda x:x[1]*(-1))
cd = sorted(cd)
ans = 0
for q in cd:
    for p in ab:
        if q[0] > p[0] and q[1] > p[1]:
            ans += 1
            ab.remove(p)
            break
print(ans)

Measured memory_bytes: 39280
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <climits>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

template <unsigned T>
bool nextBitset(bitset<T>& bs, int digit)
{
	if(bs.none())
		return false;
	bitset<T> x, y, z;
	x = bs.to_ulong() & (~(bs.to_ulong()) + 1ULL);
	y = bs.to_ulong() + x.to_ulong() + 0ULL;
	z = bs & ~y;
	if(bs[digit-1] && bs == z)
		return false;
	bs = ((z.to_ulong() / x.to_ulong()) >> 1) + 0ULL;
	bs |= y;
	return true;
}

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

	vector<double> l(n), a(n), b(n);
	for(int i=0; i<n; ++i)
		cin >> l[i] >> a[i] >> b[i];

	double ret = 0.0;
	bitset<20> bs((1<<m)-1);
	do{
		double tmp = 0.0;
		for(int i=0; i<n; ++i){
			if(!bs[i])
				continue;
			for(int j=i+1; j<n; ++j){
				if(!bs[j])
					continue;
				tmp += pow(l[i]-l[j], 2.0) + pow(a[i]-a[j], 2.0) + pow(b[i]-b[j], 2.0);
			}
		}
		ret = max(ret, tmp);
	}while(nextBitset(bs, n));

	printf("%.10f\n", ret);
	return 0;
}

Measured memory_bytes: 932
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv,
       std.format;

void main()
{
foreach(i; 0..10000){
	auto ip = readln.chomp.to!int;
	if(ip == 0) break;
	else writefln("Case %s: %s", i+1, ip);
}
}


Measured memory_bytes: 2400
#include <iostream>
using namespace std;
int main(void){
  int n,a,i,d[3]={};
  cin >> n;
  for (i=0;i<n;i++){
    cin >> a;
    if (a%2) d[0]++;
    else if (a%4) d[1]++;
  }
  d[2]=n-d[0]-d[1];
  if ((d[1]==0&&d[0]-1<=d[2])||(d[1]&&d[0]<=d[2])) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int> g(n);
    rep(i, n) {
        int a;
        cin >> a;
        --a;
        g[i] = a;
    }
    vector<int> cnt(n, -1);
    int now = 0;
    cnt[0] = 0;
    while(1) {
        if (cnt[now] == k) {
            cout << now + 1 << endl;
            return 0;
        }
        if (cnt[g[now]] != -1) {
            ll loop_num = cnt[now] - cnt[g[now]] + 1;
            ll rest = k - cnt[now] - 1;
            ll fin = g[now];
            //cout << rest << " " << loop_num << " " << fin << " " << rest % loop_num << endl;
            rep(i, rest % loop_num + 1) {
                now = g[now];
            }
            cout << now + 1 << endl;
            break;
        }
        cnt[g[now]] = cnt[now] + 1;
        now = g[now];
    }
    return 0;
}


Measured memory_bytes: 4808
def main():
    N,M  = map(int, input().split()) 
    if N >=3 and M >=3:
        print((N-2)*(M-2))
    elif N ==1 and M==1:
        print(1)
    elif N ==1 or M==1:
        print((N*M)-2)
    else:
        print(0)



if __name__ == '__main__':
    main()


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

int main(){
  string s;
  cin >> s;
  int count = 0;
  if(s[0] != 'A'){
    cout << "WA" << endl;
    return 0;
  }
  for(int i = 2; i < s.size() - 1; i++){
    if(s[i] == 'C'){
      count++;
    }
  }
  if(count != 1){
    cout << "WA" << endl;
    return 0;
  }
  for(int i = 0; i < s.size(); i++){
    if(s[i] != 'A' && s[i] != 'C' && s[i] >= 65 && s[i] <= 90){
      cout << "WA" << endl;
      return 0;
    }
  }
  cout << "AC" << endl;
  return 0;
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int n=in(),a,b,i,m=0,s=0;
	rep(i,n){
		a=in(),b=in();
		if(m<a){
			m=a;
			s=a+b;
		}
	}
	print(s);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
  
public class Main
{
    public static void main (String[] args)
    {
        Scanner scanner = new Scanner(System.in);
  
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
  
        if(a < b && b < c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
    }
  }
}

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

def factorization(n):
    arr = [[1,n]]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            c = temp // i
            arr.append([i, c])
    return arr

L = factorization(N)
distance = [l[0] + l[1] for l in L]

m = min(distance)
print(m-2)

Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;

int main()
{
    long int N, T;
    cin >> N >> T;
    long int A[N];
    cin >> A[0];
    int combi[3]={A[0], 0, 0};//それまでのAの最小値、差額(利益)の最大値、その差額となるのが何回あったかを格納する

    for(int i=1; i<N; i++){
        cin >> A[i];
        if(A[i]-combi[0]>combi[1]){
            combi[1]=A[i]-combi[0];
            combi[2]=1;
        }else if(A[i]-combi[0]==combi[1]){
            combi[2]++;
        }else if(A[i]<combi[0]){
            combi[0]=A[i];
        }
    }

    cout << combi[2] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
	int a[3];
	for (int i = 0;i < 3;i++) scanf("%d",&a[i]);
	sort(a,a+3);
	int ans = 0;
	for (int i = 1;i < 3;i++)
	{
		ans += a[i] - a[i-1];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
        long long int n; cin >> n;
        map<string, long long int> mp;
        for (long long int x = 0; x < n; ++x){
            string s; cin >> s;
            sort(s.begin(), s.end());
            mp[s]++;
        }
        long long int ans = 0;
        for (auto x : mp){
            long long int q = x.second;
            if (q == 1) continue;
            q = q * (q - 1) / 2;
            ans += q;
        }
        cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11392