akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		long[] a=new long[n];
		long[] b=new long[n];
		for(int i=0;i<n;i++) {
			a[i]=scanner.nextInt();
			b[i]=scanner.nextInt();
		}
		long ans=0;
		for(int i=n-1;i>=0;i--) {
			a[i]+=ans;
			if(a[i]%b[i]==0)continue;
			ans+=b[i]-a[i]%b[i];
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 24408
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    long long n,i,frst,lst,l,total=0,j;
    map< long long,map<long long,long long> >mp;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        l=i;
        lst=l%10;
        while(l!=0)
        {
            frst=l%10;
            l/=10;
        }
        mp[frst][lst]++;
    }
    for(i=0;i<=9;i++)
    {
        for(j=0;j<=9;j++)
        {
            total+=(mp[i][j]*mp[j][i]);
        }
    }
    cout<<total<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
class UnionFind
{
public:
  int par[100005];
  int depth[100005];
  int nGroup[100005];
 
  UnionFind(int n) {
    init(n);
  }
 
  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(int x, int y) {
    return root(x) == root(y);
  }
 
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
} 
int main() {
ll n,w,q; cin>>n>>w>>q;
if(q!=n) cout << 1 << endl;
else cout << 0 << endl;}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
#define MXN 2000005
int dp[5005];
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int s[5005];
    for(int i = 1;i<=n;i++)
        scanf("%d",&s[i]);
    vector<int> v1,v2;
    //v1.pb(1);
    vector<pii> v;
    int now=1,Max=0;
    for(int i =1;i<=n;i++){
        Max=max(Max,s[i]);
        if(s[i]==now){
            v2.pb(s[i]);
        }  
        else{
            if(v2.empty()){
                if(!v1.empty()&&s[i]<v1.back()){
                    printf("0\n");
                    return 0;
                }
                v1.pb(s[i]);
            }
            else{
                if(v1.back()<s[i]){
                    v1.pb(s[i]);
                }
                else if(v2.back()<s[i]){
                    v2.pb(s[i]);
                }
                else{
                    printf("0\n");
                    return 0;
                }
            }
        }
        if((i-now+1)==v1.size()+v2.size()&&v2.size()&&i==Max){
            v.pb(mp(v1.size(),v2.size()));
          //  printf("%d %d\n",v1.size(),v2.size());
            now=i+1;
            v1.clear();
            v2.clear();
        }
    }
    dp[0]=1;
    const int mod= 1e9+7;
    for(auto it:v){
        for(int j=n;j>=0;j--){
            if(dp[j]){
                int tmp=dp[j];
                dp[j]=0;
                dp[j+it.x]+=tmp;
                dp[j+it.y]+=tmp;
                dp[j+it.x]%=mod;
                dp[j+it.y]%=mod;
            }
        }
       // for(int j =0;j<=n;j++)
        //    printf("%d ",dp[j]);
        //printf("\n");
    }
    LL ans=0;
    for(int i = 0;i<=n&&i<=m;i++){
        if(n-i<=m)ans+=dp[i];
    }
    printf("%lld\n",ans%mod);
    return 0;
}


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

int main(void) {
	char s[100000];
	scanf("%s", s);
	int sw = 1, len;
	len = (int)strlen(s);
	while ((sw) && (s[0] != '\0')) {
		if (s[len - 1] == 'r') {
			if (strcmp(s + len - 7, "dreamer") == 0) {
				s[len - 7] = '\0';
				len = (int)strlen(s);
			}
			else if (strcmp(s + len - 6, "eraser") == 0) {
				s[len - 6] = '\0';
				len = (int)strlen(s);
			}
			else {
				sw = 0;
			}
		} 
		else if (s[len - 1] == 'm') {
			if (strcmp(s + len - 5, "dream") == 0) {
				s[len - 5] = '\0';
				len = (int)strlen(s);
			}
			else {
				sw = 0;
			}
		}
		else if (s[len - 1] == 'e') {
			if (strcmp(s + len - 5, "erase") == 0) {
				s[len - 5] = '\0';
				len = (int)strlen(s);
			}
			else {
				sw = 0;
			}
		}
		else {
			sw = 0;
		}
	}
	if (sw) {
		printf("YES\n");
	}
	else if (!sw) {
		printf("NO\n");
	}
	return 0;
}

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

