akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(kbrni,n)cout<<" "<<a[kbrni];cout<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define svecp(v) cout<<#v<<":";each(kbrni,v)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

class KMP
{
public:
    string pattern;
    int plen;
    vector<int> table;
    KMP(const string s) : pattern(s), plen((int)pattern.size()), table(plen+1){
        table[0] = -1;
        int j = -1;
        for(int i = 0; i < plen; i++){
            while(j >= 0 && pattern[i] != pattern[j]) j = table[j];
            if(pattern[i+1] == pattern[++j]) table[i+1] = table[j];
            else table[i+1] = j;
        }
    }
    void search(const string& text, vector<int>& res){
        int head = 0, j = 0, tlen = (int)text.size();
        while(head + j < tlen){
            if(pattern[j] == text[head + j]){
                if(++j != plen) continue;
                res.push_back(head);
            }
            head += j - table[j], j = max(table[j], 0);
        }
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string t,p;
    cin >> t >> p;
    KMP kmp(p);
    vi res;
    kmp.search(t, res);
    rep(i,len(res)){
        cout << res[i] << "\n";
    }
}



Measured memory_bytes: 8980
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n,f=1,c=0;
	cin>>n;
	vi v(n);
	REP(i,0,n-1)cin>>v[i];
	REP(i,0,n-1){
		if(v[i]==f)
			f++;
		else
			c++;
			
	}
	if(c==n)cout<<-1;
	else cout<<c;
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 4824
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int in;
    int n;cin >> n;
    multiset<int> s;
    for(int i = 0; i < (1 << n); i++){
        cin >> in;
        s.insert(in);
    }
    int back = *s.rbegin();
    s.erase(--s.end());
    vi vec; 
    vec.pb(back);
    for(int i =1; i <= n; i++){
       vi toAdd;
       for(int x: vec){
          auto it = s.lower_bound(x);
          if(it == s.begin()){
            cout << "No" <<endl;
            return 0;
          }
          it--;
          toAdd.pb(*(it));
          s.erase(it);
       } 
       vec.insert(vec.end(), toAdd.begin(), toAdd.end());
    }

    cout << "Yes" <<endl;


}




Measured memory_bytes: 15460
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        String op = sc.next();
        int B = sc.nextInt();
        System.out.println(op.equals("+") ? A + B : A - B);
    }
}


Measured memory_bytes: 21716
Sa = input()
Sb = input()
Sc = input()

dic = {'a':Sa, 'b':Sb, 'c':Sc}

doCont = True
person = 'a'
result = ''
while doCont:
  if (len(dic[person]) == 0):
    doCont = False
    result = person.upper()
    break

  drop_card = dic[person][0]
  dic[person] = dic[person][1:]
  person = drop_card

print(result)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    
    long long a,b,i=1;
    cin >> a >> b;
    
    if(a>b){
        swap(a,b);
    }
    
    for (;;){
        if ((i * a) % b == 0){
           break ;
        }else{
            i++;
        }
    }
    
     cout << a * i << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	
	public static int sumOfDigit(int n) {
		int sum = 0;
		
		while(n > 0) {
			sum += n  % 10;
			n /= 10;
		}
		return sum;
	}
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int total = 0;
		
		for(int i = 1; i <= n; i++) {
			int sum = sumOfDigit(i);
			if(sum >= a && sum <= b) {
				total += i;
			}
		}
		
		System.out.println(total);
	}

}

Measured memory_bytes: 23252
#include <stdio.h>
#include<math.h>
#define PI 3.141592653589793
int main(void){
    int a,b,C;
    double rad,S,L,h;
    scanf("%d %d %d",&a,&b,&C);
    rad=C*PI/180.0;
    S=a*b*sin(rad)/2;
    L=sqrt(a*a+b*b-2*a*b*cos(rad))+a+b;
    h=b*sin(rad);
    printf("%.8f %.8f %.8f\n",S,L,h);
    return 0;
    
}



Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    ll x = max({a, b, c});
    
    if( (a+b+c)%2 == x%2 ) {
        out((3*x - (a+b+c))/2);
    }
    else {
        out((3*(x+1) - (a+b+c))/2);
    }
    
    re0;
}

