akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int Max = 10000;
		int[] x = new int[Max];
		int n = 0; // xの要素数
		Scanner sc = new Scanner(System.in);
		int input = 100;
		boolean inputjudge = true; // 入力要素が範囲内に収まっているかを確認するための変数;

		for (int i = 0; i < x.length; i++) {
			input = sc.nextInt();
			if (input >= 1 && input <= 10000) {
				x[i] = input;
				n++;
			} else if (input == 0) {
				break;
			} else { // 入力された値が範囲外のとき
				inputjudge = false;
				break;
			}
		}

		if (inputjudge == true) {

			for (int i = 0; i < n; i++) {
				System.out.println("Case " + (i + 1) + ": " + x[i]);

			}
		}
	}

}



Measured memory_bytes: 42920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c;
    char d,e;
  	string s;
  	cin>>a;
	
  if(a>999)
    cout<<"ABD"<<endl;
  else
    cout<<"ABC"<<endl;
  
 return 0;
}

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

using namespace std;

//Shortcut
#define long long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define X first
#define Y second
#define sz size
#define ft(i , a , b) for (long i = (long)a ; i <= (long)b ; i++)
#define fd(i , a , b) for (long i = (long)a ; i >= (long)b ; i--)
#define lt(i , a , b , c) for (long i = (long)a ; i <= (long)b ; i += (long)c)
#define ld(i , a , b , c) for (long i = (long)a ; i >= (long)b ; i -= (long)c)
#define pll pair <long , long>
#define pls pair <long , string>
#define vtl vector <long>
#define vts vector <string>
#define vtp vector <pll>
#define dql deque <long>
#define mll map <long , long>
#define prio priority_queue<pll , vector<pll > , greater<pll> >
#define pushpq(a , b) push({(long) a , (long) b})

//Variable
const long mxN = 3e3 + 5;
const long base = 311;
const long oo = 1e15;
const long MOD = 1e9 + 7;
const long d4i[4] = {-1 , 0 , 1 , 0} , d4j[4] = {0 , 1 , 0 , -1};
const long d8i[8] = {-1 , -1 , 0 , 1 , 1 , 1 , 0 , -1} , d8j[8] = {0 , 1 , 1 , 1 , 0 , -1 , -1 , -1};

long TestCase;
long lenS , lenT , l;
long dp[mxN][mxN];
bool mark[mxN][mxN];

string s , t , answer;

long cal(int i , int j) {
    long &ans = dp[i][j];
    bool &tie = mark[i][j];

    if (i > lenS || j > lenT) return 0;
    if (tie) return ans;
    tie = true;

    if (s[i] == t[j]) ans = cal(i + 1 , j + 1) + 1;
    else ans = max(cal(i + 1 , j) , cal(i , j + 1));
    return ans; 
}

void trace(int i , int j) {
    if (i > lenS || j > lenT || l == 0) return;
    if (s[i] == t[j] && dp[i][j] == dp[i + 1][j + 1] + 1) {
        cout << s[i];
        trace(i + 1 , j + 1);
    }
    else {
        if (dp[i][j] == dp[i][j + 1]) trace(i , j + 1);
        else trace(i + 1 , j);
    }
}

void Solve() {
    cin >> s;
    cin >> t;
    lenS = s.sz();
    lenT = t.sz();
    s = "#" + s;
    t = "#" + t;
    cal(1 , 1);
    if (!dp[1][1]) {
        cout << " ";
        return;
    }
    else {
        l = dp[1][1];
        trace(1 , 1);
        cout << answer;
    }
}

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
    //cin >> TestCase;
    TestCase = 1;
    while(TestCase--)
        Solve();
    return 0;
}

Measured memory_bytes: 83060
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