int main(){
    int N,P = 0;
    cin >> N;
    for(int i = 0;i < N; i++){
        int l, r;
        cin >> l >> r;
        P +=r - l + 1;
    }
    cout << P <<endl;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
d = (x2-x1, y2-y1)

x3 = x2 - d[1]
y3 = y2 + d[0]

x4 = x1 + x3 - x2
y4 = y1 + y3 - y2
print("{} {} {} {}".format(x3,y3, x4,y4))

Measured memory_bytes: 3060
#include <stdio.h>
#define SIZE 1000
#define MOD 1000000007
typedef long long int lli;

int main(void){
    int n;
    scanf("%d", &n);

    if(n == 1){
        printf("1\n");
    }else{
        int prime[SIZE + 1] = {};
        for(int i = 2; i <= SIZE; i++){
            if(prime[i] == 0){
                prime[i] = i;
                for(int j = i * i; j <= SIZE; j += i){
                    if(prime[j] != -1) prime[j] = -1;
                }
                //printf("%d\n", prime[i]);
            }
        }

        int tmp, num_div;
        lli ans = 1;
        for(int i = 2; prime[i] <= n && i <= SIZE; i++){
            if(prime[i] > 1){
                //printf("-XXXXXXXXXXXXX-\ni = %d, prime = %d\n-XXXXXXXXXXXXX-\n\n", i, prime[i]);
                num_div = 0;
                for(int j = prime[i]; j <= n; j += prime[i]){
                    //printf("j = %d\n\n", j);
                    //if(j % prime[i] == 0){
                        tmp = j;
                        //num_div = 0;
                        while(tmp % prime[i] == 0){
                            tmp /= prime[i];
                            num_div++;
                            //printf("tmp = %d, num_div = %d\n", tmp, num_div);
                        }
                    //}
                }
                ans = (ans * ((lli)num_div + 1)) % MOD;
                //printf("ans = %lld\n\n", ans);
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}

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

int main() {
    int64_t k, a, b, x = 0;
    cin >> k >> a >> b;
    k++;
    if (a + 1 >= b) {
        cout << k << endl;
        return 0;
    }
    while (k > 0) {
        if (k >= a + 2) {
            x += b, k -= a + 2;
            while (k >= 2 and x >= b) x += (b - a), k -= 2;
        } else
            k--, x++;
        // cout << k << " " << x << endl;
    }
    cout << x << endl;
    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 300
i64 d[MAX_N][MAX_N];
i64 G[MAX_N][MAX_N];

int main() {
    i64 N; cin >> N;
    REP(i, N) REP(j, N) {
        cin >> d[i][j];
        G[i][j] = d[i][j];
    }

    bool ok = true;
    REP(k, N) {
        REP(i, N) {
            REP(j, N) {
                if (d[i][j] > d[i][k] + d[k][j]) ok = false;
            }
        }
    }
    if (!ok) {
        cout << -1 << endl;
        return 0;
    }

    REP(k, N) {
        REP(i, N) {
            for (i64 j = i + 1; j < N; j++) {
                if (i == j) continue;
                if (i == k || j == k) continue;
                if (d[i][j] == d[i][k] + d[k][j]) G[i][j] = 0;
            }
        }
    }

    i64 ans = 0;
    REP(i, N) {
        for (i64 j = i + 1; j < N; j++) {
            ans += G[i][j];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n1 = Integer.parseInt(in.next());
            int n2 = Integer.parseInt(in.next());
            int n3 = Integer.parseInt(in.next());
            int n4 = Integer.parseInt(in.next());
            boolean ok = false;
            String tmp = new String(Integer.toString(n1) + Integer.toString(n2) + Integer.toString(n3) + Integer.toString(n4));
            if (tmp.contains("1") && tmp.contains("9") && tmp.contains("7") && tmp.contains("4")) ok = true;
            out.println(ok ? "YES" : "NO");

        }

    }
}



Measured memory_bytes: 25044
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll sum = 0, n;
	cin>>n;
	vector<int> a(n);
	rep(i, n) cin>>a[i];
	sort(all(a)); reverse(all(a));
	rep(i, n){
		if(i%2) sum -= a[i];
		else sum += a[i];
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
unittest
{
//	assert( [ "2 3", "1 2 3", "0 1 1" ].parse.expand.solve == "3\n2 2 2 3\n1 1 1 2\n1 3 1 2" );
	assert( [ "2 3", "1 2 3", "0 1 1" ].parse.expand.solve == "3\n1 2 1 1\n1 3 1 2\n2 2 2 3" );		// 別解
//	assert( [ "3 2", "1 0", "2 1", "1 0" ].parse.expand.solve == "3\n1 1 1 2\n1 2 2 2\n3 1 3 2" );
	assert( [ "3 2", "1 0", "2 1", "1 0" ].parse.expand.solve == "2\n2 2 1 2\n1 2 1 1" );		// 別解
//	assert( [ "1 5", "9 9 9 9 9" ].parse.expand.solve == "2\n1 1 1 2\n1 3 1 4" );
	assert( [ "1 5", "9 9 9 9 9" ].parse.expand.solve == "2\n1 2 1 1\n1 4 1 3" );		// 別解
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hw = input.front.split.to!( long[] );
	auto ass = new long[][]( hw[ 0 ], hw[ 1 ] );
	foreach( ref as; ass )
	{
		input.popFront;
		as = input.front.split.to!( long[] );
	}
	return tuple( hw[ 0 ], hw[ 1 ], ass );
}

auto solve( long h, long w, long[][] ass )
{
	auto n = 0L;
	string[] ops;
	
	foreach( y; 0 .. ass.length )
	{
		if( y % 2 == 0 )
		{
			// 偶数行目は左のマスから順に操作
			foreach( x; 0 .. ass[ y ].length )
			{
				if( ass[ y ][ x ] % 2 == 0 ) continue;		// 偶数枚のマスは移動不要
				auto t = moveCoin( ass, y, x );
				n += t[ 0 ];
				ops ~= t[ 1 ];
			}
		}
		else
		{
			// 奇数行目は右のマスから順に操作
			foreach_reverse( x; 0 .. ass[ y ].length )
			{
				if( ass[ y ][ x ] % 2 == 0 ) continue;		// 偶数枚のマスは移動不要
				auto t = moveCoin( ass, y, x );
				n += t[ 0 ];
				ops ~= t[ 1 ];
			}
		}
	}
	
	// 出力フォーマットを整える
	return format( "%d\n%s", n, ops.join( "\n" ) );
}

Tuple!( long, string[] ) moveCoin( ref long[][] ass, long dst_y, long dst_x )
{
	auto n = 0L;
	string[] ops;
	auto src_y = dst_y;
	auto src_x = dst_x;
	
	// 移動元を判定
	if( dst_y % 2 == 0 )
	{
		// 偶数行目は右から左に移動（右端だったら下の行から移動）
		if( dst_x < ass[ dst_y ].length - 1 ) src_x++;
		else                                  src_y++;
	}
	else
	{
		// 奇数行目は左から右に移動（左端だったら下の行から移動）
		if( 0 < dst_x ) src_x--;
		else            src_y++;
	}
	
	// 移動元が盤面をはみ出てるのであきらめる
	if( ass.length <= src_y ) return tuple( n, ops );
	
	// 移動実行（移動元が0枚だったら更に一つ先から移動する）
	if( ass[ src_y ][ src_x ] == 0 )
	{
		auto t = moveCoin( ass, src_y, src_x );
		if( t[ 0 ] == 0 ) return tuple( n, ops );		// 移動できなかったのであきらめる
		n += t[ 0 ];
		ops ~= t[ 1 ];
	}
	ass[ dst_y ][ dst_x ]++;
	ass[ src_y ][ src_x ]--;
	n++;
	ops ~= format( "%d %d %d %d", src_y + 1, src_x + 1, dst_y + 1, dst_x + 1 );
	
	return tuple( n, ops );
}


Measured memory_bytes: 22524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  string s;
  cin >> s;

  if (s == "Sunny") cout << "Cloudy\n";
  else if (s == "Cloudy") cout << "Rainy\n";
  else cout << "Sunny\n";

  return (0);
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <iterator>
#include <tuple>
using namespace std;
using ll = long long;

int main()
{
  int h, w;
  cin >> h >> w;
  int field[501][501];
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      cin >> field[i][j];
    }
  }
  vector<vector<int>> ans;
  int cnt = 0;
  for (int i = 0; i < h; ++i)
  {
    if (i % 2 == 0)
    {
      for (int j = 0; j < w; ++j)
      {
        if (field[i][j] % 2 != 0)
        {
          if (j != w - 1)
          {
            field[i][j]--;
            field[i][j + 1]++;
            vector<int> tmp;
            tmp.push_back(i);
            tmp.push_back(j);
            tmp.push_back(i);
            tmp.push_back(j + 1);
            ans.emplace_back(tmp);
            cnt++;
          }
          else if (i != h - 1)
          {
            field[i][j]--;
            field[i + 1][j]++;
            vector<int> tmp;
            tmp.push_back(i);
            tmp.push_back(j);
            tmp.push_back(i + 1);
            tmp.push_back(j);
            ans.emplace_back(tmp);
            cnt++;
          }
          else
            break;
        }
      }
    }
    else
    {
      for (int j = w - 1; j >= 0; --j)
      {
        if (field[i][j] % 2 != 0)
        {
          if (j != 0)
          {
            field[i][j]--;
            field[i][j - 1]++;
            vector<int> tmp;
            tmp.push_back(i);
            tmp.push_back(j);
            tmp.push_back(i);
            tmp.push_back(j - 1);
            ans.emplace_back(tmp);
            cnt++;
          }
          else if (i != h - 1)
          {
            field[i][j]--;
            field[i + 1][j]++;
            vector<int> tmp;
            tmp.push_back(i);
            tmp.push_back(j);
            tmp.push_back(i + 1);
            tmp.push_back(j);
            ans.emplace_back(tmp);
            cnt++;
          }
          else
            break;
        }
      }
    }
  }
  cout << cnt << endl;
  for (int i = 0; i < ans.size(); ++i)
  {
    cout << ans[i][0] + 1;
    for (int j = 1; j < ans[i].size(); ++j)
    {
      cout << ' ' << ans[i][j] + 1;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 11184
import java.util.Scanner;
import java.util.TreeSet;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    TreeSet<Integer> set = new TreeSet<Integer>();
    int n = sc.nextInt();
    for(int a=0;a<n;a++){
      set.add(sc.nextInt());
    }
    System.out.println(set.last()-set.first());
  }
}

Measured memory_bytes: 21076
#include <iostream>
using namespace std;
int main() {
  int n,t,a;
  cin >> n >> t >> a;
  t *= 1000;
  a *= 1000;
  int m = 1000000000;
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    int h;
    cin >> h;
    if (m > abs(t - h*6 - a)) {
      m = abs(t - h*6 - a);
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    long long n,r;
    cin>>n;
    long long minv=10000000000;
    long long maxv=-10000000000;
    for(int i=0; i<n; i++){
        cin>>r;
        maxv=max(maxv,r-minv);
        minv=min(minv,r);
    }
    cout<<maxv<<endl;
    return 0;
    
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int m[n], cnt=n, small;
    for (int i=0; i<n; i++)
    {
        cin>>m[i];
    }
    sort(m,m+n);
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<i; j++)
        {
            if (m[i]==m[j])
            {
                cnt--;
                j=i;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

namespace Flipping_SIgns
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int negatif = 0;
            double otpt = 0;
            for (int i = 0; i < N; i++)
            {
                if (A[i] < 0)
                {
                    negatif++;
                    A[i] = 0 - A[i];
                }
            }
            int smallest = A[0];
            for (int i = 1; i < N; i++)
            {
                if (A[i] < smallest)
                {
                    smallest = A[i];
                }
            }
            for (int i = 0; i < N; i++)
            {
                otpt = otpt + A[i];
            }
            if (negatif % 2 == 1)
            {
                otpt = otpt - 2 * smallest;
            }
            Console.WriteLine(Convert.ToString(otpt));
            Console.ReadKey();
        }
    }
}



Measured memory_bytes: 28124
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    char c[10]; cin >> c;

    if (c[0] != c[1] && c[1] != c[2] && c[2] != c[0]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    sys.setrecursionlimit(10 ** 7)

    N, K = map(int, input().split())
    *A, = (int(x) - 1 for x in input().split())

    rs = [-1] * N

    def dfs(cur=0, rest=K):
        if ~rs[cur]:
            loop_range = rs[cur] - rest
            rest %= loop_range

        if rest == 0:
            return cur + 1  # -> 1-ind

        rs[cur] = rest
        return dfs(A[cur], rest - 1)

    print(dfs())


if __name__ == '__main__':
    main()


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

#define ll long long
#define ld long double
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
const int MOD=1e9+7;

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	ll maxi=0;
	maxi=(ll)a*c;
	maxi=max(maxi,(ll)a*d);
	maxi=max(maxi,(ll)b*c);
	maxi=max(maxi,(ll)b*d);
	cout<<maxi;
	return 0;
}


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

using namespace std;

const int MAX_N = 123456;
int n, k, a[MAX_N];
long long partialk[MAX_N], positive_sum[MAX_N];


int main() {

    cin >> n >> k;

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

        if (i == 0)
            positive_sum[i] = max(a[i], 0);

        else
            positive_sum[i] = positive_sum[i - 1] + max(a[i], 0);

//        cout << positive_sum[i] << " ";
    }

//    cout << endl;

    long long max_sum, black_k, white_k;

    for (int i = 0; i < k; ++i)

        partialk[0] += a[i];


    black_k = partialk[0] + positive_sum[n - 1] - positive_sum[k - 1];

    white_k = positive_sum[n - 1] - positive_sum[k - 1];


    max_sum = max(black_k, white_k);


//    printf("black k :: %d = partialk[0] :: %d + positive sum[n - 1] :: %d - positive sum[k - 1] :: %d\n",
//           black_k, partialk[0], positive_sum[n - 1], positive_sum[k - 1]);
//
//    cout << endl;
//
//    printf("white k :: %d = positive sum[n - 1] :: %d + positive sum[k - 1] :: %d\n",
//           white_k, positive_sum[n - 1], positive_sum[k - 1]);
//
//    cout << endl;


//    printf("i :: %d black k :: %d white k :: %d max sum :: %d\n", 0, black_k, white_k, max_sum);
//    cout << "partialk :: " << partialk[0] << " ";


    for (int i = k; i < n; ++i) {

        partialk[i - k + 1] = partialk[i - k] + a[i] - a[i - k];


        black_k = partialk[i - k + 1] + positive_sum[n - 1] - positive_sum[i] + positive_sum[i - k];

        white_k = positive_sum[n - 1] - positive_sum[i] + positive_sum[i - k];


//        printf("black k :: %d = partialk[i - k + 1] :: %d + positive sum[n - 1] :: %d - positive sum[i] :: %d + positive sum[i - k] :: %d\n",
//                black_k, partialk[i- k + 1], positive_sum[n - 1], positive_sum[i], positive_sum[i - k]);
//
//        cout << endl;
//
//        printf("white k :: %d = positive sum[n - 1] :: %d - positive sum[i] :: %d + positive sum[i - k] :: %d\n",
//                white_k, positive_sum[n - 1], positive_sum[i], positive_sum[i - k]);
//
//        cout << endl;


        if (max(black_k, white_k) > max_sum)
            max_sum = max(black_k, white_k);

//        printf("i :: %d black k :: %d white k :: %d max sum :: %d\n", i, black_k, white_k, max_sum);

//        cout << partialk[i - k + 1] << " ";

//       printf("partialk i - k :: %d a[i] :: %d a[i - k] :: %d \n", partialk[i - k], a[i], a[i - k]);

    }
//    cout << endl;

    cout << max_sum << endl;
    return 0;
}


Measured memory_bytes: 5460
import itertools


def m():
    S = input()
    ans = 0
    for i in range(len(S)):
        for item in itertools.combinations(range(len(S) - 1), i):
            if len(item) == 0:
                ans += int(S)
                continue
            ind = 0
            for j in item:
                ans += int(S[ind:j+1])
                ind = j+1
            ans += int(S[ind:])
    return ans


print(m())


Measured memory_bytes: 65784
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}


void solve()
{
	ll k, x;
	cin >> k >> x;
	if (k * 500 >= x)
		cout << "Yes";
	else
		cout << "No";
	 
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))

from collections import Counter
count = Counter(A)
 
s = 0
for c in list(count.values()):
    s += c*(c-1)/2

ans = 0
for a in A:
    n = count[a]
    ans = s - n*(n-1)/2 + (n-1)*(n-2)/2
    print(int(ans))

Measured memory_bytes: 32228
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int x[110];
signed main()
{
    int n;
    cin >> n;
    REP(i, n)
        cin >> x[i];
    ll minn = INF;
    for (int p = 0; p <= 110; p++)
    {
        ll tmp = 0;
        for (int i = 0; i < n; i++)
        {
            tmp += (x[i] - p) * (x[i] - p);
        }
        chmin(minn, tmp);
    }
    cout << minn << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f[100001]={0},a[101];
int main()
{
	int i,j,n,k,min_v=INT_MAX,flag=0;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		min_v=min(min_v,a[i]);
	}
	for(i=0;i<=min_v;i++)
		f[i]=1;
	for(i=1;i<=k;i++)
	{
		flag=1;
		for(j=1;j<=n;j++)
		{
			if(a[j]<=i)
			{
				if(f[i-a[j]]==1)
				{
					flag=0;
					break;
				}
			}	
		}
		if(flag==1)
			f[i]=1;
		else
			f[i]=0;
	}
	if(f[k]==0)
		printf("First");
	else
		printf("Second");
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
    double d,t,s,t_;
    scanf("%lf %lf %lf",&d,&t,&s);
    t_=d/s;
    
    if (t_<=t){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;

}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
const long long INF = INT64_MAX;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

pll factor_sub(ll n, ll m)
{
	ll i = 0;
	while (n % m == 0)
	{
		i++;
		n /= m;
	}
	return make_pair(i, n);
}

vpll factrization(ll n)
{
	vpll a;
	ll c, m;
	tie(c, m) = factor_sub(n, 2);
	if (c > 0)
		a.push_back(make_pair(2, c));
	for (ll i = 3; m >= i * i; i += 2)
	{
		tie(c, m) = factor_sub(m, i);
		if (c > 0)
			a.push_back(make_pair(i, c));
	}
	if (m > 1)
		a.push_back(make_pair(m, 1));
	return a;
}

map<ll, ll> ctr;

ll num(ll n) {
    ll c = 0;
    for(auto ct:ctr) {
        if(ct.second >= n) {
            c++;
        }
    }
    return c;
}

void solve() {
    ll N;
    cin >> N;
    for(int i = 2; i <= N; i++) {
        vpll fs = factrization(i);
        for(auto &f:fs) {
            ctr[f.first] += f.second;
        }
    }
    ll f74 = num(74);
    ll f24 = num(24);
    ll f14 = num(14);
    ll f4 = num(4);
    ll f2 = num(2);
    std::cout << f74 + f24 * (f2 - 1) + f14 * (f4 - 1) + f4 * (f4 - 1) * (f2 - 2) / 2 << endl;
}

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

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    if s[i] == "AC":
        ac += 1
    elif s[i] == "WA":
        wa += 1
    elif s[i] == "TLE":
        tle += 1
    elif s[i] == "RE":
        re += 1
    else:
        pass
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))



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

typedef long long ll;

ll a[200005];
ll c[200005];
int n, k;

ll slv(int lo, int hi)
{
	if (lo == hi) return 0;
	if (lo+1 == hi) return a[lo] >= 0;
	int mid = (lo+hi) / 2;
	ll ans = slv(lo, mid)+slv(mid, hi);
	vector<ll> s1, s2;
	for (int i = lo;i < mid;i++) s1.push_back(c[mid-1]-c[i-1]);
	for (int i = mid;i < hi;i++) s2.push_back(c[i]-c[mid-1]);
	sort(s1.begin(), s1.end(), greater<ll>());
	sort(s2.begin(), s2.end(), greater<ll>());
	int ptr = s1.size()-1;
	for (unsigned i = 0;i < s2.size();i++)
	{
		while (ptr >= 0 && s1[ptr]+s2[i] < 0) ptr--;
		ans += ptr+1;
	}
	return ans;
}

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 1;i <= n;i++) scanf("%lld", a+i);
	for (int i = 1;i <= n;i++) a[i] -= k;
	for (int i = 1;i <= n;i++) c[i] = c[i-1]+a[i];
	printf("%lld\n", slv(1, n+1));
	return 0;
}


