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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A == B && A != C) || (B == C && B != A) || (C == A && C != B)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long int lli;
    #define MAX 300005
    #define endl "\n"
    vector <lli > adj[MAX+5];
    lli ans[MAX];
    queue <lli> q;
    lli N,M;
    void BFS(int source, vector <lli> adj[MAX+5], vector <bool> &visited){
        visited[source] = true;
        q.push(source);
        while(!q.empty()){
            source = q.front();
            visited[source] = true;
            for(auto i = adj[source].begin(); i != adj[source].end(); i++){
                if(!visited[*i]){
                    visited[*i] = true;
                    ans[*i] = source;
                    q.push(*i);
                }
            }
            q.pop();
        }
    }
    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
       cin>>N>>M;   
       for(lli i = 0; i<M; i++){
           lli A,B;
           cin>>A>>B;
           adj[A].push_back(B);
           adj[B].push_back(A);
       }
       vector <bool> visited(N+5, 0);
       BFS(1,adj, visited);
       //cout<<endl;
       bool flag = true;
       for(lli i = 2; i<=N; i++){
           if(!ans[i])  
                flag = false;
       }
       if(flag){
           cout<<"Yes"<<endl;
            for(lli i = 2; i<=N; i++)
                cout<<ans[i]<<endl; 
       }
        else
        {
            cout<<"No"<<endl;
        }
        
    }

Measured memory_bytes: 17588
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll Gcd(ll x, ll y){
	if(y==0) return x;
	return Gcd(y,x%y);
}

