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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
std::vector<std::string> split(const std::string &str, const char delemiter) {std::vector<std::string> res;std::stringstream ss(str);std::string buffer; while( std::getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
int msb(int x) {return x?31-__builtin_clz(x):-1;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int M = 10000;
    vector<int> ans(M+1,0);
    for(int i = 1; i*i <= M; ++i) {
        for(int j = 1; j*j <= M; ++j) {
            for(int k = 1; k*k <= M; ++k) {
                int a = i*i+j*j+k*k+i*j+j*k+k*i;
                if(a<=M) ans[a]++;
            }
        }
    }
    int N; cin >> N;
    for(int i = 1; i <= N; ++i) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3588
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);   
       //値の取得
       int N = sc.nextInt();
	   int[] A = new int[N];
       for(int i=0;i<N;i++){
        A[i] = sc.nextInt();
       }
      //カウント
      int count=0;
      //両想いうさぎ
      for(int i=0;i<N;i++){
        if(A[A[i]-1]==i+1){
          count++;
        }
      }              
       System.out.println(count/2);
    }
}

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

const int MAXN=2*1e5+10;
const int MOD=1e9+7;

int pre[MAXN];
int nodenum[MAXN];

int Find(int a){
    if(pre[a]!=a)
        pre[a]=Find(pre[a]);
    return pre[a];
}

void join(int x,int y) {
    int fx=Find(x),fy=Find(y);
    if(fx!=fy){
        pre[fy]=fx;
        nodenum[fx]+=nodenum[fy];
    }
    else return;
}