// a^n mod を計算する

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  vector<ll> b(n+1);
  vector<ll> c(n+1);

  for(int i=1; i<=n; i++){
    cin >> a.at(i); 
  }
  for(int i=1; i<=n; i++){
    cin >> b.at(i); 
  }
  for(int i=1; i<=n-1; i++){
    cin >> c.at(i); 
  }

  ll answer = 0;
  for(int i = 1; i<=n-1; i++){
    answer += b.at(a.at(i));
    if(a.at(i+1)== a.at(i)+1){
      answer += c.at(a.at(i));
    }
  }
  answer += b.at(a.at(n));
  cout << answer<< endl;
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N, M;
    cin >> N >> M;

    vi K(M), P(M);
    vector<vector<int>> D(M);

    REP(i, M) {
        int k;
        cin >> k;
        D[i].resize(k);
        REP(j, k) {
            cin >> D[i][j];
            --D[i][j];
        }
    }
    vi p(M);
    REP(i, M) cin >> p[i];

    int ans = 0;
    for (int i=0; i<(1<<N); ++i) {
        bool ok = true;
        for (int j=0; j<M; ++j) {
            int c = 0;
            for (int id : D[j]) {
                if ((i >> id) & 1) {
                    c += 1;
                }
            }
            c %= 2;
            if (c != p[j]) {
                ok = false;
            }
        }
        if (ok) {
            ans += 1;
        }
    }
    print(ans);

}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int na=scan.nextInt();
int nb=scan.nextInt();
  
if(na%nb==0){
  System.out.println(na/nb);
}else{
  System.out.println((na/nb)+1);
}
  
}
}

Measured memory_bytes: 22612
#include<set>
#include<map>
#include<ctime>
#include<cstdio>
#include<queue>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const double eps=1e-8;
const int maxn=3e5+10;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
LL a[maxn],b[maxn];
int sum[maxn];
int low_bit(int x)
{
    return x&(-x);
}
void add(int x)
{
    while(x<maxn)
    {
        sum[x]++;
        x+=low_bit(x);
    }
}
int get_ans(int x)
{
    int ans=0;
    while(x)
    {
        ans+=sum[x];
        x-=low_bit(x);
    }
    return ans;
}
int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        memset(sum,0,sizeof(sum));
        for(int i=0;i<n;i++)
        {
            scanf("%lld",&a[i]);
            a[i]-=k;
        }
        b[1]=a[0];
        b[n+1]=0;
        for(int i=1;i<n;i++)
        {
            a[i]+=a[i-1];
            b[i+1]=a[i];
        }
        sort(b+1,b+n+2);
        add(lower_bound(b+1,b+n+2,0ll)-b);
        LL ans=0;
//        for(int i=1;i<=n+1;i++)
//            printf("b[%d]=%lld\n",i,b[i]);
        for(int i=0;i<n;i++)
        {
            int k=lower_bound(b+1,b+n+2,a[i])-b;
            if(k>=maxn) while(1);
            ans+=get_ans(k);//printf("k=%d ans=%lld a[%d]=%lld\n",k,ans,i,a[i]);
            add(k);
        }
        printf("%lld\n",ans);
    }
}

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

int SS(int n) {
  int x = 0;
  while (n > 0) {
    x += (n % 10);
    n /= 10;
  }
  return x;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (SS(i) >= A && SS(i) <= B) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        string s = ins();
        string ans;
        ans += s[0];
        ans += to_string(s.size() - 2);
        ans += s.back();
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
#define f for
#define tn return
#define bk break
#define cn continue
#define ve vector
#define st string
#define ch char
#define ft first
#define sec second


void solve()
{
	int x;
	cin>>x;
	int ans;
	if(x>=400 && x<=599)
	ans=8;
	else if(x>=600 && x<=799)
	ans=7;
	else if(x>=800 && x<=999)
	ans=6;
	else if(x>=1000 && x<=1199)
	ans=5;
	else if(x>=1200 && x<=1399)
	ans=4;
	else if(x>=1400 && x<=1599)
	ans=3;
	else if(x>=1600 && x<=1799)
	ans=2;
	else if(x>=1800 && x<=1999)
	ans=1;
	cout<<ans<<endl;
}


int main()
{
	fastio
	solve();

}

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

int main() {
  int n;
  double x, ans = 0.0;
  string u;
  cin >> n;
  for (size_t i = 0; i < n; i++) {
    cin >> x >> u;
    if (u == "JPY") {
      ans += x;
    } else {
      ans += x * 380000.0;
    }
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
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)*}
    };
}

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

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize,
        v: [usize; n]
    }
    let d = 1000000007;
    let mut ans1 = 0;
    let mut bit = BIT::new(2001);
    for &x in v.iter().rev() {
        ans1 += bit.sum(x - 1) as usize;
        bit.add(x, 1);
    }
    let mut ans2 = 0;
    for &x in v.iter().rev() {
        ans2 += bit.sum(x - 1) as usize;
    }
    ans1 %= d;
    ans2 %= d;
    println!("{}", (k * ans1 + k * (k - 1) / 2 % d * ans2) % d);
}