Measured memory_bytes: 5832
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N;
    cin>>N;
    LL a[N];
    REP(i,N)cin>>a[i];

    LL sum[N];
    sum[0]=a[0];
    REP(i,N-1){
        sum[i+1]=sum[i]+a[i+1];
    }

    LL ans =100000000000000000L;
    REP(i,N-1){
        ans =min(ans,abs(sum[N-1]-2*sum[i]));
    }
    cout<<ans<<endl;

    return 0;
}

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

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

const int INF = 1000000007;

int main(void){
	ll a,b,x;
	cin>>a>>b>>x;

	ll cnt=0;

	if(a % x == 0 || a == 0) cnt = 1;
	cnt +=  (b / x) - (a / x);

	printf("%lld\n", cnt);

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"Yes"<<endl
#define prN         cout<<"No"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	string s;
	sc(s);
	fs(i,s){
		if(i!=0 and s[i]!=s[i-1])cnt++;
	}
	if(cnt>=1)prY;
	else prN;
	
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

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

int main(){
    int x,time,su;
    std::cin >> x;
    for (int i = 1; i < 100000000; i++) {
        /* code */
        su+=i;
        time++;
        if(su>=x){
            if(su==x)break;
            if(su%2==1){
               // time=time+1;
                break;
            }
            else{
                //time=time+1;
                break;
            }
        }
    }
    std::cout << time << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
using namespace std;

ll MOD;

void mtxprd( int p, int q, int r, const ll* A, const ll* B, ll* C )
{
    int i, j, k;
    for(i=0; i<p; i++) {
        for(k=0; k<r; k++) {
            C[i*r+k] = 0;
            for(j=0; j<q; j++) {
                C[i*r+k] = (C[i*r+k] + A[i*q+j] * B[j*r+k])%MOD;
            }
        }
    }

    return;
}

void mtxuni(int dim, ll* mtx){
    int i,j;
    for(i=0; i<dim; i++) {
        for(j=0; j<dim; j++) {
            mtx[i*dim+j]=(i==j? 1: 0);
        }
    }
    return;
}

void mtxcpy(int dim, const ll* mtx, ll* mtx2){
    int i,j;
    for(i=0; i<dim; i++) {
        for(j=0; j<dim; j++) {
            mtx2[i*dim+j]=mtx[i*dim+j];
        }
    }
    return;
}

void mtxpow(int dim, const ll* mtx, ll n, ll* mtx2){ //x^n(mod M)
    vector<ll> mtx0(dim*dim);
    vector<ll> mtxtmp(dim*dim);
    mtxcpy( dim, mtx, &mtx0[0] );
    mtxuni( dim, mtx2 );
    while(n != 0){        
        if(n&1) {
            mtxprd( dim, dim, dim, mtx2, &mtx0[0], &mtxtmp[0] );
            mtxcpy( dim, &mtxtmp[0], mtx2 );
        }
        mtxprd( dim, dim, dim, &mtx0[0], &mtx0[0], &mtxtmp[0] );
        mtxcpy( dim, &mtxtmp[0], &mtx0[0] );
        n = n >> 1;
    }
    return;
}

ll calc( ll mtx[3][3], ll vec[3], ll n )
{
#if 1
    ll mtx2[3][3];
    mtxpow( 3, (ll*)mtx, n, (ll*)mtx2 );

    ll vecnew[3];
    mtxprd( 3, 3, 1, (ll*)mtx2, vec, vecnew );
    vec[0]=vecnew[0];
    vec[1]=vecnew[1];
    vec[2]=vecnew[2];
#else
    int i;
    for(i=0; i<n; i++) {
        ll vecnew[3];
        mtxprd( 3, 3, 1, (ll*)mtx, vec, vecnew );
        vec[0]=vecnew[0];
        vec[1]=vecnew[1];
        vec[2]=vecnew[2];
    }
#endif
    return vec[0];
}

int main(int argc, char* argv[])
{
    ll L,A,B;
    scanf("%lld%lld%lld%lld", &L, &A, &B, &MOD);

    ll ans = A;
    if(L==1) {
        printf("%lld\n", ans%MOD);
        return 0;
    }

    int i;
    ll tmp=1;
    for(i=1; i<=20; i++) {
        tmp=tmp*10;
        if(tmp>A+B) break;
    }
    int keta=i;
    //printf("%d\n", i);

    ll curr = 1;
    for(i=keta; i<keta+20; i++) {
        ll max = (tmp-A)%B==0? ((tmp-A)/B-1): (tmp-A)/B;
        max = MIN(max, L-1);
        if(curr>max) break;
#ifdef _DEBUG
        printf("[%d]%lld %lld\n", i, curr, max);
#endif
        ll mtx[3][3]={0};
        mtx[0][0]=tmp%MOD;
        mtx[0][1]=mtx[1][1]=mtx[1][2]=mtx[2][2]=1;

        ll vec[3]={ans%MOD, (A+B*curr)%MOD, B%MOD};
        ans = calc( mtx, vec, max-curr+1);

        tmp = (tmp*10);
        curr = max+1;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
def selectionSort(a,n):
    cnt = 0
    for i in range(n-1):
        minj = i
        for j in range(i+1,n):
            if a[j] < a[minj]:
                minj = j

        if i != minj: 
            temp = a[minj]
            a[minj] = a[i]
            a[i] = temp
            cnt += 1
    print(" ".join(map(str,a)))
    print(cnt)

n = int(input())
a = list(map(int,input().split()))

selectionSort(a,n)

Measured memory_bytes: 7708
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

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

  if (s.substr(2,1) == s.substr(3,1)&& s.substr(4,1) == s.substr(5,1)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

n = int(input())
a = list(map(int,input().split()))

#ひとつものぞかず、同じ数のボールをとるのは？
c = collections.Counter(a)
maxa = 0
item = [0 for i in range(max(a))]
for key,value in c.items():
    item[key-1] = value
    maxa += (value)*(value-1)//2
for i in range(len(a)):
    d = (item[a[i]-1])*(item[a[i]-1]-1)//2-(item[a[i]-1]-1)*(item[a[i]-1]-2)//2
    print(maxa-d)


Measured memory_bytes: 26004
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
typedef int long l;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    c *= 2;
    int ans = 0;
    if (y >= x) {
        int tmp;
        tmp = x;
        x = y;
        y = tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    // xの方が大きい
    if (a + b > c) {
        ans += c * y;
        x -= y;
        y = 0;
        if (a > c) {
            ans += c * x;
        } else {
            ans += a * x;
        }
    } else {
        ans += a * x + b * y;
    }
    cout << ans << endl;
    return 0;
}

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

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

    int p;
    bool b[N];
    for (int i = 1; i <= N; i++)
    {
        cin >> p;
        b[i - 1] = p == i;
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (b[i])
        {
            ans++;
            if (i + 1 < N)
            {
                b[i + 1] = false;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384