akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x, t; cin >> n >> x >> t;
  cout << t*((n+x-1)/x) << endk;
  return 0;
}


Measured memory_bytes: 3644
a,b = input().split()
a = int(a)
b = int(b)
c = 0
for i in range(10000):
    d = c*0.08
    e = c*0.1
    d = int(d)
    e = int(e)
    if d == a and e == b:
        print(c)
        break
    elif c == 9999:
        print('-1')
        break
    else:
        c += 1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
int a,b;
int p[105];
int main(void)
{
  int N,ans=0;
  cin >> N;
  for(int i=0;i<N;i++)
    {
      cin >> p[i];
    }
  for(int i=1;i<=100;i++)
    {
      int cnt=0;
      for(int j=0;j<N;j++)
	{
	  if(p[j]>=i) cnt++;
	}
      if(cnt>=i) ans=i;
    }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3104
import sys

def main():
    N = int(sys.stdin.readline())
    A = list(map(int, sys.stdin.readline().rstrip().split()))

    n = max(A)
    a = -1
    d = n
    for e in A:
        if e == n:
            continue
        if abs(e - n/2) < d:
            a = e
            d = abs(e - n/2)
    
    print(n, a)


if __name__ == '__main__':
    main()

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

bool check(int x, int y, int z) {
	return y-x == z-y;
}

int main() {
	int a[3];
	scanf("%d%d%d", a+0, a+1, a+2);
	if (check(a[0], a[1], a[2]) || check(a[0], a[2], a[1]) || check(a[1], a[0], a[2])
		|| check(a[1], a[2], a[0]) || check(a[2], a[0], a[1]) || check(a[2], a[1], a[0])) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;


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

    for(int i=1;i<n;i++){
      for(int j=0;j<n-1;j++){
        std::cout << a[j]<<" ";
      }

      std::cout << a[n-1] << '\n';
      int v=a[i];
      int j=i-1;
      while (j>=0&&a[j]>v) {
        a[j+1]=a[j];
        j--;
      }
      a[j+1]=v;


    }

    for(int j=0;j<n-1;j++){
      std::cout  << a[j]<<" ";
    }
    std::cout << a[n-1] << '\n';



}

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

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

	vector<double> p(N);
	for(uint32_t i=0; i<N; i++) cin >> p[i];
	
	vector<vector<double>> dp(N+1, vector<double>(N+1, 1));
	
	for(uint32_t i=1; i<=N; i++) {
		dp[i][0] = dp[i-1][0] * (1 - p[i-1]);
		dp[i][i] = dp[i-1][i-1] * p[i-1];
	}
	
	for(uint32_t i=2; i<=N; i++) {
		for(uint32_t j=1; j<i; j++) {
			dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j] * (1 - p[i-1]);
		}
	}

	double ans = accumulate(dp[N].begin() + N/2 + 1, dp[N].end(), (double)0);
	cout << setprecision(10) << ans << endl;
	
	return 0;

}

Measured memory_bytes: 70656
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A= new int[N];

		for(int i=0; i<N; i++){
			A[i] = sc.nextInt();
		}

		// 降った雨の量 x[i]
		// xi + xi+1 = Ai
		int[] x = new int[N];
		// x1 = S - (x2 + x3 + ... xn)
		//    = x1 - x2 + x3 - x4 + .... - xn-1 + xn
		x[0]=0;
		for(int i=0;i<N;i++){
			x[0] += i%2==0 ? A[i] : -1*A[i];
		}
		// xi = 2Ai - xi
		for(int i=0; i<N-1; i++){
			x[i+1] = 2*A[i] - x[i];
		}

		for(int i=0;i<N;i++){
			System.out.print(x[i] + " ");
		}
		System.out.println();
	}
}


Measured memory_bytes: 63672
#include <bits/stdc++.h>
using namespace std;
 
#define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i)
 
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
 
#define LOWBIT(x) ((x)&(-x))
 
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
 
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
 
template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
    in >> p.first >> p.second;
    return in;
}
 
template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
    for (auto &x: v)
        in >> x;
    return in;
}
 
template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]" << "\n";
    return out;
}

inline int gc(){
	static const int BUF = 1e7;
	static char buf[BUF], *bg = buf + BUF, *ed = bg;
	
	if(bg == ed) fread(bg = buf, 1, BUF, stdin);
	return *bg++;
} 

inline int ri(){
	int x = 0, f = 1, c = gc();
	for(; c<48||c>57; f = c=='-'?-1:f, c=gc());
	for(; c>47&&c<58; x = x*10 + c - 48, c=gc());
	return x*f;
}
 
typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef pair< string, int > PSI;
typedef set< int > SI;
typedef vector< int > VI;
typedef vector< PII > VPII;
typedef map< int, int > MII;
typedef multimap< int, int > MMII;
typedef unordered_map< int, int > uMII;
typedef pair< LL, LL > PLL;
typedef vector< LL > VL;
typedef vector< VL > VVL;
typedef priority_queue< int > PQIMax;
typedef priority_queue< int, VI, greater< int > > PQIMin;
const double EPS = 1e-10;
const LL inf = 0x7fffffff;
const LL infLL = 0x7fffffffffffffffLL;
const LL mod = 1e9 + 7;
const int maxN = 1e5 + 7;
const LL ONE = 1;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555;

int N, s[maxN];
LL ans;

int main(){
	INIT(); 
	cin >> N;
	Rep(i, N) cin >> s[i];
	
	For(i, 1, N - 3) { // 枚举 A - B 
		LL ret = 0;
		For(k, 1, (N - 1) / i) {
			LL tmp = N - 1 - i * k;
			if(tmp <= i || tmp % i == 0 && tmp / i <= k) break;
			ret += s[i * k] + s[tmp];
			ans = max(ans, ret);
		}
	}
	
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define INF 200005

int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int n;
    double d;
    cin >> n >> d;
    int tot=0;
    for(int i=0;i<n;i++)
    {
    	long long x,y;
    	cin >> x >> y;
    	double dis=(x*x)+(y*y);
    	dis=sqrt(dis*1.0);
    	if(dis<=d)
    	{
    		tot++;
    	}
    }
    cout << tot << "\n";
}


Measured memory_bytes: 3776
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(void){
    struct point{
        double x;
        double y;
    } p1, p2;
    double result;

    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    result = sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
    cout << fixed << setprecision(5) << result << endl;
    return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll n, k;
	cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	sort(a, a+n);
	for(int i=0;i<k;i++){
		ans+=a[i];
	}
	cout<<ans;


    return 0;
}


Measured memory_bytes: 3664
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>

using namespace std;

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

#define pb push_back
#define fs first
#define sc second
#define openfile {freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
#define debug 0
int vtchan[100000], vtle[100000];
int check[21];
string s;
int main() {
   if (debug) openfile;
   while (1)
   {
      getline(cin, s);
      if (s[0]=='0') break;
      memset(check, 0, sizeof check);
      check[0]=1;
      int res =0;
      int tmp;
      int n = s.length();
      vtchan[0]=0; vtle[0]=0;
      /*
      cout << s << endl;
      for (int i=1; i<n; ++i)
      {
         for (int j=0; j<=i; ++j)
         {
            int le=0, chan=0;
            if (s[j]=='0') continue;
            for (int t=j; t<=i; ++t)
            {
               if (t%2) le+=(int)(s[t]-48);
               else chan+=(int)(s[t]-48);
            }
            if ((le-chan+11)%11==0)
            {
               for (int t=j; t<=i; ++t)
                  cout << s[t];
               cout << endl;
            }
         }
      }
      cout << endl;*/

      for (int i=0; i<n; ++i)
      {
         if (i%2)
         {
            vtle[i+1]=(vtle[i]+(int)(s[i]-48))%11;
            vtchan[i+1]=vtchan[i];
         }
         else
         {
            vtchan[i+1]=(vtchan[i]+(int)(s[i]-48))%11;
            vtle[i+1]=vtle[i];
         }
         if (s[i]=='0') --check[(vtle[i]-vtchan[i]+11)%11];
         tmp = check[(vtle[i+1]-vtchan[i+1]+11)%11];
         res+= tmp;

         check[(vtle[i+1]-vtchan[i+1]+11)%11] = tmp+1;
      }
      cout << res << endl;
   }
   return 0;
}

Measured memory_bytes: 1932
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class A {
public:
	void solve(istream& in, ostream& out) {
        int n, k, x, y;
        in >> n >> k >> x >> y;
        if(n <= k) out << x * n << endl;
        else out << x * k + y * (n - k) << endl;
	}
};

int main() {
	A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input().strip())
A = Counter(list(map(int, input().strip().split(' '))))
tmp = 0
for k,v in sorted(A.items(), reverse=True):
  if v >= 4:
    if tmp > 0:
      print(k*tmp)
      exit()
    else:
      print(k*k)
      exit()
  elif v >= 2:
    if tmp > 0:
      print(k*tmp)
      exit()
    else:
      tmp = k
print(0)


Measured memory_bytes: 21412
A, B = [int(i) for i in input().split()]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

print(len(set(prime_decomposition(gcd(A, B)))) + 1)

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

int main(){
	int length;
	std::cin >> length;
	for (int i = 0; i < length; i++)
	{
		std::vector<int> side;
		for (int j = 0; j < 3; j++)
		{
			int scan_num;
			std::cin >> scan_num;
			side.push_back(scan_num);
		}
		std::sort(side.begin(), side.end());
		if (side[0] * side[0] + side[1] * side[1] == side[2] * side[2])
			std::cout << "YES\n";
		else
			std::cout << "NO\n";
	}
	return 0;

}



Measured memory_bytes: 2944
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <vector>

