akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cmath>

using ll = long long;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

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

    int B[N];
    for(int i = 0; i < N; i++) B[i] = A[i];

    sort(A, A+N);

    int a1 = A[N-1];
    int a2 = A[N-2];

    for(int i = 0; i < N; i++) {
        if(B[i] == a1) {
            cout << a2 << endl;
        } else {
            cout << a1 << endl;
        }
    }

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int ans = 0;
    if (n % 2 == 1)
    {
        int left = a[n / 2];
        int right = b[n / 2];
        ans = right - left + 1;
    }
    else
    {
        int left = a[n / 2 - 1] + a[n / 2];
        int right = b[n / 2 - 1] + b[n / 2];
        ans = right - left + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  if(N%2==0){
  cout<<(N*(N-2))/2<<endl;
    for(int i=1;i<=N-1;i++){
    for(int j=i+1;j<=N;j++){
    if(j!=N+1-i){
    cout<<i<<" "<<j<<endl;
    }
    
    }
    }
  }else{
  cout<<((N-1)*(N-1))/2<<endl;
    for(int i=1;i<=N-1;i++){
    for(int j=i+1;j<=N;j++){
      if(j!=N-i){
      cout<<i<<" "<<j<<endl;
      }
    }
    }
  }
   return 0;
}


Measured memory_bytes: 256
#![allow(unused)]

use std::cmp::{min, max};

