akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;

signed main(){
	int a, b, c, k;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
	if(k%2 == 1){
		printf("%lld\n", b-a);
	}else{
		printf("%lld\n", a-b);
	}
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
class dice
{
  private:
  int status[6];
  public:
  dice();
  int showup(void);
  void rotate(char);
};

dice::dice()
{
  for(int i=0;i<6;i++)
    cin>>status[i];
}


int dice::showup()
{
  cout<<status[0]<<endl;
}

void dice::rotate(char s)
{
  switch(s)
  {
    int tmp;
    case 'N':
      tmp=status[0];
      status[0]=status[1];
      status[1]=status[5];
      status[5]=status[4];
      status[4]=tmp;
      break;
    case 'E':
      tmp=status[0];
      status[0]=status[3];
      status[3]=status[5];
      status[5]=status[2];
      status[2]=tmp;
      break;
    case 'W':
      tmp=status[0];
      status[0]=status[2];
      status[2]=status[5];
      status[5]=status[3];
      status[3]=tmp;
      break;
    case 'S':
      tmp=status[0];
      status[0]=status[4];
      status[4]=status[5];
      status[5]=status[1];
      status[1]=tmp;
      break;
  }
}

int main()
{
  dice di1;
  string s;
  cin>>s;
  for(int i=0;s[i];i++)
    di1.rotate(s[i]);
  di1.showup();
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <queue>
#include <utility>
using namespace std;

typedef pair<int,int> P;
int H,W;
int w = 0,b = 0;
char G[51][51];
int inf = 1e8;
int visited[51][51] = {0};
int d[51][51] = {0};
int dx[] = {-1,1,0,0};
int dy[] = {0,0,1,-1};

bool in(int x,int y){
	return 0<=x && x<H && 0<=y && y<W && G[x][y] == '.';
}

void dfs(){
	queue<P> q;
	visited[0][0] = 1;
	q.push(P(0,0));
	while(q.size()){
		P p = q.front();q.pop();
		if(p.first == H-1 && p.second == W-1) break;
		for(int i=0;i<4;i++){
			int n = p.first + dx[i],m = p.second + dy[i];
			if(in(n,m) && d[n][m] == inf){
				q.push(P(n,m));
				d[n][m] = d[p.first][p.second] + 1;
			}
		}
	}
}

int main(){
	cin >> H >> W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> G[i][j];
			if(G[i][j]=='.') w++;
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			d[i][j] = inf;
		}
	}
	d[0][0] = 1;
	dfs();
	if(d[H-1][W-1] != inf) cout << w-d[H-1][W-1] << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()

E_cnt = S.count('E')
S_cnt = 0

min_cnt = 10 ** 6
for i in range(N):
    cnt = 0
    if S[i] == 'E':
        E_cnt -= 1
        cnt = S_cnt + E_cnt
    else:
        cnt = S_cnt + E_cnt
        S_cnt += 1
    min_cnt = min(min_cnt, cnt)

print(min_cnt)



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

public class Main {

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

		String str[] = br.readLine().split(" ");

		int h = Integer.parseInt(str[0]);
		int w = Integer.parseInt(str[1]);

		char matrix[][] = new char[h][w];

		for (int i = 0; i < h; i++) {
			char c[] = br.readLine().toCharArray();
			for (int j = 0; j < w; j++) {
				matrix[i][j] = c[j];
			}
		}

		int left[][] = new int[h + 10][w + 10];
		int right[][] = new int[h + 10][w + 10];
		int top[][] = new int[h + 10][w + 10];
		int bottom[][] = new int[h + 10][w + 10];

		for (int i = 0; i < h; ++i) {
			int cur = 0;
			for (int j = 0; j < w; ++j) {
				if (matrix[i][j] == '#')
					cur = 0;
				else
					++cur;
				left[i][j] = cur;
			}
		}

		for (int i = 0; i < h; ++i) {
			int cur = 0;
			for (int j = w - 1; j >= 0; --j) {
				if (matrix[i][j] == '#')
					cur = 0;
				else
					++cur;
				right[i][j] = cur;
			}
		}

		for (int j = 0; j < w; ++j) {
			int cur = 0;
			for (int i = 0; i < h; ++i) {
				if (matrix[i][j] == '#')
					cur = 0;
				else
					++cur;
				top[i][j] = cur;
			}
		}

		for (int j = 0; j < w; ++j) {
			int cur = 0;
			for (int i = h - 1; i >= 0; --i) {
				if (matrix[i][j] == '#')
					cur = 0;
				else
					++cur;
				bottom[i][j] = cur;
			}
		}

		int max = 0;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (matrix[i][j] == '#')
					continue;
				max = Math.max(max, left[i][j] + right[i][j] + top[i][j] + bottom[i][j] - 3);
			}
		}

		System.out.println(max);
	}

}