Measured memory_bytes: 256
# Prime numbers
import math
import random
def miller_rabin_test(n, k=20):
    """n > 2????´???°???????????????"""
    if n == 2: return True
    li = []
    if n % 2 == 0:
        return False
    s = 0
    n1 = n - 1
    d = n1
    while d % 2 == 0:
        s += 1
        d //= 2
    for i in range(k):
        a = random.randint(1, n1)
        first = 1 != pow(a, d, n)
        li.clear()
        for r in range(0, s): # 0~s-1?????????
            result = pow(a, pow(2,r)*d, n)
            li.append(result)
        if first and li.count(n1) == 0:
            return False # ????????°
    return True
counter = 0
for _ in range(int(input())):
	if miller_rabin_test(int(input())): counter += 1
print(counter)


Measured memory_bytes: 11656
#include<iostream>

using namespace std;

void Calculate(int, int&, int&);

int main(){
  int n, m, count;

  while(1){
    cin >> n;
    if(n == 0) break;

    n = 1000 - n;
    count = 0;

    Calculate(500, n, count);
    Calculate(100, n, count);
    Calculate(50, n, count);
    Calculate(10, n, count);
    Calculate(5, n, count);
    Calculate(1, n, count);

    cout << count << endl;
  }

  return 0;
}

void Calculate(int m, int& n, int& count){
  int x;

  while(1){
    x = n - m;
    if(x < 0) break;
    ++count;
    n = x;
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    fast_io();
    
    ll n,m;
    cin >> n >> m;

    vll h(n);
    rep(i,n) cin >> h[i];

    vll max_memo(n);

    rep(i,m){
        ll a,b;
        cin >> a >> b;
        assign_max(max_memo[a-1],h[b-1]);
        assign_max(max_memo[b-1],h[a-1]);
    }
    
    ll count = 0;
    rep(i,n){
        if(h[i] > max_memo[i]) count++;
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 4432
/* ITP1_5_D: Structured Programming */

#include <iostream>
using namespace std;

void call(int n) {
    for (int i = 1; i <= n; i++) { // CHECK_NUM:
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        }
        else {
            do { // INCLUDE3:
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
            } while (x /= 10);
        }
    }
    cout << endl;
}

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    call(n);

    return 0;
}

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

namespace ABC058A___ι_l
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] pillars = input.Split(' ');
            int a = int.Parse(pillars[0]);
            int b = int.Parse(pillars[1]);
            int c = int.Parse(pillars[2]);

            string result = "NO";
            bool isBeauty = (2 * b - a - c == 0);

            if (isBeauty)
            {
                result = "YES";
            }

            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 13140
n,m = map(int,input().split())
c = []
for i in range(m):
    a,b =  map(int,input().split())
    if a == 1:
        c.append(b)
    if b == n:
        c.append(a)
        
if len(c) == len(set(c)):
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Measured memory_bytes: 23288
A, B, C, D, E, F = map(int, input().split())

w = set()
for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = (A * i + B * j) * 100
        if a < F:
            w.add(a)
