akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int T, X;
  cin >> T >> X;

  float ans = float(T) / X;
  printf("%.6f", ans);

  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	map<int,int>o,e;
	int a,N;
	vector<P>ev,ov;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>a;
		if(i%2==0)
		{
			e[a]++;
		}
		else
		{
			o[a]++;
		}
	}

	for(auto i:e)
	{
		if(ev.size()<3||i.second>1)
		ev.push_back(make_pair(i.first,i.second));
	}
	for(auto i:o)
	{
		if(ov.size()<3||i.second>1)
		ov.push_back(make_pair(i.first,i.second));
	}
	int res=N;
	
	for(auto i:ev)
	{
		for(auto j:ov)
		{
			if(i.first==j.first)
			{
				res=min(min(res,N-j.second),N-i.second);
			}
			else
			{
				res=min(res,N-i.second-j.second);
			}
		}
	}

	printf("%d\n",res);
}


Measured memory_bytes: 4992
def main(N, K, h):
    dp = [0 for _ in range(N)]

    for i in range(1, N):
        tmp = [dp[j]+abs(h[i]-h[j]) for j in range(max(0, i-K), i)]

        dp[i] = min(tmp)

    print(dp[-1])

N, K = map(int, input().split())
h = list(map(int, input().split()))

main(N, K, h)


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

int main() {
  int N;
  cin >> N;
  vector<string> v(N);
  for (int i = 0; i < N; i++) cin >> v[i];
  bool shiritori = true;
  for (int i = 0; i < N - 1; i++) {
    if (v[i][v[i].size()-1] != v[i+1][0]) {
      shiritori = false;
      break;
    }
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < N - 1; i++) {
    if (v[i] == v[i+1]) {
      shiritori = false;
      break;
    }
  }
  if (shiritori) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    double ret = 0;
    for (int i = 0; i < n; i++)
    {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY")
            ret += x;
        else
            ret += x * 380000;
    }
    cout << fixed << setprecision(10) << ret << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;
#define ll long long 
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48,ch=getchar();}
	return x*f;
}
const int maxn = 200010;
char S[maxn],T[maxn];
int U1[maxn],D1[maxn],L1[maxn],R1[maxn];
int U2[maxn],D2[maxn],L2[maxn],R2[maxn];
int main(){
	int n=read(),m=read(),K=read();
	int sx=read(),sy=read();
	scanf("%s",S+1);
	scanf("%s",T+1);
	for(int i=1;i<=K;i++){
		U1[i]=U1[i-1]+(S[i]=='U');
		U2[i]=U2[i-1]+(T[i]=='U');
		D1[i]=D1[i-1]+(S[i]=='D');
		D2[i]=D2[i-1]+(T[i]=='D');
		L1[i]=L1[i-1]+(S[i]=='L');
		L2[i]=L2[i-1]+(T[i]=='L');
		R1[i]=R1[i-1]+(S[i]=='R');
		R2[i]=R2[i-1]+(T[i]=='R');
	}
	bool flag=0;
	for(int i=1;i<=K;i++){
		if(sy-L1[i]+R2[i-1]<=0){flag=1;break;}
		if(sy+R1[i]-L2[i-1]>m){flag=1;break;}
		if(sx-U1[i]+D2[i-1]<=0){flag=1;break;}
		if(sx+D1[i]-U2[i-1]>n){flag=1;break;}
	}
	if(sy-L1[K]<=0){
		int nd=1-sy+L1[K];
		//printf("%d\n",nd);
		for(int i=K;i>=0;i--){
			if(R2[K]-R2[i]==nd){
				//printf("%d\n",i );
				for(int j=i+1;j<=K;j++)
					if(sy-L1[j]+(R2[j]-R2[i])>m){flag=1;break;}
				break;
			}
		}
	}
	if(sy+R1[K]>m){
		int nd=sy+R1[K]-m;
		for(int i=K;i>=0;i--){
			if(L2[K]-L2[i]==nd){
				for(int j=i+1;j<=K;j++)
					if(sy+R1[j]-(L2[j]-L2[i])<=0){flag=1;break;}
				break;
			}
		}
	}
	if(sx-U1[K]<=0){
		int nd=1-sx+U1[K];
		for(int i=K;i>=0;i--){
			if(D2[K]-D2[i]==nd){
				for(int j=i+1;j<=K;j++)
					if(sx-U1[j]+(D2[j]-D2[i])>n){flag=1;break;}
				break;
			}
		}
	}
	if(sx+D1[K]>n){
		int nd=sx+D1[K]-n;
		for(int i=K;i>=0;i--){
			if(U2[K]-U2[i]==nd){
				for(int j=i+1;j<=K;j++)
					if(sx+D1[j]-(U2[j]-U2[i])<=0){flag=1;break;}
				break;
			}
		}
	}
	if(flag) printf("NO\n");
	else printf("YES\n");
	return 0;
}
  

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