int main() {
    int n,m,a,b,ans=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) pre[i]=i,nodenum[i]=1;
    for(int i=1;i<=m;i++){
        scanf("%d%d",&a,&b);
        join(a,b);
    }
    for(int i=1;i<=n;i++){
        if(pre[i]==i){
            ans=max(nodenum[i],ans);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5212
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
	for (int i = 1; i < 10; ++i){
		for (int j = 1; j < 10; ++j){
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	return 0;
}

Measured memory_bytes: 1096
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

ll ncr(ll n, ll r){
  if(n < r) return 0;
  if(r > n-r) r = n-r;

  ll a = 1, b = 1;
  for(int i = 0; i < r; i++){
    a *= (n - i);
  }
  for(int i = 0; i < r; i++){
    b *= (i + 1);
  }
  return a/b;
}

int main(){
  int N, M;
  cin >> N >> M;
  cout << ncr(N, 2) + ncr(M, 2) << endl;
}

Measured memory_bytes: 256
gets
XL = $<.map{|ln| ln.split.map(&:to_i) }
XL.sort_by!{|x,l| x+l }
n, r = 0, -Float::INFINITY
XL.each{|x,l|
	next unless r <= x-l
	r = x+l
	n += 1
}
p n


Measured memory_bytes: 12536
#include<stdio.h>
int main(void)
{
  char str[2];
    scanf("%s", str);
    
  if(str[0]=='A') printf("T");
  if(str[0]=='C')printf("G");
  if(str[0]=='G')printf("C");
  if(str[0]=='T')printf("A");
  
 return 0;
}

Measured memory_bytes: 128
#include<utility>
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

class Amidakuji {
public:
private:
	int w;	// 縦線の本数
	int n;	// 横棒の本数
	int an_list[30];
	int bn_list[30];
public:
	void inputWN(int ww, int nn);
	void inputList();
	int* calc();
private:
	int a(int n);
	int b(int n);
};

int main() {
	Amidakuji amidakuji;
	int w, n;
	cin >> w >> n;
	int* status = new int[w];
	
	amidakuji.inputWN(w, n);
	amidakuji.inputList();
	
	status = amidakuji.calc();
	
	for(int i = 0; i < w; ++i) {
		cout << status[i] << endl;
	}
}


void Amidakuji::inputWN(int ww, int nn) {
	w = ww;
	n = nn;
}

void Amidakuji::inputList() {
	int an, bn;
	for(int i = 0; i < n; ++i) {
		scanf("%d,%d", &an, &bn);
		
		an_list[i] = an;
		bn_list[i] = bn;
	}
}

int* Amidakuji::calc() {
	int* status = new int[w];
	for(int i = 0; i < w; ++i) {
		status[i] = i + 1;
	}
	
	for(int i = 0; i < n; ++i) {
		int an = a(i)-1;
		int bn = b(i)-1;
		
		swap(status[an], status[bn]);
	}
	
	return status;
}

int Amidakuji::a(int n) {
	return an_list[n];
}

int Amidakuji::b(int n) {
	return bn_list[n];
}

Measured memory_bytes: 0
use std::io::*;
use std::str::*;

// const MOD: i32 = 1000000007;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let a: usize = read().unwrap();
    let b: usize = read().unwrap();
    let s: String = read().unwrap();

    for i in 0..a {
        match s.chars().nth(i).unwrap() {
            '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '0' => continue,
            _ => {
                println!("No");
                return;
            }
        }
    }
    if s.chars().nth(a).unwrap() != '-' {
        println!("No");
        return;
    }
    for i in a + 1..(a + 1 + b) {
        match s.chars().nth(i).unwrap() {
            '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '0' => continue,
            _ => {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a % 2 == 1 && b % 2 == 1){
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int READ(){
    string s;
    cin >>s;
    string t = s[0] + s.substr(2);
    return stoi(t);
}

const int N = 4001;

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

    vector<int> a(n);
    rep(i,n) a[i] = READ();

    vector<vector<int>> x(N);
    rep(i,n) x[a[i]].pb(i);

    int ct = 0;
    vector<int> ans(n);
    rep(i,N){
        int p = x[i].size();
        for(int j:x[i]) ans[j] = ct*3 + p - 1;
        ct += p;
    }
    rep(i,n) cout << ans[i] << "\n";
    return 0;
}



Measured memory_bytes: 4480
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
        cout<<k;
    else if(k<=a+b)
        cout<<a;
    else
        cout<<a-1*(k-b-a);

}


Measured memory_bytes: 3652
import java.util.Scanner;
import java.lang.Math;


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

		double c1,c2,c3;
		double x1,x2,x3,x0;
		double y1,y2,y3,y0;

		while(cin.hasNext())
		{
			x1 = cin.nextDouble();
			y1 = cin.nextDouble();
			x2 = cin.nextDouble();
			y2 = cin.nextDouble();
			x3 = cin.nextDouble();
			y3 = cin.nextDouble();
			x0 = cin.nextDouble();
			y0 = cin.nextDouble();
			
			c1 = cross(x0,y0,x1,y1,x2,y2);
			c2 = cross(x0,y0,x2,y2,x3,y3);
			c3 = cross(x0,y0,x3,y3,x1,y1);
			
			if(c1*c2>0 && c2*c3>0 && c3*c1>0)
			{
				System.out.println("YES");
			}
			else
			{
				System.out.println("NO");
			}	
		}
	}
	
	static double cross( double x1, double y1,
			double x2, double y2, double x3, double y3)
	{
		x2-=x1; y2-=y1;
		x3-=x1; y3-=y1;

		return x2*y3-x3*y2;
	}
}

Measured memory_bytes: 12000
#include <cstdio>
using namespace std;

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

    int diff = (n > m) ? (n - m) : (m - n);
    long long sum = 1;

    //printf("%d\n", diff);

    if (diff >= 2)
        puts("0");
    else if (diff == 1) {
        for (int i = 2; i <= n; i++) {
            sum = sum * i % 1000000007;
        }
        for (int i = 2; i <= m; i++) {
            sum = sum * i % 1000000007;
        }
        printf("%lld\n", sum);
    }
    else {
        sum *= 2;
        for (int i = 2; i <= n; i++) {
            sum = sum * i % 1000000007;
            sum = sum * i % 1000000007;
        }
        printf("%lld\n", sum);
    }

    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){
    int ans=0;
    while(n>0){
        n /= 10;
        ans++;
    }
    return ans;
}


int main() {
ll n;
cin>>n;
ll ans = 0;
ll cnt = 0,num = 9;
rep(i,keta(n)-1){
    cnt += num;
    num *= 10;
}
//cout<<cnt<<endl;
  ll as = 1;
  rep(i,keta(n)-1){
  as *= 10;
  }
for(int i = 9;i >= 0;i--){
    ll Q = i*as + cnt;
    if(Q <= n){
        cout<<i+(keta(n)-1)*9<<endl;
return 0;
    }
}


return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll
signed main(){
    int n;cin>>n;
    ll a[200020],s[200020];
    s[0]=0;
    rep(i,0,n){
        cin>>a[i];
        s[i+1]=s[i]+a[i];
    }
    ll res=0;
    int right=0;
    int sum=0;
    rep(left,0,n){
        while(right<n&&(sum^a[right])==(sum+a[right])){
            sum+=a[right];
            ++right;
        }
        res+=right-left;
        if(left==right)++right;
        else {
            sum-=a[left];
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
    int n,r;
    cin>>n>>r;
    if(n<10)
    {
        n=10-n;
        n=100*n;
        r+=n;
        cout<<r<<endl;

    }
    else {cout<<r<<endl;}
    return 0;
}


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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        m: usize,
        mut a: [i64; n],
        mut bc: [(i64, i64); m],
    }

    a.sort();
    bc.sort_by_key(|&(a, b)| (-b, -a));

    let mut i = 0;
    for (b, c) in bc {
        let mut j = 0;
        while i < n && j < b && a[i] < c {
            a[i] = c;
            i += 1;
            j += 1;
        }

        if i >= n {
            break;
        }
    }

    let ans = a.iter().sum::<i64>();

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <iostream>
using namespace std;
int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx, dy = ty - sy;

  // 行き
  string s1 = string(dx,'R') + string(dy,'U');
  // 帰り
  string s2 = string(dx,'L') + string(dy,'D');
  // 行き
  string s3 = 'D' + string(dx+1,'R') + string(dy+1, 'U') + 'L';
  // 帰り
  string s4 = 'U' + string(dx+1,'L') + string(dy+1, 'D') + 'R';

  cout << s1 + s2 + s3 + s4 << endl;
}


Measured memory_bytes: 256
T=list(input())
S=[int(i) for i in T]
N=len(S)-1
K=0
for i in range(2**N):
    t=str(bin(i))[2:]
    t="0"*(N-len(t))+str(t)
    t=t.replace("1","+").replace("0", " ")
    u=str(S[0])
    for i in range(N):
        u+=str(t[i])+str(S[i+1])
    u=u.replace(" ","")
    v=u.split("+")
    M=0
    for i in v:
        M+=int(i)
    K+=M
print(K)


Measured memory_bytes: 3064
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };


int main()
{
	int n, w;
	while (cin >> n >> w&&n)
	{
		int a[120] = {};
		int maxi = 0,ind=0;
		FOR(i, n)
		{
			inin(x);
			a[x / w]++;
			ind = max(ind, x / w);
			maxi = max(maxi, a[x / w]);
		}
		double ans = 0.01;
		ind++;
		FOR(i, ind )
		{
			ans += 1.0*a[i] / maxi*(ind-1-i)/(ind-1);
		}
		printf("%.8f\n", ans);


	}
}

Measured memory_bytes: 3048
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int n, q, k; cin >> n >> k >> q;
  vector<int> v(n, 0);
  for (int i =0 ; i < q; i++) {
    int temp; cin >> temp;
    v[temp-1]++;
  }
  for (int i : v) {
    if (i > q-k) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
function main(input) {
  const args = input.split('\n');
  
  const N = args[0];
  nums = args.slice(1, args.length).map(n => parseInt(n, 10));
  
   console.log(nums.filter((n, i) => nums.indexOf(n) === i).length);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29580
#include<iostream>
#include<cstdio>
#include<algorithm>
int n,a[105],b[2]={};
int main() {
    scanf("%d",&n);int now=0;
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    std::sort(a+1,a+1+n);
    for(int i=n;i;i--) {
        b[now]+=a[i];
        now^=1;
    }
    printf("%d\n",b[0]-b[1]);
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    res = 0
    left = 0
    add_total = 0
    xor_total = 0
    for right in range(n):
        add_total += A[right]
        xor_total ^= A[right]
        while add_total != xor_total:
            add_total -= A[left]
            xor_total ^= A[left]
            left += 1
        res += right - left + 1

    print(res)


if __name__ == '__main__':
    resolve()


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

int n, temp, sum;

int main(){
    cin >> n;
    int a[n];
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    for (int i=0; i<n; i++){
        cin >> temp;
        a[i] -= temp;
        if (a[i] > 0){
            sum += a[i];
        }
    }

    cout << sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

int q;
string s;
deque<char> v;

int main(){
	cin >> s;
	for(auto x : s){
		v.push_back(x);
	}
	ri(q);
	int op, f;
	char c;
	int type = 0;
	while(q--){
		ri(op);
		if(op == 1){
			type ^= 1;
		}
		else{
			ri(f);
			c = getchar();
			while(!isalpha(c)) c = getchar();
			if(f == 1){
				if(type){
					v.push_back(c);
				}
				else{
					v.push_front(c);
				}
			}
			else{
				if(type){
					v.push_front(c);
				}
				else{
					v.push_back(c);
				}
			}
		}
	}
	if(type){
		while(!v.empty()){
			putchar(v.back());
			v.pop_back();
		}
		puts("");
	}
	else{
		while(!v.empty()){
			putchar(v.front());
			v.pop_front();
		}
		puts("");
	}
	return 0;
}


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

int main() {
    int h = 1, w = 1;
    while (h != 0 && w != 0) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (i == 0 || i == h - 1) cout << '#';
                else {
                    if (j == 0 || j == w - 1) cout << '#';
                    else cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

template<class c> auto try_out(c a) -> decltype(cerr << a, 0);
char try_out(...);

struct debug {
#ifdef LOCAL
template<class c, class d> debug& operator << (pair<c, d> e) {
	return *this << "(" << e.first << ", " << e.second << ")";
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) != 1, debug&>::type operator << (c a) {
	cerr << boolalpha << a;
	return *this;
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) == 1, debug&>::type operator << (c a) {
	*this << "[";
	for (auto it = a.begin(); it != a.end(); ++it)
		*this << ","[1 - (it != a.begin())] << *it;
	return *this << "]";
}
#else
template<class c> debug& operator << (c) {
	return *this;
}
#endif
};

#define aty(x) " [" << #x ": " << x << "] "

using ll = long long;




int main() {
    
    int n;
    cin >> n;
    if(n % 2 == 0) cout << n << endl;
    else cout << n * 2 << endl;
    
}


Measured memory_bytes: 256
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const ll INF = (ll) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

vector<vector<pair<ll, ll>>> adj;

ll N;

map<ll, ll> mp;

ll dijkstra(ll s) {
  vector<ll> d;
  d.assign(N, INF);
  d[s] = 0;
  set<pair<ll, ll>> q;
  q.insert({0, s});
  ll mx = 0;
  while (!q.empty()) {
      ll v = q.begin()->second;
      q.erase(q.begin());

      for (auto edge : adj[v]) {
          ll u = edge.first;
          ll w = edge.second;

          if (d[v] + w < d[u]) {
              q.erase({d[u], u});
              d[u] = d[v] + w;
              q.insert({d[u], u});
          }
      }
  }
  for (ll i = 0; i < N; i++) {
    if (mp[i] == 1) continue;
    // cout << d[i] << ' ';
    mx = max(mx, d[i]);
  }
  return mx;
}

int main() {
  ll n, m;
  cin >> n >> m;
  N = n*m;
  string str[n];
  adj.resize(N);
  for (ll i = 0; i < n; i++) {
    cin >> str[i];
  }
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < m; j++) {
      if (str[i][j] == '.') {
        if (j+1 < m and str[i][j+1] == '.') {
          ll a, b;
          a = m*i+j;
          b = m*i+j+1;
          adj[a].pb({b, 1});
          adj[b].pb({a, 1});
        }
        if (i+1 < n and str[i+1][j] == '.') {
          ll a, b;
          a = m*(i)+j;
          b = m*(i+1)+j;
          adj[a].pb({b, 1});
          adj[b].pb({a, 1});
        }
      } else {
        mp[i*m+j]++;
      }
    }
  }
  // dijkstra(0);
  ll mx = 0;
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < n; j++) {
      if (str[i][j] == '.') {
        mx = max(mx, dijkstra(i*m+j));
      }
    }
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int f(vi a) {
  int n = a.size() - 1;
  int res = 0;
  for (int i = 0; i < a.size(); ++i) {
    if ((i & n) == i) res += a[i];
  }
  return res % 2;
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  vi a(n);
  for (int i = 0; i < n; ++i) a[i] = s[i] - '0';
  vi b(n-1);
  int c1 = 0;
  for (int i = 0; i + 1 < n; ++i) {
    b[i] = abs(a[i] - a[i + 1]);
    c1 += b[i] == 1;
  }
  --n;
  if (c1 == 0) {
    for (int i = 0; i < b.size(); ++i) b[i] /= 2;
    cout << f(b) * 2 << endl;
  } else {
    for (int i = 0; i < b.size(); ++i) b[i] %= 2;
    cout << f(b) << endl;
  }
  return 0;
}


Measured memory_bytes: 13084
a, b, c, d = list(map(int, input().split()))

if a >= 0 and b >= 0 and c >= 0 and d >= 0:
    ans = b * d
elif a >= 0 and b >= 0 and c < 0 and d < 0:
    ans = a * d
elif a < 0 and b < 0 and c >= 0 and d >= 0:
    ans = b * c
elif a < 0 and b < 0 and c < 0 and d < 0:
    ans = a * c
else:
    ans = max(a * c, b * d)
print(ans)


Measured memory_bytes: 9144
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string s = Console.ReadLine();
        sb.Append(((s == "a" || s == "i" || s == "u" || s == "e" || s == "o") ? "vowel" : "consonant")+"\n");
    }
}

Measured memory_bytes: 2648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long n = Long.parseLong(scan.next());
        long blue = Long.parseLong(scan.next());
        long red = Long.parseLong(scan.next());
        scan.close();

        long total = blue + red;

        long syo = n / total;
        long amari = n % total;

        long answer = syo * blue;
        if (amari <= blue) {
            answer += amari;
        } else {
            answer += blue;
        }

        System.out.println(answer);
    }

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;
const int N=200010;
const LL inf=18446744073709551615ull;
int n,X,a[N];
LL f[N];
int main(){
	scanf("%d%d",&n,&X);
	for(int i=1; i<=n; ++i)scanf("%d",&a[i]),f[i]=f[i-1]+a[i];
	LL mn=inf;
	for(int i=1; i<=n; ++i){
		LL ans=(f[n]-f[n-i])*2;
		for(int j=n,k=3; j>=1; j-=i,k+=2)
			ans+=1ll*(f[j]-f[max(j-i,0)])*k;
		mn=min(mn,ans+1ll*(i+n)*X);
	}
	printf("%lld",mn);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  int l1, l2, l3;
  l1 = s1.size();
  l2 = s2.size();
  l3 = s3.size();
  int cnt1, cnt2, cnt3;
  cnt1 = cnt2 = cnt3 = 0;
  char t = 'A';
  while(true) {
    if(t == 'A' && cnt1 == l1 || t == 'B' && cnt2 == l2 || t == 'C' && cnt3 == l3) break;
    if(t == 'A') {
      if(s1[cnt1] == 'b') t = 'B';
      else if(s1[cnt1] == 'c') t = 'C';
      ++cnt1;
    } else if(t == 'B') {
      if(s2[cnt2] == 'a') t = 'A';
      else if(s2[cnt2] == 'c') t = 'C';
      ++cnt2;
    } else {
      if(s3[cnt3] == 'a') t = 'A';
      else if(s3[cnt3] == 'b') t = 'B';
      ++cnt3;
    }
  }

  cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        int[] input = new int[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=int.Parse(Console.ReadLine());
        }
        //int[] input = "5 100".Split().Select(i=>int.Parse(i)).ToArray();
        
        var sortList=input.OrderBy(i => abc(i)).ToArray();
        double total = 0;
        //Console.WriteLine(string.Join(",",sortList));
        for(int a = 0; a < 5; a++)
        {
            if (a == 4) 
            {
                    total += (double)sortList[a];
            }else{
                total += Math.Ceiling((double)sortList[a] / 10) * 10;

            }
            
            
        }
        
        /*
        for(int a = 0; a < 5; a++)
        {
            for (int b = 0;b < 5; b++)
            {
                for (int c = 0; c < 5; c++)
                {
                    for (int d = 0; d < 5; d++)
                    {
                        for (int e = 0; e < 5; e++)
                        {

                        }
                    }
                }
            }
        }
        */
        /*
        int n = input[0];
        int q = input[1];
        //int seed = Environment.TickCount;

    */
        Console.WriteLine((int)total);

        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法

        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();
        
    }
    static int abc(int i)
    {
        int val = 10 - i % 10;
        if (val == 10)
        {
            val = 0;
        }
        return val;
    }
}

Measured memory_bytes: 13268
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define MAXI (1<<32)
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define SIZ 1000005
#define SIZE 200005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

/*bool comp(const pair<ll,ll>&a,const pair<ll,ll>&b){
	return a.ff<b.ff || (a.ff==b.ff && a.ss<b.ss);
}*/

//ll p[20000005]={0};
//vector<ll>ans;
/*void sieve(){
    ll i,j;
    p[0]=p[1]=1;
    for(i=2;i*i<=20000005;i++){
        if(!p[i]){
            for(j=2*i;j<20000005;j+=i){
                p[j]=1;
            }
        }
    }
    fo(i,2,20000005){
        if(!p[i]){
            ans.pb(i);
        }
    }
}*/

signed main(){ 
    IOS
    //io_set();
    ll n, x, c = 0, f = 0;
    cin >> n;
    vll v;
    rep(i, n){
        cin >> x;
        v.pb(x);
        if(x%2 != 0){
            f=1;
        }
    }
    if(f){
        cout << 0 << endl;
        return 0;
    }
    ll ans = INT_MAX;
    rep(i, n){
        c = 0;
        x = v[i];
        if(x%2 == 0){
            while(x%2 == 0){
                c++;
                x /= 2;
            }
        }
        ans = min(ans,c);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;


int main(){
  ll ans=0;
  ll n,d;
  cin>>n>>d;
  ll x,y;
  
  rep(i,n){
    cin>>x>>y;
    
    if(x*x+y*y<=d*d){
      ans++;
    }
  }
  
  cout<<ans<<endl;
}




Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

#define MOD 1000000007

using namespace std;

typedef long long int64;

int main(void){
    int64 N,K;
    cin>>N>>K;
    vector<int64> A(N);
    vector<int64> fall(N);
    vector<int64> f_all(N);
    int64 anstmp=0,ans=0;
    
    int64 tmp=0;
    for(int64 i=0;i<N;i++){
        cin>>A[i];
        tmp=0;
        for(int64 j=0;j<i;j++){
            if(A[j]>A[i]){
                tmp++;
            }
        }
        fall[i]=tmp;
        anstmp+=fall[i];
        anstmp%=MOD;
    }

    for(int64 i=0;i<N;i++){
        tmp=0;
        for(int64 j=0;j<N;j++){
            if(A[j]>A[i]){
                tmp++;
            }
        }
        f_all[i]=tmp;
    }

    for(int64 i=0;i<N;i++){
        ans+=(f_all[i]*((K*(K-1)/2)%MOD))%MOD;
    }

    for(int64 i=0;i<N;i++){
        ans+=fall[i]*K%MOD;
    }

    cout<<ans%MOD<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define LL long long
int N,I;
LL A[100];
int main()
{
	scanf("%d",&N);
	A[0]=2;
	A[1]=1;
	for(I=2;I<=N;I++)
	A[I]=A[I-1]+A[I-2];
	printf("%lld",A[N]);
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
# モジュールのインポート
import sys
import itertools


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N, K = list(map(int, input().split()))
    a = list(map(int, input().split()))

    return N, K, a


def main(N: int, K: int, a: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 建物の個数(1 <= N <= 15)
        K (int): 色の数(1 <= K <= N)
        a (list): 高さ(1 <= a_i <= 10**9)
    """
    # 求解処理
    ans = sys.maxsize
    for buildings in itertools.combinations(range(N), K):
        cost = 0
        highest = a[0] - 1
        for n in range(N):
            a_n = a[n]
            built = 0
            if n in buildings:
                built = max(highest - a_n + 1, 0)
                cost += built
            highest = max(highest, a_n + built)
        ans = min(ans, cost)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, K, a = get_input()

    # メイン処理
    main(N, K, a)


Measured memory_bytes: 9240
a,b=map(int,input().split())

if a%2==0 and b%2==0:
  print(int((a+b)/2))
elif a%2==1 and b%2==1:
  print(int((a+b)/2))
elif a%2==0 and b%2==1:
  print(int((a+b+1)/2))
else:
  print(int((a+b+1)/2))

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

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

  long long ans = 0;

  map<string, int> mp;
  
  for (int i = 0;i < n;i++){
    sort(s[i].begin(),s[i].end());
    if (mp.count(s[i])){
      mp[s[i]]++;
      ans += mp[s[i]];
    }
    else{
      mp[s[i]] = 0;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 14032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
int gcd(int a,int b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
/*
*/

int main() {
   string S;
   cin >> S;
   int N = S.size();
   int M = (S.size()-1)/2 + 1;//回文処理のスタート

   int ans  = 0;
   for(int i = M;i<N;i++){
       if(S[N-i-1] != S[i]) ans++; 
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<cstdio>
#include<queue>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	int f=1,x=0;
	char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
	return f*x;
}
#define MAXN 100
#define INF 0x3f3f3f3f
int hang[MAXN+5],lie[MAXN+5];
char str[MAXN+5][MAXN+5];
int main(){
	int h=read(),w=read();
	for(int i=1;i<=h;i++)
		scanf("%s",str[i]+1);
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			hang[i]+=(str[i][j]=='#'?1:0);
	for(int j=1;j<=w;j++)
		for(int i=1;i<=h;i++)
			lie[j]+=(str[i][j]=='#'?1:0);
	//printf("%d %d\n",h-ans1,w-ans2);
	for(int i=1;i<=h;i++){
		if(!hang[i]) continue;
		for(int j=1;j<=w;j++)
			if(lie[j]) printf("%c",str[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int X, A, B;
    cin >> X >> A >> B;

    int count = (X - A) / B;
    cout << (X - A - B * count) << endl;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
A = list(map(int, input().split()))
d = {}
min_ = 10**18
for a in A:
    p = a-min_
    if p not in d:
        d[p] = 1
    else:
        d[p] += 1
    if a <= min_:
        min_ = a
M = max(d.keys())
print(d[M])


Measured memory_bytes: 24628
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N, A, B;
    cin >> N >> A >> B;

    ll duplicate = floor(double(N) / double(A+B)), mod = N % (A+B), ans;
    // cerr << "duplicate = " << duplicate << endl;
    ans += duplicate * A;
    ans += min(mod, A);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int S;
		do{
			S = Integer.parseInt(br.readLine());
		}while(!(0 <= S && S < 86400));

		int h,m,s;
		h = m = s = 0;
		while(S >= 3600){
			S -= 3600;
			h++;
		}
		while(S >= 60){
			S -= 60;
			m++;
		}
		s = S;

		System.out.println(h + ":" + m + ":" + s);
	}
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
  string s;
  cin >> s;

  int res = 1;
  rep(i, s.size()) {
    if (s[i] != 'A') continue;
    for (int j = i + res; j < (int)s.size(); j++) {
      if (s[j] == 'Z') {
        res = max(res, j - i + 1);
      }
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,m,count=0;cin>>n>>m;
  vector<long long>v(n),vv(n);
  map<long long,long long>frq;
  for(long long i=0;i<n;i++)
  {cin>>v[i];
  }
  while(m--)
  {
  long long a,b;cin>>a>>b;
    a--,b--;
    vv[a]=max(vv[a],v[b]);
    vv[b]=max(vv[b],v[a]);
    frq[a]++;frq[b]++;
  }
  for(long long i=0;i<n;i++)
  {if(vv[i]==0)continue;
  else if(v[i]>vv[i])count++;
  }
  for(long long i=0;i<n;i++)
  {if(frq[i]==0)count++;
  }
  cout<<count;
}


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

#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)

// clang-format off
template<typename T>void compress(vector<T>& v, map<T, int>& zip) {
  zip.clear();
  sort(ALL(v));
  v.erase(unique(ALL(v)), v.end());
  REP(i, v.size()) zip[v[i]] = i;
}
// clang-format on

const int dd[] = {0, 1, 0, -1, 0};
vector<int> xs, ys;
int sx[1010], sy[1010], ex[1010], ey[1010];
bool vis[2020][2020];

int dfs(int x, int y) {
  if (x < 0 || xs.size() - 1 <= x || y < 0 || ys.size() - 1 <= y) return 0;
  if (vis[y][x]) return 0;
  vis[y][x] = true;
  REP(d, 4) { dfs(x + dd[d], y + dd[d + 1]); }
  return 1;
}

int main() {
  int W, H;
  map<int, int> zip_x, zip_y;

  while (cin >> W >> H, W || H) {
    xs.clear();
    ys.clear();

    int N;
    cin >> N;
    REP(i, N) cin >> sx[i] >> sy[i] >> ex[i] >> ey[i];
    xs.insert(xs.end(), sx, sx + N);
    xs.insert(xs.end(), ex, ex + N);
    xs.insert(xs.end(), {0, W});
    ys.insert(ys.end(), sy, sy + N);
    ys.insert(ys.end(), ey, ey + N);
    ys.insert(ys.end(), {0, H});
    compress(xs, zip_x);
    compress(ys, zip_y);

    memset(vis, false, sizeof(vis));
    REP(i, N) {
      int zsx = zip_x[sx[i]];
      int zex = zip_x[ex[i]];
      int zsy = zip_y[sy[i]];
      int zey = zip_y[ey[i]];
      FOR(y, zsy, zey) FOR(x, zsx, zex) vis[y][x] = true;
    }
    int ans = 0;
    REP(y, ys.size() - 1) REP(x, xs.size() - 1) ans += dfs(x, y);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 11644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int area = a * b;
        int around = 2 * (a + b);
        System.out.println("" + area + " " + around);
    }
}


Measured memory_bytes: 26264
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,h,w,min,max=0;
  cin >> h >> w;
  int maps[h][w],maze[h][w];

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      maze[i][j]=0;
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a;
      if(a == 1){
	a=0;
      } else{
	a=1;
      }
      maps[i][j]=a;
    }
  }

  for(int i=0;i<w;i++){
    if(maps[0][i]== 1){
      maze[0][i]=1;
      max=1;
    }
  }
  for(int i=0;i<h;i++){
    if(maps[i][0] == 1){
      maze[i][0]=1;
      max=1;
    }
  }

  for(int i=1;i<h;i++){
    for(int j=1;j<w;j++){
      if(maps[i][j] == 1){
	if(maze[i-1][j-1] == maze[i-1][j] && maze[i-1][j] == maze[i][j-1]){
	  maze[i][j]=(maze[i][j-1]+1);
	} else{
	  min=maze[i-1][j-1];
	  if(min > maze[i-1][j]){
	    min=maze[i-1][j];
	  }
	  if(min > maze[i][j-1]){
	    min=maze[i][j-1];
	  }
	  maze[i][j]=min+1;
	}
	if(max < maze[i][j]){
	  max=maze[i][j];
	}
      }
    }
  }


  cout << max*max << endl;
  return 0;
}

Measured memory_bytes: 18392
//AtCoder ABC050 A - Addition and Subtraction Easy
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
    int A,B;
    string op;
    cin>>A>>op>>B;
    int ans= (op[0]=='+')?A+B:A-B;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
input=sys.stdin.readline
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
pos = np.sort(a[a>0])
neg = np.sort(np.abs(a[a<0]))
zero = (a==0).sum()

INF = 2*(10**18)
l = -INF
r = INF
while(r-l>1):
    mid = (l+r)//2
    cnt = 0
    if mid >= 0:
        cnt = len(pos)*len(neg)  #(+) * (-)
        cnt += (len(pos)+len(neg)) * zero # 0 * (non-zero)
        cnt += (zero*(zero-1))//2 # 0 * 0
        x = np.searchsorted(pos, mid//pos, side='right').sum() #(+) * (+)
        x += np.searchsorted(neg, mid//neg, side='right').sum() #(-) * (-)
        x -= (pos*pos<=mid).sum()
        x -= (neg*neg<=mid).sum()
        cnt += x/2
    else:
        #積がmid以上になれば良い -> midよりも小さい
        cnt = (len(neg) - np.searchsorted(neg, abs(mid)//pos + (mid%pos!=0), side='left')).sum()
    #print(mid, cnt)
    #cnt := 積がmid以下になる物の数
    #k番目の数　-> それ以下のものがk個以上ある事が必要
    #cntがk個よりも少ない -> 条件を満たしていない
    #cntがそれ以上ならok
    if cnt < k:
        l = mid
    else:
        r = mid
print(r)


Measured memory_bytes: 32296
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main(){
    int n,q;
    cin >> n;
    int s[n+1];
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    cin >> q;
    int t[q];
    for(int i=0;i<q;i++){
        cin >> t[i];
    }
    int ans=0;
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(t[i]==s[j]){
                ans++;
                goto l;
            }
        }
    l:;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3124