Measured memory_bytes: 108720
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	cout<<n-k+1;
}

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

int main(){
   ll n;
   cin >>n;
   vector<ll> a(n);
   rep(i,n)cin >> a[i];
   ll sum = 0;
   rep(i,n){
      sum+=a[i];
   }
   map<ll,ll>mp;
   rep(i,n){
      mp[a[i]]++;
   }
   int q;
   cin >> q;
   rep(i,q){
      int b,c;
      cin >> b>>c;
      sum-=mp[b]*b;
      sum+=mp[b]*c;
      mp[c]+=mp[b];
      mp[b]=0;
      cout << sum <<endl;
   }
}

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


int main(){
  long long maxn=0, minn = 10e9+1;
  int n;

  cin >> n;
  
  long long in;
  for(int i=0;i<n;++i){
    cin >> in;
    
    maxn = max(maxn, in);
    minn = min(minn, in);
  }

  cout << maxn - minn << endl;

  return 0;
}


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

class UnionFind{
    vector<int> par;
    vector<long long> wei;
    int groupCount;

public:
    UnionFind(int n = 0){
        init(n);
    }

    void init(int n = 0){
        par.resize(n);
        fill(par.begin(), par.end(), -1);

        wei.resize(n);
        fill(wei.begin(), wei.end(), 0LL);

        groupCount = n;

        return;
    }

    int root(int x){
        if(par[x] < 0){
            return x;
        }
        int r = root(par[x]);
        wei[x] += wei[par[x]];
        return par[x] = r;
    }

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

    int size(int x){
        return -par[root(x)];
    }

    long long weight(int x){
        root(x);
        return wei[x];
    }

    long long diff(int x, int y){
        return weight(y) - weight(x);
    }

    bool unite(int x, int y, long long w = 0){
        w += weight(x) - weight(y);

        x = root(x);
        y = root(y);

        if(x == y){
            return false;
        }

        if(par[y] < par[x]){
            swap(x, y);
            w = -w;
        }

        par[x] += par[y];
        par[y] = x;
        wei[y] = w;
        --groupCount;

        return true;
    }

    int size(void){
        return groupCount;
    }
};

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

    int n, m;
    cin >> n >> m;

    UnionFind uf(n);
    for(int i = 0 ; i < m ; ++i){
        int x, y, z;
        cin >> x >> y >> z;
        uf.unite(x - 1, y - 1);
    }

    cout << uf.size() << endl;

    return 0;
}

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

void MAIN() {
    int n;
    scanf("%d", &n);
    std::vector<int> cnt(n);
    int maxEle = 0;
    for(int i = 0; i < n; ++ i) {
        int val;
        scanf("%d", &val);
        maxEle = std::max(maxEle, val);
        ++ cnt[val];
    }
    int minEle = (maxEle + 1) / 2;
    for(int i = 0; i < minEle; ++ i) {
        if(cnt[i] > 0) {
            puts("Impossible");
            return ;
        }
    }
    if(maxEle & 1) {
        if(cnt[minEle] != 2) {
            puts("Impossible");
            return ;
        }
    } else {
        if(cnt[minEle] != 1) {
            puts("Impossible");
            return ;
        }
    }
    for(int i = minEle + 1; i <= maxEle; ++ i) {
        if(cnt[i] < 2) {
            puts("Impossible");
            return;
        }
    }
    puts("Possible");
}

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


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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int N = 250000;
const int B = 500;
const int BKT = (N + B - 1) / B;