int main() {


    int k,n;
    cin >> k >> n;
    vector <int> a(n);
    vector <int> diff(n);

    rep(i,n) cin >> a.at(i);

    rep(i,n-1) diff.at(i) = a.at(i+1) - a.at(i);
    diff.at(n-1) = k - a.at(n-1) + a.at(0);

    int maxdiff = 0;
    rep(i,n) maxdiff = max(maxdiff,diff.at(i));
    int total = 0;
    rep(i,n) total += diff.at(i);

    cout << total - maxdiff << endl;
}

Measured memory_bytes: 1792
// Last Change: 04/09/2019 23:15:35.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  pair<int, int> A, B, C, D, v;

  cin >> A.first >> A.second >> B.first >> B.second;

  v.second = B.first - A.first;
  v.first = -(B.second - A.second);

  C.first = B.first + v.first;
  C.second = B.second + v.second;

  v.second = v.first;
  v.first = -(C.second - B.second);

  D.first = C.first + v.first;
  D.second = C.second + v.second;

  cout << C.first << " " << C.second << " " << D.first << " " << D.second
       << endl;

  //NS::LoopUntilZeroInpput();
}


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

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
//    int t = Integer.parseInt(sl[1]);
//
//    for(int i = 0; i < n; i++)
//    {
//      s = r.readLine();
//      sl = s.split(" ");
//      time[i] = Integer.parseInt(sl[0]);
//      deli[i] = Integer.parseInt(sl[1]);
//    }
//
//    int dp[][] = new int[3001][3001];
//
//    for(int i = 1; i <= t; i++)
//    {
//      dp[i][0] = deli[0];
//    }
//
//    for(int j = 0; j <= n; j++)
//    {
//      for(int i = time[j]; i <= t; i++)
//      {
//          dp[i][j] = Math.max(dp[i - time[j]][j - 1] + deli[j], dp[i - 1][j]);
//      }
//    }
    
    boolean f[] = new boolean[100001];
    f[100] = true;
    f[101] = true;
    f[102] = true;
    f[103] = true;
    f[104] = true;
    f[105] = true;
    

    for(int i = 106; i <= 100000; i++)
    {
      f[i] = f[i - 100] || f[i - 101] || f[i - 102] ||  f[i - 103] || f[i - 104] || f[i - 105];
    }
    
    System.out.println(f[n] ? 1 : 0);
  }

}




class RemRing
{
 long module;
 public RemRing(long module)
 {
   this.module = module;
 }

 public long sum(long a, long b)
 {
   return (a + b + module) % module;
 }

 public long sub(long a, long b)
 {
   return (a - b + module) % module;
 }

 public long prod(long a, long b)
 {
   return (a * b) % module;
 }

 public long div(long a, long b)
 {
   return (a * inv(b)) % module;
 }

 public long inv(long a)
 {
   long b = this.module;
   long u = 1;
   long v = 0;
   while(b > 0)
   {
     long t = a / b;
     a -= t * b;
     u -= t * v;
     long z = a;
     a = b;
     b = z;
     z = u;
     u = v;
     v = z;
   }
   u %= this.module;
   if(u < 0) u += this.module;
   return u;
 }
}

Measured memory_bytes: 23252
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#include<iomanip>
#include<random>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  string s; cin >> s;
  ll n=s.size()+1;
  vector<ll> a(n,-1);
  
  if (s[0]=='<'){a[0]=0;}
  if (s[n-2]=='>'){a[n-1]=0;}

  rep(i,n-2){
    if(s[i]=='>' && s[i+1]=='<'){
      a[i+1]=0;
    }
  }

  rep(i,n-2){
    if (s[i]=='<' && s[i+1]=='>'){
      int l=0,r=0,li=i,ri=i+1;
      while (s[li]=='<'){
        l++;
        li--;
      }
      while (s[ri]=='>'){
        r++;
        ri++;
      }
      if (l>=r){
        for (int j=li+2; j<i+2; j++){
          a[j]=a[j-1]+1;
        }
      } else {
        for (int j=ri-1; j>=i+1; j--){
          a[j]=a[j+1]+1;
        }
      }
    }
  }

  rep(i,n){
    if (a[i]==0){
      if (a[i-1]==-1){
        int j=i-1;
        while (a[j]==-1){
          a[j]=a[j+1]+1;
          j--;
        }
      }
      if (a[i+1]==-1){
        int j=i+1;
        while (a[j]==-1){
          a[j]=a[j-1]+1;
          j++;
        }
      }
    }
  }

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

  ll ans=0;

  rep(i,n){
    ans += a[i];
  }

  cout << ans << endl;


  

  return 0;
}