int main(void) {
	ll a,b; cin >> a >> b;
	ll gcd = Gcd(a,b);
	ll ans=0;
	for(ll i=2; i*i<=gcd; i++){
		if(gcd%i) continue;
		ans++;
		while(gcd%i==0) gcd/=i;
	}
	if(gcd!=1) ans++;
	ans++;
	out(ans);
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  string S;
  cin >> S;
  int N = S.size();
  for (auto i = 1; i < N; ++i) {
    string T = S.substr(0, N-i);
    int M = T.size();
    if (M % 2 == 0) {
      string X = T.substr(0, M/2);
      string Y = T.substr(M/2, M/2);
      if (X == Y) {
        cout << M << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
satisfy = 0
for i in range(N):
    satisfy += B[A[i]-1]
    if i <= N-2:
        if A[i+1]-A[i] == 1:
            satisfy += C[A[i]-1]
print(satisfy)

Measured memory_bytes: 61360
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)  	
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
const double pi = acos(-1.0);
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }
ll read()     //输入外挂
{
    ll res = 0, ch, flag = 0;
    if ((ch = getchar()) == '-')
        flag = 1;
    else if (ch >= '0' && ch <= '9')
        res = ch - '0';
    while ((ch = getchar()) >= '0' && ch <= '9')
        res = res * 10 + ch - '0';
    return flag ? -res : res;
}
ll a[maxn];
bool cmp(ll a, ll b) {
    return a > b;
}
int main() {
    ll n, m,sum=0;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum >= n) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1024
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    string s = to_string(n);
    string s2 = s;
    reverse(s2.begin(), s2.end());
    cout << (s == s2 ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;

typedef pair<char, char> P;

int N;
long long X[1010], Y[1010];

void input(){
	scanf("%d", &N);
	for(int i = 0; i < N; ++i){
		scanf("%lld%lld", X + i, Y + i);
	}
}

vector<long long> D;

string calc(long long val){
	string ans = "";
	long long cur = val;
	if(val % 2 != 0){
		for(int i = 0; i + 1 < D.size(); ++i){
			long long nxt;
			long long nxtm = cur - D[i];
			if(nxtm % (D[i] * 4) != 0){
				ans = ans + "+";
				nxt = nxtm;
			}else{
				ans = ans + "-";
				nxt = cur + D[i];
			}
			cur = nxt;
		}
		if(cur < 0) ans = ans + "-";
		else ans = ans + "+";
	}else{
		cur++;
		ans = "-";
		for(int i = 1; i + 1 < D.size(); ++i){
			long long nxt;
			long long nxtm = cur - D[i];
			if(nxtm % (D[i] * 4) != 0){
				ans = ans + "+";
				nxt = nxtm;
			}else{
				ans = ans + "-";
				nxt = cur + D[i];
			}
			cur = nxt;
		}
		if(cur < 0) ans = ans + "-";
		else ans = ans + "+";
	}
	return ans;
}

string restoreArm(long long x, long long y){
	string s1 = calc(x + y);
	string s2 = calc(x - y);
	string ans = "";
	for(int i = 0; i < s1.size(); ++i){
		pair<char, char> p = make_pair(s1[i], s2[i]);
		if(p == P('+', '+')) ans += "R";
		if(p == P('+', '-')) ans += "U";
		if(p == P('-', '+')) ans += "D";
		if(p == P('-', '-')) ans += "L";
	}
//	printf("%lld %lld:\n", x, y);
//	printf("%s %s\n", s1.c_str(), s2.c_str());
	return ans;
}

int main(){
	input();
	bool e = false, o = false;
	for(int i = 0; i < N; ++i){
		long long a = X[i] + Y[i];
		if(a % 2 == 0) e = true;
		else o = true;
	}
	if(e && o){
		printf("-1\n");
		return 0;
	}
	if(e){
		D.push_back(1);
		long long val = 1;
		while(val < 1e10){
			D.push_back(val);
			val *= 2;
		}
	}else{
		long long val = 1;
		while(val < 1e10){
			D.push_back(val);
			val *= 2;
		}
	}
	printf("%d\n", D.size());
	for(int i = 0; i < D.size(); ++i){
		printf("%lld%c", D[i], i + 1 == D.size() ? '\n' : ' ');
	}
	for(int i = 0; i < N; ++i){
		string str = restoreArm(X[i], Y[i]);
		printf("%s\n", str.c_str());
	}
	return 0;
}


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

int n;
long long Xor[300000];
long long Sum[300000];

long long ans = 0;

int main() {
    Xor[0] = 0;
    Sum[0] = 0;

    cin >> n;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        Xor[i] = Xor[i - 1] ^ a;
        Sum[i] = Sum[i - 1] + a;
    }

    for (int l = 1; l <= n; l++) {
        int low, mid, high;
        low = l;
        high = n;
        while (low <= high) {
            mid = (low + high) / 2;
            if ((Xor[mid] ^ Xor[l - 1]) < Sum[mid] - Sum[l - 1]) {
                high = mid - 1;
            } else {
                if(mid == n) break;
                if((Xor[mid + 1] ^ Xor[l - 1]) < Sum[mid + 1] - Sum[l - 1]) {
                    break;
                } else {
                    low = mid + 1;
                }
            }
        }
        ans += (mid - l + 1);
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3840
#include<iostream>
using namespace std;
int a[200050];
int main() {
	
	int n,i;
	cin >> n;
	for ( i = 0;i < n;i++) {
		cin >> a[i];
	}
	for (i =n-1;i >= 0;i-=2) {
		cout << a[i]<<" ";
	}
	i++;
	if (n % 2) i += 2;
	for (;i <= n-2;i += 2) {
			cout << a[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int n;
    int ans;
    cin>>n;
    if(n%2==0){
        ans=n/2;
        cout<<ans<<endl;
    }
    else{
        ans=n/2;
        cout<<ans+1<<endl;
    }

    
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def f(st, en):
    n = en - st + 1
    return n * (st + en) // 2

def main():
    N, K = LI()
    cnt = 0
    for i in range(K, N+2):
        m = f(0, i-1)
        M = f(N - (i-1), N)
        cnt += (M - m + 1)
        cnt %= mod
    print(cnt % mod)



main()



Measured memory_bytes: 10860
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = BigInteger.Parse(ReadLine());
        var m = BigInteger.Parse(ReadLine());
        if(n > m)
            WriteLine("GREATER");
        else if(n < m)
            WriteLine("LESS");
        else
            WriteLine("EQUAL");
    }
}


Measured memory_bytes: 18168
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <math.h> 

using namespace std;



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

	long long n, i, j, k, ans, carry, x;
	bool valid = true;

	cin >> n;
	vector<long long> a(n + 1), s(n + 2);
	for (i = 0; i <= n; i++) cin >> a[i];
	s[n + 1] = 0; 
	for (i = n; i >= 0; i--) s[i] = s[i + 1] + a[i];

	ans = 0;
	carry = 1;
	for (i = 0; i <= n; i++) {
		if (carry < a[i]) {
			valid = false;
			break;
		}
		
		carry -= a[i];
		carry = min(carry, s[i + 1]);

		ans += carry + a[i];

		carry *= 2;
	}

	if (!valid) ans = -1;
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 4768
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
a=0
N=int(input())
for i in range(1,N+1):
  for j in range(i,N+1):
    for k in range(j,N+1):
      if i==j==k:
        a+=i
      elif i==j or j==k or i==k:
        c=euclid(i, j)
        c=euclid(c, k)
        a+=3*c
      else:
        c=euclid(i, j)
        c=euclid(c, k)
        a+=6*c
print(a)

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

int main() {
    
    int a, b;
    cin >> a >> b;
    
    if ((b-1)%(a-1) == 0)
        cout << (b-1)/(a-1);
    else 
        cout << (b-1)/(a-1) + 1;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+5;
const long long inf=0x3f3f3f3f;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long n;
	cin>>n;
	if(n%2==0||n%5==0)
	{
		cout<<"-1\n";
		return 0;
	}
	long long x=7,ans=1;
	while(1)
	{
		if(x%n==0)
		{
			cout<<ans<<endl;
			return 0;
		}
		x=x%n;
		x=x*10+7;
		ans++;
	}
	return 0;
}




Measured memory_bytes: 3640
#include <iostream>
#include <cstring>
#define Max 100
using namespace std;
int dp[Max];
int fib(int n){
    if(n==0 || n==1)
        return 1;
    if(dp[n]>0)
        return dp[n];
    else{
        dp[n]=fib(n-1)+fib(n-2);
        return dp[n];
    }
    
}

int main()
{
    int n;
    cin>>n;
    memset(dp,0,100);
    cout<<fib(n)<<endl;
    return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int tmp;

		tmp = a;
		a = b;
		b = tmp;

		tmp = a;
		a = c;
		c = tmp;

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

		sc.close();

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
long long num[10000006];
int main(){
	int n;
	cin>>n;
	long long ans=0;
	for(long long i=1;i<=n;i++){
		for(long long j=i;j<=n;j+=i){
			num[j]++;
		}
	}	
	for(long long i=1;i<=n;i++){
		ans+=i*num[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 81720
import bisect
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for n in range(1,N):
  b=L[n]
  for k in range(n):
    a=L[k]
    index=bisect.bisect_left(L,a+b)
    ans+=(index-n-1)
print(ans)

Measured memory_bytes: 3188
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    a: usize,
    b: usize
    }
    let da = divisor(a);
    let mut cd = vec![];
    for i in da {
        if b % i == 0 {
            cd.push(i);
        }
    }
    let mut ans = 0;
    for i in (0..cd.len()).rev() {
        let mut f = true;
        for j in 0..i {
            if gcd(&cd[i], &cd[j]) != 1 {
                f = false;
                break;
            }
        }
        if f { ans += 1; }
    }
    println!("{}", ans);
}

fn divisor(m: usize) -> Vec<usize> {
    let mut l = Vec::new();
    for i in 1.. {
        if i * i > m { break; }
        if m % i == 0 {
            l.push(i);
            l.push(m / i);
        }
    }
    l.sort();
    l.dedup();
    l
}

// O(log(N))
fn gcd(a: &usize, b: &usize) -> usize {
    let (mut x, mut y) = if a < b { (*b, *a) } else { (*a, *b) };
    let mut r = x % y;
    while r != 0 {
        x = y;
        y = r;
        r = x % y;
    }
    y
}



Measured memory_bytes: 2208
//Author : Ayush Jain

#include <bits/stdc++.h>
using namespace std;

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
const int N=1e5 + 5;
const int M=1e5 + 5;

ull pw[67];
void pre()
{
	pw[0]=1;
	for(int i=1;i<64;i++) pw[i]=2*pw[i-1];
}

int main()
{
	ios_base::sync_with_stdio(false);
	pre();
	int n,i,j;
	ll s[2005],dp[2005],x,y;
	cin>>n>>x>>y;
	for(i=0;i<n;i++){
		cin>>s[i];
	}	
	for(i=0;i<n;i++){
		if(i==n-1){
			dp[i]=abs(s[i]-y);
		}
		else{
			dp[i]=abs(s[i]-s[n-1]);
			for(j=i+1;j<n-1;j++){
				dp[i]=min(dp[i],abs(s[j]-s[n-1]));
			}
		}
	}
	ll ans=-1;
	for(i=0;i<n;i++) ans=max(ans,dp[i]);
	cout<<ans<<endl;	
		
	return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - AtCoder Alloy
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a >= h && b >= w) cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip>
using namespace std;


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

	double ans = 0;
	for(int i=0;i<n;i++){
		double x;
		cin >> x;
		ans += 1/x;
	}
	cout << fixed << setprecision(6) << 1/ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
//const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

const ll MOD = 998244353; 

struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
	mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
	mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
	mint operator+(const mint a) const {mint res(*this); return res+=a;}
	mint operator-(const mint a) const {mint res(*this); return res-=a;}
	mint operator*(const mint a) const {mint res(*this); return res*=a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
 		return a;
	}

	// for prime mod
	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return (*this) *= a.inv();}
	mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

int main() {
//	cout << fixed << setprecision(15);
	int n, s;
	cin >> n >> s;
	vi a(n);
	rep(i, n) cin >> a[i];

	vector<vector<mint>> dp(n+1, vector<mint>(s+1));
	for(int i = 1; i <= n; i++) {
		int _a = a[i-1];
		dp[i][0] = 1;	// only A is in L-R but not selected
		if(_a <= s) dp[i][_a] = 1;	// only A is in L-R and selected
		rep(j, s+1) dp[i][j] += dp[i-1][j];	// Add A to L-R but not selected
		rep(j, s+1) if(j+_a <= s) dp[i][j+_a] += dp[i-1][j];	// Add A to L-R and selected
	}

	mint ans;
	rep(i, n+1) ans += dp[i][s];
	cout << ans.x << endl;
}


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

int main() {
	int a,b,i;
	cin>>a>>b;
	if(a>b)
	{
		for(i=0;i<a;i++) cout<<b;
	}
	else 
	{
		for(i=0;i<b;i++) cout<<a;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using std::cout;
using std::cin;

int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    
    int en;
    int ans;
    int set[]={500,100,50,10,5,1};
    
    
    
    
    while(cin>>en&&en!=0)
    {
    en=1000-en;
        
        for (int i=0;i<sizeof(set)/sizeof(set[0]); ++i)
        {
            while(true)
            {
                if(set[i]<=en)
                {
                    en-=set[i];
                    ++ans;
                }
                else
                {
                    break;
                }
            }
        }
        cout<< ans <<"\n";
        ans=0;
    }

    
    return 0;
}

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

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

  map<int, int> table;
  rep(i, M)
  {
    int a, b;
    cin >> a >> b;

    if (table.count(a))
    {
      if (table[a] == b)
      {
        continue;
      }
      table[1] = -1;
      break;
    }
    table[a] = b;
  }

  if (M == 0)
  {
    if (N == 1)
      cout << 0 << endl;
    else if (N == 2)
      cout << 10 << endl;
    else
      cout << 100 << endl;
  }
  else if (M != 0)
  {
    if (table.count(1))
    {
      if (table[1] == 0)
      {
        if (N == 1)
          cout << 0 << endl;
        else
          cout << -1 << endl;
      }
      if (table[1] == -1)
        cout << -1 << endl;
    }

    if (N == 1)
    {
      if (!table.count(1))
        table[1] = 1;
      if (table[1] >= 1)
        cout << table[1] << endl;
    }

    else if (N == 2)
    {
      if (!table.count(1))
        table[1] = 1;
      if (table[1] >= 1)
        cout << table[1] * 10 + table[2] << endl;
    }

    else if (N == 3)
    {
      if (!table.count(1))
        table[1] = 1;
      if (table[1] >= 1)
        cout << table[1] * 100 + table[2] * 10 + table[3] << endl;
    }
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=100005;
typedef long long LL;
int n,h[N],cnt,d[N];
bool jdg;
LL c[N],a[N],tot[N],mx[N];
struct edge{int v,n;} e[N<<1];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

void addedge(int u,int v)
{
	e[cnt]=(edge){v,h[u]},h[u]=cnt++,++d[u];
	e[cnt]=(edge){u,h[v]},h[v]=cnt++,++d[v];
}

void dfs(int x,int fa)
{
	if(d[x]==1) {c[x]=a[x]; return;}
	for(int i=h[x]; i!=-1; i=e[i].n)
		if(e[i].v!=fa)
			dfs(e[i].v,x),tot[x]+=c[e[i].v],mx[x]=max(mx[x],c[e[i].v]);
	if(tot[x]<a[x]) jdg=1;
	if(mx[x]*2>tot[x])
	{
		int lst=mx[x]-(tot[x]-mx[x]);
		int nw=tot[x]-mx[x];
		if(lst+nw>a[x]) jdg=1;
		c[x]=lst+2*(a[x]-lst-nw);
	}
	else
	{
		int lst=tot[x]&1;
		int nw=tot[x]>>1;
		if(lst+nw>a[x]) jdg=1;
		c[x]=lst+2*(a[x]-lst-nw);
	}
}

int main()
{
	n=getint();
	rep(i,1,n) a[i]=getint();
	if(n==2)
	{
		if(a[1]==a[2]) puts("YES");
		else puts("NO");
		return 0;
	}
	memset(h,-1,sizeof(h));
	rep(i,1,n-1) addedge(getint(),getint());
	rep(i,1,n) if(d[i]!=1) {dfs(i,0),jdg|=(bool)(c[i]>0); break;}
	if(jdg) puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll a;
	cin >> a;
	ll temp = a;
	temp += pow(a, 2);
	temp += pow(a, 3);
	cout << temp;
}

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

int main() {
  int n,m;
  while(cin >> n >> m && n) {
    string s[n];
    int x[n],y[n];
    for(int i=0; i<n; i++) cin >> s[i] >> x[i] >> y[i];
    while(m--) {
      int t;
      cin >> t;
      for(int i=0; i<n; i++) {
        if(y[i]-x[i]<t&&t<=y[i]) {
          cout << s[i] << " " << t-y[i]+x[i] << endl;
          goto next;
        }
      }
      cout << "Unknown" << endl;
    next:;
    }
  }
  return 0;
}


Measured memory_bytes: 3244
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	int x,y;
	int gx,gy;
	void solve(){
		Scanner sc=new Scanner(System.in);
		x=sc.nextInt();
		y=sc.nextInt();
		if(x==2)gx=3;
		else if(x==4 ||x==6 || x==9 || x==11)gx=2;
		else gx=1;
		
		if(y==2)gy=3;
		else if(y==4 ||y==6 || y==9 || y==11)gy=2;
		else gy=1;
		
		if(gx==gy)System.out.println("Yes");
		else System.out.println("No");
		
		
	}
	
}


Measured memory_bytes: 21716
#include <iostream>
#define llint long long
#define mod 924844033

using namespace std;

llint n, d;
llint dp[2005][2], ndp[2005][2];

const int FACT_MAX = 2005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

int main(void)
{
	cin >> n >> d;
	make_fact();
	
	dp[0][0] = 1;
	for(int i = 1; i <= min(n, 2*d); i++){
		for(int j = i; j <= n; j+=2*d){
			for(int k = 0; k <= n; k++){
				for(int l = 0; l < 2; l++){
					ndp[k][l] = 0;
				}
			}
			
			for(int k = 0; k <= n; k++){
				for(int l = 0; l < 2; l++){
					ndp[k][0] += dp[k][l], ndp[k][0] %= mod;
					if(l == 0 && j-d >= 1) ndp[k+1][0] += dp[k][l], ndp[k+1][0] %= mod;
					if(j+d <= n) ndp[k+1][1] += dp[k][l], ndp[k+1][1] %= mod;
				}
			}
			for(int k = 0; k <= n; k++){
				for(int l = 0; l < 2; l++){
					dp[k][l] = ndp[k][l];
				}
			}
		}
		for(int k = 0; k <= n; k++){
			dp[k][0] += dp[k][1], dp[k][0] %= mod;
			dp[k][1] = 0;
		}
	}
	
	llint ans = 0;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j < 2; j++){
			if(i % 2) ans += mod - dp[i][j] * fact[n-i] % mod;
			else ans += dp[i][j] * fact[n-i] % mod;
			ans %= mod;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    final int n = stdin.nextInt();
	    final int m = stdin.nextInt();

	    if ( n == 0 && m == 0 ) {
		break;
	    }

	    ArrayList<ArrayList<Integer> > list = new ArrayList<ArrayList<Integer>>();
	    for ( int i = 0; i < n; i++ ) {
		list.add( new ArrayList<Integer>() );
	    }

	    for ( int i = 0; i < m; i++ ) {
		final int p1 = stdin.nextInt() - 1;
		final int p2 = stdin.nextInt() - 1;

		list.get( p1 ).add( p2 );
		list.get( p2 ).add( p1 );
	    }
	    boolean[] visited = new boolean[ n ];
	    dfs( list, 0, 0, visited );
	    int count = 0;
	    for ( int i = 1; i < visited.length; i++ ) {
		if ( visited[ i ] ) {
		    count++;
		}
	    }
	    System.out.println( count );
	}	
    }

    static void dfs( final ArrayList<ArrayList<Integer>> list, final int p, final int depth, final boolean[] visited ) {

	visited[ p ] = true;
	if ( depth == 2 ) {
	    return;
	}
	for( final int to : list.get( p ) ){
	    dfs( list, to, depth + 1, visited );
	}	
    }    
}

Measured memory_bytes: 46336
import java.util.Scanner;

public class Main{
	static public void main (String args[]){
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("\\s");
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a<b && b<c){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

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

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      m: usize,
      lrs: [(i64, i64); m]
    }
    let mut ll = 1;
    let mut rr = n as i64;
    for &(l, r) in lrs.iter() {
        ll = max(l, ll);
        rr = min(r, rr);
    }
    let ans = max((rr-ll+1), 0);
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;


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

int main(){

    int x;
    cin >> x;
    if(x == 0){
        cout << "1" << endl;
    }
    else{
        cout << "0" << endl; 
    }

    return 0;
}

Measured memory_bytes: 3668
N = int(input())
ans = []
if N % 2 == 0:
    # 偶数のとき
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if i + j == N+1:
                continue
            ans.append((i, j))
else:
    # 奇数のとき
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if i + j == N:
                continue
            ans.append((i, j))

print(len(ans))
for s, t in ans:
    print(s, t)


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

int main()
{
    int n;
    cin >> n;
    int a[103];
    int b[103]{0};
    int l = n, r = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[a[i]]++;
        l = min(l, a[i]);
        r = max(r, a[i]);
    }
    if(l * 2 < r){
        cout << "Impossible" << endl;
        return 0;
    }
    for(int i = r; i > l; i--){
        if(b[i] < 2){
            cout << "Impossible" << endl;
            return 0;
        }
    }
    if(b[l] - r % 2 != 1){
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
}


Measured memory_bytes: 3628
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

signed main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ret = 0;
    for (int r = 0; r <= 3000; r++) {
        for (int g = 0; g <= 3000; g++) {
            int remain = N - G * g - R * r;
            if (remain >= 0 && remain % B == 0) ret++;
        }
    }
    cout <<ret << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
array = list(map(int,input().split()))
d,f = 0,0
ans = []
for i in range(N):
  if i == 0:
    ans.append(0)
    f = array[0]
    continue
  n = array[i]
  d = f - n
  if d >= 0:
    ans.append(d)
  else:
    ans.append(0)
  if n > f:  
    f = n
print( sum(ans) )

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

struct Edge
{
    int a, b;
    ll cost;
    Edge(int a, int b, ll cost) : a(a), b(b), cost(cost){};
    bool operator<(const Edge &right) const
    {
        return cost < right.cost;
    }
};

struct UnionFind
{
    vector<int> d;
    UnionFind(int n = 0) : d(n, -1){};

    // find
    int find(int x)
    {
        if (d[x] < 0)
        {
            return x;
        }

        return d[x] = find(d[x]);
    }

    //unite
    bool unite(int x, int y)
    {
        x = find(x);
        y = find(y);

        if (x == y)
            return false;

        if (d[x] > d[y])
        {
            swap(x, y);
        }

        d[x] += d[y];
        d[y] = x;

        return true;
    }

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

vector<Edge> edges;
int main()
{
    int V, E;
    cin >> V >> E;

    ll tot = 0;

    UnionFind uf = UnionFind(V);
    for (int i = 0; i < E; i++)
    {
        int a, b;
        ll cost;
        cin >> a >> b >> cost;
        edges.push_back(Edge(a, b, cost));
    }
    sort(edges.begin(), edges.end());

    for (Edge edge : edges)
    {
        if (uf.same(edge.a, edge.b))
            continue;
        uf.unite(edge.a, edge.b);
        tot += edge.cost;
        // if (uf.unite(edge.a, edge.b))
        // {
        //     tot += edge.cost;
        // }
    }

    cout << tot << endl;
    return 0;
}


Measured memory_bytes: 4956
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll u, v; cin >> u >> v;
    u--; v--;
    vector<ll> g[n];
    ll a, b;
    rep(i, n-1){
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ll d_from_u[n];
    memset(d_from_u, -1, sizeof(d_from_u));
    d_from_u[u] = 0;
    ll d_from_v[n];
    memset(d_from_v, -1, sizeof(d_from_v));
    d_from_v[v] = 0;

    queue<ll> que;
    que.push(u);
    while(!que.empty()){
        ll now = que.front();
        que.pop();

        for(ll nxt : g[now]){
            if(d_from_u[nxt] == -1){
                d_from_u[nxt] = d_from_u[now] + 1;
                que.push(nxt);
            }
        }
    }

    que.push(v);
    while(!que.empty()){
        ll now = que.front();
        que.pop();

        for(ll nxt : g[now]){
            if(d_from_v[nxt] == -1){
                d_from_v[nxt] = d_from_v[now] + 1;
                que.push(nxt);
            }
        }
    }

    // rep(i, n){
    //     cout << d_from_v[i] << endl;
    // }

    ll vmax = 0;
    rep(i, n){
        if(d_from_u[i] < d_from_v[i]){
            vmax = max(vmax, d_from_v[i]);
        }
    }

    cout << vmax - 1 << endl;

    return 0;
}

Measured memory_bytes: 8064
N = int(input())
src = list(map(int,input().split()))

cs = [0] * 8
free = 0
for a in src:
    if a >= 3200:
        free += 1
    else:
        cs[a//400] += 1
fix = len([1 for c in cs if c])
mx = fix + free
mn = fix + (0 if fix else 1)
print(str(mn) + ' ' + str(mx))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n,x;cin>>n>>x;
    vector<int>v(n);rep(i,n)cin>>v[i];
    int ans=0;
    int temp=INF;
    rep(i,n-1){
        if(v[i]+v[i+1]>x){
            ans+=v[i]+v[i+1]-x;
            v[i+1]=max(0LL,v[i+1]-(v[i]+v[i+1]-x));
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
using namespace std;


long long C[100][100];
void conbination(){
	for(int i=0;i<100;i++){
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++){
			C[i][j] = C[i-1][j-1]+C[i-1][j];
		}
	}
}
int main(){
	//	freopen("in.txt","r",stdin);
	conbination();
	int N,P;
	int even = 0;
	int odd  = 0;
	ll ans = 0;
	cin >> N >> P;
	for (int i = 0; i < N; ++i)
	{
		int tmp;
		cin >> tmp;
		if(tmp%2 == 0) even++;
	}
	odd = N - even;
	for(int i=P;i<=odd;i+=2){
		ans += C[odd][i];
	}
	ans = ans * pow(2,even);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import sys
def MI(): return map(int, sys.stdin.readline().split())
if __name__ == "__main__":
    N, K = MI()
    result = 0
    mod = 10**9+7
    if N+1 == K:
        print(1)
    else:
        for i in range(K, N+2):
            result += i*(N-i+1)+1
        print(result%mod)

Measured memory_bytes: 9056
n, m, k = map(int, input().split())
eq_k = False
for p in range(n+1):
  for q in range(m+1):
    area = p * (m - q) + q * (n - p)
    #print(p, q, area)
    if area == k:
      eq_k = True
      break
  if eq_k: break
if eq_k:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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 pair<int,int> P;

int main(){
  stack<int> q;
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,n){
    if(q.size()==0)q.push(s[i]);
    else if(q.top()==s[i])continue;
    else q.push(s[i]);
  }
  cout << q.size() << endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<algorithm>
#include<math.h>

using namespace std;

#define	PI 3.141592

int main(void)
{
  int a=1, b=1;
  double n=0.0;
  double e=0.0;
  int r=90;

  while(a!=0 || b!=0)
    {
      scanf("%d,%d", &a, &b);
      n+=a*sin(r*PI/180.0);
      e+=a*cos(r*PI/180.0);
      r-=b;
      r%=360;
    }

  cout<<(int)e<<endl<<(int)n<<endl;

}

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

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

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

    a[s-1] = i+1;
  }

  for (int i = 0; i < n; ++i) cout << a[i] << (i == n-1 ? '\n' : ' ');

  return (0);
}


Measured memory_bytes: 4020
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); 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; }
const int INF = 1 << 30;
int a[1010];
int c[1010];
int dp[1010][4100];
int main(){
    int n, m; cin >> n >> m;
    rep(i,m){
        int b;
        cin >> a[i] >> b;
        rep(j,b){
            int tmp;
            cin >> tmp;
            tmp--;
            c[i] |= 1<<tmp;
        }
    }
    rep(i,1010)rep(j,4100) dp[i][j] = INF;
    rep(i,m)dp[i][0] = 0;
    dp[0][c[0]] = a[0];
    rep(i,m)rep(j,1<<n){
        if(dp[i][j] != INF) chmin(dp[i+1][j|c[i]],dp[i][j] + a[i]);
        chmin(dp[i+1][j],dp[i][j]);
    }
    //rep(i,m)rep(j,(1<<n)) cout << i << " " << j << " " << dp[i][j] << endl;
    int ans = dp[m-1][(1<<n)-1];
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16384
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    
    String ans = "No";
    for(int i = 0; i <= N; i++){
      for(int j = 0; j <= M; j++){
        int a = i*(M-j);
        int b = j*(N-i);
        if(a+b == K){
          ans = "Yes";
          break;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23252
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr64()
	N := list[0]
	K := list[1]

	//var ans float64 = 0
	ans := big.NewRat(0, 1)
	var i int64
	for i = 1; i <= N; i++ {
		var bit int64 = 1
		for {
			if K <= bit*i {
				//ans += 1.0 / (float64(i) * float64(bit))
				var r = big.NewRat(1, bit*N)
				ans = ans.Add(ans, r)
				break
			}
			bit <<= 1
		}
	}

	fmt.Printf("%s\n", ans.FloatString(20))
}

func getStdin() string {
	return readLine()
}
func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    int n,m,i;
   cin>>n>>m;
   int pen=0,ans=0,p;
   string s;
   map<int,int> mp,mark;
   for(i=0;i<m;i++)
   {
       cin>>p>>s;
       if(s=="AC")
       {
           if(mark[p]!=1)
           {ans++;
           pen+=mp[p];
           mark[p]=1;
           }
       }
       else
       {
           if(mark[p]!=1)
           mp[p]++;
       }
   }
   cout<<ans<<" "<<pen;
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int N;
        String s;
        int redCounter = 0;
        int blueCounter = 0;
        Scanner scanner = new Scanner(System.in);

        N = Integer.valueOf(scanner.nextLine());
        s = scanner.nextLine();

        String c;
        for(int i = 0; i < N; i++) {
             c = String.valueOf(s.charAt(i));
            if (c.equals("B")) {
                blueCounter++;
            } else {
                redCounter++;
            }
        }
        if (redCounter > blueCounter) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 23252
#  --*-coding:utf-8-*--

def f(R, G):
    return 2*G-R

def test():
    assert f(2002, 2017) == 2032
    assert f(4500, 0) == -4500

def main():
    R = int(input())
    G = int(input())

    print(f(R,G))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int n;
int seq[300050];

bool chk(int mid)
{
	int val = seq[1];
	for(int i = 2;i <= n; i += 2)
	{
		if(val >= mid) val = max(val + seq[i + 1] - seq[i],seq[i + 1]);
		else val += seq[i + 1] - seq[i];
	}
	return val >= mid;
}

int main()
{
	scanf("%d",&n);
	int ji = 0,ou = 0;
	for(int i = 1;i <= n; ++ i)
	{
		scanf("%d",&seq[i]);
		if(i % 2) ji += seq[i];
		else ou += seq[i];
	}
	if(n % 2 == 0)
	{
		printf("%d %d\n",max(ji,ou),min(ji,ou));
	}
	else
	{
		int l = 0,r = 300000000,ans;
		while(l <= r)
		{
			int mid = (l + r) >> 1;
			if(chk(mid)) ans = mid,l = mid + 1;
			else r = mid - 1;
		}
		printf("%d %d\n",ou + ans,ji - ans);
	}
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <cassert>

#include <vector>
#include <algorithm>
using namespace std;

#define rep_init(i, init, n) for(int i = (init); i < n; ++i)
#define rep(i, n) rep_init(i, 0, n)

void Main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int dur = max(0, min(B, D) - max(A, C));

	cout << dur << endl;
}

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

	Main();
	return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int A,B;

int digit_count(int x)
{
	int res = 0;
	do{
		res++;
	}while(x /= 10);
	return res;
}

int main()
{
	while(~scanf("%d%d",&A,&B)){
		printf("%d\n",digit_count(A + B));
	}

	return 0;
}

Measured memory_bytes: 3140