int n, s[N], mx[BKT], mn[BKT], add[BKT];
inline void update(int i){
	if(i * B >= n / 2) return;
	int m = inf, M = -inf;
	for(int j = i * B; j < n / 2 && j < (i + 1) * B; j++){
		m = min(m, s[j]);
		M = max(M, s[j]);
	}
	mn[i] = m; mx[i] = M;
}
void query(int l, int r, int x){
	while(l < r && l % B) s[l++] += x; update(max(0, l / B - 1));
	while(l < r && r % B) s[--r] += x; update(r / B);
	
	l /= B; r /= B;
	while(l < r) add[l++] += x;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n;
	rep(i, n){
		int a; cin >> a;
		if(i < n / 2) s[i] += a;
		else s[n - i - 1] -= a;
	}
	for(int i = 0; i < BKT; i++) update(i);
	
	int q; cin >> q;
	while(q--){
		int l, r, x; cin >> l >> r >> x; l--;
		if     (r <= n / 2) query(l, r, x);
		else if(l >= n / 2) query(n - r, n - l, -x);
		else{
			query(l, n / 2, x);
			query(n - r, n / 2, -x);
		}
		/*
		rep(i, n / 2) cerr<<s[i]+add[i/B]<<" ";cerr<<endl;
		rep(i, n / 2) cerr<<mx[i/B]<<" ";cerr<<endl;
		rep(i, n / 2) cerr<<mn[i/B]<<" ";cerr<<endl;
		*/
		int res = 1;
		rep(i, BKT) if(!(mx[i] == mn[i] && mx[i] + add[i] == 0)) res = 0;
		/*
		rep(i, BKT) if(!(mx[i] == mn[i] && mx[i] + add[i] == 0)){
			dbg(i);
			dbg(mx[i]); dbg(mn[i]); dbg(add[i]); exit(0);
		}*/
		printf("%d\n", res);
	}
	
	return 0;
}

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

void solve(int N, int K, vector<int> p)
{
    sort(p.begin(), p.end());
    int res = 0;
    for (int i = 0; i < K; i++)
    {
        res += p.at(i);
    }
    cout << res << endl;
}

int main()
{
    int N;
    cin >> N;
    int K;
    cin >> K;
    vector<int> p(N);
    for(int i = 0 ; i < N ; i++){
        cin >> p.at(i);
    }
    solve(N, K, move(p));
    return 0;
}


Measured memory_bytes: 3628
#include<stack>
#include<map>
#include<set>
#include<cstdio>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm> 
using namespace std;
int main(){
	int n,x,t,i;
	vector<int> v;
	cin>>n>>x;
	for(i=1;i<=n;i++){
		cin>>t;
		v.push_back(t);
	}
	sort(v.begin(),v.end());
	int ans=0;
	i=0;
	while(x>0 && i<v.size()){
		ans++;
		x-=v[i];
		i++;
	}
	if(x){
		ans+=x/v[0];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll x;
    cin>>x;
    for(ll b = -1000; b<1000; b++)
    {
        for(ll a = b + 1; a<1000; a++)
        {
            ll b1 = b*b*b*b*b;
            ll a1 = a*a*a*a*a;
            if((a1 - b1) == x)
            {
                cout<<a<<" "<<b<<'\n';
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
#[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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[allow(unused_macros)]
macro_rules ! vec_md { ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) } ; ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] } ; ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] } ; }

#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        a: [[u64;n];n]
    }

    let mut dp = vec_md![0u64;n+1;1<<n];
    dp[0][0] = 1;
    for i in 0..n {
        for mask in bit_fixed_size_subsets(i, n) {
            for j in 0..n {
                if mask >> j & 1 == 0 && a[i][j] == 1 {
                    dp[i+1][mask | (1 << j)] += dp[i][mask] % M;
                    dp[i+1][mask | (1 << j)] %= M;
                }
            }
        }
    }
    println!("{}", dp[n][(1<<n)-1]);
}

#[allow(dead_code)]
fn bit_fixed_size_subsets(k: usize, n: usize) -> Vec<usize> {
    let mut ret = vec![];
    let mut x: i64 = (1 << k as i64) - 1;
    while x < 1 << n {
        ret.push(x as usize);
        if k == 0 {
            break;
        }
        let t = x | (x - 1);
        x = (t + 1) | (((!t & -!t) - 1) >> (x.trailing_zeros() + 1));
    }
    ret
}

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

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

  int n = s.size();
  int m = (n - 1) / 2;

  int k = m, c = 0;
  if (n & 1) {
    --k;
    ++c;
  }

  while(k >= 0) {
    if (s[k] != s[m] || s[n-k-1] != s[m]) {
      break;
    }
    k--;
    c += 2;
  }

  int res = n - (n - c) / 2;
  cout << res << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

const ll mod = 1LL << 32;