Measured memory_bytes: 4740
N = int(input())
L = sorted(list(map(int, input().split())))
res = 0
for i in range(N - 1, 1, - 1):
    j = i - 1
    k = 0
    while j > k:
        while j > k and L[i] >= L[j] + L[k]:
            k += 1
        res += j - k
        j -= 1
print(res)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>

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

typedef long long ll;

const int mod = 1e9 + 7;

int add(int a, int b){
    return (a + b) % mod;
}
int mul(int a, int b){
    return ll(a) * b % mod;
}

int n;
char s[2][53];
int c[52][2];

int main(){
    cin >> n >> s[0] >> s[1];
    int i = 0;
    while(i < n){
        if(s[0][i] == s[1][i]){
            if(i == 0){
                c[i][0] = 1;
            }
            else{
                c[i][0] = add(mul(c[i - 1][0], 2), mul(c[i - 1][1], 2));
            }
            ++i;
        }
        else{
            if(i == 0){
                c[1][1] = 1;
            }
            else{
                c[i + 1][1] = add(c[i - 1][0], mul(c[i - 1][1], 3));
            }
            i += 2;
        }
    }
    cout << (s[0][n - 1] == s[1][n - 1] ? mul(c[n - 1][0], 3) : mul(c[n - 1][1], 6)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
int x,y,z,k;
ll a[2000];
ll b[2000];
ll c[2000];
ll ab[5000000];
ll abc[5000000];
int t=0;

bool cmp(ll a, ll b)
{
    return a>b;
}

int main()
{
    cin>>x>>y>>z>>k;
    for (int i=0; i<x; ++i)
        scanf("%lld",&a[i]);
    for (int i=0; i<y; ++i)
        scanf("%lld",&b[i]);
    for (int i=0; i<z; ++i)
        scanf("%lld",&c[i]);
    sort(a,a+x,cmp);
    sort(b,b+y,cmp);
    sort(c,c+z,cmp);
    for (int i=0; i<x; ++i)
        for (int j=0; j<y; ++j)
            ab[i*x+j]=a[i]+b[j];
    sort(ab,ab+x*y,cmp);
    for (int i=0; i<min(3000,x*y); ++i)
        for (int j=0; j<z; ++j)
    {
        abc[t++]=ab[i]+c[j];
    }
    sort(abc,abc+t,cmp);
    for (int i=0; i<k; ++i)
    {
        printf("%lld\n",abc[i]);
    }

    
    return 0;
}



Measured memory_bytes: 33024
N,M = map(int, input().split())
L = [0]*(N+1)
for _ in range(M):
    a,b = map(int, input().split())
    L[a] += 1
    L[b] += 1

ans = "YES"
for l in L:
    if l%2 == 1:
        ans = "NO"
        break
print(ans)

Measured memory_bytes: 3828
#include <iostream>
using namespace std;
int main() {
 int a;
 int x[10000000];
  cin >> a;
  for (int i = 0; i < a; ++i) {cin >> x[i];}
 int ans;
 for (int j = 0; j < a; ++j) {
 	for (int k = j; k < a; ++k) {
 		if (k != j) {ans += x[k] * x[j];} 
 	}
 }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    int n=s.length()-2;
    cout<<s[0]<<n<<s[n+1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a + b + c) >= 22)
        cout << "bust";
    else
        cout << "win";

    return 0;
}


Measured memory_bytes: 256
import numpy as np


def solve(string):
    n, m, c, *ba = map(int, string.split())
    b = np.asarray(ba[:m])
    a = np.asarray(ba[m:])
    a.resize((n, m))
    return str(np.sum(np.dot(b, a.T) > -c))


if __name__ == '__main__':
    n, m, o = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, o) + '\n'.join([input() for _ in range(n + 1)])))


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

using namespace std;

const int INF = 1e18L + 5;

void a()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}

int main()
{
    a();

    int n, w;
    long long ans = 0, vt = 0;
    cin >> n >> w;
    vector<pair<int,int>> val;
    for(int i = 0; i < n; i++){
        int weight, value;
        cin >> weight >> value;
        vt += value;
        val.push_back(make_pair(weight, value));
    }
    vector<long long> dp(vt + 1,INF);

    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = vt - val[i].second; j >= 0; j--){
            dp[j+val[i].second] = min(dp[j+val[i].second], dp[j] + val[i].first);
        }
    }

    for(long long i = 0; i <= vt; i++){
        if(dp[i] <= w){
            ans = max(ans, i);
        }
    }

    cout << ans;
}

Measured memory_bytes: 3912
#include<iostream>
#include<math.h>
using namespace std;
const long MAX_N=(long) 1e12+1;

