akhauriyash/Code-Regression huggingface dataset:
import sys
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = (2*10**5)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, = map(int, input().split())
ps = list(map(int, input().split()))
p2i = dict()
i = 0
for p in ps:
    if p not in p2i:
        i += 1
        p2i[p] = i
        continue
    x = p2i[p]
    break
X = min(x-1, i-1)
Y = min(N-x, N-i)
for i in range(1, N+2):
    print((cmb(N+1, i) - cmb(X+Y, i-1))%mod)


Measured memory_bytes: 84720
#include <iostream>

using namespace std;

int main(){

  int n, q;
  int c = 0;
  
  cin >> n;

  int s[n];

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

  cin >> q;

  for(int i = 0; i < q; i++){
    int t;
    cin >> t;
    for(int j = 0; j < n; j++){
      if(s[j] == t){
	c++;
	break;
      }
    }
  }

  cout << c << '\n';



  return 0;
} 
  



Measured memory_bytes: 3128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

public class Don
{
    public Don() { }
    private Reader r = new Reader();

    public void Solve()
    {
        var x = r.nextInt();

        if (x < 1200)
        {
            Console.WriteLine("ABC");
        } else
        {
            Console.WriteLine("ARC");
        }


    }

    public static void Main(string[] args)
    {
        new Don().Solve();
    }

}

class Reader
{
    string[] s;
    int i;
    char[] cs = new char[] { ' ' };

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

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

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

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

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

}

Measured memory_bytes: 2776
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

// long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a;
// }

// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int MOD = 1000000007;

int main() {
    string S;
    int N;
    cin >> N >> S;
    for(auto c : S) {
        char C = 'A' + (c - 'A' + N) % 26;
        cout << C;
    }
    cout << endl;
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

LL K, A, B;

int main(void) {
    cin >> K >> A >> B;
    LL ans = K + 1;
    if (A >= K) {
        DEBUG("A")
        cout << K + 1 << endl;
    } else if (A < B) {
        LL tmp = K - (A - 1);
        if (tmp % 2 == 0) {
            DEBUG("B")
            cout << max((tmp / 2) * B - (tmp - 1) / 2 * A, ans) << endl;
        } else {
            DEBUG("C")
            cout << max((tmp - 1) / 2 * B - (tmp - 2) / 2 * A + 1, ans) << endl;
        }
    } else {
        DEBUG("D")
        cout << K + 1 << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();

		if (a == b && b == c && a % 2 == 0) {
			System.out.println(-1);
		} else {
			int ans = 0;
			while (true) {
				if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
					break;
				}
				int ab = a + b;
				int bc = b + c;
				int ca = c + a;
				a = bc / 2;
				b = ca / 2;
				c = ab / 2;
				ans++;
			}
			System.out.println(ans);
		}
	}
}


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

int main(){
    vector<int> v(5);
    for(int i = 0; i < 5; i++) cin >> v[i];

    int maxw = 0, idx = 0;
    for(int i = 0; i < 5; i++){
        int w = 0;
        if(v[i] % 10) w = 10 - v[i] % 10;
        if(w >= maxw){
            maxw = w;
            idx = i;
        }
    }

    int ans = 0;
    for(int i = 0; i < 5; i++){
        if(i == idx) continue;
        ans += v[i];
        if(ans % 10) ans += 10 - ans % 10;
    }
    ans += v[idx];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    ll n,k;
    vector<pair<int,int>> v;
    cin>>n>>k;
    int a,b;
    REP(i,n)
    {
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    int ans;
    for(auto i:v)
    {
        k-=i.second;
        if(k<=0)
        {ans=i.first;break;}
    }
    cout<<ans;
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vii vector<vi>

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 gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  int ans = -n;
  rep(i,n) ans += a[i];
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z') OUT("A")
    else OUT("a")

    return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		long[] a=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long ans=0,o=1;
		Array.Sort(a,ca);
		var hs=new Dictionary<long,int>();
		for(int i=0;i<n;i++){
			if(hs.ContainsKey(a[i])&&hs[a[i]]>0){
				ans++;
				hs[a[i]]--;
				continue;
			}
			for(int j=1;(o<<j)-a[i]<=a[i];j++){
				if((o<<j)>a[i]){
					if(hs.ContainsKey((o<<j)-a[i])){hs[(o<<j)-a[i]]++;}
					else{hs.Add((o<<j)-a[i],1);}
				}
			}
		}
		Console.WriteLine(ans);
	}
	static int ca(long a,long b){
		if(a<b){return 1;}
		else if(a>b){return -1;}
		else{return 0;}
	}
}