struct BIT {
    v: Vec<i64>,
    n: usize
}

impl BIT {
    fn new(n: usize) -> BIT {
        BIT{v: vec![0; n + 1], n: n}
    }

    // add x to i th element
    fn add(&mut self, i: usize, x: i64) {
        let mut id = i as i64 + 1;
        while id <= self.n as i64 {
            self.v[id as usize] += x;
            id += id & -id;
        }
    }

    // sum up to i th element
    fn sum(&self, i: usize) -> i64 {
        let mut id = i + 1;
        let mut ret = 0;
        while id > 0 {
            ret += self.v[id];
            id &= id - 1;
        }
        ret
    }
}


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

const long long mod=1000000007ll;

int main()
{
  int n;
  scanf("%d",&n);
  static long long T[100000],A[100000];
  for(int i=0;i<n;i++){
    scanf("%d",T+i);
  }
  for(int i=0;i<n;i++){
    scanf("%d",A+i);
  }
  static long long M1[100000],M2[100000];
  for(int i=0;i<n;i++){
    if(i==0||T[i-1]<T[i]){
      M1[i]=T[i];
    }
    else{
      M1[i]=-1;
      M2[i]=T[i];
    }
  }
  long long ans=1ll;
  for(int i=0;i<n;i++){
    if(i==n-1||A[i]>A[i+1]){
      if(M1[i]!=-1&&M1[i]!=A[i]){
	ans=0;
      }
      M1[i]=A[i];
    }
    else{
      if(M1[i]!=-1&&M1[i]>A[i]){
	ans=0;
      }
      else if(M1[i]==-1){
	M2[i]=min(M2[i],A[i]);
      }
    }
  }
  for(int i=0;i<n;i++){
    if(M1[i]==-1){
      ans*=M2[i];
      ans%=mod;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 3328
def main():
    N = int(input())
    S = input()
    from collections import Counter
    c = Counter(S)
    result = 1
    if len(list(c.values())) < 3:
        print(0)
        return
    for v in c.values():
        result *= v
    piyo = (N-3) // 2
    for p in range(piyo+1):
        for i in range(N-1 - 2*p -2 + 1):
            a, b, c = S[i] , S[i+p+1] , S[i + (p+1)*2]
            if a != b and a != c and b != c:
                result -= 1
    print(result)
main()

Measured memory_bytes: 9312
/*
	0218:Dividing Students
*/
#include	<iostream>

using namespace std;

int main(void) {
	while(1) {
		int n;
		cin >> n;
		
		if( n == 0 ) { break; }
		
		for(int i = 0; i < n; i++) {
			int pm, pe, pj;
			cin >> pm >> pe >> pj;
			
			if( pm == 100 ||  pe == 100  ||  pj == 100 ) { cout << 'A' << endl; }
			else if( ( (double)pm + pe ) / 2 >= 90.0 ) { cout << 'A' << endl; }
			else if( ( (double)pm + pe + pj ) / 3 >= 80.0 ) { cout << 'A' << endl; }
			else if( ( (double)pm + pe + pj ) / 3 >= 70.0 ) { cout << 'B' << endl; }
			else if( ( (double)pm + pe + pj ) / 3 >= 50.0 && ( pm >= 80 || pe >= 80 ) ) { cout << 'B' << endl; }
			else { cout << 'C' << endl; }
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll x[101],y[101],h[101],nowh,nowx,nowy;

int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		x[i]=a;y[i]=b;h[i]=c;
		if(nowh!=0){
			continue;
		}
		if(c==0){
			continue;
		}
		nowh=c;nowx=a;nowy=b;
	}
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			ll cx=i;ll cy=j;
			bool flag=true;
			ll H=nowh+abs(nowx-cx)+abs(nowy-cy);
			for(int k=0;k<n;k++){
				ll chx=x[k],chy=y[k];ll z=0;
				if(h[k]!=max(z,H-abs(chx-cx)-abs(chy-cy))){
					flag=false;
					break;
				}
			}
			if(flag){
				cout <<cx <<" "<<cy << " "<< H;
			}
		}
	}
	return 0;
}

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

using namespace std;

int nums[5];

int main(void){
    for(int i = 0; i < 5; i++){
        cin >> nums[i];
    }
    for(int i = 0; i < 5; i++){
        if(nums[i] == 0){
            cout << i+1 << endl;
            exit(0);
        }
    }
    return 0;
}

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

const int maxx=100;
int dx[9]={0,+1,-1,0,0,+1,+1,-1,-1};
int dy[9]={0,0,0,+1,-1,+1,-1,-1,+1};
int ans[maxx][maxx],n,m;
char mapp[maxx][maxx];

int main(){
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(register int i=1;i<=n;i++)
        for(register int j=1;j<=m;j++){
            cin>>mapp[i][j];
            if(mapp[i][j]=='#')
                for(register int k=1;k<=8;k++)
                    ++ans[i+dx[k]][j+dy[k]];
        }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)
            if(mapp[i][j]=='.')
                cout<<ans[i][j];
            else
                cout<<"#";
        cout<<endl;
    }
    return 0;
}

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