char Hex[17] = "0123456789abcdef";
ll from16(string str) {
	ll res = 0;
	for (int i = 0; i < str.size(); ++i) {
		res *= 16;
		res += '0' <= str[i] && str[i] <= '9' ? (str[i]-'0') : (str[i]-'a')+10;
	}
	return res;
}
string to16(ll x) {
	string res = "";
	x %= mod;
	do {
		res += Hex[x % 16];
		x /= 16;
	} while (x > 0);
	reverse(res.begin(), res.end());
	return res;
}
string solve(vector<string>& v) {
	vector<ll> vl(9);
	for (int i = 0; i < v.size(); ++i) {
		vl[i] = from16(v[i]);
	}
	ll res = 0;
	for (int i = 0; i < 32; ++i) {
		ll sum = 0;
		for (int j = 0; j < 8; ++j) {
			sum += vl[j]^res;
		}
		ll bit = (1LL << i);
		if ((sum&bit) != (vl[8]&bit)) {
//			cout << 1 << " ";
			res |= bit;
		}
//		else cout << 0 << " ";
	}
//	cout << endl;
//	cout << res << endl;
	return to16(res);
}
int main() {
	int D; cin >> D;
	for (int i = 0; i < D; ++i) {
		vector<string> v(9);
		for (int j = 0; j < 9; ++j) {
			cin >> v[j];
		}
		cout << solve(v) << endl;
	}
}

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

int main() {
	string s;
	int starts, ends;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == 'A') {
			starts = i;
			break;
		}
	}
	for (int i = 0; i < s.size(); i++) {
		if (s.at(s.size() - (i + 1)) == 'Z') {
			ends = s.size() - (i + 1);
			break;
		}
	}
	cout << ends -starts + 1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define N 200100
#define pii pair<int,int>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define inf 1e9
void solve(){
	string s;
	cin>>s;
	int len=s.length();
	ll ans=0;
	int j=len-1;
	for(int i=0;i<len/2;i++){
		if(s[i]!=s[j])
			ans++;
		j--;
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define LEN 100005

typedef struct pp{
  char name[10];
  int t;
} P;

P Q[LEN];
int head,tail,n;

P dequeue(void);
void enqueue(P);
int min(int ,int );

int main(){
  int i,q;
  P u;
  int elaps = 0,c; /*elapsは経過時間*/

  scanf("%d %d",&n,&q);

  for(i = 1; i <= n ; i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t );
  }
  head = 1;
  tail = n+1;

  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u); /*処理が完了していない場合は後尾に格納*/
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}

P dequeue(void){
  P a = Q[head];
  head = (head + 1)% LEN;
  return a;
}

void enqueue(P a){
  Q[tail] = a;
  tail = (tail +1)%LEN;
}

int min(int a,int b){
  if(a > b)return b;
  else return a;
}



