akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i=0; i<n ; i++){
            int number = scanner.nextInt();
            List<Integer> arrayNumber = new ArrayList<>();

            while (number != 0){
                arrayNumber.add(number % 10) ;
                number /= 10;
            }
            Collections.sort(arrayNumber);
            int min = calculate(arrayNumber);
            Collections.sort(arrayNumber, Collections.reverseOrder());
            int max = calculate(arrayNumber);
            System.out.println(max - min);
        }
    }

    static int calculate (List<Integer> arr){
        int size = arr.size();
        int result = 0;
        for (int i= 0; i<size; i++){
            result += arr.get(size-i-1) * Math.pow(10, i );
        }
        return result;
    }

}



Measured memory_bytes: 26104
#include<bits/stdc++.h>
#define fora(i,a,b) for(int i=a,Wub=b;i<Wub;++i)
#define ford(i,a,b) for(int i=a,Wub=b;i>=Wub;--i)
#define SPEEDIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 1000000
#define MOD 1073741824
using namespace std;
typedef long long ll;

int main(){
    int a;
    cin>>a;
    cout<<(a<1200?"ABC":"ARC")<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin>>N;
  vi A(N),B(N);
  REP(i,N){
    cin>>A[i];
    B[i]=A[i];
  }
  sort(ALL(B));
  int tmp;
  REP(i,N){
    tmp=A[i];
    if(B[N-1]==tmp){
      cout<<B[N-2]<<"\n";
    }else{
      cout<<B[N-1]<<"\n";
    }
  }
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

template<int mod> struct ModInt{
    long long x=0; 
    constexpr ModInt(long long x=0):x((x%mod+mod)%mod){}
    constexpr ModInt operator+(const ModInt& r)const{return ModInt(*this)+=r;}
    constexpr ModInt operator-(const ModInt& r)const{return ModInt(*this)-=r;}
    constexpr ModInt operator*(const ModInt& r)const{return ModInt(*this)*=r;}
    constexpr ModInt operator/(const ModInt& r)const{return ModInt(*this)/=r;}
    constexpr ModInt& operator+=(const ModInt& r){ if((x+=r.x)>=mod) x-=mod; return *this;}
    constexpr ModInt& operator-=(const ModInt& r){ if((x-=r.x)<0) x+=mod; return *this;}
    constexpr ModInt& operator*=(const ModInt& r){ if((x*=r.x)>=mod) x%=mod; return *this;}
    constexpr ModInt& operator/=(const ModInt& r){ return *this*=r.inv();}
    ModInt inv() const {
        long long s=x,sx=1,sy=0,t=mod,tx=0,ty=1;
        while(s%t!=0){
            long long temp=s/t,u=s-t*temp,ux=sx-temp*tx,uy=sy-temp*ty;
            s=t;sx=tx;sy=ty;
            t=u;tx=ux;ty=uy;
        }
        return ModInt(tx);
    }
    ModInt pow(long long n) const {
        ModInt a=1;
        while(n>0){
            if(n&1) a*=*this;
            *this*=*this;
            n>>=1;
        }
        return a;
    }
    friend constexpr ostream& operator<<(ostream& os,const ModInt<mod>& a) {return os << a.x;}
    friend constexpr istream& operator>>(istream& is,ModInt<mod>& a) {return is >> a.x;}
};
using mint = ModInt<MOD>;

struct combination{
    int N;
    vector<mint> fac,finv,inverse;
    combination(int N):N(N){
        fac.resize(N+1);finv.resize(N+1);
        fac[0]=1;
        for(int i=1;i<=N;++i){fac[i]=fac[i-1]*i;}
        finv[N]=fac[N].inv();
        for(int i=N-1;i>=0;--i){finv[i]=finv[i+1]*(i+1);}
    }
    void inverse_build(){
        inverse.resize(N+1);
        inverse[1]=1;
        for(int i=2;i<=N;++i){inverse[i]=finv[i]*fac[i-1];}
    }
    mint c(int n,int k){
        if(n<k||n<0||k<0) return 0;
        return fac[n]*finv[n-k]*finv[k];
    }
    mint p(int n,int k){
        if(n<k||n<0||k<0) return 0;
        return fac[n]*finv[n-k];
    }
};

int main(){
    combination com(10000000);
    int x,y;
    cin >> x >> y;
    mint ans = 0;
    if(2*y-x<0||2*x-y<0);
    else if((2*y-x)%3 != 0 || (2*x-y)%3 != 0);
    else{
        int s = (2*x-y)/3;
        int t = (2*y-x)/3;
        ans = com.c(s+t,s);
    }
    cout << ans << endl;
    return 0;
}

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

int h, w;
string ma[51];
bool visited[51][51];
int dy[4] = {-1, 1, 0, 0};
int dx[4] = {0, 0, -1, 1};

int cnt;
void dfs(int y, int x) {
    visited[y][x] = true;
    cnt++;

    for (int i = 0; i < 4; i++) {
        int ny = y + dy[i], nx = x + dx[i];
        if (ny >= 0 && ny < h && nx >= 0 && nx < w && ma[ny][nx] == '#' && !visited[ny][nx]) {
            dfs(ny, nx);
        }
    }
}

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        cin >> ma[i];
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (ma[i][j] == '#' && !visited[i][j]) {
                cnt = 0;
                dfs(i, j);
                if (cnt == 1) {
                    cout << "No\n";
                    return 0;
                }
            }
        }
    }

    cout << "Yes\n";

    return 0;
}


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