w.remove(0)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    t = min(F - a, E * a // 100)
    for i in range(t // C + 1):
        for j in range(t // D + 1):
            b = C * i + D * j
            if a + b > F:
                continue
            if b > E * a // 100:
                continue
            concentration = 100 * b / (a + b)
            if concentration > best_concentration:
                best_concentration = concentration
                best_a = a
                best_b = b
print(best_a + best_b, best_b)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int D, N;
int A[100], E[100], R[100];
int DP[101][101];
int main()
{
	while (true){
		int ans = 100000;
		scanf("%d%d", &D, &N);
		if (D == 0 && N == 0)return 0;
		for (int i = 0; i < N; i++){
			scanf("%d%d%d", &A[i], &E[i], &R[i]);
		}
		for (int i = 0; i <= 100; i++)for (int j = 0; j <= 100; j++)DP[i][j] = 100000;
		DP[0][0] = 0;
		for (int i = 0; i <= D; i++){
			for (int j = 0; j <= 100; j++){
				if (DP[i][j] == 100000)continue;
				for (int k = 0; k < N; k++){
					if (R[k]>j)continue;
					DP[min(100, i + A[k])][min(100,j + E[k])] = min(DP[min(100, i + A[k])][min(100,j + E[k])], DP[i][j] + 1);
				}
			}
		}
		
		for (int i = D; i <= 100; i++){
			for (int j = 0; j <= 100; j++){
				if (DP[i][j] != 100000){
					ans = min(ans, DP[i][j]);
				}
			}
		}
		if (ans == 100000)printf("NA\n");
		else printf("%d\n", ans);
	}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int N,M,C;
	cin>>N>>M>>C;
	vector<int>v(M);
	for(auto& i: v){
		cin>>i;
	}
	int ans=0;
	REP(i,N){
		int s=C;
		REP(i,M){
			int a;
			cin>>a;
			s+=a*v[i];
		}
		if(s>0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int k = Integer.parseInt(sc.next());
		int s = Integer.parseInt(sc.next());

		int ans = 0;
		for(int x=0; x<=k; x++){
			for(int y=0; y<=k; y++){
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    
    ll x = b/c - (a-1)/c;
    //if(a%c==0) x++;
    ll y = b/d - (a-1)/d;
    //if(a%d==0) y++;

    ll kosuu = b-a+1;
    ll e = __gcd(c,d);
    e = (c*d)/e;

    ll z = b/e - (a-1)/e;

    cout << b-a + 1 -x -y +z << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;
	int i;
	int first = 1;
	int na;

	scanf("%d %d", &a, &b);
	while (a != 0 || b != 0){
		if (first != 1){
			printf("\n");
		}
		else {
			first = 0;
		}

		na = 1;
		for (i = a; i <= b; i++){
			if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0){
				printf("%d\n", i);
				na = 0;
			}
		}
		if (na == 1){
			printf("NA\n");
		}

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

	return (0);
}

Measured memory_bytes: 616
import math
a, b, h, m = map(int, input().split())
if abs(6 * m - 0.5 * m - 30 * h) > 180:
    aida_kaku = 360 - abs(6 * m - 0.5 * m- 30 * h)
else:
    aida_kaku = abs(6 * m - 0.5 * m - 30 * h)

aida_rad = math.radians(aida_kaku)
c_2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(aida_rad)
print(math.sqrt(c_2))

Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MAXN 3009

ll dp[MAXN][MAXN], n, seq[MAXN];

ll calc(int i, int j, bool taro){
    if (dp[i][j] != -1) return dp[i][j];
    if (i == j && taro) return dp[i][j] = seq[i];
    if (i == j && !taro)    return dp[i][j] = 0;
    if (taro)
        return dp[i][j] =  max(seq[i] + calc(i + 1, j, !taro), seq[j] + calc(i, j - 1, !taro));
    return dp[i][j] = min(calc(i + 1, j, !taro), calc(i, j - 1, !taro));
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    memset(dp, -1, sizeof dp);
    ll sum = 0;
    cin >> n;
    rep(i, 0, n)cin >> seq[i], sum += seq[i];
    cout << calc(0, n - 1, 1) - ((ll)sum - dp[0][n-1]) << '\n';
    return 0;
}


Measured memory_bytes: 71296
#include<bits/stdc++.h>
using namespace std;
int main(void){
	long long x,k,d,o,p;
	cin >> x >> k >> d;
	x = abs(x);
	o = x /d;	
	p = x % d;
	if(o <= k){
		if((k - o) % 2 == 0)	cout << p << endl;
		else					cout << abs(p - d) << endl;		
	}
	else{
		cout << x - d * k << endl;
	}
	return 0;
}
	

Measured memory_bytes: 3596
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const double PI = 3.141592653589793238462643383;

int main() {
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  long double kaku,hs,ms;
  hs = h*30+m*0.5;
  ms = m*6;
  if (hs > ms) kaku = hs-ms;
  else kaku = ms-hs;
  long double ans;
  long double aabb = double(a*a+b*b);
  ans = aabb - 2*a*b*cos(kaku * PI / 180.0);
  ans = sqrt(ans);
  printf("%.20Lf\n", ans);
  // cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 3488
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
string a;
int main()
{
	cin>>a;
	int n,s=0; 
	n=a.size();
	for(int i=0;i<n;++i)	
    {
		if(a[i]=='C') 
		{
			for(int j=i+1;j<n;j++)
            {
            	if(a[j]=='F')
            	{
            	    s++;
            	}
            }
        
		}
	}
	if(s!=0)
	 cout<<"Yes";
	else
	 cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ;count = 0 ;pro = 1

n=int(input())
a=int(input())
n%=500
if n<=a:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3808
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    int n, m;
    int a[101];
    cin >> n >> m;
    rep(i, n) cin >> a[i];
    int to = 0;
    rep(i, n) {
        to += a[i];
    }
    // int z = to / (4*m);
    
    int count = 0;

    rep(i, n) {
        if (a[i]*4*m >= to) count += 1;
    }
    if (count < m) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<char>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    ll s, w;
    cin >> s >> w;
    if(s <= w){
        cout << "unsafe";
    }else{
        cout << "safe";
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    ll ans = 0;
    for (int i = 1; i <= N; ++i) ans += (ll)i * (N-i+1);

    rep(i, N-1) {
        int v, u;
        cin >> v >> u;
        if (v > u) swap(v, u);
        ans -= (ll)v * (N-u+1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3460
#include <iostream>
#include <vector>
#include <climits>
#include <stack>
#include <cstdio>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <regex>
#include <algorithm>
#include <math.h>
#include <string>
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 ALL(obj) obj.begin(), obj.end()
#define UNIQUE(v) v.erase(unique(All(v)), v.end());
typedef long long ll;

typedef pair<int, int> P;
vector<P> vecp;
int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1};

#define N 1000
// input

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  if (a < b){
    REP(i,b){
      cout << a;
    }
  }else{
    REP(i,a){
      cout << b;
    }
  }
}

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

#define ll long long
#define rep(i,n) for(int i=0;(i)<n;i++)

using namespace std;

int main()
{
	string s; cin>>s;
	ll ans = 700;
	rep(i, 3){
		if (s[i]=='o') ans+=100;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  string s;
  cin >> s;
  int n = int(s.size());
  vector<int> ans(n);
  rep(ri,2){
    int cnt = 0;
    rep(i,n){
      if(s[i]=='R'){
        cnt++;
      }else{
        ans[i] += cnt/2;
        ans[i-1] += (cnt+1)/2;
        cnt = 0;
      }
    }
    reverse(ans.begin(),ans.end());
    reverse(s.begin(),s.end());
    rep(i,n){
      if(s[i]=='R'){
        s[i] = 'L';
      }else{
        s[i] = 'R';
      }
    }
  }
  rep(i,n){
    cout << ans[i] << endl;
  }
  return 0;

}

Measured memory_bytes: 3840
import scala.collection.mutable.Stack

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val e = List.fill(n-1)((sc.nextInt()-1, sc.nextInt()-1, sc.nextLong()))
  val adj = Array.fill(n)(List[(Int, Long)]())
  for ((a, b, c) <- e) {
    adj(a) ::= (b, c)
    adj(b) ::= (a, c)
  }
  val q = sc.nextInt()
  val k = sc.nextInt()-1
  val xy = List.fill(q)((sc.nextInt()-1, sc.nextInt()-1))

  val d = Array.fill(n)(-1L)
  d(k) = 0
  val stack = Stack(k)
  while (stack.nonEmpty) {
    val u = stack.pop()
    for ((v, c) <- adj(u) if d(v) == -1) {
      stack.push(v)
      d(v) = d(u) + c
    }
  }

  val pw = new java.io.PrintWriter(Console.out)
  for ((x, y) <- xy) {
    pw.println(d(x) + d(y))
  }
  pw.flush()
}


Measured memory_bytes: 97484
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        int a,b,sub1,sub2;
        Scanner in= new Scanner(System.in);
        a=in.nextInt(); b=in.nextInt();
        sub1=a+b;
        if(sub1%2==0)
            System.out.println(""+(sub1/2));
        else
            System.out.println("IMPOSSIBLE");
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define ll long long
#define ull unsigned long long
#define MOD  1000000007
#define MAX  1e9
#define pb   push_back
#define F    first
#define S    second

ll calc(vector<vector<char>> v, ll n, ll m){
	vector<vector<ll>> dp(n, vector<ll>(m,0));
	dp[0][0] = 1;
	for(ll i = 0; i < n; ++i){
		for(ll j = 0; j < m; ++j){
			if(v[i][j] == '#')
				continue;
			ll a = 0, b = 0;
			if(i-1>=0) a = dp[i-1][j];
			if(j-1>=0) b = dp[i][j-1];
			dp[i][j] = ((dp[i][j] + a)%MOD + b)%MOD;
			// cout<<dp[i][j]<<" ";
		}
		// cout<<endl;
	}
	return dp[n-1][m-1];
}

signed main() {
	ll t=1;
	//cin>>t;
	while(t--){
		ll n,m;
		cin>>n>>m;
		vector<vector<char>> v(n, vector<char>(m));
		rep(i,n){
			rep(j,m){
				cin>>v[i][j];
			}
		}
		cout<<calc(v,n,m);
		
	}
	
}

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

long long gcd(long long x, long long y) {
	if(y == 0) return x;
	else return gcd(y, x % y);
}

int main() {
	int c[3][3];
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> c[i][j];
		}
	}

	int a[3] = {}, b[3];
	for(int i = 0; i < 3; i++) b[i] = c[0][i];
	a[1] = c[1][0] - b[0];
	a[2] = c[2][0] - b[0];
	bool ok = true;
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if(c[i][j] != a[i] + b[j]) {
				ok = false;
				break;
			}
		}
	}

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


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

#define ll long long
#define SZ(x) ((int)(x).size()) 
#define ALL(v) (v).begin(), (v).end()
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define reveach(i, v) for (__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++ i) 
#define REP(i,a,n) for ( int i=a; i<int(n); i++ )
#define FOR(i,a,n) for ( int i=n-1; i>= int(a);i-- )
#define lson rt<<1, L, m
#define rson rt<<1|1, m, R
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fi first
#define se second
#define CLR(a, b) memset(a, b, sizeof(a))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

const int N = 3001;
int vis[N];
const int limit=3000;
bool isprime[limit+1];
vector<ll> prime;
 
void init(){
	REP(i, 0, limit+1) isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(ll i=2;i*i<=limit;++i){
		if(isprime[i]){
			prime.push_back(i);
			for(ll j=i*i;j<=limit;j+=i)
				isprime[j]=false;
		}
	}
	return;
}
map<ll, int> cnt;
int main(){
#ifdef ac
	freopen("in.txt","r",stdin);
#endif
	//freopen("out.txt","w",stdout);
    init();
    int m = prime.size();
    int n;
    cin >> n;
    REP(i, 0, n){
        ll cur;
        cin >> cur;
        REP(j, 0, m){
            ll cube = 1ll * prime[j] * prime[j] * prime[j];
            while(cur % cube == 0) cur /= cube;
        }
        cnt[cur] ++;
    }
    ll ans = 0ll;
    for(auto &it : cnt){
        if(it.fi == 1)
            ans += min<ll>(1ll, it.se);
        else{
            ll tar = 1ll * it.fi * it.fi;
            REP(j, 0, m){
                ll cube = 1ll * prime[j] * prime[j] * prime[j];
                while(tar % cube == 0) tar /= cube;
            }
            ans += max<ll>(it.se, cnt[tar]);
            it.se = 0ll;
            cnt[tar] = 0ll;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 21376
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if a[j]<a[minj]:
            minj=j
    a[i],a[minj]=a[minj],a[i]
    if i!=minj:c+=1
print(*a)
print(c)


Measured memory_bytes: 5600
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  int a,p,ans;
  cin>>a>>p;
  ans=(a*3+p)/2;
  cout<<ans;
  return 0;
}

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

int main()
{
    cin >> N;
    A.resize(N);
    int sum = 0;
    for (int i=0; i<N; i++)
    {
        cin >> A[i];
        sum += A[i];
    }

    bitset<2000*2000+1> dp(1);
    for (auto a : A) dp = dp | (dp << a);

    for (int i=(sum+1)/2; ;i++)
    {
        if (dp[i])
        {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 2176
import numpy as np

A, B, H, M = map(int, input().split())
a = np.array([[0., float(A)]])
b = np.array([[0., float(B)]])
hour_rad = -np.deg2rad(30.*H + 30. * float(M / 60))
hour_rotate = np.array([[np.cos(hour_rad), -np.sin(hour_rad)],
                        [np.sin(hour_rad), np.cos(hour_rad)]])
minute_rad = -np.deg2rad(6.*M)
minute_rotate = np.array([[np.cos(minute_rad), -np.sin(minute_rad)],
                        [np.sin(minute_rad), np.cos(minute_rad)]])
diff = np.dot(hour_rotate, a.T) - np.dot(minute_rotate, b.T)
d_pow = np.sum(diff ** 2)
d = np.sqrt(d_pow) if d_pow > 0. else 0.
print(d)

Measured memory_bytes: 27264
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, k;
    cin>>n>>k;
    int p[1010];
    for(int i=0; i<n; i++) cin>>p[i];
    sort(p, p+n);
    int ans=0;
    for(int i=0; i<k; i++) ans+=p[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3660
N = int(input())
S = input()
Flag = True
if N % 2 == 1:
  Flag = False
else:
  for i in range(0,int(N/2)):
    a = S[i]
    b = S[int(i+(N/2))]
    if a != b :
      Flag = False
if Flag == True:
  print('Yes')
elif Flag == False:
  print('No')


Measured memory_bytes: 3060
#include<iostream> 
#include<cstdio>
#include<cstdlib>
#include<algorithm>

using namespace std;

int a[100005];

int main() 
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	double cur=a[1];
	for(int i=2;i<=n;i++)
	{
		cur=(cur+a[i])/2;
	}
	cout<<cur;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+10;
ll a[N];
ll trgcd(ll a,ll b,ll c){
	return __gcd(__gcd(a,b),c);
}
int main(){
	int k;
	scanf("%d",&k);
	ll sum = 0;
	for(int i = 1; i <= k; i++)
	for(int j = 1; j <= k; j++)
	for(int c = 1; c <= k; c++){
		sum+=trgcd(i,j,c);
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 3820
#include <iostream>
using namespace std;
int main()
{
	int n, t, s[10], i, j;
	while (cin >> n && n)
	{
		for (i = 0; i < 10; i++)
			s[i] = 0;
		for (i = 0; i < n; i++)
		{
			cin >> t;
			s[t]++;
		}
		for (i = 0; i < 10; i++)
		{
			if (s[i] == 0)
				cout << "-" << endl;
			else
			{
				for (j = 0; j < s[i]; j++)
					cout << "*";
				cout << endl;
			}
		}
	}
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){
    int k,a,b;
    int largest;
    scanf("%d", &k);
    scanf("%d%d", &a, &b);
    largest = (b/k) * k;
    if(largest>=a){
        printf("OK");
    }else{
        printf("NG");
    }
    return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int64)n;i++)
#define FORr(i,k,n)  for(int64 i=(int64)k;i>=n;i--)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define FOREACHr(it, l) for (auto it = l.rbegin(); it != l.rend(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}


int main(){
	//in_o();
	int n,ans=0;
	string s;
	cin>>n;
	cin>>s;
	FOR(i,1,n){
		int tmp=0;
		FOR(j,0,26){
			if(s.substr(0,i).find((char)'a'+j)!=string::npos && s.substr(i,n-i).find((char)'a'+j)!=string::npos) tmp++;
		}
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

x = Intl()
print(x.index(0)+1)

Measured memory_bytes: 9208
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N, Y;

signed main()
{
	cin >> N >> Y;

	for (int i = 0; i <= 2000; i++)
	{
		for (int j = 0; j <= 2000; j++)
		{
			int a = i * 5000 + j * 10000;
			if (Y - a >= 0)
			{
				int k = (Y - a) / 1000;
				if (i + j + k == N)
				{
					cout << j << " " << i << " " << k << " " << endl;
					return 0;
				}
			}
		}
	}

	cout << "-1 -1 -1" << endl;
}



Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin>>v[i];
	sort(v.begin(),v.end());
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(v[i]+v[j]>v[k] && v[i]!=v[j] && v[j]!=v[k]){
//					cout<<v[i]<<' '<<v[j]<<' '<<v[k]<<endl;
					ans++;
				}
//				if(v[i]+v[j]==v[k] || v[i]==v[j] || v[j]==v[k]) continue;
//				cout<<v[i]<<' '<<v[j]<<' '<<v[k]<<endl;
//				ans++;
			}
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main()
{

    int n, m;

    cin >> n >> m;

    if(n < m)
    {
       for(int i = 0; i < m; i++)
       {
          cout << n;
       }
    }

    else
    {
       for(int i = 0; i < n; i++)
       {
          cout << m;
       }
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
	int n,m,k;
	cin>>n>>m>>k;
	int x;
	for(int i=0;i<n;i++)
	a[i]=m;
	for(int i=0;i<k;i++)
	{
		cin>>x;
		a[x-1]=a[x-1]+1;
	}
	int p;
	for(int i=0;i<n;i++)
	{
		p=a[i]-k;
		//cout<<p<<endl;
		if(p<1)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
long long f[500005], invf[500005];
const long long mod = 1e9+7;

long long power(long long a,long long b){
    long long res = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
        b /= 2;
    }
    return res;
}

long long inv(long long u){ return power(u,mod-2); }

void preWork(int n){
    f[0] = invf[0] = 1;
    for(long long i = 1; i <= n; i++){
        f[i] = f[i-1]*i%mod;
        invf[i] = inv(f[i]);
    }
}

long long getComb(int n,int m){
    if(m>n || m<0) return 0;
    else{
        long long res = f[n]*invf[m]%mod;
        res = res*invf[n-m]%mod;
        return res;
    }
}

int main(){
    preWork(500000);
    int n,m;
    scanf("%d%d",&n,&m);
    long long sign = mod-1;
    long long ans = 0;
    for(int i = 0; i <= n; i++){
        long long cur = getComb(n,i)*getComb(m-i,n-i)%mod;
        cur = cur*f[n-i]%mod;
        //printf("i = %d: %lld\n",i,cur);
        if(i%2) cur = cur*sign%mod;
        ans = (ans+cur)%mod;
    }
    //printf("ans = %lld\n",ans);
    long long mul = getComb(m,n)*f[n]%mod;
    printf("%lld\n",ans*mul%mod);
    return 0;
}


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

int main() {
  int n=0, ans=0;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    int l=0,r=0;
    cin >> l >> r;
    
    ans += (r-l+1);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DRainFlowsIntoDams solver = new DRainFlowsIntoDams();
        solver.solve(1, in, out);
        out.close();
    }

    static class DRainFlowsIntoDams {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = in.nextInt();
            long m0 = 0;
            int add = 1;
            for (int i = n - 1; i >= 0; i--) {
                m0 += add * a[i];
                add *= -1;
            }
            long[] res = new long[n];
            res[0] = m0;
            out.print(res[0]);
            for (int i = 1; i < n; i++) {
                res[i] = 2 * (a[i - 1] - res[i - 1] / 2);
                out.print(" ");
                out.print(res[i]);
            }
        }

    }
}



Measured memory_bytes: 64664
m = []

def walk(i,j):
    stack = []
    stack.append((i,j))
    while stack:
        p = stack.pop()
        pi = p[0]
        pj = p[1]
        m[pi][pj] = 0
        for k in range(-1,2):
            for l in range(-1,2):
                a = pi+k
                b = pj+l
                if a < 0 or b < 0 \
                        or a >= len(m) or b >= len(m[a]):
                            pass
                elif m[a][b] == 0:
                    pass
                else:
                    stack.append((a,b))

while True:
    w, h = map(int, input().split())
    if w == 0: break
    for i in range(h):
        m.append(list(map(int, input().split())))
    ans = 0
    for i in range(len(m)):
        for j in range(len(m[i])):
            if m[i][j] == 1:
                walk(i,j)
                ans += 1
    print(ans)
    m = []

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

string solve() {
    int x, y; cin >> x >> y;

    // total # of lengs should be even
    if (y & 1) return "No";

    int b = y/2 - x;
    int a = x - b;

    if (a < 0 || b < 0) return "No";

    return (a + b == x) ? "Yes" : "No";
}

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

	cout << solve() << endl;
}


Measured memory_bytes: 3620
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		String[] s = new String[N];
		for(int i=0;i<N;i++){
			s[i]=nextString();
		}

		int M = nextInt();
		String[] t = new String[M];
		for(int i=0;i<M;i++){
			t[i]=nextString();
		}

		Arrays.sort(s);
		Arrays.sort(t);

		long ans =0;

		long tmp=0;
		for(int i=0;i<N;i++){
			tmp++;
			if(i!=N-1 && s[i].equals(s[i+1])){
				continue;
			}
			for(int k=0;k<M;k++){
				if(s[i].equals(t[k])){
					tmp--;
				}
			}
			ans = Math.max(ans, tmp);
			tmp=0;
		}
		System.out.println(ans);
	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23252