int main() {
  unsigned long N,A,B,ans=0;
  cin >> N >> A >> B;
  
  ans = N/(A+B)*A;
  if(N%(A+B)<A) ans += N % (A+B);
  else ans += A;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;

class Program {
    static void Main(string[] args) {
        //入力
        string s = Console.ReadLine();

        int N = int.Parse(s.Split(' ')[0]);
        int M = int.Parse(s.Split(' ')[1]);

        //全ての食べ物を含んだリストを作る([1, 2, 3, 4, 5, 6, 7, …, M - 1, M])という、１～M までの数字の入ったリストができる
        List<int> allFoodList = new List<int>();
        for (int i = 1; i <= M; i++) {
            allFoodList.Add(i);
        }



        //foreach (int a in allFoodList) {
        //    Console.WriteLine(a);
        //}

        string[] t = new string[N];
        int[] K = new int[N];

        for (int i = 0; i < N; i++) {
            List<int> kariList = new List<int>();
            for (int kari = 1; kari <= M; kari++) {
                kariList.Add(kari);
            }

            t[i] = Console.ReadLine();
            K[i] = int.Parse(t[i].Split(' ')[0]);
            for (int j = 1; j <= K[i]; j++) {
                kariList.Remove(int.Parse(t[i].Split(' ')[j]));  //i番目の人が嫌いなもののリストを作った
            }

            foreach (int aaa in kariList) {
                if (allFoodList.Contains(aaa)) {
                    allFoodList.Remove(aaa);
                }
            }
        }


        //出力
        Console.WriteLine(allFoodList.Count);
    }
}

Measured memory_bytes: 13152
package main

import "fmt"

func main() {
	var X int
	fmt.Scanf("%d", &X)

	happy := 0
	var n int
	n = X / 500
	happy += n * 1000
	X -= 500 * n

	n = X / 5
	happy += n * 5
	X -= 5 * n
	fmt.Println(happy)
}


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

#define y1 as214
#define ii pair < int , ll >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)

#define ll long long
#define oo INT_MAX

const int N = 2e5 + 5;
int n;
ll f[N] , a[N] , h[N];

void up(int pos , ll val)
{
    for(int i = pos ; i <= n ; i += i & -i)
        f[i] = max(f[i] , val);
}

ll get(int pos)
{
    ll res = 0;
    for(int i = pos ; i ; i -= i & -i)
        res = max(f[i] , res);
    return res;
}

int main()
{
    //freopen("Q.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n)
        cin >> h[i];
    FOR(i , 1 , n)
        cin >> a[i];
    FOR(i , 1 , n)
        up(h[i] , get(h[i] - 1) + a[i]);
    cout << get(n);
}


Measured memory_bytes: 4992
s = input()
if s=='SUN':
  print(7)
if s=='MON':
  print(6)
if s=='TUE':
  print(5)
if s=='WED':
  print(4)
if s=='THU':
  print(3)
if s=='FRI':
  print(2)
if s=='SAT':
  print(1)

Measured memory_bytes: 3064
function main()
	N,P=map(x->parse(Int,x),split(readline()))
	s=chomp(readline())
	ans=0
	k=1
	now=0
	dp=zeros(Int,P)
	dp[1]=1
	for i=N:-1:1
		t=Int(s[i])-48
		if P==2||P==5
			if t%P==0
				ans+=i
			end
		else
			now=(now+t*k)%P;
			k=k*10%P
			ans+=dp[now+1]
			dp[now+1]+=1
		end
	end
	println(ans)
end
main()


Measured memory_bytes: 165864
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
using namespace std;
int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a <= x && x <= a + b)cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    long double t, x;
    cin >> t >> x;
    cout << t / x << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    ll A, B;
    cin >> A >> B;
    A--;
    ll xor_a = (A % 2 == 0 ? A : 0), xor_b = (B % 2 == 0 ? B : 0);
    if (((A + 1) / 2) % 2 == 1) xor_a ^= 1;
    if (((B + 1) / 2) % 2 == 1) xor_b ^= 1;
    cout << (xor_a ^ xor_b) << endl;
    return 0;
}

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