Measured memory_bytes: 41408
#include <string>
#include <vector>
#include <map>
#include <deque>
#include <iostream>
#include <queue>
#include <math.h>
#include <algorithm>
#include <fstream>

using namespace std;
typedef long long ll;


int main(void) {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) {
		cout << s;

	}
	else {
		cout << "red";

	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;


void solve()
{
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No\n";
	}
}

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


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

int main() {
    int x, y;
    while (true) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        if (x <= y) cout << x << " " << y << endl;
        else cout << y << " " << x << endl;
    }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
set<int>alpha[26];
int n,m;
string s;
int main() 
{
	cin>>n>>s>>m;
	for(int i=0;i<n;i++)
		alpha[s[i]-'a'].insert(i);
	for(int i=1;i<=m;i++)
	{
		int oper;
		cin>>oper;
		if(oper==1)
		{
			int x;
			char c;
			cin>>x>>c;
			alpha[s[x-1]-'a'].erase(x-1);
			alpha[c-'a'].insert(x-1);
			s[x-1]=c;
		} 
		else 
		{
			int x,y;
			cin>>x>>y;
			int ans=0;
			for(int i=0;i<26;i++) 
			{
				auto it=alpha[i].lower_bound(x-1);
				if(it!=alpha[i].end()&&*it<y)ans++;
			}
			cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 24196
import math
N, G = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]

ans = float('inf')
for i in range(2 ** N):
  point = 0
  num = 0
  # コンプボーナスを取る取らない
  digit = 1
  for d in range(N):
    if (digit << d) & i:
      num += S[d][0]
      point += S[d][0] * (d+1) * 100 + S[d][1]
  # 大きい方から、ばらで問題を解く
  for d in range(N)[::-1]:
    if not ((digit << d) & i):
      delta = max(0, G - point)
      n = min(math.ceil(delta / ((d+1) * 100)), S[d][0])
      num += n
      point += n * (d+1) * 100
  ans = min(ans, num)
print(ans)

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

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

    //mapのソートは宣言時に
    map<ll,ll,greater<ll>> A;
    rep(i,n){
        ll a;
        cin>>a;
        A[a]++;
    }

    vector<ll> tateyoko;
    //0で初期化されているのでpush_backはダメか？
    for(auto p:A){
        if(p.second>=4){
            tateyoko.push_back(p.first);
            tateyoko.push_back(p.first);
        }
        if(p.second>=2) tateyoko.push_back(p.first);
    }

    if(tateyoko.size()>=2)cout<<tateyoko[0]*tateyoko[1]<<endl;
    else cout<<0<<endl;

}

//pushbackの使い方(0に上書き不可)

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

string s;
vector<string> res;

void rec(int bit, int cur, string str)
{
    if (str.size() == s.size())
    {
        res.push_back(str);
    }
    char c = s[cur];
    int cnum = c - 'a';
    /*
        cout << "str : " << str << " ";
    cout << "bit : ";
    for(int i = 30; i >= 0; --i) {
        cout << ((bit>>i) & 1 ? "1" : "0") ;
    }
    cout << endl;
    */
    //cout << (bit & (1 << cnum)) << " " << str << endl;

    if (c == 'a' || bit & (1 << cnum))
    {
        rec(bit, cur + 1, str + c);
    }
    if (c != 'z')
    {
        if (!(bit & (1 << (cnum + 1))))
            rec(bit | (1 << (cnum + 1)), cur + 1, str + (char)(c + 1));
    }
}

int main()
{
    while (cin >> s, s != "#")
    {
        res.clear();
        rec(0, 0, "");
        sort(res.begin(), res.end());
        cout << res.size() << endl;
        if (res.size() < 10)
        {
            for (auto &x : res)
                cout << x << endl;
        }
        else
        {
            for (int i = 0; i < 5; i++)
                cout << res[i] << endl;
            for (int i = res.size() - 5; i < res.size(); i++)
            {
                cout << res[i] << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4356
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int v[100010];

vector<pi> ans;
vector<vi> e;
int rec(int c, int p){
	v[c] = 1;
	int out = 0;
	for(int i : e[c]) if(i != p){
		if(v[i] == 1){
			ans.emplace_back(c, i);
			out++;
		} else if(v[i] == 0){
			out += rec(i, c);
		}
	}
	v[c] = 2;
	if(c != p){
		if(out % 2){
			ans.emplace_back(c, p);
			return 0;
		}
		else{
			ans.emplace_back(p, c);
			return 1;
		}
	}
	return 0;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	e.resize(n);
	rep(i, m){
		int a, b; cin >> a >> b; a--; b--;
		e[a].pb(b);
		e[b].pb(a);
	}
	if(m % 2){
		cout << -1 << endl;
		return 0;
	}
	rec(0, 0);
	for(pi i : ans) cout << i.first + 1 << " " << i.second + 1 << endl;
	return 0;
}

Measured memory_bytes: 14452
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> s(M);
    vector<ll> c(M);
    vector<ll> ans(N, -1);
    for (ll i = 0; i < M; i++)
    {
        cin >> s.at(i) >> c.at(i);
    }

    for (ll i = 0; i < M; i++)
    {
        if (ans.at(s.at(i) - 1) != -1)
        {
            if (ans.at(s.at(i) - 1) != c.at(i))
            {
                // 矛盾する条件が与えられた
                cout << "-1" << endl;
                return;
            }
        }

        ans.at(s.at(i) - 1) = c.at(i);
    }

    if (ans.at(0) == 0 && N != 1)
    {
        cout << "-1" << endl;
        return;
    }

    if (ans.at(0) == -1 && N != 1)
    {
        ans.at(0) = 1;
    }

    for (ll i = 0; i < N; i++)
    {
        if (ans.at(i) == -1)
        {
            ans.at(i) = 0;
        }
        cout << ans.at(i);
    }

    cout << endl;

    return;
}

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


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

int n, k;
int dp[100010];
int h[100010];

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

    dp[0] = 0;

    for(int i = 1; i < n; ++i) {
        dp[i] = 1e+9;
        for(int j = 1; j <= min(i, k); ++j) {
            dp[i] = min(dp[i], dp[i-j]+abs(h[i-j]-h[i]));
        }
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int N,X,i,j,k,r;
    for(;scanf("%d%d",&N,&X),X+N;printf("%d\n",r))
    {
        for(i=1,r=0;i<=N;i++)
            for(j=i+1;j<=N;j++)
            {
                k=X-i-j;
                if(j<k&&k<=N)
                    r++;
            }
    }
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;


int64_t solve(int n, int m, int q, const vector<int> & a, const vector<int> & b, const vector<int> & c, const vector<int64_t> & d) {
    int64_t ans = 0;
    vector<int> f(n);
    while (true) {
        int64_t acc = 0;
        REP (j, q) {
            if (f[b[j]] - f[a[j]] == c[j]) {
                acc += d[j];
            }
        }
        ans = max(ans, acc);

        for (int i = n - 1; ; -- i) {
            if (i < 0) {
                return ans;
            }
            ++ f[i];
            REP3 (j, i + 1, n) {
                f[j] = f[i];
            }
            if (f[i] < m) {
                break;
            }
        }
    }
}

// generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int N, M;
    int Q;
    cin >> N >> M >> Q;
    vector<int> a(Q), b(Q), c(Q);
    vector<int64_t> d(Q);
    REP (i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        -- a[i];
        -- b[i];
    }
    auto ans = solve(N, M, Q, a, b, c, d);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(){
  int q;
  string s;
  cin >> s >> q;
  vector<string> top;
  vector<string> end;
	//if reversed, re == 1;
  int rev = 0; 
  for(int i = 0; i < q; i++){
    int t;
    cin >> t;
    if(t == 1) rev = (rev+1)%2;
    else if(t == 2){
      int f;
      string c;
      cin >> f >> c;
      if(f == 1){
        if(rev == 0) top.push_back(c);
        else if(rev == 1){
          reverse(c.begin(),c.end());
          end.push_back(c);
        }
      }else if(f == 2){
        if(rev == 0) end.push_back(c);
        else if(rev == 1){
          reverse(c.begin(),c.end());
          top.push_back(c);
        }
      }
    }
  }
  string ans;
  for(int i = top.size()-1;i >= 0; i--){
    ans += top.at(i);
  }
  ans += s;
  for(int i = 0; i < end.size(); i++){
    ans += end.at(i);
  }
  if(rev == 1) reverse(ans.begin(),ans.end());
  cout << ans << endl;  
}

Measured memory_bytes: 12400
#include<iostream>
#include<vector>

int main(){
    int N, X;
    std::cin >> N >> X;
    std::vector<int> m(N);
    int cnt = N;
    int minCost = 1000;
    for(int i = 0; i < N; i++){
        std::cin >> m[i];
        X -= m[i];
        minCost = std::min(minCost, m[i]);
    }
    cnt += X / minCost;
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <sstream>
    #include <iomanip>
    #include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <cctype>
    #include <cstring>
    #include <vector>
    #include <list>
    #include <queue>
    #include <deque>
    #include <stack>
    #include <map>
    #include <set>
    #include <algorithm>
    #include <iterator>
    #include <bitset>
    #include <ctime>



    using namespace std;

    #define FOR(i,a,b) for(int i = (a); i < (b); i++)
    #define rep(i,n) FOR(i,0,n)
    #define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
    #define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
    #define FILL(a, value) memset(a, value, sizeof(a)

    #define SZ(a) (int)a.size()
    #define ALL(a) a.begin(), a.end()
    #define PB push_back
    #define MP make_pair

    typedef  long long LL;
    typedef vector<int> VI;
    typedef pair<int, int> PII;

    const double PI = acos(-1.0);
    const int INF = 1000 * 1000 * 1000 + 7;
    const LL LINF = INF * (LL)INF;

    const double EPS = 1e-7;
    const int MAX = 20 * 1000 + 47;
    const int MAS = 1e5 * 3;
    const int MOD = 1000 * 1000 * 1000 + 7;

    double DIST(double x1, double x2, double y1, double y2)
    {
        return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
    }
    
    LL dp[3005][3005];
    int main()
    {
        int n;
        cin >> n; 
        vector<LL> a(n);
        rep(i, n)
        {
            cin >> a[i]; 
        }
        for (int l = n - 1; l >= 0; l--)
        {
            for (int r = l; r < n; r++)
            {
                if (l == r)
                {
                    dp[l][r] = a[l]; 
                }
                else
                {
                    dp[l][r] = max(a[l] - dp[l + 1][r], a[r] - dp[l][r -1]); 
                }
            }
        }
        cout << dp[0][n - 1] << endl;   

    }









Measured memory_bytes: 70016
N, M = map(int, input().split())
from_1 = [False]*N
to_N = [False]*N
for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        from_1[b-1] = True
    elif b == N:
        to_N[a-1] = True
for i in range(1, N):
    if from_1[i] and to_N[i]:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 6132
import numpy as np
if __name__ == "__main__":
    A, B, C, K = map(int, input().split())
    ans = 0
    loop = min(A, K)
    K = K - loop
    ans += loop
    loop = min(B, K)
    K = K - loop
    # +-0
    loop = min(C, K)
    K = K - loop
    ans -= loop
    print(ans)

Measured memory_bytes: 27120
! 2019.10.19
!
      program answer
      implicit none
      integer :: N
      integer,allocatable,dimension(:) :: d
      integer :: i,j
      integer :: ans
!
      read(*,*) N
      allocate(d(N))
      read(*,*) (d(i),i=1,N)
!
      ans = 0
!
      do i=1,N-1
        do j=i+1,N
          ans = ans + d(i) * d(j)
        end do
      end do
!
      write(*,*) ans
      end program answer


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

using namespace std;
using ll = long long int;

int main()
{
    int n;
    ll k;
    cin >> n >> k;

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

    int current = 1;
    int index = 1;
    vector<int> sequence;
    unordered_map<int, int> indexes;
    int begin = -1;
    while (true)
    {
        auto &elem = indexes[current];
        if (elem != 0)
        {
            begin = elem - 1;
            break;
        }
        sequence.push_back(current);
        elem = index;

        current = A[current - 1];
        index++;
    }

    if (k < sequence.size())
    {
        cout << sequence[k] << endl;
    }
    else
    {
        int rem = (k - begin) % (sequence.size() - begin);
        cout << sequence[begin + rem] << endl;
    }
}

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

int main() {
  int n, l;
  string s[100];
  cin >> n >> l;
  for (int i = 0; i < n; i++) cin >> s[i];
  sort(s, s + n);
  for (int i = 0; i < n; i++) cout << s[i];

  return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String str = br.readLine();
    	final int A = Integer.parseInt(str.split(" ")[0]);
    	final int B = Integer.parseInt(str.split(" ")[1]);
    	final int C = Integer.parseInt(str.split(" ")[2]);

    	int max = B / A;
    	if (max < C) {
    		System.out.println(max);
    	} else {
    		System.out.println(C);
    	}
	}
}


Measured memory_bytes: 23252
ans = 0
a = input()
num_len = len(a)
num = [k for k in a]
for i in range(1,num_len):
  if num[i] != "9":
    num[i-1]= chr(ord(num[i-1])-1)
    for j in range(i,num_len):
      num[j] = "9"
    break
for w in num:
  ans = ans + int(w)
print(ans)

Measured memory_bytes: 3064
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> S(M);
  vector<int> C(M);
  rep(i, M) { cin >> S[i] >> C[i]; }

  if (N == 1) {
    for (int n = 0; n <= 9; ++n) {
      bool flag = true;
      rep(i, M) {
        if (S[i] == 1) {
          if (C[i] != n) flag = false;
        } else {
          flag = false;
        }
      }
      if (flag) {
        cout << n << endl;
        return 0;
      }
    }
  } else if (N == 2) {
    for (int n = 10; n <= 99; ++n) {
      bool flag = true;
      rep(i, M) {
        if (S[i] == 1) {
          if (C[i] != (n / 10)) flag = false;
        } else if (S[i] == 2) {
          if (C[i] != (n % 10)) flag = false;
        } else {
          flag = false;
        }
      }
      if (flag) {
        cout << n << endl;
        return 0;
      }
    }
  } else {
    for (int n = 100; n <= 999; ++n) {
      bool flag = true;
      rep(i, M) {
        if (S[i] == 1) {
          if (C[i] != (n / 100)) flag = false;
        } else if (S[i] == 2) {
          if (C[i] != ((n / 10) % 10)) flag = false;
        } else if (S[i] == 3) {
          if (C[i] != (n % 10)) flag = false;
        } else {
          flag = false;
        }
      }
      if (flag) {
        cout << n << endl;
        return 0;
      }
    }
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h> 
int ans;
long long f[1000000];
long long jiequ(int x);
int main()
{
	int n;
	scanf("%d",&n);
	jiequ(n);
	printf("%lld\n",jiequ(n));
	return 0;
}

long long jiequ(int x){
	int i;
	f[0]=2;
	for(i=1;i<=x;i++){
		f[i]=f[i-1]*2+2;
	}
	if(x<=0){
		return 2;//q
	}else{
		
		return f[x-1]*2+2;
		
	}
	
}

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

class P
{
    static void Main()
    {
        int[] qhsd = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long n = int.Parse(Console.ReadLine());
        long lit = Math.Min(Math.Min(qhsd[0] * 4, qhsd[1] * 2), qhsd[2]);
        bool is2lisChaper = lit * 2 > qhsd[3];
        Console.WriteLine(is2lisChaper ? (n / 2) * qhsd[3] + (n % 2) * lit : n * lit);
    }
}

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

int main ()
{
  int N,a,b;
  cin >> N;
  int c = N;
  
  while(N > 0){
    a = N % 10;
  	N = N / 10;
  	b += a;
  }
  
  if(c % b == 0){
   cout << "Yes" << endl; 
  }else{
   cout << "No" << endl; 
  }
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m, k;

ll po(ll a, ll b, ll c, ll d){
	ll ans = 0;
	ans += a*(1+a+b)*(b+1)/2;
	ans += b*(1+b+c)*(c+1)/2;
	ans += c*(1+c+d)*(d+1)/2;
	ans += d*(1+d+a)*(a+1)/2;
	//print(ans)
	return ans%MOD;
}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m >> k;
	ll ans = 0;
	rep(i, 1, n){
		rep(j, 1, m){
			ans += po(i-1, j-1, n-i, m-j);
		}
	}
	ans /= 2;
	ans %= MOD;
	//print(ans)
	COMinit();
	ans *= COM(n*m-2, k-2);
	ans %= MOD;
	print(ans)
	return 0;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,m,x=0,y=0,z=0;
    cin>>n>>m;
    x+=m/10000;
    m%=10000;
    y+=m/5000;
    m%=5000;
    z+=m/1000;
    m%=1000;
    if(x+y+z>n)
    {
        x=-1;
        y=-1;
        z=-1;
    }
    else
    {

        int cur=x+y+z;
        int need=n-cur;
        while(x && need/9)
        {
            int div=need/9;
            if(div)
            {
                int sub=min(x,div);
                x-=sub;
                z+=10*sub;
            }
            need=n-(x+y+z);
        }
        while(x && need/1)
        {
            int div=need/1;
            if(div)
            {
                int sub=min(x,div);
                x-=sub;
                y+=2*sub;
            }
            need=n-(x+y+z);
        }
        while(y && need/4)
        {
            int div=need/4;
            if(div)
            {
                int sub=min(y,div);
                y-=sub;
                z+=5*sub;
            }
            need=n-(x+y+z);
        }
        if(need!=0)
        {
            x=-1;
            y=-1;
            z=-1;
        }
    }
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}


Measured memory_bytes: 3564
n , k , q = map(int,input().split())
a = [int(input()) for x in range(q)]
P = [k-q]*(n+1)
for x in a:
    P[x] +=1

ans = '\n'.join('No'if x <=0 else 'Yes' for x in P[1:])
print(ans)

Measured memory_bytes: 11308
n, x = map(int, input().split())
li_a = list(map(int, input().split()))
s = []
for i in range(n-1):
    s.append(li_a[i]+li_a[i+1])
ans = 0
for i in range(n-1):
    if s[i] >= x:
        k = s[i] - x
        if li_a[i+1] >= k:
            ans += s[i] - x
            if i != n-2:
                s[i+1] -= k
                li_a[i+1] -= k
        else:
            ans += s[i] - x
            if i != n-2:
                s[i+1] -= li_a[i+1]
                li_a[i] -= k-li_a[i+1]
print(ans)

Measured memory_bytes: 90768
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
    ll AB, BC, CA;
    cin >> AB >> BC >> CA;
    cout << (AB * BC) / 2 << endl;
    return 0;
}


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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29


int main(){


long long int n;
cin >> n;

long long int a;
map<long long int,long long int> m;
for(int i=0;i<n;i++){
cin >> a;
if(m[a]==1)m.erase(a);
else m[a]++;
}

	cout <<(int)m.size();


}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int n,r;
    cin >>n>>r;

    if(n >= 10){
        ans = r;
    }else{
        ans = r + 100*(10 - n);
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#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 <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int N, M; cin >> N >> M;
    P ab[M];
    REP(i, M) {
        int a, b; cin >> a >> b;
        ab[i] = {b, a};
    }
    sort(ab, ab+M);

    int now = 0;
    int ans = 0;
    REP(i, M) {
        int l = ab[i].second;
        int r = ab[i].first;
        if (l >= now) {
            ans++;
            now = r;
        }
    }

    cout << ans << "\n";

    return 0;
}


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

using namespace std;

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

    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    if (a == b && b == c) {
        cout << -1 << endl;
        return 0;
    }

    int cnt = 0;
    while (true) {
        if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
            cout << cnt << endl;
            break;
        }
        int na, nb, nc;
        na = (b + c) / 2;
        nb = (a + c) / 2;
        nc = (b + a) / 2;
        a = na;
        b = nb;
        c = nc;
        cnt++;
    }

    return 0;
}


Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(X, A, "+", B) :- X is A + B.
f(X, A, "-", B) :- X is A - B.

main :-
    get_number(A),
    get_string(S),
    get_number(B),
    f(X, A, S, B),
    writeln(X).


Measured memory_bytes: 8144
#include <iostream>

using namespace std;

int calc(int x) {
  int res = 0;
  for (int i = 1; i <= x; ++i) {
    if (x % i == 0) {
      ++res;
    }
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    if (calc(i) == 8) {
      ++ans;
    }
  }
  cout << ans << endl;
}


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

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int x = in.nextInt();
        int b = in.nextInt();
        if (x >= b) {
            System.out.println(10);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 23124
#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() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      int z = s - x - y;
      if (z >= 0 && z <= k) ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
int main(void){
    string s;
    cin >> s;
    int ans;
    if(s == "SUN") ans = 7;
    if(s == "MON") ans = 6;
    if(s == "TUE") ans = 5;
    if(s == "WED") ans = 4;
    if(s == "THU") ans = 3;
    if(s == "FRI") ans = 2;
    if(s == "SAT") ans = 1;
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vl a(n);
    ll sum=0;
    rep(i,n){
        cin >> a[i];
    }
  sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    rep(i,n){
        if(i==0){
            continue;
        }
        sum+=a[i/2];
    }
    cout << sum << '\n';
}

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

typedef long long ll;
typedef unsigned long long ull;

#define PrintLn(X) cout << X << endl
#define Loop(n) for(int loop_ = n; loop_; --loop_)
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, a, b) for(int i = a; i < (int)(b); ++i)

int N;
char ans[100001] = {0};
char s[100001];
bool f(char fst, char snd)
{
	ans[0] = fst;
	ans[1] = snd;
	for(int i = 1; i <= N - 2; i++){
		if(ans[i] == 'S'){
			if(!((ans[i - 1] == 'S') ^ (s[i] == 'o'))){
				ans[i + 1] = 'S';
			}else{
				ans[i + 1] = 'W';
			}
		}else{
			if(!((ans[i - 1] == 'S') ^ (s[i] == 'x'))){
				ans[i + 1] = 'S';
			}else{
				ans[i + 1] = 'W';
			}
		}
	}
	if(!((ans[0    ] == 'S') ^ !((s[0    ] == 'o') ^ (ans[N - 1] != ans[1])))) return false;
	if(!((ans[N - 1] == 'S') ^ !((s[N - 1] == 'o') ^ (ans[N - 2] != ans[0])))) return false;
	PrintLn(ans); 
	return true;
}
int main(void)
{
	cin >> N;
	cin >> s;
	if(f('S', 'S')) {return 0;}
	if(f('S', 'W')) {return 0;}
	if(f('W', 'S')) {return 0;}
	if(f('W', 'W')) {return 0;}
	PrintLn("-1");
	return 0;
}


Measured memory_bytes: 512
import numpy
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]

count = 0
for i in range(n):
    if numpy.dot(a[i], b) + c > 0:
        count += 1

print(count)


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

int main(){
  int n;
  cin>>n;
  int ans[n*n];
  for(int i=0;i<n*n;i++){
    ans[i]=0;
  }
  int vec[n];
  int copyvec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
    copyvec[i]=vec[i];
    ans[vec[i]-1]=i+1;
  }
  int vecb[n];
  for(int i=0;i<n;i++){
    vecb[i]=i;
  }
  sort(copyvec,copyvec+n);
  int vecc[n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(copyvec[i]==vec[j]){
        vecc[i]=j;
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<vec[vecc[i]];j++){
      if(ans[j]==0){
        if(vecb[vecc[i]]>0){
          ans[j]=vecc[i]+1;
          vecb[vecc[i]]--;
          if(vecb[vecc[i]]==0){
            break;
          }
        }
      }
    }
  }
  for(int i=0;i<n;i++){
    vecb[i]=n-i-1;
  }
  for(int i=n*n-1;i>=0;i--){
    if(ans[i]==0){
      for(int j=n-1;j>=0;j--){
        if(vecb[vecc[j]]>0){
          ans[i]=vecc[j]+1;
          vecb[vecc[j]]--;
          break;
        }
      }
    }
  }
  int x[n+3];
  for(int i=0;i<n+3;i++){
    x[i]=0;
  }
  for(int i=0;i<n*n;i++){
    x[ans[i]]++;
    if(x[ans[i]]==ans[i]){
      if(i+1!=vec[ans[i]-1]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  for(int i=1;i<n;i++){
    if(x[i]!=n){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  for(int i=0;i<n*n;i++){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 2176
import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

if max(A)==0:
    print("Yes")
    sys.exit()

from collections import Counter
C=Counter(A)

flag=1

if len(C)==3:
    
    if N%3!=0:
        flag=0

    for v in C.values():
        if v!=N//3:
            flag=0

    A=0
    for k in C.keys():
        A^=k

    if A!=0:
        flag=0


elif len(C)==2:

    if N%3!=0:
        flag=0

    if not (0 in C.keys()):
        flag=0

    
    if C[0]!=N//3:
        flag=0

else:
    flag=0
    
if flag==1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14104
// 2017/12/11 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		string s1;
		cin >> s1;

		if(s1==".")
			break;

		string s2;
		cin >> s2;

		if(s1==s2){
			cout << "IDENTICAL" << endl;
			continue;
		}

		string t1 = s1;
		string t2 = s2;

		while(true){
			size_t d1b = t1.find('\"');
			if(d1b==string::npos)
				break;
			t1.replace(d1b, 1, "@");

			size_t d1e = t1.find('\"');
			t1.replace(d1e, 1, "@");

			size_t d2b = t2.find('\"');
			if(d2b==string::npos)
				break;
			t2.replace(d2b, 1, "@");

			size_t d2e = t2.find('\"');
			t2.replace(d2e, 1, "@");

			string u1 = s1;
			u1.replace(d1b+1, d1e-d1b-1, "");
			string u2 = s2;
			u2.replace(d2b+1, d2e-d2b-1, "");

//			cout << u1 << endl;
//			cout << u2 << endl;

			if(u1==u2){
				t1 = u1;
				t2 = u2;
				break;
			}
		}

		if(t1==t2){
			cout << "CLOSE" << endl;
		}
		else{
			cout << "DIFFERENT" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3100