Measured memory_bytes: 3296
#include<cstdio>
long long modpow(long long a,long long b,long long p)
{
    long long ret=1;
    for(;b>0;b>>=1,a=(a*a)%p)
        if(b&1)
            ret=(ret*a)%p;
    return ret;
}
long long phi(long long n)
{
    long long res=n,t=n;
    for(long long i=2;i*i<=t;i++)
        if(t%i==0)
        {
            res-=res/i;
            while(t%i==0)
                t/=i;
        }
    if(t>1)
        res-=res/t;
    return res;
}
long long gcd(long long a,long long b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
long long exgcd(long long a,long long b,long long &x,long long &y)
{
    if(b==0)
    {x=1;y=0;return a;}
    long long g;
    g=exgcd(b,a%b,y,x);
    y-=a/b*x;
    return g;
}
long long solve(long long A,long long M)
{
    if(M==1)
        return 1;
    long long pM,At,d,t,x,y;
    pM=phi(M);
    d=gcd(M,pM);
    t=solve(A,d);
    At=modpow(A,t,M);
    exgcd(M/d,pM/d,x,y);
    x=x*(((t-At)%pM+pM)%pM)/d;
    x=((x%(pM/d))+pM/d)%(pM/d)+pM/d;
    return x*M+At;
}
int main()
{
    int Q;
    long long A,M;
    scanf("%d",&Q);
    while(Q--)
    {
        scanf("%lld%lld",&A,&M);
        printf("%lld\n",solve(A,M));
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    char S[9], T[9];
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < 3; ++i) ans += S[i] == T[i];
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;
int par[100010];
int urank[100010];

void init(int n){
   for(int i=0;i<n;i++){
      par[i]=i;
      urank[i]=0;
   }
}
int find(int x){
   if(par[x]==x)return x;
   else return par[x]=find(par[x]);
}
void unite(int x,int y){
   x=find(x);
   y=find(y);
   if(x==y)return ;
   if(urank[x]<urank[y])par[x]=y;
   else {
      par[y]=x;
      if(urank[x]==urank[y])urank[x]++;
   }
}
bool same(int x,int y){
   return find(x)==find(y);
}


int main(){
   int n,m;
   cin>>n>>m;
   vector<int> a(m),b(m);
   for(int i=0;i<m;i++){
      cin>>a[i]>>b[i];
      a[i]--;b[i]--;
   }

   int ans=0;
   for(int i=0;i<m;i++){
      init(n);
      for(int j=0;j<m;j++){
         if(i!=j)unite(a[j],b[j]);
      }
      bool flag=false;
      for(int j=0;j<n;j++){
         for(int k=0;k<n;k++){
            if(!same(j,k))flag=true;
         }
      }
      if(flag)ans++;
   }
   cout<<ans<<endl;
}

   


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

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

  for (int i = 0; i < N; i++) {
    string s;
    cin >> s ;
    if(s == "Y"){
      A = "Four" ;
      cout << A << endl;
      break;
      }
  	}
  if(A != "Four")
   cout << "Three" << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p = -1) {
    for (int u : to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

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

    int n, q;
    cin >> n >> q;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    ans.resize(n);
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    debug(to[0], ans);
    dfs(0);
    rep(i, n) { cout << ans[i] << endl; }
    return 0;
}


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

using namespace std;

int main() {
    int N;
    int twos, fours, nons;
    twos = fours = nons = 0;
    const int MAXN = 1e5+5;
    vector<int> a(MAXN,0);
    cin >> N;
    for(int i = 1; i <= N; ++i) {
        cin >> a[i];
        if((a[i]%2) != 0) {
            ++nons;
        } else {
            if((a[i]%4) == 0) {
                ++fours;
            } else {
                ++twos;
            }
        }
    }
    bool failure = false;
    if(nons) {
        fours -= nons-1;
        if(fours < 0)
            failure = true;
        if(twos%2 != 0 and fours == 0)
            failure = true;
    } else {
        fours -= twos%2;
        if(fours < 0)
            failure = 0;
    }
    if(failure)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int H;
int heap[500000];

inline void max_heapify(int node) {
    int left = node * 2 + 1, right = node * 2 + 2, largest = node;
    if (left < H && heap[left] > heap[node]) {
        largest = left;
    }
    else {
        largest = node;
    }
    if (right < H && heap[right] > heap[largest]) {
        largest = right;
    }
    if (largest != node) {      // a child is bigger than the parent.
        int tmp = heap[node];
        heap[node] = heap[largest];
        heap[largest] = tmp;
        max_heapify(largest);
    }
}

inline void build_max_heap() {
    for (int i = H / 2 - 1; i >= 0; --i) {
        max_heapify(i);
    }
}

int main(void) {

    scanf("%d", &H);

    for (int i = 0; i < H; ++i) {
        scanf("%d", heap + i);
    }

    build_max_heap();

    for (int i = 0; i < H; ++i) {
        printf(" %d", heap[i]);
    }
    printf("\n");

    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    double l; cin >> l;
    double v = pow(l / 3, 3);
    setpre(10); out(v);
}

Measured memory_bytes: 512
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second

typedef pair< int, int > iP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int main() {
    
    int N, M;
    while(cin >> N >> M, N) {
        vector< vector< iP > > pc(N + 1);
        int r; cin >> r;
        while(r--) {
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            pc[n].push_back(iP(t, m));
        }
        int q; cin >> q;
        while(q--) {
            int ans = 0;
            int begin, end, m; cin >> begin >> end >> m;
            vector< bool > used(1270, true);
            for(int i = 1; i <= N; i++) {
                for(int j = 0; j < pc[i].size(); j += 2) {
                    if(pc[i][j].sc == m) {
                        for(int k = max(begin, pc[i][j].fr); k < min(pc[i][j +  1].fr, end); k++) {
                            if(used[k]) ans++, used[k] = false;
                        }
                    }
                }
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long N) {
  int a = N % 10;
  string ans = "";
  if (a == 3) {
    ans = "bon";
  } else if (a <= 1 || a == 6 || a == 8) {
    ans = "pon";
  } else {
    ans = "hon";
  }
  cout << ans << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3700
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func mainFn() {
	a, b := getInt(), getInt()

	ans := max(0, a - 2*b)
	puts(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// -----------------------------------------

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// scanner.Buffer(make([]byte, buf), buf)
	scanner.Split(bufio.ScanWords)
	mainFn()
	writer.Flush()
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}

func puts(a ...interface{}) {
	if _, err := fmt.Fprintln(writer, a...); err != nil {
		panic(err)
	}
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func Abs(x int) int {
	if x < 0 {
		return -x
	} else {
		return x
	}
}

// 8 qeens problem

func Available(board [8][8]rune, row, col int) bool {
	// horizontal
	for _, v := range board[row] {
		if v == 'Q' {
			return false
		}
	}
	// vertical
	for _, r := range board {
		if r[col] == 'Q' {
			return false
		}
	}
	// diagonal
	for i := 0; i < 8; i++ {
		left  := col - Abs(row - i)
		right := col + Abs(row - i)
		if 0 <= left && left < 8 {
			if board[i][left] == 'Q' {
				return false
			}
		}
		if 0 <= right && right < 8 {
			if board[i][right] == 'Q' {
				return false;
			}
		}
	}
	return true
}
func Done(row [8]rune) bool {
	for _, v := range row {
		if v == 'Q' {
			return true;
		}
	}
	return false
}
func Fill(board [8][8]rune, row int, col int) bool {

	if col == 8 {
		return false
	}
	if row == 8 {
		for _, row := range board {
			for _, col := range row {
				fmt.Printf("%c", col)
			}
			fmt.Println()
		}
		return true
	}
	// alread set has qeen 
	if Done(board[row]) {
		return Fill(board, row+1, col)
	}

	if Available(board, row, col) {
		board[row][col] = 'Q'
		if Fill(board, row + 1, 0) {
			return true
		} else {
			board[row][col] = '.'
			return Fill(board, row, col + 1)
		}
	} else {
		return Fill(board, row, col + 1)
	}
}

// 一次元の配列にしたほうがいいような

func main() {
	var board [8][8]rune
	// fill board
	for r, row := range board {
		for c, _ := range row {
			board[r][c] = '.'
		}
	}

	var k int
	fmt.Scanf("%d", &k)
	for i := 0; i < k; i++ {
		var r, c int
		fmt.Scanf("%d %d", &r, &c)
		board[r][c] = 'Q'
	}
	// for _, row := range board {
	// 	for _, col := range row {
	// 		fmt.Printf("%c", col)
	// 	}
	// 	fmt.Println()
	// }
	Fill(board, 0, 0)
	// fmt.Println(result)
	// for _, row := range board {
	// 	for _, col := range row {
	// 		fmt.Printf("%c", col)
	// 	}
	// 	fmt.Println()
	// }
	// for r, row := range board {
	// 	for c, _ := range row {
	// 		if Available(r, c) {
	// 			fmt.Printf(". ")
	// 		} else {
	// 			fmt.Printf("x ")
	// 		}
	// 	}
	// 	fmt.Println()
	// }
}


Measured memory_bytes: 1216
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 998244353;
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}

string str;
int n, k;
ll dp[305][305][305];

int main(){
	cin >> str;
	n = str.size();
	cin >> k; chmin(k, n);
	dp[0][0][0] = 1;
	for(int i=0;i<n;i++){
		int pre = n-1-i;
		while(pre >= 0 && str[pre] == '1') pre--;
		
		rep(j, i+1){
			rep(all, k+1){
				if(dp[i][j][all] == 0) continue;
				if(str[n-1-i] == '0'){
					//0 & 0
					add(dp[i+1][j+1][all], dp[i][j][all]);
					//0 & 1
					if(i > j){
						add(dp[i][j+1][all], dp[i][j][all]);
					}
				}
				else{
					//1 & 0
					if(pre != -1 && all+n-1-i-pre <= k) add(dp[n-pre][j+1][all+n-1-i-pre], dp[i][j][all]);
					//1 & 1
					add(dp[i+1][j+1][all], dp[i][j][all]);
				}
			}
		}
	}
	//cout << dp[2][1][1] << endl;
	ll ans = 0;
	rep(j, n+1) rep(i, k+1) ans += dp[n][j][i];
	cout << (ans%mod) << endl;
}

Measured memory_bytes: 81580
# D - Built?
from heapq import *

# Aでxの根を求める
def find(A, x):
    p = A[x]
    if p == x:
        return x
    a = find(A, p)
    A[x] = a
    return a

# Aでxとyの属する集合の併合
def union(A, x, y):
    if find(A, x) > find(A, y):
        bx, by = find(A, y), find(A, x)
    else:
        bx, by = find(A, x), find(A, y)
    # 根をbx(値の小さい方)に統一 
    A[by] = bx

N = int(input())
X = [(0,0)] * N
Y = [(0,0)] * N

for i in range(N):
    x, y = map(int, input().split())
    X[i] = (x, i)
    Y[i] = (y, i)

X.sort()
Y.sort()
H = []
heapify(H)

for i in range(N - 1):
    x1, j1 = X[i]
    x2, j2 = X[i+1]
    y1, k1 = Y[i]
    y2, k2 = Y[i+1]
    # ヒープ構造を用いて常にHの先頭に最小値を持ってくる
    # X座標とY座標でそれぞれHに追加
    heappush(H, (x2 - x1, j1, j2))
    heappush(H, (y2 - y1, k1, k2))

answer = 0
V = [i for i in range(N)]

while H:
    w, s, t = heappop(H)
    # sとtの集合が異なっていた時、道を作る
    if find(V, s) != find(V, t):
        union(V, s, t)
        answer += w

print(answer)

Measured memory_bytes: 53544
#include <iostream>

using namespace std;

int N;
int sum[300005];

int main(void)
{
	cin >> N;
	char c;
	for(int i = 1; i <= N; i++){
		cin >> c;
		sum[i] = sum[i-1];
		if(c == 'E') sum[i]++;
	}
	
	int ans = 1e9;
	for(int i = 1; i <= N; i++){
		ans = min(ans, (i-1) - sum[i-1] + sum[N] - sum[i]);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<algorithm>
using namespace std;

const int maxn = 2000 + 10;
int a[maxn];

int main()
{
    int n,x,y;
    while(scanf("%d%d%d",&n,&x,&y) == 3)
    {
        for(int i = 1; i <= n; i++)
            scanf("%d",&a[i]);
        if(n == 1)
            printf("%d\n",abs(a[1] - y));
        else
            printf("%d\n",max(abs(a[n] - y),abs(a[n] - a[n - 1])));
    }
    return 0;
}


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

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    
    int x;
    cin>>x;
    
    vector<int> p(3);
    int ans=0;
    
    rep(i,a){
        rep(j,b){
            rep(k,c){
                if(500*i+100*j+50*k==x)ans++;
            }
        }
    }
    cout<<ans;
    
    
    return 0;
    }



Measured memory_bytes: 3572
from queue import LifoQueue

MAP = input()

que = LifoQueue()
res = LifoQueue()

for i, m in enumerate(MAP):
    if m=='\\':
        que.put(i)
    elif m=='/':
        if not que.empty():
            j = que.get(False)
            v = i - j
            t = (j, v)
            while not res.empty():
                pre = res.get(False)
                if (pre[0] > j):
                    t = (t[0], t[1] + pre[1])
                else:
                    res.put(pre)
                    res.put(t)
                    break
            else:
                res.put(t)

summaly = 0
lakes = []
while not res.empty():
    v = res.get()
    lakes.append(v[1])
    summaly += v[1]

print(summaly)
print(len(lakes), *(reversed(lakes)))



Measured memory_bytes: 7732
#include <iostream>

using namespace std;

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

    bool ans = true;
    int n = s.length();
    for (int i = 0; i < (n - 1) / 2; i++) {
        if (s[i] != s[n - 1 - i]
             || s[i] != s[(n - 1) / 2 - 1 - i]
             || s[(n + 3) / 2 - 1 + i] != s[n - 1 - i]) {
            ans = false;
            break;
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
fun main(args: Array<String>?): Unit {
    repeat(readLine()!!.trim().toInt()) {
        val initial = readLine()!!.trim().toInt()
        val year = readLine()!!.trim().toInt()
        var maxCount = initial
        repeat(readLine()!!.trim().toInt()){
            val arg = readLine()!!.trim().split(' ')
            val type = arg[0].toInt()
            val r = arg[1].toDouble()
            val fee = arg[2].toInt()
            val result = when(type) {
                0 -> {
                    var baseMoney = initial
                    var gain = 0
                    repeat(year) {
                        gain += (baseMoney * r).toInt()
                        baseMoney -= fee
                    }
                    baseMoney + gain
                }
                1 -> {
                    var money = initial
                    repeat(year) {
                        money += (money * r).toInt() - fee
                    }
                    money
                }
                else -> TODO()
            }
            if (result > maxCount) maxCount = result
        }
        println(maxCount)
    }
}



Measured memory_bytes: 40548
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int n,d,ans=0;
int a[12][12];
int main(){
	cin>>n>>d;
	for (int i=0;i<n;i++) for (int j=0;j<d;j++) cin>>a[i][j];
	for (int i=0;i<n;i++) for (int j=i+1;j<n;j++){
		int o=0;
		for (int k=0;k<d;k++) o+=abs(a[i][k]-a[j][k])*abs(a[i][k]-a[j][k]);
		for (int q=0;q<1000;q++) if (q*q==o) ans++;
	}
	cout<<ans;
}

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

int main(){
  double a, b;
  cin >> a >> b;
  double t = (b - a)/2.0;
  if(abs(t - 180.0) < abs(t)) t -= 180.0;
  if(abs(t + 180.0) < abs(t)) t += 180.0;
  if(abs(t - 360.0) < abs(t)) t -= 360.0;
  if(abs(t + 360.0) < abs(t)) t += 360.0;
  while(a+t >= 360.0) t -= 360;
  while(a+t < 0.0) t += 360;
  printf("%.12f\n", a+t);
  return 0;
}



Measured memory_bytes: 3272
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);
ll cnt[3000],cnt1[3000];
int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	string s;
	ll ans=0,i,j,val;
	cin>>s;
	rep(i,2019){
		cnt[i]=0;
	}
	cnt[s[0]-'0']=1;
	cnt[0]++;
	f(i,1,s.length()){
		rep(j,2019){
			val=j*10+s[i]-'0';
			val%=2019;
			cnt1[val]+=cnt[j];
		}
		rep(j,2019){
			cnt[j]=cnt1[j];
			cnt1[j]=0;
		}
		ans+=cnt[0];
		cnt[0]++;
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);


int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h)rep(j,w) cin >> a[i][j];
  vector<vector<char>> b(h+2,vector<char>(w+2));
  rep(i,h+2){
    rep(j,w+2){
      b[i][j]='#';
    }
  }
  rep(i,h){
    rep(j,w){
      b[i+1][j+1]=a[i][j];
    }
  }
  rep(i,h+2){
    rep(j,w+2){
      cout << b[i][j];
    }
    cout << endl;
  }
  return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll a;
  scanf("%lld",&a);
  ll b;
  scanf("%lld",&b);
  ll sum=0;
  for (int i=1; i<=b-a; i++) {
    sum+=i;
  }
  cout << sum-b << endl;
}

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


Measured memory_bytes: 256
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll h,w;
  cin>>h>>w;
  vvc a(h,vc(w));

  rep(i,h)
  {
    rep(j,w)
    {
      cin>>a[i][j];
    }
  }
  rep(i,h+2){
    rep(j,w+2){
      if(j==w+1)cout<<'#'<<endl;
      else if(i==0||j==0||i==h+1)cout<<'#';
      else cout<<a[i-1][j-1];
    }
  }
  
}

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

using namespace std;

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

  int q;
  cin >> q;
  vector<int> primes(100001, 1);
  primes[0] = primes[1] = 0;
  for (int i = 2; i < 100001; ++i) {
    if (primes[i] == 0)
      continue;
    for (int p = i * 2; p < 100001; p += i) {
      primes[p] = 0;
    }
  }
  vector<int> sums(100001);
  for (int i = 3; i < 100001; i += 2) {
    if (primes[i] && primes[(i + 1) / 2]) {
      sums[i] = 1;
    }
  }
  for (int i = 1; i < 100001; ++i) {
    sums[i] += sums[i - 1];
  }

  for (int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    if (l % 2 == 0)
      ++l;
    cout << sums[r] - sums[l - 1] << "\n";
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

vector<int> v[100010];
int par[100010], Rank[100010], SIZE[100010];

void init(int n)
{
    rep(i, n)
    {
        par[i] = i;
        Rank[i] = 0;
        SIZE[i] = 1;
    }
}
int find(int x)
{
    if (par[x] == x)
        return x;
    else
        return par[x] = find(par[x]);
}
void unit(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (Rank[x] < Rank[y])
    {
        par[x] = y;
        SIZE[y] += SIZE[x];
    }
    else
    {
        par[y] = x;
        SIZE[x] += SIZE[y];
        if (Rank[x] == Rank[y])
            Rank[x]++;
    }
}
bool same(int x, int y)
{
    return find(x) == find(y);
}

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

    int n, m;
    cin >> n >> m;
    init(n);
    rep(i, m)
    {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        unit(x, y);
    }
    int ans = 0;
    rep(i, n) if (par[i] == i) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 4992
import java.util.*;
class Main {
    static int N,K;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        K = sc.nextInt();

        System.out.println(dfs(1,0));

    }
    public static int dfs(int i, int depth) {
        if(depth == N) return i;
        return Math.min(dfs(i*2,depth+1), dfs(i+K, depth+1));
    }
}

Measured memory_bytes: 22100
#include<stdio.h>
#include<string.h>
int main(void){
    char s[3];
    scanf("%s",s);
    if(strlen(s) == 2) printf("%s\n",s);
    if(strlen(s) == 3){
        for(int i = 2; i >= 0; i--) printf("%c",s[i]);
        printf("\n");
    }
    return 0;
}

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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
    int h,w,n;
    cin >> h >> w >> n;

    int max,min;

    if(h > w) {
        max = h;
        min = w;
    } else {
        max = w;
        min = h;
    }

    int count = 0;
    for(int i = 1;i <= min; i++) {
        count++;
        if(i * max >= n) {
            break;
        }
    }

    cout << count << endl;

}

Measured memory_bytes: 256