string a, b;
int N, M;
vector<vector<int> > dp;

int dfs(int n, int m) {
  if ( n == N || m == M ) return 0;
  if ( dp[n][m] >= 0 ) return dp[n][m];
  
  int ret = 0;
  //cout << n << " " << m << " " << cnt << endl;
  if ( a[n] == b[m] ) ret = dfs(n+1, m+1)+1;
  else ret = max(ret, max(dfs(n+1, m), dfs(n, m+1)));

  return dp[n][m] = ret;
}

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

  while ( q-- ) {
    cin >> a >> b;
    N = a.size();
    M = b.size();
    dp = vector<vector<int> >(N+1, vector<int>(M+1, -1));    
    cout << dfs(0, 0) << endl;
  }
  
  return 0;
}



Measured memory_bytes: 10816
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

int main()
{
  int n, a, b;
  cin >> n;
  if(n==1){
    cout << "Hello World" << endl;
  }
  else{
    cin >> a >> b;
    cout << a + b << 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;
typedef long long ll;

int main(){
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}

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

int c[4][4]={0};

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

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

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let nn = n as i64;
    let a: Vec<i64> = (0..n).map(|_| sc.ne()).collect();
    let sum: i64 = a.iter().fold(0, |acc, &x| acc + x);
    let sumn: i64 = (1..nn + 1).fold(0, |acc, x| acc + x);
    let mut ok = true;
    if sum % sumn != 0 {
        ok = false;
    }
    let key = sum / sumn;
    let mut cntd = 0;
    for i in 0..n {
        let j = (i + 1) % n;
        let x = a[j] - a[i];
        match x {
            val if val == key => {}
            val if val > 0 => ok = false,
            _ => {
                let d = key - x;
                if d % nn != 0 {
                    ok = false;
                } else {
                    cntd += d / nn;
                }
            }
        }
    }
    if cntd != key {
        ok = false;
    }
    println!("{}", if ok { "YES" } else { "NO" });
}
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => return None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => panic!("parse error"),
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b) {return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b) {return a = (a < b ? a : b);}

const int MAX_N = 1e5 + 10;
int dp[MAX_N];

vi g[MAX_N];
int h[MAX_N];

vi topo_sort(int v) {

    stack<int> st;

    //入次数が0の頂点であればstに追加
    rep(i, v) if (h[i] == 0) st.push(i);

    //ソートされた後のグラフ
    vi ans;
    //stがなくなるまでループ
    while (st.size()) {
        //stの集合のから一つ取り出す
        int i = st.top(); st.pop();
        ans.push_back(i);
        for (auto& j : g[i]) {
            //隣接する頂点の入次数をマイナス1
            h[j]--;
            //これによって入次数が0になればstに追加
            if (h[j] == 0) st.push(j);
        }
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].pb(b);
        h[b]++;
    }
    auto v = topo_sort(n);
    for(auto&& i : v) {
        for(auto&& j : g[i]) chmax(dp[j], dp[i]+1);
    }
    int ans = 0;
    rep(i, n) chmax(ans, dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7032
// AOJ 2507 Computer Onesan
// 2018.2.7 bal4u
 
#include <stdio.h>

#define M 1000000

int dp[102] = {1,4,12,38};

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

	scanf("%d%d", &n, &m);
    if (m == 1) for (i = 1; i <= n; i++) dp[i] = (dp[i-1]<<1) % M;
    else {
		for (i = 4; i <= n; i++) {
			dp[i] = dp[i-4] + (dp[i-3]<<1) - dp[i-2]*3 + (dp[i-1]<<2);
			dp[i] %= M;	if (dp[i] < 0) dp[i] += M;
		}
	}
    printf("%d\n", dp[n]);
	return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int sum = 0;
  map<int, int> cnt;
  REP(i, N){
    cnt[A[i]]++;
    sum += A[i];
  }

  int Q;
  cin >> Q;

  REP(i, Q){
    int a, b;
    cin >> a >> b;

    sum += (b-a)*cnt[a];
    cnt[b] += cnt[a];
    cnt[a] = 0;
    cout << sum << "\n";
  }

  return 0;
}