int main(){
    long N;
    cin >> N;
    long j,tmp,ans;

    ans=MAX_N;
    for(long i=1; i<= (long) sqrt( (double) N ); i++){
        if( N%i==0 ){
            j=N/i;
            tmp= (i-1) + (j-1);
            if(ans>tmp){
                ans=tmp;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())


int main() {
  int X;
  cin >> X;
  print((X>=30)?"Yes":"No");
  return 0;
}

Measured memory_bytes: 3616
import math

# a: 時針、b: 分針、c: 時間、d: 分
a, b, c, d = map(int, input().split())

# 時針・分針の分割角度
d_th_h = 360 / (12 * 60)
d_th_m = 360 / 60

th_h = d_th_h * 60 * c + d_th_h * d
th_m = d_th_m * d

th = abs(th_h - th_m) / 180 * math.pi

print(math.sqrt(a**2 + b ** 2 - 2 * a * b * math.cos(th)))

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

int l, maxV, minV;
int value(int v[10]){
  int rtn=0, ex=1;
  for( int i=l-1;i>=0;i-- ){
    rtn += v[i] * ex;
    ex *= 10;
  }
  return rtn;
}

int main(){
  string a;
  int v[10];
  map<int,int> m;

  while( cin>>a>>l && (a!="0" || l>0) ){
    m.clear();
    for( int i=0;i<l;i++ ){
      if( i<(int)a.length() )
	v[i] = a[i]-'0';
      else
	v[i] = 0;
    }
    int index = 0;
    int ba = value(v);
    m[ ba ] = index++;

    while( true ){
      sort( v, v+l );
      minV = value(v);
      reverse( v, v+l );
      maxV = value(v);
      ba = maxV - minV;
 
      if( m.find(ba)!=m.end() ){
	cout << m[ba] << " " 
	     << ba << " "
	     << (index-m[ba]) << endl;
	break;
      }
      m[ ba ] = index++;
      for( int i=0;i<l;i++ ){
	v[i] = ba%10;
	ba = ba/10;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#define RI register int
#define CI const int&
#define pb push_back
using namespace std;
const int N=1005,K=105;
using namespace std;
int k,n,a[K],b[K],ans[N]; vector <int> q[K]; bool vis[K];
inline bool cmp(vector <int> A,vector <int> B)
{
	for (RI i=0;i<A.size()&&i<B.size();++i)
	if (A[i]!=B[i]) return A[i]<B[i]; return A.size()<B.size();
}
inline void fail(vector <int>& v)
{
	for (RI i=1;i<=k;++i) v.pb(k+1);
}
inline void solve(CI st,CI num,vector <int>& res)
{
	res.clear(); memset(vis,0,sizeof(vis)); memcpy(b,a,sizeof(b));
	RI i; for (i=1;i+num<=k;++i) vis[ans[st-i]]=1;
	for (i=1;i<=k;++i) if (!vis[i])
	{
		if (b[i]) --b[i]; else return fail(res);
	}
	int x=*max_element(b+1,b+k+1),y=*min_element(b+1,b+k+1);
	if (x>2*y+1) return fail(res); vector <int> A,B,C; //A:b[i]=x; B:b[i]=y; C:otherwise
	if (x==2*y+1)
	{
		bool exist=0; for (i=1;i+num<=k;++i) 
		if (b[ans[st-i]]==x) exist=1; else if (b[ans[st-i]]==y&&exist) return fail(res);
		for (i=k;i;--i) if (!vis[i])
		{
			if (b[i]==x) A.pb(i); else if (b[i]==y) B.pb(i); else C.pb(i);
		}
	} else for (i=k;i;--i) if (!vis[i]) C.pb(i);
	for (i=1;i<=num;++i) if (A.size())
	{
		int x=C.size()?C.back():k+1; if (A.back()<x) res.pb(A.back()),A.pop_back();
		else res.pb(x),C.pop_back();
	} else
	{
		int x=B.size()?B.back():k+1,y=C.size()?C.back():k+1;
		if (x<y) res.pb(x),B.pop_back(); else res.pb(y),C.pop_back();
	}
}
int main()
{
	RI i,j; for (scanf("%d",&k),i=1;i<=k;++i) scanf("%d",&a[i]),n+=a[i];
	if (*max_element(a+1,a+k+1)>2*(*min_element(a+1,a+k+1))) return puts("-1"),0;
	int num; for (i=1;i<=n;i+=q[num].size())
	{
		if (i==1) solve(i,k,q[num=1]); else
		{
			for (j=1;j<=k;++j) solve(i,j,q[j]); num=1;
			for (j=2;j<=k;++j) if (cmp(q[j],q[num])) num=j;
		}
		for (j=0;j<q[num].size();++j) ans[i+j]=q[num][j],--a[q[num][j]];
	}
	for (i=1;i<=n;++i) printf("%d ",ans[i]); return 0;
}

Measured memory_bytes: 3260
#include<iostream>
using namespace std;
int swap(int, int);
int main(){
   int a,b,c,tmp;
   
   cin >> a >> b >> c;
   
   if (a < b) {
       
   } else {
       tmp = a;
       a = b;
       b = tmp;
      
   }

   if (a < c) {
       
   } else {
       tmp  = a;
       a = c;
       c = tmp;
      
   }

   if ( b < c) {
       
   } else {
       tmp = b;
       b = c;
       c = tmp;
       
   }

   cout << a << " " << b << " " << c << endl;
 
  
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix[i]<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define iP pair<int,P>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

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

	int N,M,X,A;
	vector<int> ve;
	
	cin>>N>>M>>X;
	REP(i,M){
		cin>>A; ve.pb(A);
	}
	vector<int>::iterator itr=upper_bound(ve.begin(),ve.end(),X);
	size_t d=(int)distance(ve.begin(),itr);
	print(min(d,M-d));
	return 0;
}


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

using namespace std;

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

    vector<pair<char, int>> a;
    for (int i = 1; i < n; ++i) {
        char sgn; int val; cin >> sgn >> val;
        a.emplace_back(sgn, val);
    }
    n -= 1;

    // Reduce until -
    for (int i = 0; i <= n; ++i) {
        if (i == n || a[i].first == '-') {
            a.erase(a.begin(), a.begin() + i);
            break;
        } else {
            ans += a[i].second;
        }
    }

    if (a.empty()) {
        cout << ans << endl;
        return 0;
    }
    
    n = a.size(); 
    vector<int> dp(n + 1, 0);
    vector<int> suff(n + 1, 0);
    for (int i = n - 1; i >= 0; --i) {
        suff[i] = suff[i + 1] + a[i].second;
        if (a[i].first == '-') {
            int j = i + 1;
            int now = 0;
            while (j < n && a[j].first == '+') {
                now += a[j].second;
                ++j;
            }
            dp[i] = max(
                    dp[j] + now - a[i].second, 
                    suff[j] - now - a[i].second);
        }
    }
    cout << ans + dp[0] << endl;

    return 0;
}


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

using namespace std;
const int N = 210;
int _w;

int n;

namespace G {
	int head[N], nxt[N*N], to[N*N], eid;
	void init() {
		eid = 0;
		memset(head, -1, sizeof head);
	}
	void link( int u, int v ) {
		to[eid] = v, nxt[eid] = head[u], head[u] = eid++;
	}
}

int color[N], ccn;
vector<int> cc[N];

bool bfs_bipartite( int s ) {
	++ccn;
	queue<int> q;
	color[s] = 0, q.push(s);
	while( !q.empty() ) {
		int u = q.front(); q.pop();
		cc[ccn].push_back(u);
		using namespace G;
		for( int i = head[u]; ~i; i = nxt[i] ) {
			int v = to[i];
			if( color[v] == -1 ) {
				color[v] = 1 - color[u];
				q.push(v);
			} else if( color[v] == color[u] ) {
				return false;
			}
		}
	}
	return true;
}

bool bipartite() {
	memset(color, -1, sizeof color);
	for( int i = 1; i <= n; ++i )
		if( color[i] == -1 )
			if( !bfs_bipartite(i) )
				return false;
	return true;
}

int dis[N];

int bfs_solve( int s ) {
	memset(dis, -1, sizeof dis);
	queue<int> q;
	dis[s] = 1, q.push(s);
	while( !q.empty() ) {
		int u = q.front(); q.pop();
		using namespace G;
		for( int i = head[u]; ~i; i = nxt[i] ) {
			int v = to[i];
			if( dis[v] == -1 ) {
				dis[v] = dis[u] + 1;
				q.push(v);
			}
		}
	}
	return *max_element(dis, dis+N);
}

int solve( const vector<int> &nod ) {
	int ans = 0;
	for( int u : nod )
		ans = max(ans, bfs_solve(u));
	return ans;
}

int main() {
	cin >> n;
	G::init();
	for( int i = 1; i <= n; ++i ) {
		char str[N];
		cin >> (str+1);
		for( int j = 1; j <= n; ++j )
			if( str[j] == '1' )
				G::link(i, j);
	}
	if( !bipartite() ) {
		puts("-1");
	} else {
		int ans = 0;
		for( int i = 1; i <= ccn; ++i )
			ans += solve( cc[i] );
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder_問題4_B1問目_
{
    class Program
    {
        static void Main(string[] args)
        {
            //問題4　入力を受け取る
            int a = Convert.ToInt32(Console.ReadLine());
            int b = Convert.ToInt32(Console.ReadLine());
            int c = Convert.ToInt32(Console.ReadLine());
            int x = Convert.ToInt32(Console.ReadLine());
            int check = 0;

            for (int i = 0; i <= a; i++)
            {
                for (int k = 0; k <= b; k++)
                {
                    for (int m = 0; m <= c; m++)
                    {
                        if (x == i * 500 + k * 100+ m * 50)
                        {
                            check += 1;
                        }
                    }
                }
            }
            Console.WriteLine(check);
        }
    }
}

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

typedef long long ll;

const ll INF = (1LL<<60);
struct edge { ll to, cost; };
typedef pair<ll, ll> P;   // firstは最短距離、secondは頂点の番号

const ll MAX_V = 110000, MAX_E = 110000;

ll V, E;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
	// greater<P>を指定することでfirstが小さい順に取り出せるようにする
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	// 始点 s の距離は０
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		// PQ内にあるものの中で最も距離の短いものを取り出す
		P p = que.top(); que.pop();
		ll v = p.second;
		if (d[v] < p.first) continue;
		// 頂点 v と隣接している頂点を調べる
		for (ll i = 0; i<G[v].size(); i++) {
			edge e = G[v][i];
			// この時点での頂点 e.to への最短距離より頂点 v を経由して頂点 e.to に行く経路の方が短いとき最短距離を更新する
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
int main() {
	cin >> V;
	for (ll i = 0; i < V-1; i++) {
		ll s, t, cost;
		cin >> s >> t >> cost;
		s--; t--;
		G[s].push_back(edge{ t, cost });
		G[t].push_back(edge{ s, cost });
	}
	ll Q, K;
	cin >> Q >> K;
	K--;
	vector<ll> x(Q), y(Q);
	for (ll i = 0; i < Q; i++) {
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
	}

	dijkstra(K);
	
	for (ll i = 0; i < Q; i++) {
		cout << d[x[i]]+d[y[i]] << endl;
	}

}


Measured memory_bytes: 12912
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main(void){
  int n;
  vector<int> a(3000);

  cin >> n;
  for(int i = 0; i < n; i ++)
    cin >> a.at(i);

  int result = 0;
  for(int i = 0; i < n; i ++)
    result += a.at(i)-1;

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
A, B, C, K = map(int, input().split())

ans = 0
num_of_cards = K

if A <= num_of_cards:
    ans += 1*A
    num_of_cards -= A
    if B <= num_of_cards:
        ans += 0
        num_of_cards -= B
        if C <= num_of_cards:
            ans += -1*C
        else:
            ans += -1*num_of_cards
    else:
        ans += 0
else:
    ans += 1*num_of_cards

print(ans)

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int stick[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    VI a(m);
    REP(i, m) cin >> a[i];
    vector<string> dp(n + 10, "");

    sort(ALL(a));
    REP(i, m) dp[stick[a[i]]] = (char)('0' + a[i]);

    REP(i, n + 1) {
        string max_str = "";
        REP(j, m) {
            if(i - stick[a[j]] < 0) continue;
            if(dp[i - stick[a[j]]] == "") continue;
            string cand = dp[i - stick[a[j]]] + (char)('0' + a[j]);
            
            if(max_str.size() < cand.size()) 
                max_str = cand;
            else if(max_str.size() == cand.size() and max_str < cand)
                max_str = cand;
        }

        if(dp[i].size() < max_str.size()) 
            dp[i] = max_str;
        else if(dp[i].size() == max_str.size() and dp[i] < max_str)
            dp[i] = max_str;
    }

    // REP(i, n + 1) cout << i << " " << dp[i] << ln;
    cout << dp[n] << ln;
    return 0;
}


Measured memory_bytes: 41472
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A, B, K = map(int, input().split())
    AK = [i for i in range(A, min(B + 1, A + K))]
    BK = [i for i in range(max(A, B - K + 1), B + 1)]

    result = list(set(AK) | set(BK))
    result.sort()

    for i in result:
        print(i)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int C[510], S[510], F[510];
    rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];
    rep(i, N) {
        int t = 0;
        for(int j = i; j < N - 1; j++) {
            t = max(t, S[j]);
            t += (F[j] - t % F[j]) % F[j] + C[j];
        }
        cout << t << endl;
    }

    return 0;
}


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

using namespace std;

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

	int k, n;
	cin >> k >> n;

	vector<long long> a;
	a.resize(n);

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

	long long ans = k;

	for(int i = 0; i + 1 < n; ++i) {
		ans = min(ans, k - (a[i + 1] - a[i]));
	}

	ans = min(ans, k - (k - a.back() + a[0]));

	cout << ans << '\n';

	return 0;
}

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

int box(vector<int> w, int k, int p) {
    int n = w.size();
    int sum = 0;
    for (int i = 0; i < k; i++) {
        int weight = 0;
        while (weight + w.at(sum) <= p) {
            weight += w.at(sum);
            sum++;
            if (sum == n) {
                return n;
            }
        }
    }

    return sum;
}

int solve(vector<int> w, int k) {
    int left = 0;
    int right = 100000 * 10000;
    while (left < right) {
        int mid = (left + right) / 2;
        if (box(w, k, mid) < w.size()) {
            left = mid + 1;
        } else if (box(w, k, mid) >= w.size()) {
            right = mid;
        }
    }

    return right;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> w(n);
    for (int i = 0; i < n; i++) {
        cin >> w.at(i);
    }

    int ans = solve(w, k);
    cout << ans << endl;
}


Measured memory_bytes: 4084
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	var L, R int
	fmt.Scan(&L, &R)
	m := 2019
	for i := L; i <= R; i++ {
		for j := i + 1; j <= R; j++ {
			if m > (i*j)%2019 {
				m = (i * j) % 2019
			}
			if m == 0 {
				fmt.Println(0)
				return
			}
		}
	}
	fmt.Println(m)
}

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

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

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

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s; cin >> s;
    int a1 = (s[0]-'0')*10+(s[1]-'0');
    int a2 = (s[2]-'0')*10+(s[3]-'0');

    if((a1 <= 12 && a1) && (a2 <= 12 && a2)){
        cout << "AMBIGUOUS\n";
        return 0;
    }
    if((a1 <= 12 && a1)){
        cout << "MMYY\n";
        return 0;
    }
    if((a2 <= 12 && a2)){
        cout << "YYMM\n";
        return 0;
    }
    cout << "NA\n";


    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    
    A.sort()
    
    print(A[-1] - A[0])
    
        
if __name__ == "__main__":
	main()


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

int main()
{
	int n, d, x, a[110];

	cin >> n >> d >> x;

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

	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j*a[i]+1 <= d; j++)
		{
			ans++;
		}
	}

	cout << ans + x << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n;
    long long num = 0, bnum = 0;
    scanf("%d", &n);
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &b[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &c[i]);
    }
    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end(), greater<int>());
    sort(c.begin(), c.end(), greater<int>());
    auto cite = c.begin();
    int j = 0;
    for (int i = 0; i < n; i++)
    {
        for (; b[j] > a[i] && j < n; j++)
        {
            cite = lower_bound(cite, c.end(), b[j], greater<int>());
            bnum += cite - c.begin();
        }
        num += bnum;
    }
    printf("%lld\n", num);
}

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

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

   int ans = (n % k == 0) ? 0 : 1;

   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
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);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string bans(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b,k;cin>>a>>b>>k;
  fori(i,a,b+1){
    if((a<=i&&i<=a-1+k)||(b+1-k<=i&&i<=b+1)){
      cout << i << endl;  
    }
  }
}


Measured memory_bytes: 256
/*
By Tianyi Chen. All rights reserved.
Date: 2018-09-01
*/
#include<bits/stdc++.h>
using namespace std;
int n,k,a,b;
int64_t q(int64_t x){
 return x*x*x;
}
int main(){
 scanf("%d%d",&n,&k);
 for(int i=1;i<=n;++i)if(i%k==0)++a;else if(2*i%k==0)++b;
 printf("%lld\n",q(a)+q(b));
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

int a[N], b[N];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    map<int, int> freq;
    for(int i = 1; i < n; i++){
        b[i - 1] = i - a[0];
        b[i - 1] = a[i] - b[i - 1];
        freq[b[i - 1]]++;
    }
    ll ans = freq[0];
    for(int i = 1; i < n; i++){
        freq[b[i - 1]]--;
        int x = a[0] - a[i] - i;
        ans += freq[x];
    }
    cout << ans;

    return 0;

}


Measured memory_bytes: 22132
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long x,long long y){
	if(x%y==0)return y;
	return gcd(y,x%y);
}
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 d=exgcd(b,a%b,y,x);
	y-=a/b*x;
	return d;
}
long long phi(long long x){
	int ans=1;
	for(int i=2;i*i<=x;i++){
		if(x%i==0){
			ans*=(i-1);
			x/=i;
			while(x%i==0)x/=i,ans*=i;
		}
	}
	if(x!=1)ans*=(x-1);
	return ans;
}
long long power(long long x,long long k,long long P){
	long long ans=1;
	while(k){
		if(k&1)(ans*=x)%=P;
		(x*=x)%=P;
		k>>=1;
	}
	return ans;
}
long long solve(long long a,long long m){
	if(m==1)return 1;
	long long M=phi(m);
	long long d=gcd(M,m);
	long long t=solve(a,d);
	long long At=power(a,t,m);
	long long x,y;
	exgcd(M/d,m/d,x,y);
	__int128 A=(At-t%M)/d*x;
	__int128 ans=(__int128)t%M+A*M;
	ans%=m/d*M;
	ans+=m/d*M;
	ans%=m/d*M; 
	ans+=m/d*M; 
//	printf("%lld\n",ans);
	return ans;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		long long x,m;
		scanf("%lld%lld",&x,&m);
		long long ans=solve(x,m);
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		int count = 0;
		int X[] = new int[5];
		int d = 0;
		
		for (int i = 0; i < 5; i++) {
			int x = scanner.nextInt();
			X[i] = x;
		}
		int k = scanner.nextInt();
		
		for (int m = 4; m > 0; m--) {
			for (int n = 0; n < m; n++) {
				d = X[m] - X[n];
				//System.out.println(d);
			if (d > k) {
				count += 1;
			}
			}
		}
		//System.out.println("countは"+count);
		if (count != 0) {
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}
	}
}


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

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

