akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

ll MOD = 10000000019LL;

ll mulmod(ll a, ll n, bool f) {
  ll res = 0;
  n = abs(n);
  while(n>=1) {
    if (n % 2 == 1)
      res = (res + a) % MOD;
    a =  a*2%MOD;
    n = n/2;
  }
  if (f) res *= -1;
  return (res+MOD)%MOD;
}

ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a;
  x = 1; y = 0;
  if (b) {
    g = extgcd(b, a%b, y, x);
    y -= (a/b) * x;
  }
  return g;
}

ll invMod(ll a, ll p) {
  ll x, y;
  if (extgcd(a,p,x,y) == 1) return (x+p)%p;
  return 0;
}

int main() {
  int n;
  cin >> n;
  ll x = 0;
  REP(i, n) {
    int op, y;
    cin >> op >> y;
    if (op == 1) {
      x = (x+y+MOD)%MOD;
    } else if (op == 2) {
      x = (x-y+MOD)%MOD;
    } else if (op == 3) {
      x = mulmod(x, abs(y), y<0) ;
    } else {
      x = mulmod(x, invMod(abs(y), MOD), y<0);
    }
  }
  if (x<=INT_MAX) {
  } else x -= MOD;
  cout << x << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int n;
  if (b < 10) n = 10 * a + b;
  else if (b == 100) n = 1000 * a + b;
  else n = 100 * a + b;
  bool ans = false;
  for (int i = 0; i * i < 100100; i++) {
    if (i * i == n) {
      ans = true;
      break;
    }
  }
  if (ans) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 3568
S = input()
S_size = len(S)

if S_size % 2 == 0:
    S_left = list(S[: S_size//2])
    S_right = list(reversed(S[S_size//2 :]))
else:
    S_left = list(S[: S_size//2])
    S_right = list(reversed(S[(S_size//2 + 1) :]))

counter = 0
for i in range(len(S_left)):
    if S_left[i] == S_right[i]:
        pass
    else:
        counter += 1

print(counter)



Measured memory_bytes: 38384
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

S = read_str()

def solve():
    ans = 0
    N = len(S)
    s1 = S[0: (N - 1) // 2]
    s2 = S[(N + 3) // 2 - 1 :N]
    if S != S[::-1]:
        return 'No'
    if s1 != s1[::-1]:
        return 'No'
    if s2[::-1] != s2[::-1]:
        return 'No'
    return 'Yes'

if __name__ == "__main__":
    print(solve())

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = System.Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int x = int.Parse(input[1]);
            int count = n;
            int[] hoge = new int[n];
            for(int i = 0; i < n; i++)
            {
                hoge[i] = int.Parse(System.Console.ReadLine());
            }
            Array.Sort(hoge);
            x -= hoge.Sum();
            count += x / hoge[0];
            System.Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}



int N;
map<string, ll> memo[110];

bool ok (string s) {
  if ((s.substr(0, 3) == "AGC") || (s.substr(1, 3) == "AGC")) {
    return false;
  }
  if ((s.substr(0, 3) == "GAC") || (s.substr(1, 3) == "GAC")) {
    return false;
  }
  if ((s.substr(0, 3) == "ACG") || (s.substr(1, 3) == "ACG")) {
    return false;
  }
  if (s[0] == 'A' && s[1] == 'G' && s[3] == 'C') {
    return false;
  }
  if (s[0] == 'A' && s[2] == 'G' && s[3] == 'C') {
    return false;
  }

  return true;
}

ll dfs(int n, std::string str) {
  if (n == N) {
    return 1;
  }

  if (memo[n][str] != -1) {
    return memo[n][str];
  }

  vector<char> v = {'A', 'G', 'C', 'T'};

  ll ans = 0;
  for (auto curr: v) {
    string tmp = str + curr;

    if (ok(tmp)) {
      ans += dfs(n+1, str.substr(1, 3) + curr);
      ans %= MOD;
    }
  }

  memo[n][str] = ans;
  return ans;
}

int main () {
  cin >> N;

  vector<string> v = {"A", "G", "C", "T"};

  Rep(i, 110) {
    for (auto p: v) {
      for (auto q: v) {
        for (auto r: v) {
          string tmp = p + q + r;
          memo[i][tmp] = -1;
        }
      }
    }
  }

  ll ans = dfs(0, "TTT");

  cout << ans << "\n";
}

Measured memory_bytes: 1024
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;


public class Main {
	
	class Tree {
		String s;
		
		public Tree(String s) {
			this.s = s;
		}
		
		int parse() {return parse(s);}
		
		int parse(String str) {
			LinkedList<Integer> list = new LinkedList<Integer>();
			boolean flag = false;
			for(int i=1; i<str.length(); i++) {
				int j=i+1;
				if(j >= str.length()) break;
				int cnt = 1;
				for(; j<str.length(); j++) {
					if(str.charAt(j) == '[') cnt++;
					if(str.charAt(j) == ']') cnt--;
					if(cnt == 0) break;
				}
				if(str.charAt(i) == '[') {
					
					String sub = str.substring(i,j+1);
					if(sub.charAt(1) != '[') flag = true;
					list.add(parse(sub));
					
				} else {
					String sub = str.substring(i,j);
					list.add(Integer.parseInt(sub));
				}
				i=j;
			}
			if(list.size() == 1) return list.get(0);
			Collections.sort(list);
			int n = list.size()/2 + 1;
			int sum = 0;
			for(int i=0; i<n; i++) {
				int e = list.pollFirst();
				if(flag) {
					sum += e/2 + 1;
				} else {
					sum += e;
				}
				
			}
			return sum;
		}
	}
	
	public Main() {
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()) {
			int n = scanner.nextInt();
			for(int i=0; i<n; i++) {
				String s = scanner.next();
				int result = new Tree(s).parse();
				System.out.println(result);
			}
			break;
		}
		scanner.close();
	}
	
	public static void main(String[] args) {
		new Main();
	}

}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n;
    cin >> n;
    vint l(n);
    rep(i, n) cin >> l[i];
    sort(ALL(l));
    int sum = accumulate(l.begin(), l.end() - 1, 0);
    if (sum > l.back()) {
        puts("Yes");
    }
    else {
        puts("No");
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 123456789012345
#define int ll
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//

//
//initialization finish


// your function is here
//

//
// your function finished

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//

	int n; cin >> n;

    int cnt = 1;
    int pcnt = 0;
    while(1)
    {
        cnt ++;
        bool isSosu = true;
        FOR(i,2,cnt) if(cnt%i == 0) isSosu = false;

        if(isSosu && cnt % 5 == 1)
        {
            Print(cnt);
            pcnt++;
        }
        if(pcnt == n) break;
    }

	//
	// your code finished


	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,k,a[26]={},ans=0,b;
  cin >> n >> k;
  b=n/k;
  string s[10000]={};
  for(int i=0; i<n; i++) {
    cin >> s[i];
    a[s[i][0]-'A']++;
  }
  sort(a,a+26,greater<int>());
  while(a[k-1]>0&&b) {
    ans++,b--;
    for(int i=0; i<k; i++) {
      a[i]--;
    }
    sort(a,a+26,greater<int>());
  }
  cout << ans << endl;
}


Measured memory_bytes: 896
#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>;

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size()) if (s[i] == t[i]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void){

    int  a, b, c, d;

    scanf("%d%d%d%d", &a, &b, &c, &d);

    while(1){
        c -= b;
        if(c <= 0){
            printf("Yes\n");
            break;
        }
        a -= d;
        if(a <= 0){
            printf("No\n");
            break;
        }

    }
    return 0;
}


Measured memory_bytes: 1636
#include <stdio.h>
#define N 200005

char s[N] = {0}, t[N] = {0}, *p, *q;
int main()
{
    int cnt = 0;
    scanf("%s%s", s, t);
    p = s; q = t;
    while(*p && *q)
        if(*p++ != *q++) 
            cnt++;
    printf("%d\n", cnt);

    return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N, W;
int v[111], w[111];
int dp[111][111111];

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

   rep (i, N) {
      for (int j = 0; j <= W; j++) {
         // dp[i+1][j] = dp[i][j];
         chmax(dp[i+1][j], dp[i][j]);
         if (j + w[i] <= W) {
            chmax(dp[i+1][j+w[i]], dp[i][j]+v[i]);
         }
      }
   }

   cout << dp[N][W] << endl;

   return 0;
}


Measured memory_bytes: 7392
import sys,queue,math
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in input().split()]
_LI = lambda : [int(x)-1 for x in input().split()]

N,M = LI()
B = [_LI() for _ in range(M)]

g = [i for i in range(N)]
c = [1 for _ in range(N)]

def root(x):
    if x != g[x]: g[x] = root(g[x])
    return g[x]

def union(x,y):
    rx = root(x)
    ry = root(y)
    if rx != ry:
        if c[ry] > c[rx]: ry,rx = rx,ry
        g[ry] = rx
        c[rx] += c[ry]
        c[ry] = 0

k = []
for a,b in B[::-1]:
    ra = root(a)
    rb = root(b)
    if ra == rb:
        k.append(0)
    else:
        k.append(c[ra]*c[rb])
        union(ra,rb)

ans = 0
for a in k[::-1]:
    ans += a
    print (ans)

Measured memory_bytes: 93528
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  string s;
  cin >> s;
  int ans=0;
  rep(i,0,s.size()){
    if(s[i]=='1') ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long ans=1e18;
    for(long long i=1;i*i<=n;i++){
        if(n %i != 0)continue;
         
             long long j=n/i;
             ans = min(ans,i+j-2);
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
    double n, m, d, ans;
    cin >> n >> m >> d;
    ans = (n - d) / (n * n) * (m -1);
    if(d > 0) ans *= 2;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n;
 	cin>>n;
 	set<string>st;
 	for(ll i=0;i<n;i++)
 	{
 		string s;
 		cin>>s;
 		st.insert(s);
 	}	
 	cout<<st.size()<<endl;
    return 0;
}

Measured memory_bytes: 19200
<?php
$sheets_cnt = intval(trim(fgets(STDIN)));
$nums = explode(' ', trim(fgets(STDIN)));
rsort($nums);
$answer = 0;
for ($i=0; $i < $sheets_cnt; $i++) {
  if ($i % 2 == 0) {
    $answer += $nums[$i];
  } else {
    $answer -= $nums[$i];
  }
}
echo $answer."\n";


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define PI acos(-1.0)
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define MOD 1000000007
#define MOD1 998244353
#define ep 0.000000001
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, 1};
int dy4[] = {1, -1, 1, -1};
//#define fio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main()
{
    #ifndef ONLINE_JUDGE
    freopen ("in.txt", "r", stdin);
    freopen ("out.txt", "w", stdout);
    #endif
    int n, x, y; vi a, b;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        a.pb(x);b.pb(y);
    }
    bool flag=false;
    for(int i=0;i<n-2;i++){
        int c=0;
        for(int j=i,k=0;k<3;j++,k++){
            if(a[j]==b[j])c++;
        }
        if(c==3){
            flag=true;break;
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
//https://thebestoffersintheweb.com/redirect/57a764d042bf8/

Measured memory_bytes: 3632
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    // n の階乗の約数の個数を mod 1e9+7 で出力
    // n を構成する素数と，その数を求める

    val counter = IntArray(1001)

    // そもそも 1000 の階乗は計算結果を保持しておけないので注意
    // どうする？？
    // 愚直に全探索でも間に合う

    // 実装が汚い，きれいな方針は？
    for (i in 1 until counter.size) {
        // 素数の場合だけカウント -> 素数判定が間違っている？？
        if(isPrime(i)) {
            // n の階乗で出てくる値一つ一つで当該の素数が何回出てくるか確認
            for (j in 1..n) {
                var k = j
                while (k % i == 0 && k != 0) {
                    counter[i] += 1
                    k /= i
                }
            }
        }
    }

//    val ans = counter.filter { it != 0 }.map { it + 1 }.fold(1) { acc, i -> acc * i % (1e9+7).toInt()}

    var tmp = 1L
    for (v in counter) {
        if ( v != 0 ){
            tmp = tmp * (v+1) % (1e9+7).toLong()
        }
    }
    // WA: 値が大きくなるとWA なぜ？ -> 素数判定が間違っていた & Long を使っていなかったのオーバーフローした
    println(tmp)
}

// 素数判定
// そもそも小さい値から順に割っていけば素数で割った結果を得られる
fun isPrime(x: Int): Boolean {
    if (x == 2){
        return true
    }

    if (x < 2 || x % 2 == 0) {
        return false
    }

    var i = 3

    while (i <= Math.sqrt(x.toDouble()).toInt()) {
        if (x % i == 0) {
            return false
        }
        i += 1
    }
    return true
}

Measured memory_bytes: 31748
def gcd(m,n):
  x = max(m, n)
  y = min(m, n)
  
  if x%y == 0:
    return y
  else:
    while x%y!=0:
      z=x%y
      x=y
      y=z
    else:
      return z
def lcm(m,n):
  return int(m*n/gcd(m,n))

Num = input().split()
A = int(Num[0])
B = int(Num[1])

print(lcm(A,B))

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

int main(){
  int N;
  cin >> N;
  
  
  
  while(1){ 
    bool chk = true;
    double limit= sqrt(N);
  	for (int i = 2; i <(int)( limit ); ++i){
      if(N%i==0){
        chk = false;
        ++N;
        break;
      }
 	 }
    if (chk) break;   
  }
  cout << N << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); scanf().tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
  int x,n;
  cin>>x>>n;
  int sum  =0;
  for(int i=0;i<n;i++)
  {
    int y;
    cin>>y;

    sum += y;
  }
  if(sum > x)cout<<-1;
  else cout<<x - sum;
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i = 1 ; i <= 10000; i++) {
			int x = sc.nextInt();
			if(x == 0) {
				break;
			}
			System.out.println("Case " + i + ": " + x);
		}
	}
}

Measured memory_bytes: 42236
from sys import stdin
import math
import fractions
from collections import deque
import itertools

INF = 10 ** 10

N = int(stdin.readline().rstrip())
W = [int(x) for x in stdin.readline().rstrip().split()]

data = [0] * (N+1)

for i in range(1, N+1):
    data[i] = data[i-1] + W[i-1]

ans = INF

for i in range(1, N+1):
    left = data[i]
    right = data[N] - left
    ans = min(abs(left-right), ans)


print(ans)

Measured memory_bytes: 66396
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var num1 = Convert.ToInt32(input[0], 16);
        var num2 = Convert.ToInt32(input[1], 16);

        if (num1 == num2) Console.WriteLine("=");
        else if (num1 > num2) Console.WriteLine(">");
        else Console.WriteLine("<");
    }
}

Measured memory_bytes: 13268
x, y = map(int, input().split())

flag = 0

for i in range(101):
    for j in range(101):
        if i+j == x:
            if 2*i+4*j == y:
                print("Yes")
                flag += 1
                break
    else:
        continue
    break

if flag==0:
    print("No")





Measured memory_bytes: 62940
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*C++になってるか認したほうがよくない？WOWWOW*/
/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    int N, M; cin>>N>>M;
    int a, S=0;
    for(int i=0; i<M; i++){
        cin>>a;
        S+=a;
    }
    if(S>N){
        cout<<"-1"<<endl;
    }
    else{
        cout<<N-S<<endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<cmath>

using namespace std;
typedef long long LL;

LL x,y=1,p,q;

int main(){
	
	int i,j,k,n;
	cin>>n>>k;
	for(i=1;i<=n;i++){
		cin>>j;
		if(j&1){
			p=x+y;
			q=x+y;
		}else{
			p=2*x;
			q=2*y;
		}
		x=p,y=q;
	}
	
	if(k)cout<<x<<endl;
	else cout<<y<<endl;

	return 0;
}


Measured memory_bytes: 256
<?php


$n = trim(fgets(STDIN));
$aline = trim(fgets(STDIN));

$a = explode(' ', $aline);


$carry = 0;

for ($i = 0; $i < (int) $n; $i++) {
    $carry += 1 / (float) $a[$i];
}

echo 1 / $carry;



Measured memory_bytes: 4728
#include <iostream>

using namespace std;

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

    char a[n][n], b[n][n];

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

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
            cin >> b[i][j];
        }
    }

    bool f = true;

    for (int i = 0; i < n - m + 1; i++) {
        for (int j = 0; j < n - m + 1; j++) {
            f = true;
            for (int k = 0; k < m; k++) {
                for (int l = 0; l < m; l++) {
                    if (a[k + i][l + j] != b[k][l]) {
                        f = false;
                        break;
                    }
                }
            }

            if (f) {
                cout << "Yes" << endl;
                return 0;
            }

        }
    }

    if (!f) {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef struct{
  int key;
  int left,right,parent;
}node;

node t[500005];

void pre(int u){
  printf(" %d",t[u].key);

  if(t[u].left!=-1)pre(t[u].left);
  if(t[u].right!=-1)pre(t[u].right);
  
  return;
}
void in(int u){
  
  if(t[u].left!=-1)in(t[u].left);
  printf(" %d",t[u].key);
  if(t[u].right!=-1)in(t[u].right);

  return;
}
main()
{

  for(int i=0;i<500005;i++){
    t[i]=(node){-1,-1,-1,-1};
  }

  int n;
  string q;
  int a;
  int next=0;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> q;
    if(q=="insert"){
      cin >> a;
      int b=0;
      int num=0;
      if(next==0){
	t[next].key=a;
      }else{
	while(num!=-1){
	  b=num;
	  if(t[num].key<a){
	    num=t[num].right;
	  }else{
	    num=t[num].left;
	  }
	}
	if(t[b].key<a){
	  t[b].right=next;
	}else{
	  t[b].left=next;
	}
	t[next].key=a;
	t[next].parent=b;
      }
      next++;
    }

    if(q=="print"){
      in(0);
      printf("\n");
      pre(0);
      printf("\n");
    }
  }

  return (0);
}

Measured memory_bytes: 11036
//Disjoint Set: Union Find Tree
#include <iostream>
#include <vector>

using namespace std;

class UnionFindTree {
private:
    vector<int> p, rank;
public:
    UnionFindTree(int size) {
        p = vector<int>(size);
        rank = vector<int>(size,0);
        for(int i=0; i<size; i++) p[i] = i;
    }

    int findSet(int x) {
        if(p[x] != x) p[x] = findSet(p[x]);
        return p[x];
    }

    void unite(int x, int y) {
        int sx = findSet(x), sy = findSet(y);
        if(rank[sx] > rank[sy]) p[sy] = sx;
        else {
            p[sx] = sy;
            if(rank[sx] == rank[sy]) rank[sx]++;
        }

    }

    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    }
};

int main() {
    int n, q, com, x, y;
    cin >> n >> q;
    UnionFindTree S(n);
    for(int i = 0; i < q; i++) {
        cin >> com >> x >> y;
        if(com == 0) {
            S.unite(x, y);
        }
        else if(com == 1) {
            if(S.same(x, y)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
}



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

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

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

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

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

ll top(ll a)
{
  while (a > 9)
    a /= 10;
  return a;
}

ll pow10(ll n)
{
  ll a = 1;
  rep(i, n) a *= 10;
  return a;
}

inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}

inline ll div_down(ll a, ll d)
{
  if (a < 0)
    return -(CEIL(-a, d));
  else
    return (a / d);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  ll n;
  cin >> n;
  ll cnt = 0;
  for (ll a = 1; a <= n; ++a)
  {
    if (a % 10 == 0)
      continue;
    if (top(a) == a % 10 && a % 10 <= n)
      cnt++;
    rep(d, 6)
    {
      ll b = (a % 10) * pow10(d + 1) + top(a);
      if (div_down(n - b, 10) < 0)
        continue;
      cnt += min(div_down(n - b, 10) + 1, pow10(d));
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int N,A,B=0,C=0;
    scanf("%d\n%d",&N,&A);
    C=N*N;
    if((1 <= N && N <= 100) && (0 <= A && A<=C))
    {
     B = C - A;
     printf("\n%d\n",B);
    }
return 0;
}

Measured memory_bytes: 1728
public class Main {
  private static void solve() {
    int n = ni();
    int[] a = na(n);
    
    if (a[0] != 0) {
      System.out.println(-1);
      return;
    }
    
    long ret = 0;
    for (int i = 0; i < n - 1; i ++) {
      if (a[i + 1] == a[i] + 1) {
        ret ++;
      } else if (a[i + 1] <= a[i]) {
        ret += a[i + 1];
      } else {
        System.out.println(-1);
        return;
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 46864
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;
const ll LINF = ll(1e18);
const ll MOD = ll(1e9+7);

int main(){
  int h, w;cin>>h>>w;
  vector<vector<char> > field(h, vector<char>(w));
  vector<vector<int> > tp(h, vector<int>(w, 0)),
                       bp(h, vector<int>(w, 0)),
                       lp(h, vector<int>(w, 0)),
                       rp(h, vector<int>(w, 0));
  rep(i, h)rep(j, w){
    cin>>field[i][j];
  }
  rep(i, h){
    for(int j=1;j<w;j++){
      if(field[i][j-1]=='#')lp[i][j] = 0;
      else lp[i][j] = lp[i][j-1]+1;
    }
    for(int j=w-2;j>=0;j--){
      if(field[i][j+1]=='#')rp[i][j] = 0;
      else rp[i][j] = rp[i][j+1]+1;
    }
  }
  rep(j, w){
    for(int i=1;i<h;i++){
      if(field[i-1][j]=='#')tp[i][j] = 0;
      else tp[i][j] = tp[i-1][j]+1;
    }
    for(int i=h-2;i>=0;i--){
      if(field[i+1][j]=='#')bp[i][j] = 0;
      else bp[i][j] = bp[i+1][j]+1;
    }
  }
  int ans=-1;
  rep(i, h)rep(j, w){
    if(field[i][j]=='#')continue;
    ans=max(ans, tp[i][j]+bp[i][j]+lp[i][j]+rp[i][j]+1);
  }
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 67072
parseInt(x) = parse(Int,x)

function main()
	N,M,C = map(parseInt, split(readline()))
  	b = map(parseInt, split(readline()))
  ans = 0
  	for i = 1:N
  		a = map(parseInt, split(readline()))
    	if sum(a.*b) + C > 0
      		ans += 1
    end
  end
  println(Int64(ans))
end
main()

Measured memory_bytes: 114952
#include <stdio.h>
#include <string.h>

int main(void)
{
  int i, k, l, m = 1, n;
  char s[100001];

  scanf("%s", s);
  scanf("%d", &k);

  l = strlen(s);
  m = l;  

  for (i = 0; i < l; i++) {
    if (s[i] == 'a') {
      continue;
    } else {
      m = 'z' - s[i] + 1;
      if (k >= m) {
	s[i] = 'a';
	k -= m;
      }
    }
  }

  s[l - 1] += k % 26;

  printf("%s\n", s);

  return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> A(N);
  for(int i=0;i<N;++i){
    cin>>A.at(i).first;
    A.at(i).second=i+1;
  }
  sort(A.begin(),A.end());
  for(int i=0;i<N;++i){
    cout<<A.at(i).second<<" ";
  }
}

Measured memory_bytes: 1536
# Validate the input before processing
def checkValidInput (inputString):    
    if not inputString:
        return 0;
    noChars = len(inputString);
    upperInput = inputString.upper()    
    isUpperCase = 1 if (inputString == upperInput) else 0;
    if ((noChars == 12) and (isUpperCase == 1)):
        return 1;
    else:
        return 0;

# Wait the input from users, initialize data, process the input
inputstr = raw_input("") 
while (checkValidInput(inputstr) != 1):
    print "The input string is not 12 characters count or not in upper case."
    inputstr = raw_input("Enter your input string: ")

# Print the output
outputstr = inputstr[:4] + ' ' + inputstr[4:]
print outputstr


Measured memory_bytes: 2568
n,k=map(int,input().split())
S=list(input())
for i in range(n):
        if S[k-1]=="A":
                S[k-1]="a"
        elif S[k-1]=="B":
                S[k-1]="b"
        elif S[k-1]=="C":
                S[k-1]="c"
print("".join(S))



Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

int main(void){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    
    if (k <= a + b){
        cout << min(k,a) << endl;
        return 0;
    }
    
    cout <<  a - (k-(a+b)) << endl;
    return 0;
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
int inf = 1e9+7;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[n];
    rep(i,0,n) cin >> a[i];
    int min = inf;
    int cnt = 0;
    rep(i,0,n){
        if(min<a[i]) continue;
        cnt++;
        min = a[i];
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) ((x).begin(), (x).end())
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int x;
    cin >> x;
    ll ans = 0;
    int y = x / 500;
    x -= y * 500;
    ans += 1000LL * y;
    x -= x % 5;
    cout << ans + x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void){

  int N;  cin >> N;
  bool ans = false;
  for(int i = 1 ;i <= 9 ; i++){
    for(int j = 1; j <= 9 ; j++){
		if(i * j == N) ans = true;
    }
  }

  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>

#define ll long long
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> k(n);
	vector<vector<int>> a(n);
	for (int i = 0; i < n; i++) {
		cin >> k[i];
		a[i].resize(k[i]);
		for (int j = 0; j < k[i]; j++) {
			cin >> a[i][j];
		}
	}
	vector<int> food(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < k[i]; j++) {
			food[a[i][j] - 1]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < m; i++) {
		if (food[i] == n) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#ABC146 B
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

N = ni()
S = si()
# SS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
# SSS = 'NOPQRSTUVWXYZABCDEFGHIJKLM'
S1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans = []

for i,s in enumerate(S) :
    idx = S1.find(s)
    idx += N
    ans.append(S1[idx:idx+1])

aans = ''

for a in ans:
    aans += a

print(aans)

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cmath>
using namespace std;

int main(){
	char c[2][3];
	for (int i = 0; i < 2; i++){
		for (int j = 0; j < 3; j++){
			cin >> c[i][j];
		}
	}
	for (int j = 0; j < 3; j++){
		if (c[0][j] != c[1][2 - j]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
struct Knife{
	int iHurt;
	int iType=0;
}arrKnives[1000000];

bool cmp(Knife nifKnife1, Knife nifKnife2){
	return (nifKnife1.iHurt>nifKnife2.iHurt);
}

int main(){
	ios::sync_with_stdio(false);
	int n, iHP;
	register int i,c = 0;
	scanf("%d %d", &n, &iHP);
	for (i = 1; i <= n; ++i){
		scanf("%d", &arrKnives[c].iHurt);
		++c;
		arrKnives[c].iType = 1;
		scanf("%d", &arrKnives[c].iHurt);
		++c;
	}
	sort(arrKnives, arrKnives + c, cmp);
	int iSum = 0;
	for (i = 0; i<c; ++i){
		if (arrKnives[i].iType == 1){
			++iSum;
			iHP -= arrKnives[i].iHurt;
			if (iHP <= 0){
				printf("%d", iSum);
				break;
			}
		}
		else if (arrKnives[i].iType != 1){
			if (iHP%arrKnives[i].iHurt == 0)
				iSum += iHP / arrKnives[i].iHurt;
			else 
				iSum += iHP / arrKnives[i].iHurt + 1;
			printf("%d", iSum);
			break;
		}
	}
endapp:
	//system("pause > nul");
	return 0;
}

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



int main(){
int n;
cin>>n;
double p[n+1];

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

double dp[n+2][n+2];
dp[0][0]=1-p[0];
 dp[0][1]=p[0];

for(int i=1;i<n;i++){
for(int j=0;j<=(i+1);j++){
 if(j>0)dp[i][j]+=dp[i-1][j-1]*(p[i]);
 dp[i][j]=dp[i][j]+(dp[i-1][j])*(1-p[i]);
}

}double ans=0.0;
for(int i=1+(n-n%2)/2;i<=n;i++){
ans+=dp[n-1][i];
}

cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 70400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		String t = scanner.next();

		int start = 0;
		while (true){
			int idx = s.indexOf(t.substring(0, 1), start);
			if(idx==-1) break;
			start=idx+1;
			if(t.endsWith(s.substring(0, idx)) && t.startsWith(s.substring(idx))) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");

	}
}

Measured memory_bytes: 21844
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn f(a: &mut usize, b: &mut usize, t1: usize, t2: usize) {
    let r1 = (t1 - *a % t1) % t1;
    let r2 = (t2 - *b % t2) % t2;
    let bn = (*a + r1) / t1 * t2;
    let an = (*b + r2) / t2 * t1;
    if bn < *b {
        *a = an;
        *b += r2;
    } else if an < *a {
        *b = bn;
        *a += r1;
    } else {
        let c1 = bn - *b + r1;
        let c2 = an - *a + r2;
        if c1 < c2 {
            *b = bn;
            *a += r1;
        } else {
            *a = an;
            *b += r2;
        }
    }
}

fn main() {
    input! {
        n: usize,
        ta: [(usize, usize); n],
    }

    let mut a = 1;
    let mut b = 1;

    for (t1, t2) in ta {
        let na = (a + t1 - 1) / t1;
        let nb = (b + t2 - 1) / t2;
        let n = max(na, nb);
        a = n * t1;
        b = n * t2;
    }

    println!("{}", a + b);
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
  int a,b,c,d,x;
  scanf("%d %d %d %d", &a,&b,&c,&d);
  x = (c+b-1)/b;
  if((x-1)*d < a)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 1720
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100005;

inline int read()
{
	int ret, f=1;
	char c;
	while((c=getchar())&&(c<'0'||c>'9'))if(c=='-')f=-1;
	ret=c-'0';
	while((c=getchar())&&(c>='0'&&c<='9'))ret=(ret<<3)+(ret<<1)+c-'0';
	return ret*f;
}

int n, m, rt, deg[maxn];

int head[maxn], tot;
struct edge{
	int nxt, to;
}e[maxn<<1];

void Addedge(int x, int y)
{
	e[++tot] = (edge){head[x], y};
	head[x] = tot;
}

void dfs(int x, int fa)
{
	int id;
	for(int i = head[x]; i; i = e[i].nxt)
	{
		id = e[i].to;
		if(id == fa)	continue;
		if(id == rt)
		{
			printf("Yes");
			exit(0);
		}
		if(deg[id] == 2)
			dfs(id, x);
	}
}

int main()
{
	n = read(); m = read();
	int u, v;
	for(int i = 1; i <= m; ++i)
	{
		u = read();
		v = read();
		Addedge(u, v);
		Addedge(v, u);
		++ deg[u];
		++ deg[v];
	}
	for(int i = 1; i <= n; ++i)
		if(deg[i] & 1)
		{
			printf("No");
			return 0;
		}
	for(int i = 1; i <= n; ++i)
		if(deg[i] >= 6)
		{
			printf("Yes");
			return 0;
		}
	int cnt = 0;
	for(int i = 1; i <= n; ++i)
		cnt += (deg[i] == 4);
	if(cnt >= 3)
	{
		printf("Yes");
		return 0;
	}
	if(cnt <= 1)
	{
		printf("No");
		return 0;
	}
	for(int i = 1; i <= n; ++i)
		if(deg[i] == 4)
		{
			rt = i;
			break;
		}
	dfs(rt, 0);
	printf("No");
	return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define SIZE 10000

struct WORD {
	char value[13];
	struct WORD *next;
};

struct WORD* HashTable[SIZE];	//default: all NULL

int HashFunc(char s[]) {
	long long hash = 0;
	for (int i = 0; s[i] != '\0'; i++) {
		hash += s[i] * (i + 1);
	}
	return (int)(hash * 13 % SIZE);
}

void AddWord(char s[], int hashNum) {
	struct WORD* newWord = (struct WORD*)malloc(sizeof(struct WORD));
	strcpy(newWord->value, s);
	newWord->next = NULL;
	if (HashTable[hashNum] == NULL) HashTable[hashNum] = newWord;
	else {
		newWord->next = HashTable[hashNum];
		HashTable[hashNum] = newWord;
	}
}

void Insert(char s[]) {
	int hash = HashFunc(s);
	AddWord(s, hash);
}

void Find(char s[]) {
	int hash = HashFunc(s);
	struct WORD* pos;
	for (pos = HashTable[hash]; pos != NULL; pos = pos->next) {
		if (!strcmp(s, pos->value)) {
			printf("yes\n");
			return;
		}
	}
	printf("no\n");
	return;
}

int main() {
	int n;
	char command[7], value[13];
	for (int i = 0; i < SIZE; i++) {
		HashTable[i] = NULL;
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s %s", command, value);
		if (!strcmp(command, "insert")) Insert(value);
		else if (!strcmp(command, "find")) Find(value);
	}

	return 0;
}


Measured memory_bytes: 19640
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		boolean flag = false;
		for(int i = 0; i <= N; i++){
			if(flag == true)break;
			for(int j = 0; j <= N-i; j++){
				if(flag == true)break;
				if(i * 10000 + j * 5000 + (N-i-j)*1000 == Y){
					System.out.println(i + " " + j + " " + (N-i-j));
					flag = true;
				}
			}
		}
		if(flag == false)System.out.println("-1 -1 -1");
	
	
	
	}



}





Measured memory_bytes: 21844
<?php
$N = trim(fgets(STDIN));
$L = explode(" ", trim(fgets(STDIN)));

$nums = array_count_values($L);
$sum = 0;
$lefts = [];
foreach ($nums as $key => $val) {
    $sum += $key * floor($val / 2);
    if ($val % 2 == 1) {
        $lefts[] = $key;
    }
}

sort($lefts);
for ($i = 0; $i < count($lefts); $i++) {
    if ($i % 2 == 0) {
        $sum += $lefts[$i];
    }
}
echo $sum;

Measured memory_bytes: 3064