Measured memory_bytes: 9964
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define chmin(x, y) x = min(x, y)
#define ll long long
#define ld long double
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

pair<ld, ld> Input[100];

int main() {
  int N; cin >> N;
  ld ans = 0.0;
  rep(i, N) {
    ld x, y; cin >> x >> y;
    Input[i] = make_pair(x, y);
  }
  sort(Input, Input+N);
  do {
    rep(i, N-1) {
      ans += pow(pow((Input[i+1].first - Input[i].first), 2) + pow((Input[i+1].second - Input[i].second), 2), 0.5);
    }
  } while(next_permutation(Input, Input+N));
  ld x = 1;
  rep(i, N) {
    x *= i+1;
  }
  cout << setprecision(12) << ans/x << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
static const int MAX=10000;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
int n;
vector<pair<int, int> >adj[MAX];
void dijkstra(){
  priority_queue<pair<int, int> >PQ;
  int color[MAX];
  int d[MAX];
  int i,j;
  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  d[0]=0;
  PQ.push(make_pair(0,0));
  color[0]=GRAY;

  while(!PQ.empty()){
    pair<int, int>f=PQ.top(); PQ.pop();
    int u=f.second;
    color[u]=BLACK;

    if(d[u]<f.first*(-1)) continue;
    for(j=0;j<adj[u].size();j++){
      int v=adj[u][j].first;
      if(color[v]==BLACK) continue;
      if(d[v]>d[u]+adj[u][j].second){
	d[v]=d[u]+adj[u][j].second;
	PQ.push(make_pair(d[v]*(-1),v));
	color[v]=GRAY;
      }
    }
  }
  for(i=0;i<n;i++){
    if(d[i]==INFTY)
      d[i]=-1;
    cout << i << " " << d[i];
    printf("\n");
  }
    
}
int main(void){
  int i,j;
  int k,v,c,u;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>u>>k;
    for(j=0;j<k;j++){
      cin>>v>>c;
      adj[u].push_back(make_pair(v,c));
    }
  }
  dijkstra();
  return 0;
}




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

using namespace std;

int main()
{
	int a, b;
    cin >> a >> b;
  if (a == b)
    cout << "Draw" << endl;
  else if (a == 1)
    cout << "Alice" << endl;
  else if (b == 1)
    cout << "Bob" << endl;
  else if(a > b)
    cout << "Alice" << endl;
  else if (a < b)
    cout << "Bob" << endl;
  
return 0;

}

Measured memory_bytes: 3660
from collections import Counter
from itertools import accumulate


def prime_factorize(n):
    """素因数分解し，ユニークな素因数のsetを返す。"""
    ans = []
    ans_add = ans.append
    while n % 2 == 0:
        ans_add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            ans_add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        ans_add(n)
    return ans