using namespace std;

int main(void)
{
  int l, r, d;
  cin >> l >> r >> d;
  int res = 0;
  rep(l, r + 1) if (i % d == 0) ++res;
  cout << res << endl;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

// ダブリング O(funcの計算量*log(e))
template<typename T=ll, typename F=function<T(T,T)>>
T binpow(T x, ll e, F func=[](T a, T b){return a*b%MOD;}, T d=1) {
  T ret = d, p = x;
  while(e > 0) {
    if(e&1) {ret = func(ret, p); e--;}
    else {p = func(p, p); e /= 2;} 
  }
  return ret;
};

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

  ll m, n;
  cin >> m >> n;
  cout << binpow(m, n) << endl;

  return 0;
}


Measured memory_bytes: 3208
//template
import java.util.*;
import java.util.stream.*;
import java.io.*;
public class Main{
	static BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out= new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	
	private static final int HUNDRED = 100;
	public static void main(String[] args) throws IOException{
		
		int k=Integer.parseInt(in.readLine());
		long sec=7;
		long cont=1;
		boolean hay=false;
		int i;
		for(i=1;i<=k;i++){
			//cont++;
			if(sec%k==0) {
				hay=true;
				break;
			}
			sec=(sec*10+7)%k;
		}
		if(hay) out.append(i+"");	
		else out.append("-1");
		
		out.flush();
		in.close();
		out.close();
	}
	public static int mcm(long num1,long num2) {
		int mcm=1;
		int i=2;
		while(i <= num1 || i <= num2)
        {
            if(num1%i==0 || num2%i==0)
            {
            mcm=mcm*i;
            if(num1%i==0) num1=num1/i;
            if(num2%i==0) num2=num2/i;
            }
            else
                i=i+1;               
        }                       
		return mcm;
	}
	public static long MCD(long a, long b) {
	       if(b==0)
	           return a;
	       else
	           return MCD(b, a % b);
	}
	private static int modulo(int S, int N) { return ((S) & (N - 1)); } // returns S % N, where N is a power of 2
	private static int isPowerOfTwo(int S) { return (S & (S - 1)) == 0 ? 1 : 0; }
	private static int[] readInts() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	}
	private static int readInt() throws IOException {
		return Integer.parseInt(in.readLine());
	}
	private static long[] readLongs() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
	}
	private static long readLong() throws IOException {
		return Long.parseLong(in.readLine());
	}
	 
}