macro_rules! dbg {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Scanner<'a, R> {
        Scanner { reader: reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let n: usize = sc.get();
    let w: usize = sc.get();
    let wvs: Vec<(usize, i64)> = (0..n).map(|_| (sc.get(), sc.get())).collect();

    let mut dp = vec![0; w + 1];
    for i in 0..n {
        let mut dp_ = vec![0; w + 1];
        for k in 1..(w + 1) {
            dp_[k] = *[
                dp_[k - 1],
                dp[k],
                if k >= wvs[i].0 { dp[k - wvs[i].0] + wvs[i].1 } else { 0 }
            ].iter().max().unwrap();
        }
        dp = dp_;
    }

    println!("{}", dp[w]);
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
char G[44][44];
int vis[44][44]={0};
int h,w;
int inbound(int i,int j){
    return i>0&&j>0&&i<=h&&j<=w&&G[i][j]=='.';
}
struct node{
    int a,b,c;
};
int a[4][2]={0,1,-1,0,0,-1,1,0};
int solve(int z,int c){
    int ret = 0 ;
    memset(vis,0,sizeof vis);

    queue<node>qq;
    qq.push({z,c,0});
    vis[z][c]=1;
    while(!qq.empty()){
        int x = qq.front().a;
        int y = qq.front().b;
        int len = qq.front().c;
        qq.pop();
        ret=max(ret,len);
        for(int i=0;i<4;i++){
            int x1= x+a[i][0];
            int y1= y+a[i][1];
            if(inbound(x1,y1)&&!vis[x1][y1]){
                vis[x1][y1]=1;
                qq.push({x1,y1,len+1});
            }
        }
    }
    return ret;
}
int main()
{

    cin  >> h>>w;
    for(int i=1;i<=h;i++){
        cin >>G[i]+1;
    }
    //visit[1][1]=1;
    int res = 0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++)
            if(G[i][j]=='.')
            res = max(res,solve(i,j));
    }
    cout << res <<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#define NDEBUG

int main() {
	int n, u, v; scanf("%d%d%d", &n, &u, &v); u--; v--;
	std::vector<std::vector<int>> g(n);
	std::vector<int> a(n - 1), b(n - 1);
	for(int i = 0; i < n - 1; i++) {
		scanf("%d%d", &a[i], &b[i]);
		a[i]--; b[i]--;

		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}

	std::vector<int> dist(n, -1);
	std::queue<int> qu({v}); dist[v] = 0;
	while(!qu.empty()) {
		auto v = qu.front(); qu.pop();

		for(auto e: g[v]) {
			if(dist[e] != -1) continue;
			dist[e] = dist[v] + 1;
			qu.push(e);
		}
	}
	
	std::vector<int> kiri(n);
	auto dfs = [&](auto && dfs, int v, int par) -> void {
		for(auto e: g[v]) {
			if(e == par) continue;
			dfs(dfs, e, v);
			kiri[v] = std::max(kiri[v], kiri[e] + 1);
		}
	};
	dfs(dfs, v, -1);

	#ifndef NDEBUG
	for(auto v: dist) cout << v << " "; cout << endl;
	for(auto v: kiri) cout << v << " "; cout << endl;
	#endif

	int ans = kiri[u];
	auto solve = [&](auto&& solve, int v, int par, int d) -> void {
		if(dist[v] > d) {
			ans = std::max(ans, d + kiri[v] + !(dist[u] % 2));
		} else if(dist[v] == d) {
			ans = std::max(ans, d);
		}
		if(dist[v] <= d) return;
		
		for(auto e: g[v]) {
			if(e == par) continue;
			solve(solve, e, v, d + 1);
		}
	};
	solve(solve, u, -1, 0);
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
#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 pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isprime(ll n){if(n<2)return 0;if(!(n%2))return !(n-2);lll d=n-1,t,y;while(!(d%2))d>>=1;vl al={2,325,9375,28178,450775,9780504,1795265022};for(ll a:al){if(n<=a)break;t=d,y=modpow(a,t,n);while(t!=n-1&&y!=1&&y!=n-1)y=y*y%n,t<<=1;if(y!=n-1&&!(t%2))return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}
const mt19937 rnd(unsigned(1357986421));
const int iinf = 1e9+6;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

const int N = 1e5;
int d;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> d;
  cout << "Christmas";
  FOR(i, 0, 25-d) cout << " Eve";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 1e3 + 7, W = 2e4 + 7;
int n, dp[W];

struct tower {
    int w = 0, s = 0, v = 0;
    tower(int w, int s, int v) {
        this -> w = w;
        this -> s = s;
        this -> v = v;
    }
    bool operator < (const tower & t) const {
        return s + w < t.s + t.w;
    }
};

vector <tower> vec;

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n;
    for (int i = 0; i < n; i++) {
        int w, s, v;
        cin >> w >> s >> v;
        vec.pb(tower(w, s, v));
    }
    sort(all(vec));
    int res = 0;
    for (int i = 1; i <= n; i++) {
        int w = vec[i - 1].w, s = vec[i - 1].s, v = vec[i - 1].v;
        for (int j = s + w; j >= w; j--) {
            dp[j] = max(dp[j], dp[j - w] + v);
        }
    }
    for (int i = 0; i < W; i++) {
        res = max(res, dp[i]);
    }
    cout << res;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	if((n+1)/2 >= k)
		cout<<"YES\n";
	else
		cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;

long long P, A[3000], F[3000], RF[3000], ANS[3000];

long long Calc(long long A, long long B) {
	if (B == 0) return 1;
	if (B % 2 == 0) {
		long long C = Calc(A, B / 2) % P;
		return (C * C) % P;
	}
	return (A * Calc(A, B - 1)) % P;
}

void init(long long N) {
	F[0] = F[1] = RF[0] = RF[1] = 1;
	for (int i = 2; i <= N; i++) {
		F[i] = (F[i - 1] * i) % P;
		RF[i] = Calc(F[i], P - 2);
	}
	return;
}

long long Comb(long long A, long long B) {
	return ((F[A] * RF[A - B]) % P * RF[B]) % P;
}

int main() {
	cin >> P;
	init(P);
	for (int i = 0; i < P; i++) cin >> A[i];
	for (int i = 0; i < P; i++) {
		if (A[i] == 0) continue;
		long long Cur = 1;
		for (int j = P - 1; j >= 0; j--) {
			if (j % 2 == P % 2) {
				ANS[j] = (ANS[j] + (Comb(P - 1, j) * Cur) % P) % P;
			}
			else {
				ANS[j] = (ANS[j] + P - (Comb(P - 1, j) * Cur) % P) % P;
			}
			Cur = (Cur * i) % P;
		}
		ANS[0] = (ANS[0] + 1) % P;
	}
	for (int i = 0; i < P; i++) {
		cout << ANS[i];
		if (i == P - 1) cout << endl;
		else cout << " ";
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string n;
    cin>>n;
    int x{};
    for(auto&i:n) (x+=i-'0')%=9;
    puts(x?"No":"Yes");
}

Measured memory_bytes: 3784
#include <iostream>

using namespace std;

int main()
{
    int counter = 0;
    int n;
    cin>>n;
    int arr[n];
    for(int i = 0 ; i < n ; i++)
    {
        cin>>arr[i];
        if(arr[i] % 2 !=0 && (i+1)%2 != 0)
        {
            counter++;
        }
    }
    cout<<counter;

}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

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

int main()
{
	fastIO
	//inp_out();
	string s;
	cin>>s;
	ll n=s.size();
	if(n&1)
	{
		cout<<"No";
		return 0;
	}
	
	for(ll i=1;i<n;i+=2)
	{
	//	db(s[i]);
		if((s[i]!='i')||(s[i-1]!='h'))
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}



Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,W = inpl()
a = [inpl() for _ in range(n)]
gds = [[0] for _ in range(4)]
a.sort(key = lambda x:x[1], reverse = True)
a.sort(key = lambda x:x[0])
# print(a)
mi = a[0][0]
for i,(w,v) in enumerate(a):
    ind = w - mi
    gds[ind].append(v)
we = [i+mi for i in range(4)]
cnt = [0] * 4
for i in range(4):
    cnt[i] = len(gds[i])
    tmp = itertools.accumulate(gds[i])
    gds[i] = list(tmp)
# print(gds)
it = itertools.product(range(cnt[0]),range(cnt[1]),range(cnt[2]),range(cnt[3]))
res = 0
for ww in it:
    if sum(we[i]*ww[i] for i in range(4)) > W: continue
    now = sum(gds[i][ww[i]] for i in range(4))
    res = max(now, res)
print(res)

Measured memory_bytes: 10460
#include<stdio.h>
#include<map>
#include<algorithm>
#include<stack>
#include<queue>
#include<string.h>
#include<math.h>
#include<iostream>
using namespace std;
long long n,k,ans;
map<int,int>mp;
int main()
{
    scanf("%lld%lld",&n,&k);
    if(n%k==0)ans=0;
    else{
        if(n>k)
        {
            n%=k;
        }
        if(k-n<n)ans=k-n;
        else ans=n;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		while (true) {
			int K = sc.nextInt();
			if (K == 0) break;
			int sum = 0;
			for (int i = 0; i < K * (K - 1) / 2; ++i) {
				sum += sc.nextInt();
			}
			System.out.println(sum / (K - 1));
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>

int main(){
  int N;
  scanf("%d",&N);
  int L[101];
  for(int i=1;i<=N;i++){
    scanf("%d",&L[i]);
  }
  int max=0;
  int max_index=0;
  for(int i=1;i<=N;i++){
    if(max<L[i]){
       max=L[i];
       max_index=i;
     }
  }
  int sum=0;
  for(int i=1;i<=N;i++){
    if(i!=max_index) sum+=L[i];
  }

  if(max<sum) printf("Yes\n");
  else printf("No\n");

  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

int main()
{
    string S, T;
    cin >> S >> T;

    int ans = 0;
    rep(i, S.size())
    {
        if (S[i] != T[i])
        {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Input();
		var sa = Input();
		
		var n = p[0].ToInt();
		var x = p[1].ToLong();
		var a = new long[n];
		for(int i = 0; i < n; i++)
			a[i] = sa[i].ToLong();
		
		long wa = 0;
		for(int i = 0; i < n - 1; i++)
		{
			var o = (a[i] + a[i+1]) - x;
		
			if(o > 0)
			{
				if(a[i+1] > o)
				{
					a[i+1] -= o;
					wa += o;
				}
				else
				{
					wa += a[i+1];
					var q =  (o - a[i+1]);
					wa += q;
					a[i] -= q;
					a[i+1] = 0;
				}
			}
		}
		Console.WriteLine(wa);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 25436
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)//rep(i,回数){処理}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n,x,t;
    cin >> n >> x >> t;
    if (n <= x) {
        cout << t << endl;
    } else {
        if (n%x == 0) {
            cout << (n/x) * t << endl;
        } else {
            cout << ((n/x)+1) * t << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #a,b,c=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    hh=list(map(int, readline().rstrip().split()))

    maxmove=0
    move=0
    for i in range(1,n):
        if hh[i]<=hh[i-1]:
            move+=1
        else:
            maxmove=max(maxmove,move)
            move=0
    maxmove=max(maxmove,move)
    print(maxmove)
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 17292
import sys
#input=sys.stdin.readline
class UnionFind():
  def __init__(self,n):
    self.n=n
    self.parent=list(range(n))
    self.size=[1]*n
    #print(self.size, end=" self.size \n")
  def find(self,x):
    if self.parent[x]==x:
      return x
    else:
      self.parent[x]=self.find(self.parent[x])
      return self.parent[x]
  def union(self,x,y):
    x=self.find(x)
    y=self.find(y)
    if x==y:
      return
    else:
      if self.size[x]>=self.size[y]:
        self.parent[y]=x
        self.size[x]+=self.size[y]
      else:
        self.parent[x]=y
        self.size[y]+=self.size[x]
  def cnt(self,x):
    return self.size[self.find(x)]
def main():
  n,m,k=map(int,input().split())
  u=UnionFind(n)
  ans=[0]*n
  for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    u.union(a,b)
    ans[a]-=1
    ans[b]-=1
  for _ in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    if u.find(c)==u.find(d):
      ans[c]-=1
      ans[d]-=1
  for i in range(n):
    ans[i]+=u.cnt(i)-1
  print(" ".join(map(str,ans)))
main()


Measured memory_bytes: 18712
#include <bits/stdc++.h>
using namespace std;
 
int main() {

	int X, Y;
	cin >> X >> Y;
  
  if ( Y % 2 == 0 ){
    
    if ( Y >= 2*X && Y <= 4*X ){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
    }
    
  
  else{
    cout << "No" << endl;
  }




}

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

using namespace std;

int A, B, ans;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> A >> B;
    
    ans = max({A+B, A-B, A*B});
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	string s;
	int a, w;

	cin >> s >> w;

	a = s.size();

	for (int i = 0; i < a; i++) {
		if (i % w == 0) cout << s[i];
	}

	return 0;
}


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

int target[123456];
int point[123456];
int main(){
	int people, num;
	int buf;
	scanf("%d%d", &people, &num);
	for (int a = 0; a < num; a++){
		scanf("%d", &target[a]);
	}
	for (int a = 0; a < num; a++){
		for (int b = 0; b < people; b++){
			scanf("%d", &buf);
			if (buf == target[a]){
				point[b]++;
			}
			else{
				point[target[a] - 1]++;
			}
		}
	}
	for (int a = 0; a < people; a++){
		printf("%d\n", point[a]);
	}
	return 0;
}

Measured memory_bytes: 2672
#include <cstdio>
#include <vector>

using namespace std;

const int MAX_N=30;

vector<int> in;

int array[MAX_N+5];

void dfs(int n,int i){
	if (n==0){
		//???????????????????????£???
		for (int j=0;j<i;j++){
			if (j) printf(" ");
			printf("%d",array[j]);
		}
		printf("\n");
	}
	int pre=(i ? array[i-1] : n);
	for (int j=pre;j>0;j--){
		if (j<=n){
			array[i]=j;
			dfs(n-j,i+1);
		}
	}
}

int main(){
	int n;
	do{
		scanf("%d",&n);
		if (n) in.push_back(n);
	}while(n);
	for (int i=0;i<in.size();i++){
		dfs(in[i],0);
	}
	return 0;
}

Measured memory_bytes: 1056
N, M = map(int, input().split())
is_broken_array = [0] * N
for i in range(M):
    is_broken_array[int(input())-1] = 1

past = 1
past_past = 0
mod = 10**9 + 7

for is_broken in is_broken_array:
    if is_broken:
        now = 0
        # print(past_past, past, now)
    else:
        now = past + past_past
        # print(past_past, past, now)
        now = now % mod
    past_past = past
    past = now

print(now)

Measured memory_bytes: 44248
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define EPS (1e-10)
using namespace std;
class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}

  bool operator < (const Point &p) const{
    return x!=p.x?x<p.x:y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
  }
};
double norm(Point p){return p.x*p.x+p.y*p.y;}
double abs(Point p){return sqrt(norm(p));}
double cross(Point a,Point b){return a.x*b.y-a.y*b.x;}
double dot(Point a,Point b){return a.x*b.x+a.y*b.y;}
double getDistancePP(Point a,Point b){return abs(a-b);}
int CCW(Point p0,Point p1,Point p2){
  Point a=p1-p0;
  Point b=p2-p0;
  if(cross(a,b)>EPS)return 1;
  if(cross(a,b)<-EPS)return -1;
  if(dot(a,b)<-EPS)return 2;
  if(norm(a)<norm(b))return -2;
  return 0;
}
int main(){
  int n,m;
  Point p;
  while(cin>>n,n){
    vector<Point>a[51];
    cin>>m;
    while(m--){cin>>p.x>>p.y;a[0].push_back(p);}
    int cc[10],cp[10];
    r(i,a[0].size()-2)cc[i]=CCW(a[0][i],a[0][i+1],a[0][i+2]);
    r(i,a[0].size()-1)cp[i]=getDistancePP(a[0][i],a[0][i+1]);
    r(i,n){cin>>m;
      while(m--){
        cin>>p.x>>p.y;
        a[i+1].push_back(p);
      }
    }
    for(int j=1;j<n+1;j++){
      if(a[0].size()!=a[j].size())continue;
      int dd[10],d2[10],d=0,d3=0,dp[10],o=0,oo=0,pd[10];
    r(i,a[j].size()-2)dd[i]=CCW(a[j][i],a[j][i+1],a[j][i+2]);
    r(i,a[j].size()-2)if(dd[i]!=cc[i])d++;int c=a[j].size()-3;
    r(i,a[j].size()-2)if(dd[i]==cc[c--])d3++;
    r(i,a[j].size()-1)dp[i]=getDistancePP(a[j][i],a[j][i+1]);
    c=a[j].size()-2;
    r(i,a[j].size()-1)if(dp[i]!=cp[i])o++;
    r(i,a[j].size()-1)if(dp[i]!=cp[c--])oo++;
    if((!oo&&!d3)||(!d&&!o))cout<<j<<endl;
    }
    cout<<"+++++"<<endl;
  }
}

Measured memory_bytes: 3044
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <memory>

using namespace std;

int main() {
    int n;
    cin>>n;
    std::unordered_set<string> s;
    string st;
    for (int i=0;i<n;++i){
        cin>>st;
        s.emplace(st);
    }
    cout<<s.size();
}

Measured memory_bytes: 17644
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int a, b;
	int m[4] = { 0 };

	REP(i, 3) {
		scanf("%d%d", &a, &b);
		m[a-1]++; m[b-1]++;
	}
	REP(i, 4) {
		if (m[i] == 0 || m[i] > 2) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
int main()
{
	int M=read(),D=read();
	int ans=0;
	for(int i=1;i<=M;i++)for(int j=1;j<=D;j++)if(j>=10&&j<100)
	{
		int u=j%10,v=j/10;
		if(u>=2&&v>=2&&u*v==i)ans++;
	}
	pr2(ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int n;
    int sweets[1001][5];
    int P, Q, R, C;
    int comps[4];

    while(cin>>n && n) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 4; j++) {
                cin >> sweets[i][j];
            }
            sweets[i][4] = 4*sweets[i][1] + 9*sweets[i][2] + 4*sweets[i][3];
        }
        for (int i = 0; i < 4; i++) {
            cin >> comps[i];
        }

        bool na_flag = true;
        for (int i = 0; i < n; i++) {
            bool flag = true;
            for (int j = 0; j < 4; j++) {
                flag &= (sweets[i][j+1] <= comps[j]);
            }
            if (flag) {
                cout << sweets[i][0] << endl;
                na_flag = false;
            }
        }
        if(na_flag) {
            cout << "NA" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
		cin>>n;
	double sum=0;
	double m[n+1];
	string t[n+1];

	for(int i=1;i<=n;i++)
	{
		cin>>m[i]>>t[i];
		
		if(t[i]=="JPY")
		{
			sum+=m[i]*1.0;
		}
		else{
			sum+=m[i]*1.0*380000;
		}
	}
	
	if(sum==int(sum)) cout<<fixed<<setprecision(1)<<sum<<endl;
	else
	{
		cout<<sum<<endl;
	}
	return 0;
}



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

int main()
{
    int n;
    cin>>n;
    int s[4];
    for(int i=0;i<4;i++) s[i]=0;
    string S;
    for(int i=0;i<n;i++)
    {
        cin>>S;
        if(S[0]=='A') s[0]+=1;
        else if(S[0]=='W') s[1]+=1;
        else if(S[0]=='T') s[2]+=1;
        else if(S[0]=='R') s[3]+=1;
    }
    cout<<"AC x "<<s[0]<<"\n";
    cout<<"WA x "<<s[1]<<"\n";
    cout<<"TLE x "<<s[2]<<"\n";
    cout<<"RE x "<<s[3]<<"\n";
}


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
    long int i,n,sum=0,temp=0;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
        if(temp<arr[i]) temp=arr[i];
    }
    cout<<sum-temp+(temp/2);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
using P = pair<int, int>;
struct SegmentTree{
  int n;
  vector<P> v;
  vector<vector<int> > dat;
  SegmentTree(){};
  SegmentTree(int n,vector<P> v):v(v){init(n);build();};
  
  void init(int n_){
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,vector<int>());
  }  
  void build(){
    for(auto p:v)
      dat[p.first+n].emplace_back(p.second);    
    for(int i=0;i<n;i++)
      sort(dat[i+n].begin(),dat[i+n].end());
    
    for(int i=n-1;i;i--){
      merge(dat[(i<<1)|0].begin(),dat[(i<<1)|0].end(),
	    dat[(i<<1)|1].begin(),dat[(i<<1)|1].end(),
	    back_inserter(dat[i]));
    }
  }
  // [a,b) * [c,d)
  inline int query(int a,int b,int c,int d){
    int res=0;
    auto calc=[a,b,c,d](vector<int> &x){
      auto latte=lower_bound(x.begin(),x.end(),d);
      auto malta=lower_bound(x.begin(),x.end(),c);
      return int(latte-malta);
    };
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) res+=calc(dat[l++]);
      if(r&1) res+=calc(dat[--r]);
    }
    return res;
  }
  
};

signed ABC106_D(){
  int n,m,q;
  scanf("%d %d %d",&n,&m,&q);
  vector<int> x(m),y(m);
  for(int i=0;i<m;i++) scanf("%d %d",&x[i],&y[i]);
 
  vector<P> vp;
  for(int i=0;i<m;i++) vp.emplace_back(x[i],y[i]);
 
  SegmentTree seg(n+1,vp);
 
  for(int i=0;i<q;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%d\n",seg.query(a,b+1,a,b+1));    
  }
  return 0;
}

//END CUT HERE
signed main(){
  ABC106_D();
  return 0;
}


Measured memory_bytes: 17136
from collections import defaultdict
w = input()
if len(w) % 2 != 0:
  print('No')
else:
  d = defaultdict(int)
  for e in w:
    d[e] += 1
  ans = 'Yes'
  for e in dict(d).values():
    if e % 2 != 0:
      ans = 'No'
      break
  print(ans)

Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define SZ(x) ((int)((x).size()))

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

template<class TH>
void _dbg(const char* name, TH val){
    clog << name << ": " << val << endl;
}
template<class TH, class... TA>
void _dbg(const char* names, TH curr_val, TA... vals) {
    while(*names != ',') clog << *names++;
    clog << ": " << curr_val << ", ";
    _dbg(names+1, vals...);
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
    #define dbg_arr(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg(...)
    #define dbg_arr(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    bool works = true;
    if (N%3) works &= a[0] == a[N-1];
    else {
        works &= a[0] == a[N/3 - 1] && a[N/3] == a[2*N/3 - 1] && a[2*N/3] == a[N-1];
        works &= (a[0] ^ a[N/3] ^ a[2*N/3]) == 0;
    }
    cout << (works?"Yes":"No") << "\n";
}


Measured memory_bytes: 640
import decimal

n = int(input())

ans = 0
for i in range(n):
    x, v = input().split()
    if v == 'JPY':
        ans += int(x)
    else:
        a = decimal.Decimal(x)
        b = decimal.Decimal(380000)
        c = a * b
        ans += c

print(ans)

Measured memory_bytes: 5332
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], x = l[1];
            var a = Console.ReadLine().Split().Select(int.Parse).OrderBy(z => z).ToArray();
            var count = 0;

            while (x > 0 && count < N)
            {
                if (a[count] <= x)
                {
                    if (count == N - 1 && x != a[count]) break;

                    x -= a[count];
                    count++;

                }
                else
                    x -= a[count];
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    ll ans=0;
    rep(i,n){
        while(a.at(i)%2==0){
            ans++;
            a.at(i)/=2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3688
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)

int main(void){
    CIN_NO_SYNC;

    int w,n;
    cin >> w >> n;
    int p[31];
    REP(i, w) p[i+1] = i+1;

    REP(i, n){
        int a,b; char c;
        cin >> a >> c >> b;
        swap(p[a], p[b]);
    }
    REP(i, w) printf("%d\n", p[i+1]);

    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int
#define Vec vector

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

const ll mod = (ll) 1e9 + 7;
int main(){
	
	int N;
	cin >> N;
	
	// forbid
	//  A*GC 0*12
	//  AGC  012
	//  GAC  102
	//  ACG  021
	//  AG*C 01*2
	
	//  0123 <=> AGCT
	Vec<Vec<ll>> dp(N);
	for(int i=0;i<N;i++) dp[i].resize(4 * 4 * 4);
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				dp[2][i * 16 + j * 4 + k] = 1;
				if(i == 0 && j == 1 && k == 2) dp[2][i * 16 + j * 4 + k] = 0;
				if(i == 1 && j == 0 && k == 2) dp[2][i * 16 + j * 4 + k] = 0;
				if(i == 0 && j == 2 && k == 1) dp[2][i * 16 + j * 4 + k] = 0;
			}
		}
	}
	
	for(int t=2;t+1<N;t++){
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				for(int k=0;k<4;k++){
					ll me = dp[t][i * 16 + j * 4 + k];
					// (i , j, k) -> (j, k, n)
					for(int n=0;n<4;n++){
						if(i == 0 && k == 1 && n == 2) continue; // A*GC
						if(j == 0 && k == 1 && n == 2) continue; // *AGC
						if(j == 1 && k == 0 && n == 2) continue; // *GAC
						if(j == 0 && k == 2 && n == 1) continue; // *ACG
						if(i == 0 && j == 1 && n == 2) continue; // AG*C
						dp[t+1][j * 16 + k * 4 + n] += me; if(dp[t+1][j * 16 + k * 4 + n] >= mod) dp[t+1][j * 16 + k * 4 + n] -= mod;
					}
				}
			}
		}
	}
	
	ll ans = 0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				ans += dp[N-1][i * 16 + j * 4 + k];
				if(ans >= mod) ans -= mod;
			}
		}
	}
	
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	long start = System.currentTimeMillis();
	long fin = System.currentTimeMillis();
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int N = sc.nextInt();
		while (N-- > 0) {
			int k = sc.nextInt();
			int p = sc.nextInt();
			System.out.println(k % p == 0 ? p : k % p);
		}
	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(char[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (a[i] >= border)
	int lower_bound(int a[], int border) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (border <= a[mid]) {
				r = mid;
			} else {
				l = mid;
			}
		}
		// r = l + 1
		return r;
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if ( a <= 9 && b <= 9) cout << a*b << endl;
    else cout << "-1" << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int len = (int)s.size();
    vector<pair<char, int>> v;
    int cnt = 1;
    for (int i = 1; i < len; i++) {
        if (s.at(i - 1) == s.at(i)) cnt++;
        else {
            v.push_back(make_pair(s.at(i - 1), cnt));
            cnt = 1;
        }
    }
    v.push_back(make_pair(s.at(len - 1), cnt));

    vector<int> ans(len + 1);
    int index = 0;
    for (int i = 0; i < (int)v.size(); i++) {
        if (i != 0) index--;
        if (v.at(i).first == '<') {
            for (int j = 0; j < v.at(i).second + 1; j++) {
                ans.at(index) = max(ans.at(index), j);
                index++;
            }
        }
        else {
            for (int j = 0; j < v.at(i).second + 1; j++) {
                ans.at(index) = max(ans.at(index), v.at(i).second - j);
                index++;
            }
        }
    }

    long long sum = 0;
    for (int i = 0; i < len + 1; i++) {
        sum += (long long)ans.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 4856
while True:
  m, f, r = map(int, input().split())
  g=m+f
  if m == -1 and f == -1 and r == -1:
    break
  if m == -1 or f == -1 or g<30:
    print("F")
  elif g >= 80:
    print("A")
  elif g >= 65:
    print("B")
  elif g >= 50:
    print("C")
  elif g >= 30:
    print("C" if r >= 50 else "D")


Measured memory_bytes: 5596
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<sstream>
using namespace std;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int a, b, c;
    while (cin >> a >> b)
    {
        while (b--)
        {
            cin >> c;
            a -= c;
        }
        if (a > 0)cout << "No" << '\n';
        else cout << "Yes" << '\n';
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << ((b - a) % 2 ? "Borys" : "Alice") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	vll x(n),y(m) ;
	for(auto &i:x) cin >> i ;
	for(auto &i:y) cin >> i ;
	sort(all(x)) ;
	sort(all(y)) ;
	vll xsum(n,0),xsub(n,0) ;
	for(int i=1;i<n;i++) xsub.at(i) = sa(x.at(i),x.at(i-1))*i%mod ;
	for(int i=1;i<n;i++) xsum.at(i) = (xsum.at(i-1)+xsub.at(i))%mod ;
	for(int i=1;i<n;i++) (xsum.at(i) += xsum.at(i-1)) %= mod ;
	vll ysum(m,0),ysub(m,0) ;
	for(int i=1;i<m;i++) ysub.at(i) = sa(y.at(i),y.at(i-1))*i%mod ;
	for(int i=1;i<m;i++) ysum.at(i) = (ysum.at(i-1)+ysub.at(i))%mod ;
	for(int i=1;i<m;i++) (ysum.at(i) += ysum.at(i-1)) %= mod ;
//	for(auto i:xsum) cout << i << " " ; cout << endl ;
//	for(auto i:ysum) cout << i << " " ; cout << endl ;
	cout << xsum.at(n-1)*ysum.at(m-1)%mod << endl ;
}


Measured memory_bytes: 4992
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#define N 200020
using namespace std;
int n,k,cnt;
char ch[N];
int main()
{
	scanf("%d%d%s",&n,&k,ch+1);
	for(int i=1;i<=n;i++)
	{
		int j=i;
		while(ch[j+1]==ch[i])j++;
		cnt++;i=j;
	}
	cnt=max(1,cnt-2*k);
	printf("%d\n",n-cnt);
}

Measured memory_bytes: 888