def main():
    n = int(input())
    primes = prime_factorize(n)
    acc = tuple(accumulate(range(1, 42)))
    counted = Counter(primes)
    ans = 0

    for c in counted.values():
        for i, x in enumerate(acc):
            if c >= x:
                tmp = i + 1
            else:
                break
        ans += tmp

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9468
#include<iostream>
using namespace std;
int main(){
  int h1,s1,h2,s2;
cin>>h1>>s1>>h2>>s2;
  while(true)
  {
    if(h2-s1>0)
      h2-=s1;
    else{
      cout<<"Yes";
      break;
    }
    if(h1-s2>0)
    	h1-=s2;
    else
    {
		cout<<"No";break;
    }
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iomanip>
#define fi(n) for(int i = 0; i < n; i++)
#define fj(n) for(int j = 0; j < n; j++)
#define fk(n) for(int k = 0; k < n; k++)
#define imax INT_MAX
#define imin INT_MIN
#define lmin LONG_LONG_MIN
#define lmax LONG_LONG_MAX
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define st first
#define nd second

using namespace std;
typedef long long ll;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> X >> Y >> Z;
  Out(Z);
  Out(X);
  Out(Y);
}

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

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

int main() {
	int h,w;
	cin>>h>>w;
	string s[h];
	rep(i,h) cin>>s[i];
	int dx[8]={1,0,-1,0,1,1,-1,-1};
	int dy[8]={0,1,0,-1,1,-1,1,-1};
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='#') continue;
			int num=0;
			for(int k=0;k<8;++k){
				int ni=i+dy[k];
				int nj=j+dx[k];
				
				if(ni<0||h<=ni)continue;
				if(nj<0||w<=nj)continue;
				if(s[ni][nj]=='#')num++;
			}
			s[i][j]=char(num+'0');
		}
	}
	rep(i,h) cout<<s[i]<<endl;
		
	return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
ans = 0
for i in range(100000000):
  if a%2==1 or b%2==1 or c%2==1:
    break
  else:
    a, b, c = (b+c)//2, (c+a)//2, (a+b)//2
    ans += 1
if ans == 10**8:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 40428
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 



using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
int main(void){
    ll N,K,Q;cin>>N>>K>>Q;
    ll d=Q-K;
    ll p[N];REP(i,N)p[i]=0;
    ll n;
    REP(i,Q){
        cin>>n;
        p[n-1]++;
    }
    REP(i,N){
        ifYN(p[i]>d);
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int N, Q;
    cin >> N >> Q;
    string str;
    cin >> str;

    vector<int> s(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        if (i + 1 < N && str[i] == 'A' && str[i + 1] == 'C')
        {
            s[i + 1] = s[i] + 1;
        }
        else
        {
            s[i + 1] = s[i];
        }
    }

    for (int q = 0; q < Q; q++)
    {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        cout << s[r] - s[l] << endl;
    }

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int p[n];
    int i;
    rep(i, n) {
        cin >> p[i];
    }

    int cnt = 0;
    for (int i=0; i<n-2; i++) {
        if ((p[i+1] <= p[i] && p[i+2] <= p[i+1]) ||
            (p[i] <= p[i+1] && p[i+1] <= p[i+2])) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), R(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) R.at(0) += A.at(i);
    else R.at(0) -= A.at(i);
  }
  for (int i = 1; i < N; i++) R.at(i) = 2 * A.at(i - 1) - R.at(i - 1);
  for (int i = 0; i < N; i++) cout << R.at(i) << " ";
  cout << endl;
}

Measured memory_bytes: 2048
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
S = Counter(int(_) for _ in stdin.readline().rstrip().split())
Q = int(stdin.readline().rstrip())
T = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in T:
    if i in S:
        ans += 1
print(ans)