Measured memory_bytes: 36836
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

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

  int n;
  ll odd=0;
  cin >> n;
  vector<int> a(n+1);  
  REP(i,n) {
    cin >> a[i];
    if(a[i]%2) odd++;
  }

  //if()
  
  if(odd%2) cout << "NO" << endl;
  else cout << "YES" << endl;
  
  return 0;
}


Measured memory_bytes: 640
N = 6
ARR = [2, 3, 3, 1, 3, 1]

# N = 6
# ARR = [5, 2, 4, 2, 8, 8]

N = 32
ARR = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5]

N = int(input())
ARR = list(map(int, input().split()))


def calculate(n, arr):
    A = {}
    B = {}

    for i in range(1, n + 1):
        Ai = arr[i - 1]
        Aj = arr[i - 1]

        a = Ai + i
        b = (i - Aj)

        if A.get(a) == None:
            A.__setitem__(a, [i])
        else:
            tmp = A.__getitem__(a)
            tmp.append(i)
            A.__setitem__(a, tmp)

        if B.get(b) == None:
            B.__setitem__(b, [i])
        else:
            tmp = B.__getitem__(b)
            tmp.append(i)
            B.__setitem__(b, tmp)

    result = 0
    for key in A.keys():
        l1 = len(A.get(key))

        if B.get(key) != None:
            l2 = len(B.get(key))
            result += l1 * l2

    print(result)


calculate(N, ARR)


Measured memory_bytes: 91752
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;
    ull k;
    cin>>a>>b>>c>>k;
    if(k%2==0)
        cout<<a-b<<endl;
    else
        cout<<b-a<<endl;
    return 0;
}

Measured memory_bytes: 3608
// SeeAlso: https://atcoder.jp/contests/abc061/tasks/abc061_b

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int N, M;

int main() {
    cin >> N >> M;
    int ans[N];

    REP(i, N) {
        ans[i]=0;
    }
    REP(i, M) {
        int a,b;
        cin >> a >> b;
        ans[a-1] +=1;
        ans[b-1] +=1;
    }

    REP(i, N) {
        print(ans[i]);
    }

    return 0;
}


Measured memory_bytes: 256