using namespace std;

void exchange(vector<int> &array, int w, vector<vector <int> > n){

  for(int i=0;i<n.size();i++){
    int a = n[i][0]-1;
    int b = n[i][1]-1;
    //    cout << "a: " << a << ", b: " << b << endl;
    int tmp = array[a];
    array[a] = array[b];
    array[b] = tmp;
  }  
}
  

int main(){

  int w, n;
  cin >> w;
  cin >> n;

  vector<vector <int> > Yoko;
  Yoko.resize(n);
  
  for(int i=0;i<n;i++){
    Yoko[i].resize(2);
    int a, b;
    char c;
    cin >> a >> c >> b;
    Yoko[i][0] = a;
    Yoko[i][1] = b;
  }

  vector<int> array;
  for(int i=0;i<w;i++){
    array.push_back(i+1);
  }
  
  exchange(array, w, Yoko);

  for(int i=0;i<array.size();i++){
    cout << array[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces1148A_live
from collections import Counter
gi = lambda : list(map(int,input().strip().split()))
n, a, b, c, d = gi()
s = input()
if a > b:
	a, b = b, a
	c, d = d, c
a -= 1
b -= 1
c -= 1
d -= 1
if c <= d:
	temp = s[a:c]
	if "##" in temp:
		print("No")
		exit()
	temp = s[b:d]
	if "##" in temp:
		print("No")
		exit()
	print("Yes")
	exit()
temp = s[a:c]
temp2 = s[max(0, b - 1):d + 2]
if "##" in temp or "..." not in temp2:
	print("No")
	exit()
print("Yes")

Measured memory_bytes: 3892
// atcoder/abc059/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string a, b, c;
  while (cin >> a >> b >> c) {
    char x = 'a' - 'A';
    cout << (char)(a[0] - x);
    cout << (char)(b[0] - x);
    cout << (char)(c[0] - x);
    cout << endl;
  }

  return 0;
}


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

int main() {

    cerr << "Hello World" << '\n';

    string s, t;
    cin >> s >> t;
    t.pop_back();

    if (s == t) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }

    return 0;
}

Measured memory_bytes: 3640
package main

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

func solution(s string) string {
	if s[len(s)-1] == 's' {
		return s + "es"
	}
	return s + "s"
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var s string
	fmt.Fscan(r, &s)
	fmt.Println(solution(s))
}


Measured memory_bytes: 1860
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int cnt=0;
    while(n){
        ++cnt;
        n/=k;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int ac,wa,tle,re;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		char s[9];
		scanf("%s",s);
		if(s[0]=='A')ac++;
		if(s[0]=='W')wa++;
		if(s[0]=='T')tle++;
		if(s[0]=='R')re++;
	}
	printf("AC x %d\n",ac);
	printf("WA x %d\n",wa);
	printf("TLE x %d\n",tle);
	printf("RE x %d\n",re);
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

int main(){
  int x,y,z,k;cin >> x >> y >> z >> k;
  vector<ll> a(x),b(y),c(z);
  rep(i,x) cin >> a[i];
  rep(i,y) cin >> b[i];
  rep(i,z) cin >> c[i];
  sort(a.rbegin(),a.rend());
  sort(b.rbegin(),b.rend());
  sort(c.rbegin(),c.rend());
  using tup = tuple<int,int,int>;
  using T = pair<ll,tup>;
  priority_queue<T,vector<T>> q;
  q.emplace(a[0]+b[0]+c[0],tup(0,0,0));
  map<tup,int> mp;
  rep(t,k){
    T temp = q.top();
    q.pop();
    ll& num = temp.first;
    cout << num << endl;
    int& i = get<0>(temp.second); 
    int& j = get<1>(temp.second); 
    int& l = get<2>(temp.second);
    //printf("%d %d %d\n",i,j,l); 
    if(mp[tup(i+1,j,l)] == 0 && i+1 < x) {
      q.emplace(a[i+1]+b[j]+c[l],tup(i+1,j,l));
      mp[tup(i+1,j,l)] = 1;
    }
    if(mp[tup(i,j+1,l)] == 0 && j+1 < y) {
      q.emplace(a[i]+b[j+1]+c[l],tup(i,j+1,l));
      mp[tup(i,j+1,l)] = 1;
    }
    if(mp[tup(i,j,l+1)] == 0 && l+1 < z) {
      q.emplace(a[i]+b[j]+c[l+1],tup(i,j,l+1));
      mp[tup(i,j,l+1)] = 1;
    }
  }

}

Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

// 地点cにいるゴーレムが左(もしくは右)に抜けるか否かをシュミレート
int sim(int c, string &s, vector<char> &t, vector<char> &d) {
    for(int i = 0; i < t.size(); i++) {
        if(s[c] == t[i]) {
            c += (d[i] == 'L' ? -1 : 1);
        }
        if (c < 0) return 1;
        if (c >= s.size()) return 3;
    }
    return 2;
}

int main() {
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    vector<char> t(Q), d(Q);
    for(int i = 0; i < Q; i++) {
        cin >> t[i] >> d[i];
    }    

    // ゴーレムはとなりのゴーレムを飛び越えることがないので、相対的位置関係が変わらない
    // ある地点で左に抜けるゴーレムがいたとき、そのひだりのゴーレムは全て抜ける
    // そのため、二分法でその座標を求めることができる

    // 左に抜けるケース
    int ok = -1, ng = N;
    while(abs(ng - ok) > 1) {
        int c = (ng + ok) / 2;

        if(sim(c, s, t, d) == 1) ok = c;
        else ng = c;
    }
    int ok_l = ok;

    // 右に抜けるケース
    ok = N, ng = -1;
    while(abs(ng - ok) > 1) {
        int c = (ng + ok) / 2;

        if(sim(c, s, t, d) == 3) ok = c;
        else ng = c;
    }
    int ok_r = ok;

    cout << (ok_r - ok_l - 1) << endl;

    return 0;
}

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

int N;
vector<int> A;

inline void Main() {
  // code
  cin >> N;
  A.resize(N);
  rep(i, N) cin >> A.at(i);

  int t = 1e9;
  long long s = 0;
  int f = 0;
  rep(i, N) {
    t = min(t, abs(A.at(i)));
    s += abs(A.at(i));
    if(A.at(i) < 0) f++;
  }
  cout << (f % 2 == 0 ? s : s - 2 * t) << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 640
/*====================================
Auther:    Shyam Makwana
Problem:   abc179_a.cpp
====================================*/

#include <bits/stdc++.h>
using namespace std;
#define int long long int

int32_t main()
{
	int n,m;
	string str;
	cin>>str;

	int len=str.length();
	char var = str[len-1];
	if(var!='s')	
		str.append("s");	
	else
		str.append("es");
	cout<<str;
}

Measured memory_bytes: 3624
N = input()

N = '0' + N
result = 0
carry = 0
for i in range(len(N) - 1, 0, -1):
    c = int(N[i]) + carry
    n = int(N[i - 1])
    if c < 5 or (c == 5 and n < 5):
        result += c
        carry = 0
    else:
        result += 10 - c
        carry = 1
result += carry
print(result)


Measured memory_bytes: 5492
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,ans=0;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    rep(i,0,n)
    {
        set<char>s;
        s.insert(a[i]);
        s.insert(b[i]);
        s.insert(c[i]);
        ans+=(sz(s)-1);
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

using namespace std;

int main(){
	int an,bn,r;
	int flyX[100001];
	int flyY[100001];
	int px,py;
	vector<int> energy[10001];
	int sum;
	while(cin>>an>>bn>>r&&!(an==0&&bn==0&&r==0)){
		for(int i = 0; i < 10001; i++){
			energy[i].clear();
		}
		for(int i = 0; i < an; i++){
			cin>>flyX[i]>>flyY[i];
		}
		int infoMinX=10000000;
		int infoMaxX=-1;
		
		for(int i = 0; i < bn; i++){
			cin>>px>>py;
			energy[px].push_back(py);
		}
		for(int i = 0; i < 10001; i++){
			sort(energy[i].begin(),energy[i].end());
		}
		sum=0;
		for(int i = 0; i < an; i++){
			int minx=max(0,flyX[i]-4*r);
			int maxx=min(9999,flyX[i]+4*r);
			for(int j = minx; j <= maxx; j++){
				if(energy[j].empty())
					continue;
				int ovlimit=(int)(sqrt((double)(-((flyX[i]-j)*(flyX[i]-j))+16*r*r))+flyY[i]+EPS);
				double lolimit2=(-sqrt((double)(-((flyX[i]-j)*(flyX[i]-j))+16*r*r))+flyY[i]);
				int lolimit=(int)(lolimit2+EPS);
				if(!EQ(lolimit2,(int)lolimit2)){
					lolimit++;
				}
				sum+=(upper_bound(energy[j].begin(),energy[j].end(),ovlimit)
					-lower_bound(energy[j].begin(),energy[j].end(),lolimit));
			}
		}
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long
long long cnt = 0;
int main() {
	
	int A, B, K = 0, ans = 0;
	cin >> A >> B;
	int Temp = 1;
	while (Temp < B) {
		Temp += A - 1;
		ans++;
	}
	cout << ans;
	
}



Measured memory_bytes: 256
#W, H, x, y, r = map(int, input().split())
def main():

    input_array_list = []

    while True:
        input_array = input().split()
        if input_array[1] == "?":
            break
        else:
            input_array_list.append(input_array)

    for item in input_array_list:
        if item[1] == "+":
            print(str(int(item[0])+int(item[2])))
        elif item[1] =="-":
            print(str(int(item[0])-int(item[2])))
        elif item[1] == "/":
            print(str(int(item[0])//int(item[2])))
        elif item[1] == "*":
            print(str(int(item[0])*int(item[2])))

main()

# import sympy as sp

# input_list = []
# a,b,c = map(int, input().split())
# divisors = sp.divisors(c)
#
# count = 0
#
# for divisor in divisors:
#     if a <= divisor and divisor <= b:
#         count = count + 1
# print(count)
#
# while True:
#     pair_str = input().split()
#     pair_int = [int(s) for s in pair_str]
#     if pair_int[0] == 0 and pair_int[1] == 0 :
#         break
#     else:
#         input_list.append(pair_int)
#
# for pair_int in input_list:
#     if pair_int[0] <= pair_int[1]:
#         print("{} {}".format(pair_int[0], pair_int[1]))
#     else:
#         print("{} {}".format(pair_int[1], pair_int[0]))

#for i in range(10000):
#    print("Hello World")
#a = input().split()
#a_int = [int(s) for s in a]
#a_sorted = sorted(a_int)
#print(' '.join(map(str, a_sorted)))



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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	ll A, B; cin >> A >> B; A -= B;
	vector<ll> H(N);
	for (int i = 0; i < N; i++) cin >> H[i];

	ll mi = 0, ma = 0;
	for (int i = 0; i < N; i++) ma += (H[i] + B - 1) / B;
	while (ma - mi > 1) {
		ll md = (mi + ma) / 2;
		ll cnt = 0;
		for (int i = 0; i < N; i++) {
			cnt += (max(0ll, H[i] - B * md) + A - 1) / A;
		}
		if (cnt <= md) {
			ma = md;
		} else {
			mi = md;
		}
	}
	cout << ma << '\n';

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <set>

int main() {
    int n, k;
    long long ans = 0;

    std::cin >> n >> k;

    ans += k;
    for (int i = 0; i < n - 1; i++) {
        ans *= (k - 1);
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
var
        s:string;
begin
        readln(s); 
        if s[1]=s[length(s)] then
        begin
                if length(s) mod 2=1 then writeln('Second')
                else writeln('First');
        end
        else
        begin
                if length(s) mod 2=0 then writeln('Second')
                else writeln('First');
        end;
end.


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

int main()
{
	string s,t;
	cin>>s>>t;
	int count=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]==t[i])
		{
			continue;
		}
		else
		{
			count+=1;
		}
	}
	cout<<count<<endl;
}


Measured memory_bytes: 3920
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <numeric>

using namespace std;

int main(void)
{
    int n,m;
    cin >> n >> m;
    
    vector<int> h(n);
    vector<int> good(n,1);
    vector<pair<int,int>> a(m);
    for (int i = 0;i < n;i++) cin >> h[i];
    for (int i = 0;i < m;i++)
    {
        cin >> a[i].first >> a[i].second;
    }
    
    for (int i = 0;i < m;i++)
    {
        if (h[a[i].first - 1] < h[a[i].second - 1])
        {
            good[a[i].first - 1] = 0;
        }
        else if (h[a[i].first - 1] > h[a[i].second - 1])
        {
            good[a[i].second - 1] = 0;
        }
        else
        {
            good[a[i].first - 1] = 0;
            good[a[i].second - 1] = 0;
        }
    }


    cout << accumulate(good.begin(),good.end(),0) << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 4844
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline ll read(void){
	ll a=0,f=1;char c;
	while((c=tc())<'0'||c>'9')c=='-'?f=-1:0;
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
ll n,c,mx,x[100005],v[100005],nxt[100005],nxt1[100005],nxt2[100005],pre[100005],pre1[100005],pre2[100005];
int main(void){
	register int i;
	n=read(),c=read();
	for(i=1;i<=n;++i)x[i]=read(),v[i]=read();
	for(i=1;i<=n;++i)nxt[i]=v[i]+nxt[i-1];
	for(i=n;i;--i)pre[i]=v[i]+pre[i+1];
	for(i=1;i<=n;++i)nxt1[i]=max(nxt1[i-1],nxt[i]-x[i]);
	for(i=n;i;--i)pre1[i]=max(pre1[i+1],pre[i]-(c-x[i]));
	for(i=1;i<=n;++i)nxt2[i]=max(nxt2[i-1],nxt[i]-2*x[i]);
	for(i=n;i;--i)pre2[i]=max(pre2[i+1],pre[i]-2*(c-x[i]));
	for(i=0;i<=n;++i){
		mx=max(mx,pre2[i+1]+nxt1[i]);
		mx=max(mx,pre1[i+1]+nxt2[i]);
	}
	printf("%lld\n",mx);
	return 0;
}

Measured memory_bytes: 6400
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;
const int maxn=1e5+50;
int h[maxn];
int n;
long long a,b;

//ax+b(mid-x)>=h
int calc(long long h,int o){
    int l=0,r=o,ret=o;
    while (l<=r){
        int mid=(l+r)>>1;
        if (a*mid+b*(o-mid)>=h){
            ret=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    return ret;
}

bool check(int mid){
    long long cnt=0;
    for (int i=1;i<=n;i++){
        if (a*mid<h[i]) return 0;
        cnt+=calc(h[i],mid);
        if (cnt>mid) return 0;
    }
    return cnt<=mid;
}

int main(){
    scanf("%d%lld%lld",&n,&a,&b);
    for (int i=1;i<=n;i++) scanf("%d",&h[i]);
    int l=0,r=1e9,ret=1e9;
    while (l<=r){
        int mid=(l+r)>>1;
        if (check(mid)) {
            ret=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    int x, y;
    
    
    while(1){
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        
        if (y < x){
            cout << y << " " << x << endl;
            
        }else{
            cout << x << " " << y << endl;
        }
        
    }
    
    return 0;
}


Measured memory_bytes: 3072
#include <stdio.h>

int main()
{
  int a, b, c;

  fscanf(stdin, "%d %d %d", &a, &b, &c);

  if (a<=b && a<=c)       printf("%d ", a);
  else if (b<=a && b<=c)  printf("%d ", b);
  else                    printf("%d ", c);
  
  if (a>=b && a>=c)       printf("%d\n", a);
  else if (b>=a && b>=c)  printf("%d\n", b);
  else                    printf("%d\n", c);
  
  return 0;
}


Measured memory_bytes: 2104
K, N = map(int, input().split())
A = list(map(int, input().split()))

l = 0
for i in range(len(A) - 1):
    l = max(l, A[i+1] - A[i])
l = max(l, K - A[len(A) - 1] + A[0])

print(K - l)


Measured memory_bytes: 26436
#include <bits/stdc++.h>
typedef long long ll;

int main(int argc, char const *argv[]) {
    ll N, x;
    std::cin >> N >> x;
    ll a[N];
    for (size_t i = 0; i < N; i++) {
        std::cin >> a[i];
    }
    ll count = 0;
    for (size_t i = 0; i < N - 1; i++) {
        if (a[i] + a[i + 1] > x) {
            count += a[i] + a[i + 1] - x;
            if (x >= a[i]) {
                a[i + 1] = x - a[i];
            } else {
                a[i + 1] = 0;
                a[i] = x;
            }
        }
    }
    std::cout << count << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main () {
  string s;
  cin >> s;
  
  for (int i = 0; i < 4; i++) {
    cout << s.at(i);
  }
  cout << " ";
  for (int i = 0; i < 8; i++) {
    cout << s.at(i+4);
  }
  cout << endl;
}

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

#define ll long long int
#define ff first
#define ss second
#define int long long int
#define pb push_back

#define N 100010
#define MOD 1000000007


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    if(n % 2)
    {
        cout << 0;
    }
    else
    {
        int ans = 0;
        n = n / 2;
        int k = 5;

        while(n >= k)
        {
            ans += n / k;
            k *= 5;
        }
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B)cout<<C<<endl;
    else if(A>B && C>(A-B))cout<<C-(A-B)<<endl;
    else if(A>B && C<=(A-B))cout <<0<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A,B,C,X,Y;
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		X = sc.nextInt();
		Y = sc.nextInt();
		int min =A*X+B*Y;
		if (X>Y) {
			if (C*2*X<min) {
				min = C*2*X;
			}
			if (C*2*Y+(X-Y)*A<min) {
				min =C*2*Y+(X-Y)*A;
			}
		} else {
			if (C*2*Y<min) {
				min = C*2*Y;
			}
			if (C*2*X+(Y-X)*B<min) {
				min =C*2*X+(Y-X)*B;
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
int n;
ll g[101][101];
int main(){
    cin >> n;
    rep(i,n){
        int u, k;
        cin >> u >> k;
        rep(j,k){
            int node;
            cin >> node;
            g[u][node] = 1;
        }
    }

    REP(i,1,n+1)REP(j,1,n+1)cout << g[i][j] << ((j == n)?"\n":" ");
    
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];

    int min_sum = 1e9;
    rep2(i,1,101) {
        int tmp_sum = 0;
        rep(j,n) tmp_sum += (x[j]-i) * (x[j]-i);
        min_sum = min(min_sum, tmp_sum);
    }

    cout << min_sum << endl;
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    A,B,C,D = int(s[0]), int(s[1]), int(s[2]), int(s[3])
    while True:
        C -= B
        if(C <= 0):
            print('Yes')
            exit()

        A -= D
        if(A <= 0):
            print('No')
            exit()


Measured memory_bytes: 9132
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b){
        swap(a,b);
    }
    if(a>c){
        swap(a,c);
    }
    if(b>c){
        swap(b,c);
    }
    cout<<a<<" "<<b<<" "<<c<<endl;;
    return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,r;
  cin>>n>>r;
  if(n<10)
    cout << r + 100*(10-n) << endl;
  else
    cout << r << endl;


  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
//#include <tuple>

using namespace std;

//constexpr long long mod = static_cast<long long>(1e9 + 7);


int main() {
    int n;
    std::cin >> n;
    std::unordered_map<int, int> map;
    while(n-- > 0) {
        int x;
        std::cin >> x;
        auto itr = map.find(x);
        if (itr == end(map)) map.insert(std::make_pair(x, 1));
        else ++(itr->second);
    }

    int ans = 0;
    for(auto& val: map) {
        ans += val.first > val.second ? val.second : val.second - val.first;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4260
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

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

int main()
{
        int N, K;
        cin >> N >> K;
        vector<int> A(N + 1), B(N + 1, 0);
        set<int> se;

        rep(i, N)
        {
                cin >> A[i];
                B[A[i]]++;
                se.insert(A[i]);
        }

        sort(all(B));

        int ch = se.size() - K;
        int ans = 0;
        if (ch <= 0)
        {
                cout << 0 << endl;
                return 0;
        }
        else
        {
                rep(i, N)
                {
                        if (ch == 0)
                        {
                                break;
                        }
                        if (B[i] == 0)
                                continue;
                        else
                        {
                                ch--;
                                ans += B[i];
                        }
                }
        }

        cout << ans << endl;

        return 0;
}


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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll ans = 1;
    for (ll i=0; i<N; i++) {
        cin >> A[i];
        if (A[i]==0) {
            ans = 0;
        }
    }

    if (ans==0) {
        cout << 0 << endl;
        exit(0);
    }
    
    ll judge = pow(10,18);
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    
    for (ll i=0; i<N; i++) {
        if (ans <= judge/A[i]) {
            ans *= A[i];
        }
        else {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
}

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

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

    int n;
    cin >> n;
    if(n >= 1000){
        cout << "ABD" << endl;
    }else{
        cout << "ABC" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
import sys
a = [int(l) for l in sys.stdin]    
k = a[-1]
a = sorted(a[:-1])

is_far = False
for x in reversed(a):
  if (x - a[0]) > k:
    is_far = True
    break

if is_far:
  print(':(')
else:
  print('Yay!')


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

using Edges = std::vector<int>;
using Graph = std::vector<Edges>;

int Search(const Graph &edge_list, std::vector<bool> &visited,
           const int depth, const int current_node)
{
    if (static_cast<size_t>(depth) == edge_list.size())
    {
        return 1;
    }

    int n = 0;
    for (const int next : edge_list[current_node])
    {
        if (visited[next])
        {
            continue;
        }
        visited[next] = true;
        n += Search(edge_list, visited, depth + 1, next);
        visited[next] = false;
    }
    return n;
}

int main()
{
    int n, m;
    std::cin >> n >> m;
    Graph edge_list(n);
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        std::cin >> a >> b;
        --a;
        --b;
        edge_list[a].push_back(b);
        edge_list[b].push_back(a);
    }

    std::vector<bool> visited(n);
    visited[0] = true;
    int count = Search(edge_list, visited, 1, 0);

    std::cout << count << std::endl;

    return 0;
}


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





int main() {
  int g;
cin>>g;
   int t;
cin>>t;
    int s;
cin>>s;
  if(s==t && s!=g)  cout<<"Yes";
 else if(s==g && s!=t)  cout<<"Yes";
 else if(g==t && s!=g)  cout<<"Yes"; 
  else cout<<"No";
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
int main(int argc, char** argv)
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << "\n";
    return 0;
}

Measured memory_bytes: 256
/*
    author: Salam_35
    problem name:
*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 200005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));

const ll MOD = 1e9+7;

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef map<int,int>mpii;
typedef vector<ll>vecs[Max];
int main()
{
    int n,m;
    cin >> n >> m;
    if(n>9 or m>9)
        cout<<-1<<endl;
    else
        cout<<n*m<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi p(n); rep(i,n) cin >> p[i];
  set<int> st;
  rep(i,n){
    st.insert(p[i]);
    if(st.count(p[i]-1)) st.erase(p[i]-1);
  }
  int mx = 0, pre = 0;
  for(auto x : st){
    chmax(mx,x-pre);
    pre = x;
  }
  cout << n-mx;
  return 0;
}


Measured memory_bytes: 13496
void main() {
  problem();
}

void problem() {
  auto S = scan;
  auto T = scan;

  void solve() {
    writefln(T[0..$-1] == S ? "Yes" : "No");
  }

  solve();
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


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

const int mod = 1000000007;
const int Maxn = 200005;

int n;
int C[Maxn];
int me[Maxn];
int nxt[Maxn];
int dp[Maxn];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &C[i]);
    fill(me, me + Maxn, Maxn);
    for (int i = n - 1; i >= 0; i--) {
        nxt[i] = me[C[i]];
        me[C[i]] = i;
    }
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        if (nxt[i] < Maxn)
            dp[nxt[i]] = (dp[nxt[i]] + dp[i]) % mod;
        if (nxt[i] != i + 1)
            dp[i + 1] = (dp[i + 1] + dp[i]) % mod;
    }
    printf("%d\n", dp[n]);
    return 0;
}


Measured memory_bytes: 3328
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

typedef vector<int> Vec;
typedef vector<Vec> Mat;

Mat multi(Mat a, Mat b){
    Mat c(a.size(), Vec(b[0].size()));

    for(int i = 0; i < (int)a.size(); i++){
        for(int j = 0; j < (int)b[0].size(); j++){
            for(int k = 0; k < (int)b.size(); k++){
                c[i][j] = (c[i][j] + a[i][k] * b[k][j] % MOD) % MOD;
            }
        }
    }
    return c;
}

Vec multi(Mat a, Vec b){
    Vec c(a.size());

    for(int i = 0; i < (int)a.size(); i++){
        for(int j = 0; j < (int)b.size(); j++){
            c[i] = (c[i] + a[i][j] * b[j] % MOD) % MOD;
        }
    }
    return c;
}

Mat powMat(Mat a, int n){
    Mat b(a.size(), Vec(a[0].size()));;
    for(int i = 0; i < (int)a.size(); i++){
        for(int j = 0; j < (int)a[0].size(); j++){
            if(i == j){
                b[i][j] = 1;
            }
        }
    }

    while(n != 0){
        if(n % 2 == 1){
            b = multi(b, a);
        }

        n /= 2;
        a = multi(a, a);
    }
    return b;
}

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

    int n, k;
    cin >> n >> k;
    Mat mat(n, Vec(n));
    rep(i, n){
        rep(j, n){
            cin >> mat[j][i];
        }
    }

    Vec v(n, 1);
    v = multi(powMat(mat, k), v);

    int ans = 0;
    rep(i, n){
        ans += v[i];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

double P(double x, double y, int p){
    double dis = abs(x - y);
    double ans = dis;
    rep(i,p - 1) ans *= dis;
    return ans;
}

double sum(double x[128], double y[128], int p, int n){
    double ans = 0;
    rep(i,n){
        ans += P(x[i],y[i],p);
    }
    return pow(ans, 1.0 / p);
}

int main(){
    int n;
    while(cin >> n){
        double x[128], y[128];
        double maxNum = 0;
        rep(i,n) cin >> x[i];
        rep(i,n) cin >> y[i];
        rep(i,3) printf("%.6lf\n",sum(x,y,i+1,n));
        rep(i,n){
            double num = P(x[i],y[i],1);
            if(num >= maxNum) maxNum = num;
        }
        printf("%.6lf\n",maxNum);
    }
}

Measured memory_bytes: 1296
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int a=sc.nextInt();
    int b=sc.nextInt();
    int x2=x-a;
    int s=x2/b;

    System.out.println(x2-s*b);
  }
}


Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pi;
typedef pair<pi, pi> pp;
double PI = 3.1415926535897932;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

vector<pi> toppo (vector<pi>& p, int si) {
    sort(p.begin(), p.end());
    vector<pi> ret;
    ret.push_back(p[0]);
    for (int i = 1; i < si; i++) {
        while (ret.size() > 1) {
            int tmp = ret.size()-1;
            if ((p[i].second-ret[tmp-1].second)*(ret[tmp].first-ret[tmp-1].first) >= 
                (ret[tmp].second-ret[tmp-1].second)*(p[i].first-ret[tmp-1].first)) {
                ret.pop_back();
            } else {
                break;
            }
        }
        ret.push_back(p[i]);
    }
    vector<pi> ret2;
    ret2.push_back(p[si-1]);
    for (int i = si-2; i >= 0; i--) {
        while (ret2.size() > 1) {
            int tmp = ret2.size()-1;
            if ((p[i].second-ret2[tmp-1].second)*(ret2[tmp].first-ret2[tmp-1].first) >= 
                (ret2[tmp].second-ret2[tmp-1].second)*(p[i].first-ret2[tmp-1].first)) {
                ret2.pop_back();
            } else {
                break;
            }
        }
        ret2.push_back(p[i]);
    }
    ret2.pop_back();
    for (int i = 1; i < ret2.size(); i++) ret.push_back(ret2[i]);
    return ret;
}

int n;
vector<pi> now;

int main() {
    cin >> n;
    now.push_back(pi(0,0));
    rep(i,n) {
        int x, y; cin >> x >> y;
        int si = now.size();
        rep(j,si) now.push_back(pi(now[j].first+x, now[j].second+y));
        now = toppo(now, (int)now.size());
    }
    double ans = 0.0;
    rep(i,now.size()) {
        ans = max(ans, sqrt(now[i].first*(double)now[i].first+now[i].second*(double)now[i].second));
    }
    printf("%.15f\n", ans);
}

Measured memory_bytes: 256