Measured memory_bytes: 6560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a))
#define ld long double
const ll mod=1e9+7;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
void solve(){
    string s, z;
    cin >> s >> z;
    int n=s.length();
    string x=z.substr(0,n);
    if(x==s) cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main() {
    IOS;
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3612
import java.util.*;
 
public class Main {
  public static void main(final String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String s = sc.next();
    int r = 0;
    int b = 0;
    
    for(int i=0; i<N; i++){
      if(s.charAt(i)=='R'){
        r++;
      }
      if(s.charAt(i)=='B'){
        b++;
      }
    }
    if(r>b){
    System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

int main(){
    long long N;
    cin >> N;
    string S;
    const char *s = NULL;
    cin >> S;
    s = S.c_str();
    long long i;
    long long abc = 0;
    long long counta = 0;
    for(i = 0; i < N; i++){
        if(s[i] == 'A') abc = 1;
        else if(abc == 1){
            if(s[i] == 'B') abc++;
            else abc = 0;
        }
        else if(abc == 2){
            if(s[i] == 'C'){
                counta++;
                abc = 0;
            }else abc = 0;
        }
    }
    cout << counta << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
        int i = 0;
        switch (s) {
          case "SUN":
            i = 7;
            break;
          case "MON":
            i = 6;
            break;
          case "TUE":
            i = 5;
            break;
          case "WED":
            i = 4;
            break;
          case "THU":
            i = 3;
            break;
          case "FRI":
            i = 2;
            break;
          case "SAT":
            i = 1;
            break;
        }
		System.out.println(i);
	}
}

Measured memory_bytes: 22740
N = int(input())
C = input()
C = list(C)
left = 0
length = len(C) - 1
right = length


def checkLeft():
    global left

    while C[left] == "R" and left < length:
        left += 1


def checkRight():
    global right
    while C[right] == "W" and right > 0:
        right -= 1


checkLeft()
checkRight()
# print(left, right)
cnt = 0
while left < right:
    C[left] = "R"
    C[right] = "W"
    checkLeft()
    checkRight()
    cnt += 1
    # print(left, right)
print(cnt)


Measured memory_bytes: 10780
#include <stdio.h>
int main(void){
    int retu[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    scanf("%d", &K);
    printf("%d\n", retu[K-1]);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>

int main(void)
{
  double a,b,x,p,q;
  scanf("%lf%lf%lf",&a,&b,&x);
  
  if(2*x>a*a*b){
    p=atan(2*(a*a*b-x)/(a*a*a));
  }else{
    p=atan((a*b*b)/(x*2));
  }
  
  q=180*p/M_PI;
  
  printf("%lf",q);
  
  return 0;
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) {
		cout << s;
	} else {
		cout << "red";
	}
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct MaxSegTree{
    long n; vector<ll> dat;
    //?????????
    MaxSegTree(long _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<ll>(2*n-1,0);
    }
    //k??????(0-indexed)?????????a????????´
    void update(long k, ll a){
        k+=n-1;
        dat[k]=a;
        //??´??°
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[2*k+1],dat[2*k+2]);
        }
    }
    //?????¨??????????????????????????¨???
    ll _query(long a, long b, long k, long l, long r){
        if(r<=a || b<=l) return 0;

        if(a<=l && r<=b) return dat[k];
        else{
            ll vl=_query(a,b,2*k+1,l,(l+r)/2);
            ll vr=_query(a,b,2*k+2,(l+r)/2,r);
            return max(vl,vr);
        }
    }
    //[a,b)????????§???????±???????
    ll query(long a, long b){
        return _query(a,b,0,0,n);
    }
};

typedef pair<int,int> pi;

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

    ll sum=0;
    vector<pi> v(n);
    rep(i,n)
    {
        int x;
        scanf(" %d", &x);

        v[i] = pi(x,i);
        sum+=x;
    }

    sort(all(v));

    MaxSegTree st(n);

    rep(i,n)
    {
        int idx = v[i].se;
        st.update(idx, st.query(0,idx)+v[i].fi);
    }

    printf("%lld\n", sum - st.query(0,n));
    return 0;
}

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

ll P, Q, R;

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

	cin >> P >> Q >> R;
	cout << min(P+Q, min(P+R, Q+R)) << "\n";

}

Measured memory_bytes: 256
n,m=map(int,input().split())
s=input()[::-1]
ans=[]
pos=0
while pos!=n:
  for i in range(min(n-pos,m),0,-1):
    if s[pos+i]=='0':
      ans.append(i)
      pos+=i
      break
  else:
    print(-1)
    exit()
print(*ans[::-1])

Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int A[324][324];
int H,W,D,Q;
int d[100000];
int main() {
	cin>>H>>W>>D;
	std::map<ll, P> map;
	rep(i,H)rep(j,W){
		cin>>A[i][j];
		map[A[i][j]] = {i,j};
	}
	cin>>Q;
	for (int i = D+1; i <= H*W; ++i){
		d[i] = d[i-D] + abs(map[i].first-map[i-D].first) + abs(map[i].second-map[i-D].second);
	}
	rep(i,Q){
		int L,R,ans = 0;
		cin>>L>>R;
/*		while(L+D<=R){
			ans+= abs(map[L+D].first - map[L].first);
			ans+= abs(map[L+D].second- map[L].second);
			L+=D;
		}*/
		ans = d[R]-d[L];
		cout<<ans<<endl;
	}
	/*rep(i,H*W){
		cerr<<map[i+1].first<<" "<<map[i+1].second<<endl;
	}*/
}

Measured memory_bytes: 7424