int main()
{
    int n;

    while( cin >> n )
    {
        if( n == 0 )
            break;
        int a, b, sum1 = 0, sum2 = 0;
        for( int i = 0; i < n; i++ )
        {
            cin >> a >> b;
            if( a < b )
                sum2 += a + b;
            else if( a > b )
                sum1 += a + b;
            else
            {
                sum1 += a;
                sum2 += b;
            }
        }
        cout << sum1 << " " << sum2 << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[1000][1000];
ll x[200000] = {};
ll y[200000] = {};
ll x2[200000] = {};
ll y2[200000] = {};

int main() {
	ll h, w, v; cin >> h >> w;
	rep(i, 0, h)rep(j, 0, w) {
		cin >> v;
		a[i][j] = v % 2;
	}

	ll cnt = 0;
	rep(i, 0, h) {
		rep(j, 0, w - 1) {
			if (a[i][j] % 2) {
				//a[i][j]--;
				a[i][j + 1]++;

				y[cnt] = i + 1;
				x[cnt] = j + 1;
				y2[cnt] = i + 1;
				x2[cnt] = j + 2;
				cnt++;
			}
		}

		if (i != h - 1) {
			if (a[i][w - 1] % 2) {
				// a[i][w - 1]--;
				a[i + 1][w - 1]++;

				y[cnt] = i + 1;
				x[cnt] = w;
				y2[cnt] = i + 2;
				x2[cnt] = w;
				cnt++;
			}
		}
	}

	printf("%d\n", cnt);
	rep(i, 0, cnt)	printf("%d %d %d %d\n", y[i], x[i], y2[i], x2[i]);

	return 0;
}

Measured memory_bytes: 11776
#include<stdio.h>

int main(void){
	int N,D,X,i,j,k = 1,choco = 0;
	int A[100];

	scanf("%d",&N);
	scanf("%d %d",&D,&X);
	for(j = 1;j <= N;j++)
		scanf("%d",&A[j-1]);

	for(i = 1;i <= N;i++){
		while(((k-1) * A[i-1] + 1) <= D){
				choco++;
				k++;
		}
		k = 1;
	}

	printf("%d\n",choco + X);

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	int n,m,k;
	int[][] d,d2;
	int V,E;
	

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}
	
	void run(){
		int max=Integer.MAX_VALUE;

		Scanner sc=new Scanner(System.in);
		while(true){
			E=sc.nextInt();
			V=sc.nextInt();
			if(E+V==0)break;
			d=new int[V][V];
			d2=new int[V][V];


			for(int i=0;i<V;i++){
				for(int j=0;j<V;j++){
					d[i][j]=max;
					d2[i][j]=max;
				}
			}
			for(int i=0;i<E;i++){
				int a=sc.nextInt()-1;
				int b=sc.nextInt()-1;
				int cost=sc.nextInt();
				int time=sc.nextInt();
				d[a][b]=cost;
				d[b][a]=cost;
				d2[a][b]=time;
				d2[b][a]=time;
			}
			for(int kk=0;kk<V;kk++){
				for(int i=0;i<V;i++){
					for(int j=0;j<V;j++){
						if(d[i][kk]!=max&&d[kk][j]!=max){
							d[i][j]=Math.min(d[i][j], d[i][kk]+d[kk][j]);
						}
						if(d2[i][kk]!=max&&d2[kk][j]!=max){
							d2[i][j]=Math.min(d2[i][j], d2[i][kk]+d2[kk][j]);
						}
					}
				}
			}
			k=sc.nextInt();

			for(int i=0;i<k;i++){
				int p=sc.nextInt()-1;
				int q=sc.nextInt()-1;
				int r=sc.nextInt();
				solve(p,q,r);
			}
		}
	}
	
	void solve(int p,int q,int r){
		if(r==0){
			System.out.println(d[p][q]);
		}else{
			System.out.println(d2[p][q]);
		}
	}
}

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

int main() {
  long long int inf = 1000000007;
  long long int N;
  cin >> N;
  long long int ten,nine,eight,ans;
  ten=1;nine=1;eight=1;
  for (int i=0; i < N; i++) {
    ten = ten * 10;
    ten = ten % inf;
  }
  for (int i=0; i < N; i++) {
    nine = nine * 9;
    nine = nine % inf;
  }
  for (int i=0; i < N; i++) {
    eight = eight * 8;
    eight = eight % inf;
  }
  nine = nine *2;
  nine = nine % inf;
  ans = ten - nine + eight;
  if (ans < 0) {
    ans = ans + inf;
  }
  ans = ans % inf;
  cout << ans << endl;
}

Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int count=0;
  for(int i=100;i>=1;i--){
    if(a%i==0 && b%i==0)count++;
    if(count==k){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    int res = 100000;
    for (int i = 2; i < num.size(); i++) {
        int sum = (num[i] - '0') + (num[i - 1] - '0') * 10 + (num[i - 2] - '0') * 100;
        res = min(res, abs(sum - 753));
    }
    cout << res << endl;
}


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

int main() {
  int N,Y,a,b,c;
  cin >> N >> Y ;
  a=-1;
  b=-1;
  c=-1;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if(10000*i+5000*j+1000*(N-i-j)==Y){
        a=i;
        b=j;
        c=N-i-j;
        break;
      }
    }
  }
  cout << a << ' ' << b << ' ' << c << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define ll long long
const int MAXN = 1e5 + 7;
const ll INF = 1ll << 60;
using namespace std;
ll a[MAXN];
ll sum, ans = INF, res, n;
int main() {
	bool flag = 0;
	scanf("%lld", &n);
	for(int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	for(int i = 1; i <= n; i++) {
		sum += a[i];
		if(!flag) { // if flag is 0 , means sum is postive
			if(sum <= 0) {
				res += 1 - sum;
				sum = 1;
			}
		} else{ 
			if(sum >= 0) {
				res += sum + 1;
				sum = -1;
			}
		}
		flag ^= 1;
	}
	if(res < ans) ans = res;
	flag = 0, res = sum = 0;
	for(int i = 1; i <= n; i++) {
		sum += a[i];
		if(!flag) {  // if flag is 0 , means sum is negative
			if(sum >= 0) {
				res += sum + 1;
				sum = -1;
			}
		} else{
			if(sum <= 0) {
				res += 1 - sum;
				sum = 1;
			}
		}
		flag ^= 1;
	}
	if(res < ans) ans = res;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int i, j, k, l;
	int cnt = 0;
	int n;
	
	while(scanf("%d", &n) != EOF){
	cnt = 0;
		for(i=0; i<=9; i++){
			for(j=0; j<=9; j++){
				for(k=0; k<=9; k++){
					for(l=0; l<=9; l++){
						if(i+j+k+l == n) cnt++;
					}
				}
			}
		}
		printf("%d\n", cnt);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        ll n,m,k;
        cin >> n >> m >> k;
        vector<ll> a(n), b(m);
        FOR(i,0,n) cin >> a[i];
        FOR(i,0,m) cin >> b[i];
        ll ans = 0;
        ll ar = 0, br = 0;
        FOR(i,0,n) ar += a[i];
        ll ptr = 0;
        for(ll i=n;i>=0;i--){
            if(i < n) ar -= a[i];
            if(ar <= k)
           { while(ptr < m and (ar + br + b[ptr] <= k)){
                           br += b[ptr];
                           ptr++;
                       }
                       ans = max(ans,i+ptr);}
        }
        cout << ans;
    }   
}

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

mt19937_64 llrand(random_device{}());

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define gcd(x, y) __gcd((x), (y))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef vector<int> vi;
typedef vector<vi> vii;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 3e3+5;

ll n, v[N], memo[N][N][2];

ll dp (ll l, ll r, ll c) {
    if (~memo[l][r][c]) return memo[l][r][c];

    if (c == 0) {
        if (l == r) return memo[l][r][c] = v[l];
        return memo[l][r][c] = max(v[l] + dp(l+1, r, c^1),
                                   v[r] + dp(l, r-1, c^1));
    }

    if (c == 1) {
        if (l == r) return memo[l][r][c] = -v[l];
        return memo[l][r][c] = min(-v[l] + dp(l+1, r, c^1),
                                   -v[r] + dp(l, r-1, c^1));
    }
}


int main () {
    cl(memo, -1);

    scanf("%lld", &n);
    for (int i = 1; i <= n; i++) scanf("%lld", &v[i]);

    printf("%lld\n", dp(1, n, 0));


    return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    int a[n];
    vector <int> s(n, 1);

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

    for(int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;

        if(a[x - 1] < a[y - 1]) {
            s[x - 1] = 0;
        }else if(a[x - 1] > a[y - 1]) {
            s[y - 1] = 0;
        }else{
            s[x - 1] = 0;
            s[y - 1] = 0;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
        ans += s[i];
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 4052
#include<stdio.h>

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

   scanf("%d %d %d %d", &a, &b, &c, &d);

   int x = (a+d-1)/d;
   int y = (c+b-1)/b;

   if(x >= y){
      printf("Yes\n");
   }else{
      printf("No\n");
   }
   return 0;
}

Measured memory_bytes: 1636
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long b = 1;
  while(2 * b <= n) b *= 2;
  cout << 2 * b - 1 << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

string s1, s2;
int main() {
    cin >> s1 >> s2;
    int n = s1.length();
    int m = s2.length();
    if (n > m)
        cout << "GREATER" << endl;
    else if (n < m)
        cout << "LESS" << endl;
    else {
        int i = 0;
        while (i < n) {
            if (s1[i] < s2[i]) {
                cout << "LESS" << endl;
                exit(0);
            }
            else if (s1[i] > s2[i]) {
                cout << "GREATER" << endl;
                exit(0);
            }
            else {
                ++i;
            }
        }
        cout << "EQUAL" << endl;
    }
    return 0;
}


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

using namespace std;

int main(void){

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

    int result = 1;
    if(n <= 2) {
        cout << result << endl;
        return 0;
    }

    bool isInc = false;
    bool isFind = false;
    for(int i=0; i<n-1; i++) {
        if(a[i]==a[i+1]) continue;
//        cout << i << " " << result << " " << isInc << " " << isFind << endl;
        if(!isFind) {
            if(a[i] == a[i+1]) {
                continue;
            }
            else if(a[i]>a[i+1]) {
                isFind = true;
                isInc = false;
            }
            else {
                isFind = true;
                isInc = true;
            }
        }
        else {
            if(isInc) {
                if(a[i]>a[i+1]) {
                    result++;
                    isFind = false;
                    isInc = false;
                }
            }
            else {
                if(a[i]<a[i+1]) {
                    result++;
                    isFind = false;
                    isInc = true;
                }
            }
        }
//        cout << i << " " << result << " " << isInc << " " << isFind << endl;
//        cout << endl;
    }

    cout << result << endl;

    return 0;
    
}


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


int main()
{
  int n;
  cin >> n;
  int a,b,c;
  a = n % 10;
  b = ((n - a) % 100)/10;
  c = (n - a - b)/100;

  int k= a * 100 + b * 10 + c;
 
 if (k == n){
    cout << "Yes";
  }else{
    cout << "No";
 }
}


Measured memory_bytes: 256
[n, k], [*a] = [[*map(int, t.split())] for t in open(0)]
count = 0
visited = dict()
tmp = 1
while count < k:
    visited[tmp] = count
    count += 1
    tmp = a[tmp - 1]
    if tmp in visited:
        k = (k - count) % (count - visited[tmp])
        visited = {tmp: 0}
        count = 0
print(tmp)


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

vvi g;
vi col;
vi cnt(5);
bool ok = 1;

void dfs(int v, int c) {
  if (col[v]) {
    if (col[v] != c) ok = 0;
    return;
  }
  col[v] = c;
  cnt[c]++;
  for (int nv : g[v]) dfs(nv, 3 - c);
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  g.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  col.assign(n, 0);
  ll res = -m;
  for (int i = 0; i < n; ++i) if (!col[i]) {
    cnt.assign(cnt.size(), 0);
    ok = 1;
    dfs(i, 1);
    if (ok) {
      res += cnt[1] * (ll)cnt[2];
    } else {
      ll x = cnt[1] + cnt[2];
      res += x * (x-1) / 2;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 6400
#include <stdio.h>
#include <math.h>

int main(){
  int i,j,n;
  double dx,dy,w,x,y;

  while(scanf("%d",&n),n!=-1){
    x=1.0;y=0.0;
    for(i=1;i<n;i++){
      w=hypot(x,y);
      dx=-y/w;
      dy=x/w;
      x+=dx;y+=dy;
    }
    printf("%.2lf\n%.2lf\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X;
  cin >> X;
  long long i = 0;
  long long j = 0;
  for (i = -118; i < 119; i++) {
    for (j = -119; j < 118; j++) {
      if ( (((i*i)*(i*i)*i) - ((j*j)*(j*j)*j)) == X ) {
        cout << i << " " <<  j << endl;
        goto OUT;
      }
    }
  }
OUT:
  return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(){
long a,b,c,ans,keep,neep,deep;
scanf("%ld%ld%ld",&a,&b,&c);
keep=a;
neep=100000000000;
if(b<neep){
neep=b;
if(neep<keep){
deep=keep;
keep=neep;
neep=deep;
}
}
if(c<neep)
neep=c;
ans=keep*neep;
if(a%2==0)
ans=0;
if(b%2==0)
ans=0;
if(c%2==0)
ans=0;
printf("%ld\n",ans);
return 0;
}

Measured memory_bytes: 128
import numpy as np
from itertools import product

h, w, k = map(int, input().split())
arr = np.empty((0, w), int)
for _ in range(h):
    s = list(input().replace(".", "0").replace("#", "1"))
    arr = np.append(arr, np.array([list(map(int, s))]), axis=0)
cnt = 0
for i in product((0, 1), repeat=h):
    tmp = (arr.T * i).T
    cnt += sum(sum(sum(tmp * j)) == k for j in product((0, 1), repeat=w))
print(cnt)

Measured memory_bytes: 27160
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define sci(x) int x; scanf("%d", &x);
#define TC(x) sci(x); while(x--)
typedef long long ll;
using namespace std;

bool pelindrome(string s)
{
    int len=s.length();
    string s1=s;
    reverse(all(s1));
    if(s==s1) return true;
    else return false;
}

string strmaker(string s, int a, int b)
{
    string s1;
    for(int i=a-1;i<=b-1;i++){
        s1.pb(s[i]);
    }
    return s1;
}

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

    string s,s1,s2;
    cin>>s;
    int n=s.length();
    s1=strmaker(s, 1, (n-1)/2);
    s2=strmaker(s, (n+3)/2, n);
    if(pelindrome(s) && pelindrome(s1) && pelindrome(s2)) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 3600
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  while(true){
	int N, M, P; cin >> N >> M >> P;
	if(N == 0) break;
	VI xs(N);
	REP(i,N) cin >> xs[i];
	int sum = accumulate(ALL(xs), 0);
	
	cout << (xs[M-1]==0? 0: int((double)(100 - P) * sum / xs[M-1])) << endl;
  }
  
  return 0;
}

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

int main() {
  int n;
  while (cin >> n, n) {
    int key = 0, ke2 = 0, ans = 0;
    string s;
    rep(i, n) {
      cin >> s;
      if (s == "lu" || s == "ru") {
        key += 1;
      } else if (s == "ld" || s == "rd") {
        key -= 1;
      }
      if (key == 2 && ke2 == 0) {
        ans += 1;
        ke2 = 1;
      } else if (key == 0 && ke2 == 1) {
        ans += 1;
        ke2 = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3128
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;

ll mod_pow(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

ll mod_inverse(ll x) {
    return mod_pow(x, mod-2);
}

const int max_n = 500100;
ll fact[max_n];
ll fact_inv[max_n];
void calc_fact() {
    fact[0] = 1;
    for (ll i = 1; i < max_n; i++)
        fact[i] = (fact[i-1] * i) % mod;
    fact_inv[max_n-1] = mod_inverse(fact[max_n-1]);
    for (ll i = max_n-2; i >= 0; i--)
        fact_inv[i] = (fact_inv[i+1] * (i+1)) % mod;
}
ll mod_comb(ll n, ll k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return (fact[n] * fact_inv[k] % mod) * fact_inv[n-k] % mod;
}
ll mod_perm(ll n, ll k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return fact[n] * fact_inv[n-k] % mod;
}

ll solve() {
    calc_fact();
    ll vio = 0;
    for (int i = 1; i <= n; i++) {
        ll k = mod_comb(n, i);
        k *= mod_perm(m, i);
        k %= mod;
        k *= mod_perm(m-i, n-i);
        k %= mod;
        k *= mod_perm(m-i, n-i);
        k %= mod;
        vio += (i % 2 == 1 ? k : mod-k);
        vio %= mod;
    }
    ll res = mod_perm(m, n) * mod_perm(m, n);
    res %= mod;
    res += (mod - vio);
    res %= mod;
    return res;
}

void input() {
    cin >> n >> m;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 11364
import java.util.*;
public class Main
{
	static HashSet<String>HS;
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int k=in.nextInt();
			int a[]=new int[n];
			int p[]=new int[k];
			HS=new HashSet<String>();
			boolean f[]=new boolean[n];
			for(int i=0;i<n;i++)
				a[i]=in.nextInt();
			permutation(0,p,f,a);
			System.out.println(HS.size());
		}
	}
		
	static void permutation(int n,int p[],boolean f[],int a[])
	{
		if(n==p.length)
		{
			String str="";
			for(int x:p)
				str+=x;
			HS.add(str);
		}
		else 
		{
			for(int i=0;i<a.length;i++)
			{
				if(f[i]) 
					continue;
				p[n]=a[i];
				f[i]=true;
				permutation(n+1,p,f,a);
				f[i]=false;
			}
		}
	}
	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 44768
#include <bits/stdc++.h>
using namespace std;
char a[53][53], b[53][53];
int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i=0; i<n; ++i){
		scanf("%s",a[i]);
	}
	for(int i=0; i<m; ++i){
		scanf("%s",b[i]);
	}
	for(int i=0; i<n; ++i){
		for(int j=0; j<n; ++j){
			bool found=true;
			for(int k=i, k2=0; k<m+i; ++k, ++k2){
				for(int l=j, l2=0; l<m+j; ++l, ++l2 ){
					if(a[k][l]!=b[k2][l2])
					found=false;
				}
			}
			if(found==true){
				
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}

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

void solve()
{
	string s;
	cin >> s;
	
	ll ans = 0;
	ll dp[2019] = {};
	dp[s[0] - '0'] = 1;
	for(int i = 1; i<s.size(); i++)
	{
		int d = s[i] - '0';
		ll tdp[2019] = {};
		tdp[d] = 1;
		for(int j = 0; j<2019; j++)
		{
			if(dp[j] > 0)
			{
				ll rem = (10*j + d)%2019;
				if(rem == 0) ans += dp[j];
				tdp[rem] += dp[j];
			}
		}
		for(int j = 0; j<2019; j++)
		{
			dp[j] = tdp[j];
		}
	}
	cout << ans;
	
}

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



Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl

struct suffix_array {
  int n;
  vector<int> x;
  suffix_array(const char *s) : n(strlen(s)), x(n) { 
    vector<int> r(n), t(n); 
    for (int i = 0; i < n; ++i) r[x[i] = i] = s[i];
    for (int h = 1; t[n-1] != n-1; h *= 2) {
      auto cmp = [&](int i, int j) {
        if (r[i] != r[j]) return r[i] < r[j];
        return i+h < n && j+h < n ? r[i+h] < r[j+h] : i > j;
      };
      sort(x.begin(), x.end(), cmp);
      for (int i = 0; i+1 < n; ++i) t[i+1] = t[i] + cmp(x[i], x[i+1]);
      for (int i = 0; i < n; ++i)   r[x[i]] = t[i];
    }
  }
  int operator[](int i) const { return x[i]; }
};

bool contain(const string &S, int *sa, const string &T) {
  int lb = -1, ub = S.size() - 1;
  while(ub - lb > 1) {
    int mid = (lb + ub) / 2;
    if(S.compare(sa[mid], T.size(), T) >= 0) ub = mid;
    else lb = mid;
  }
  return S.compare(sa[ub], T.size(), T) == 0;
}

signed main() {
  ios::sync_with_stdio(false);
  string T; cin >> T;
  int Q; cin >> Q;
  suffix_array sary(T.c_str());
  while(Q--) {
    string P; cin >> P;
    cout << (contain(T, sary.x.data(), P) ? 1 : 0) << endl;
  }
}

Measured memory_bytes: 27400
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#include <memory.h>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){
  if(a < b) return gcd(b, a);
  if(b == 0) return a;
  else return gcd(b, a %b);
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, K; cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++)
    cin >> A[i];
  if(N == 1){
    if(K == A[0]) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  int maxA = max(A[0], A[1]), g = gcd(A[0], A[1]);
  for(int i=2;i<N;i++){
    g = gcd(g, A[i]);
    maxA = max(maxA, A[i]);
  }
  if(g == 1){
    if(K <= maxA) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
  }else{
    if(K <= maxA && K %g == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 640
//                               //
    // author : samars_diary //
    // 16-09-2020 │ 23:37:05 //
//                               //

#include <iostream>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    //#endif

    int a;
    cin>>a;
    cout<<1-a;

    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
int main()
{
    int card[4][13]={{0}};
    int n,i;
    int num;
    char gara;
    int g,j;
    scanf("%d",&n);
    for (i=0; i<n; i++) {
        scanf(" %c",&gara);
        scanf("%d", &num);
        switch (gara) {
            case 'S':
                card[0][num-1]=1;
                break;
            case 'H':
                card[1][num-1]=1;
                break;
            case 'C':
                card[2][num-1]=1;
                break;
            case 'D':
                card[3][num-1]=1;
                break;
            default:
                break;
        }
        
        
    }
    for (j=0; j<4; j++) {
        for (g=0; g<13; g++) {
            switch (j) {
                case 0:
                    if (card[0][g]==0) {
                        printf("S %d\n",g+1);
                    }
                    break;
                case 1:
                    if (card[1][g]==0) {
                        printf("H %d\n",g+1);
                    }
                    break;
                case 2:
                    if (card[2][g]==0) {
                        printf("C %d\n",g+1);
                    }
                    break;
                case 3:
                    if (card[3][g]==0) {
                        printf("D %d\n",g+1);
                    }
                    break;
                default:
                    break;
            }
        }
    }
    
    return 0;
    
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    string s;
    cin >> s;
    if (s == "Sunny")
        cout << "Cloudy" << endl;
    else if (s == "Cloudy")
        cout << "Rainy" << endl;
    else if (s == "Rainy")
        cout << "Sunny" << endl;

    return 0;
}



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> S[M];
    for (int i = 0; i < M; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int s;
            cin >> s;
            S[i].push_back(s);
        }
    }
    vector<int> p(M);
    for (int i = 0; i < M; i++)
        cin >> p[i];

    int res = 0;
    for (int i = 0; i < (1 << N); i++) {
        vector<int> light;
        for (int j = 0; j < N; j++) {
            if ((i >> j) & 1) {
                light.push_back(j + 1);
            }
        }

        bool flag = true;
        for (int j = 0; j < M; j++) {
            int cnt = 0;
            for (int k = 0; k < S[j].size(); k++) {
                if (binary_search(light.begin(), light.end(), S[j][k])) cnt++;
            }
            if (cnt % 2 != p[j]) {
                flag = false;
                break;
            }
        }
        if (flag) res++;
    }
    cout << res << endl;
    return 0;
}

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

int main(){

  int age , charge , hisCharge;
  cin >> age >> charge;
  
  if(age >= 13){
    hisCharge = charge;
  } else if(age <= 12 && age >= 6){
    hisCharge = charge / 2;
  } else if(age <= 5){
    hisCharge = 0;
  }
  cout << hisCharge << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
VI kasi(3);
for (int i = 0; i < 3; i++)
{
    cin>>kasi.at(i);
}

sort(ALL(kasi));
if (kasi.at(0)+kasi.at(1)==kasi.at(2))  
{
    cout<<"Yes"<<endl;
}

else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	map<string,int>mp;
	int n;
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		mp[s]++;
	}
	int ma=0;
	for(auto u:mp) if(u.second>ma)ma=u.second;
	for(auto u:mp)if(u.second==ma) cout<<u.first<<endl;
    return 0;
}

Measured memory_bytes: 25216
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

d, n = MAP()
m = 100 ** d * n
if n == 100:
    m = 100 ** d * 101
print(m)

Measured memory_bytes: 5192
R,G,B,N=map(int,input().split())
dp=[0]*(N+1)
dp[0]=1
for C in (R,G,B):
  for i in range(len(dp)-C):
    if dp[i]!=-1:
        dp[i+C]=dp[i]+dp[i+C]
print(dp[N])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, minj, cnt = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	for (int i = 0; i < n; i++) {
		minj = i;
		for (int j = i; j < n; j++) {
			if (a.at(j) < a.at(minj)) {
				minj = j;
			}
		}
		if (minj != i) {
			swap(a.at(i), a.at(minj));
			cnt++;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << a.at(i);
		if (i == n - 1) {
			cout << endl;
		} else {
			cout << " ";
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;


int main() {
    int d, n;
    cin >> d >> n;
    if(d==0){
        if(n==100){
            cout << "101" << endl;
        }else{
            cout << n << endl;
        }
    }else if(d==1){
        if(n==100){
            cout << "10100" << endl;
        }else{
            cout << 100*n << endl;
        }
    }else{
        if(n==100){
            cout << "1010000" << endl;
        }else{
            cout << 10000*n << endl;
        }
    }

}


Measured memory_bytes: 256
N,M = map(int, input().split())
AB = [ [int(j) for j in input().split()] for _ in range(N)]

AB = sorted(AB)

ans = 0
for i in range(N):
  if AB[i][1] <= M:
    M -= AB[i][1]
    ans += AB[i][0] * AB[i][1] 
  elif AB[i][1] == M:
    M -= AB[i][1]
    ans += AB[i][0] * AB[i][1] 
  else:
    ans += AB[i][0] * M
    break

print(ans)

Measured memory_bytes: 22376
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c=0;
    cin>>a>>b;
    c=a;
    if(b<a)
        c--;
    cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 3652
#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()
{
	int N,A,B;
	scanf("%d%d%d",&N,&A,&B);
	printf("%d\n",min(N*A,B));
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int cnt = 0;
		for(int i = 0; i < n; i++) {
			int l = stdIn.nextInt();
			int r = stdIn.nextInt();
			cnt += r-l+1;
		}
		System.out.println(cnt);
		
	}

}


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

int main() {
  string s;
  cin >> s;
  if(s.at(0) == s.at(1) && s.at(1) == s.at(2) 
  || s.at(1) == s.at(2) && s.at(2) == s.at(3)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

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


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

	for (int i=0; i<=n; i++) {
		for (int j=0; j<=n-i; j++) {
			int sum = 10000*i + 5000*j + 1000*(n-i-j);
			if (y==sum) {
				cout << i << " " << j << " " << n-i-j << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//  17:50-
//A 17:54 AC
//B 17:58 AC
bool solve(void){
	int n,m,i,j,k;cin>>m>>n;
	if(n==0){return false;}
	int s=7400000;
	vector<bool>take(s);
	for(i=m;i<s;i++){
		if(take[i]){continue;}
		n--;
		if(n<0){cout<<i<<endl;return true;}
		for(j=i;j<s;j+=i){take[j]=true;}
	}

	
	return true;
}
int main(void){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 4032
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy
    
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
s = input()

R = []
L = []

mode = 1
temp = 0
for x in s:
    if mode == 0:
        if x == 'R':
            L.append(temp)
            temp = 1
            mode = 1
        else:
            temp += 1
    else:
        if x == 'L':
            R.append(temp)
            temp = 1
            mode = 0
        else:
            temp += 1

L.append(temp)

#print(R)
#print(L)


ans = [0] * len(s)
p = 0
for i in range(len(R)):
    p += R[i]
    ans[p] = R[i] // 2
    ans[p-1] = R[i] // 2 + R[i] % 2
    ans[p-1] += L[i] // 2
    ans[p] += L[i] // 2 + L[i] % 2
    p += L[i]

print(' '.join(map(str, ans)))

Measured memory_bytes: 11296
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    int x=0; int max=0;
    for(int i=0; i<=n; i++){
        if(s[i]=='I') {x++;}
        else {x--;}
        if(max<x) max=x;
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
	x=0;static char ch;static bool flag;flag = false;
	while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
	while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const int maxn = 200010;
int a[maxn];
int main(){
	int n;read(n);
	ll s = 0;
	rep(i,1,n) read(a[i]),s += a[i];
	ll x = 0,ans = 1LL << 60;
	rep(i,1,n-1){
		x += a[i];
		s -= a[i];
		ans = min(ans,abs(x-s));
	}printf("%lld\n",ans);
	return 0;
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, K;
    std::cin >> N >> K;
    vector<int> V(N);
    REP(i, N) {
        std::cin >> V[i];
    }

    int ans     = 0;
    int pop_max = min(N, K);
    vector<int> poped_minus, poped_i_minus, poped_j_minus;
    poped_minus.reserve(N);
    poped_i_minus.reserve(N);
    poped_j_minus.reserve(N);
    for(int i = 0; i <= pop_max; i++) {
        int tmp_i_ans = 0;
        REP(j, i) {
            if(V[j] < 0) poped_i_minus.push_back(V[j]);
            else tmp_i_ans += V[j];
        }
        for(int j = 0; j <= pop_max - i; j++) {
            int tmp_j_ans = 0;
            REP(k, j) {
                if(V[N - k - 1] < 0) poped_j_minus.push_back(V[N - k - 1]);
                else tmp_j_ans += V[N - k - 1];
            }
            poped_minus.insert(poped_minus.end(),
                               poped_i_minus.begin(), poped_i_minus.end());
            poped_minus.insert(poped_minus.end(),
                               poped_j_minus.begin(), poped_j_minus.end());

            SORT(poped_minus);

            size_t push_max = K - i - j;
            int    rm_size  = min(poped_minus.size(), push_max);
            ans = max(ans, tmp_i_ans + tmp_j_ans + accumulate(poped_minus.begin() + rm_size, poped_minus.end(), 0));

            poped_minus.clear();
            poped_j_minus.clear();
        }
        poped_i_minus.clear();
    }

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

    return 0;
}


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

int n, m, a[3] = {-1, -1, -1};

int main(){
  cin >> n >> m;
  rep(i, m){
    int s, c; cin >> s >> c;
    int d = n - s;
    if((a[d] != -1 && a[d] != c) || (n > 1 && s == 1 && c == 0)){
      cout << -1 << endl;
      return 0;
    }
    a[d] = c;
  }
  rep(i, 3) cerr << a[i] << " "; cerr << endl;
  
  if(n == 1) {
    cout << max(a[0], 0) << endl;
    return 0;
  }
  
  for(int i = pow(10, n - 1); i < pow(10, n); i++){
    bool flag = true;
    int num[3] = {i % 10, (i / 10) % 10, (i / 100)};
    rep(j, n){
      if(a[j] == -1) continue;
      if(a[j] != num[j]) flag = false;
    }
    if(flag){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
def kaibun(str)
  len = str.length
  (len/2).times do |i|
    if S[i] == S[(len-1)-i] then
      result = true
    else
      result = false
      break
    end
  end

end

attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

S = attrs[0][0]
len = S.length

result = false
if kaibun(S) then
  n = (len-1)/2
  sub1 = S[0..(n-1)]
  if kaibun(sub1) then
    n = (len+3)/2
    sub2 = S[(n-1)..(len-1)]
    if kaibun(sub2) then
      result = true
    end
  end
end

puts result ? "Yes" : "No"

Measured memory_bytes: 1788
import java.util.Scanner;
import java.util.stream.IntStream;

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

        long ans = IntStream.rangeClosed(scanner.nextInt(), scanner.nextInt())
                .mapToObj(i->String.valueOf(i).toCharArray())
                .filter(ch-> ch[0]==ch[4]&&ch[1]==ch[3])
                .count();
        System.out.println(ans);
        scanner.close();
    }
}


Measured memory_bytes: 32980