akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define ll long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2100;
int a[N][N], b[N][N], l[N], f[N][N];
ll hh1[N][N], hh2[N][N], pwr[N];
int ans;
int mod = 1e9 + 7;
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    int h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; i++){
        string s;
        cin >> s;
        for (int j = 1; j <= w; j++){
            if (s[j - 1] == '#') a[i][j] = 1; else
            b[i][j] = 1;
        }
    }
    pwr[0] = 1;
    for (int i = 1; i <= w; i++){
        for (int j = 1; j <= h; j++){
            hh1[i][j] = (hh1[i][j - 1] * 10 + a[j][i] + 5) % mod;
            hh2[i][j] = (hh2[i][j - 1] * 10 + b[j][i ] + 5) % mod;
            pwr[j] = pwr[j - 1] * 10 % mod;
        }
    }
    for (int i = 1; i < w; i++){
        for (int j = 1; j <= h; j++){
            int x = a[j][i];
            int y = a[j][i + 1];
            int l = j;
            while(l <= h){
                l++;
                if (x == y && a[l][i] != a[l][i + 1]) break;
                if (x != y && a[l][i] == a[l][i + 1]) break;
            }
            l--;
            for (int k = j; k <= l; k++) f[k][i] = l - k + 1;
            j = l;
        }
    }
    for (int i = 1; i <= h; i++){
        vector < int > t;
        for (int j = 1; j < w; j++){
            t.pb(f[i][j]);
        }
        stack < pair < int, int > > s;
        s.push({-1, 0});
        for (int i = 0; i < t.size(); i++){
            while(s.top().F >= t[i]) s.pop();
            l[i] = s.top().S;
            s.push({t[i], i + 1});
        }
        while(!s.empty()) s.pop();
        s.push({-1, t.size() + 1});
        for (int i = t.size() - 1; i >= 0; i--){
            while(s.top().F >= t[i]) s.pop();
            ans = max(ans, t[i] * (s.top().S - l[i]));
            s.push({t[i], i + 1});
        }
    }
    ans = max(ans, h);
    ans = max(ans, w);
    cout << ans;
}


Measured memory_bytes: 120064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    rep(i,n){
        ll a;cin>>a;
        if(a%2==1){
            cout<<"first"<<endl;
            return 0;
        }
    }
    cout<<"second"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char s[1024],t[1024]={0};
	int i=-1,j=1,k=0;
	gets(s);
	for(;i<j;)
	{
		for(;s[j]&&s[j]!=32&&s[j]!=44&&s[j]!=46;j++);
		if(s[j]==0)
		{
			t[k-1]=0;
			puts(t);
			return 0;
		}
		if(j-i<8&&j-i>3)
		{
			while(i++<j-1)
				t[k++]=s[i];
			t[k++]=' ';
		}
		i=j++;
	}
}

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

int main(){
  string A;
  int n=0;
  cin >> A;
  for(int i=0;i<3;i++){
    if(A.at(i)=='R'){
      n++;
    }
    if(n==2){
      if(A.at(1)=='S'){
        n=1;
      }
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            int N = Integer.parseInt(br.readLine());
            int ans = 0;
            for (int i = 0; i < N; i++) {
                String[] tmpInput = br.readLine().split(" ");
                int count = Integer.parseInt(tmpInput[1]) - Integer.parseInt(tmpInput[0]) + 1;
                ans += count;
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22100
#include <stdio.h>
void solve(void)
{
	char s[0xff][102];
	char turn='a';
	int index[0xff]={0};
int count=0;
	
	scanf("%s %s %s", s['a'], s['b'], s['c']);
	
	while(s[turn][index[turn]] != '\0'){
		turn = s[turn][index[turn]++];
	}
	printf("%c\n", turn&0xdf);
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int v[int(1e5+10)];
void solve() {
	var(int, n);
	vec(int, h, n);
	v[1] = abs(h[1] - h[0]);
	rep(i, 2, n) {
		v[i] = min(abs(h[i] - h[i - 1]) + v[i - 1], abs(h[i] - h[i - 2]) + v[i - 2]);
	}
	print(v[n - 1]);
}
int main() {
	solve();
	return 0;
}


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }
inline void Yes (bool condition) { if(condition) { cout << "Yes" << endl; } else { cout << "No" << endl;} }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		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;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> N;
	string S;
	cin >> S;
	for (i = 0; i <= 9; i++) {
		for (j = 0; j <= 9; j++) {
			for (k = 0; k <= 9; k++) {
				ll check = 0;
				for (l = 0; l < N; l++) {
					if (check==0 && ctoi(S[l]) == i) check = 1;
					else if (check == 1 && ctoi(S[l]) == j) check = 2;
					else if (check == 2 && ctoi(S[l]) == k)check = 3;
				}
				if (check == 3) {
					ans++; //debug(i, j, k);
				}
			}
		}
	}
	cout << ans;
}

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

int main(){
	char a,b;
	scanf("%c %c",&a,&b);
	if(a=='D'){
		if(b=='H'){
			printf("D");
		}
		else{
			printf("H");
		}
	}
	if(a=='H'){
		if(b=='D'){
			printf("D");
		}
		else{
			printf("H");
		}
	}
} 

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

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

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

    // input
    for(;;){
        ll x, y, s;
        cin >> x >> y >> s;

        if(x==0 && y==0 && s==0){
            return 0;
        }

        ll max_price = 0;
        FOR(a, 1, 1000){
            FOR(b, a, 1000){
                ll before_price = a * (100+x) / 100 + b * (100+x) / 100;
                if(before_price==s){
                    ll after_price = a * (100+y) / 100 + b * (100+y) / 100;
                    chmax(max_price, after_price);
                }
            }
        }
        p(max_price);
    }
    
    return 0;
}


Measured memory_bytes: 3160
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int n, price[51];
  for (int i = 0; i < 51; i++)
    price[i] = -1;
  price[15] = 2244;
  price[12] = 1870;
  price[10] = 1520;
  price[5] = 850;
  price[3] = 550;
  price[2] = 380;
  for (int i = 0; i < 51; i++) {
    for (int j = 0; j < i; j++) {
      if (j + 15 == i && price[j] > 0) {
        if ((price[i] < 0 ) ||
            (price[i] > 0 && price[j] + 2244 < price[i])) {
          price[i] = price[j] + 2244;
        }
      } else if (j + 12 == i && price[j] > 0) {
        if ((price[i] < 0) ||
            (price[i] > 0 && price[j] + 1870 < price[i])) {
          price[i] = price[j] + 1870;
        }
      } else if (j + 10 == i && price[j] > 0) {
        if ((price[i] < 0) ||
            (price[i] > 0 && price[j] + 1520 < price[i])) {
          price[i] = price[j] + 1520;
        }
      } else if (j + 5 == i && price[j] > 0) {
        if ((price[i] < 0) ||
            (price[i] > 0 && price[j] + 850 < price[i])) {
          price[i] = price[j] + 850;
        }
      } else if (j + 3 == i && price[j] > 0) {
        if ((price[i] < 0) ||
            (price[i] > 0 && price[j] + 550 < price[i])) {
          price[i] = price[j] + 550;
        }
      } else if (j + 2 == i && price[j] > 0) {
        if ((price[i] < 0) ||
            (price[i] > 0 && price[j] + 380 < price[i])) {
          price[i] = price[j] + 380;
        }
      }
    }
  }
  /*                                                                                                                                                                                                        
  for (int i = 0; i < 51; i++)                                                                                                                                                                              
    cout << i*100 << " : " << price[i] << endl;                                                                                                                                                             
  */
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    cout << price[n/100] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
 
int main(){
  int coin[4] = {10,50,100,500 };
  int co[4];
  int coco[4];
  int n;
  int count = 0;
 
  while(1){
    cin >> n;
    if(n==0) break;
    if(count != 0) cout << endl;
    count = 1;
 
    int sum = 0;
    int cmin =0;
    for(int i=0;i<4;i++) {
      cin >> co[i];
      cmin += co[i];
      sum += co[i];
    }
    
    int hara,ot,harab,otsum;
    int re[4] = {0};
    cmin = 1000000;
    for(int i=0;i<=co[0];i++) {
      for(int j=0;j<=co[1];j++) {
    for(int k=0;k<=co[2];k++) {
      for(int u=0;u<=co[3];u++){
 
        hara =  i*10 + j*50 + k*100 + u*500;
        //  cout << "hara " << hara << endl;
        if(hara >= n) {
          otsum = 0;
          ot = hara - n;
          otsum = ot /500;
          ot %= 500;
          otsum += ot / 100;
          ot %=100;
          otsum += ot / 50;
          ot %= 50;
          otsum += ot/10;
          //   cout << otsum << endl;
          if(otsum+sum-i-j-k-u < cmin) {
        cmin = otsum+sum - i-j-k-u;
        re[0] = i;
        re[1] = j;
        re[2] = k;
        re[3] = u;
          }
        }
      }
    }
      }
    }
   
    for(int i=0;i<4;i++) {
      if(re[i] != 0) {
    cout << coin[i] <<" "<<re[i] <<endl;
      }
    }
  }
 
    return 0;
}

Measured memory_bytes: 1160
n=int(input())
s=0;a=0;b=0
for i in range(n):
  t,x,y=map(int,input().split())
  if abs(x-a)+abs(y-b)>t-s or (t-s-abs(x-a)-abs(y-b))%2!=0:
    print('No')
    exit()
  s=t;a=x;b=y
print('Yes')

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(void)
{
    int n,m,a[50],b[50],c[50],d[50],t1,t2,i,j;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
    for(i=0;i<m;i++)scanf("%d%d",&c[i],&d[i]);
    for(i=0;i<n;i++){
        t1=INT_MAX;
        for(j=0;j<m;j++){
            if(t1>abs(a[i]-c[j])+abs(b[i]-d[j])){
                t1=abs(a[i]-c[j])+abs(b[i]-d[j]);
                t2=j;
            }
        }
        printf("%d\n",t2+1);
    }
}

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

int main(void) 
{
    const int INF =1001001001;

    int c[10][1005];
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = INF;

    // 1 << h-1 = 2^(h-1)
    //線を引くor引かないの２通り
    rep(div, 1 << (h-1))
    {
         //2進数でビットが立っているところで分ける(div)
        int group =0;
        vector<int> id(h);
        rep(i,h)
        {
            id[i] = group;
            //シフトして１(線を引く)なら次からのグループをインクリする
            if(div >> i&1) group++;
        }
        //グループ数を表す為にインクリ
        group++;

        //縦グループ数分、横全て初期化
        rep(i,group)rep(j,w) c[i][j] = 0;
        rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j] -'0');
        
        //縦に切っていく
        int num = group - 1;
        vector<int> now(group);
        auto add = [&](int j)
        {
            rep(i,group) now[i] += c[i][j];
            rep(i,group) if(now[i] > k) return false;           
            return true;
        };
        rep(j,w)
        {
            if(!add(j))
            {
                num++;
                now = vector<int>(group);
                if(!add(j))
                {
                    num = INF;
                    break;
                }                
            }         
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string s;
  int a[100001]={};
  int st=0,cnt=0;
  bool is_ev=true;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='L'){
      cnt = (i-st);
      a[i-1]+=cnt/2;
      a[i]+=cnt/2;
      if(cnt%2!=0){
        a[i-1]++;
      }
      st=i+1;
    }
  }
  st=s.size()-1;
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='R'){
      cnt = (st-i);
      a[i]+=cnt/2;
      a[i+1]+=cnt/2;
      if(cnt%2!=0){
        a[i+1]++;
      }
      st=i-1;
    }
  }
  for(int i=0;i<s.size();i++){
    cout << a[i]<<" ";
  }
  cout << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int r,g,b,n,c=0,x,y;
    cin >> r >> g >> b >> n;
    for(int i=0;i*r<=n;i++){
        for(int j=0;i*r+j*g<=n;j++){
            x=i*r;
            y=j*g;
            if((n-(x+y))%b==0) c++;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
int main(void) {
	int K, S;
	std::cin >> K >> S;
	int count = 0;
	for (int L1 = 0; L1 <= K; L1++)
		for (int L2 = 0; L2 <= K; L2++)
			if (S - L1 - L2  <= K && S - L1 - L2>= 0)
				count++;
	std::cout << count << std::endl;
	system("pause");

}


Measured memory_bytes: 3684
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    while (a != 0 || b != 0)
    {
        if (a > b)
        {
            printf("%d %d\n", b, a);
        }
        else
        {
            printf("%d %d\n", a, b);
        }
        scanf("%d%d", &a, &b);
    }
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
////////////////////////////////////////////////////////////////////
int main()
{
    int a,b;cin >> a >> b;

    int ans=0;
    REP(i,2){
        if(a>b){
            ans+=a;
            a-=1;
        }
        else{
            ans+=b;
            b-=1;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,t,k,m,x;
    while(~scanf("%d%d",&a,&b))
    {
        t=a+b;
        k=a-b;
        m=a*b;
        if(t<k)
        {
            x=t;
            t=k;
            k=x;
        }
        if(t<m)
        {
            x=t;
            t=m;
            m=x;
        }
        if(k<m)
        {
            x=k;
            k=m;
            m=x;
        }

        printf("%d\n",t);
    }
    return 0;
}


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

int main() {
	LL a, b, k;
	cin >> a >> b >> k;
	if (a >= k) {
		cout << (a - k) << ' ' << b << '\n';
	} else if (a + b >= k) {
		cout << 0 << ' ' << (b - (k - a)) << '\n';
	} else {
		cout << "0 0\n";
	}
	return 0;
}


Measured memory_bytes: 3528
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u64; n + 1],
    }
    let mut b = vec![];
    let mut m = 1;
    for i in 0..n + 1 {
        if a[i] <= m {
            m -= a[i];
            b.push(m);
        } else {
            println!("-1");
            return;
        }
        m *= 2;
    }
    let mut l = 0;
    for i in (0..n + 1).rev() {
        if b[i] > l {
            b[i] = l;
        } else {
            break;
        }
        l = b[i] + a[i];
    }
    let mut ans = 0;
    for i in 0..n + 1 {
        ans += a[i] + b[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 4692
#include <bits/stdc++.h>
using namespace std;
#define trace1(a) cout << a << 'n';
#define trace2(a, b) cout << a << ' ' << b << 'n';
#define trace3(a, b, c) cout << a << ' ' << b << ' ' << c << 'n';
#define trace4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d << 'n';
#define trace5(a, b, c, d, e) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << 'n';
#define trace6(a, b, c, d, e, f) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << 'n';
#define range(n) for(int i = 0; i < n; i++)
#define printArr(harry, tam) range(tam) cout << harry[i] << " n"[i == tam -1];
#define maxn -2000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;

ll cnt(ll n)
{
  ll c=0;
  while(n>0){
    c++;
    n=n/10;
  }
  return c;
}
int main( ) {
      ll n;
      cin>>n;
      ll ans=INT_MAX;

      for(ll i=1;i*i<=n;i++){
        if(n%i==0)
        {ans=min(ans,max(cnt(i),cnt(n/i)));
          //cout<<i<<" "<<n/i<<" "<<ans<<endl;
        }
      }
      cout<<ans;
  }


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

int cnt[10][10];
string itos(int x) {
	string res;

	while (x > 0) {
		char c = (char)('0' + x % 10);
		res += c;
		x /= 10;
	}
	return res;
}
void solve() {
	int N; cin >> N;
	FOR(i, 1, N + 1) {
		string s = itos(i);
		int pre = s[0]-'0', suf = s[s.size() - 1]-'0';
		cnt[pre][suf]++;
	}
	ll ans = 0;
	REP(pre, 10)FOR(suf,pre, 10) {
		ans += cnt[pre][suf] * cnt[suf][pre];
		if (suf != pre)ans += cnt[pre][suf] * cnt[suf][pre];
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 256
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    println!("{}", n * n)
}


Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()

typedef tree<pair<ll,ll> ,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

string a, b, ans = "";

ll dp[3005][3005];               // LCS of string a(0 .. i) and b(0 .. j)

ll LCS(ll i, ll j)
{
	if(i < 0 || j < 0) return 0;
	if(dp[i][j] != -1) return dp[i][j];
	dp[i][j] = max(LCS(i - 1, j), LCS(i, j - 1));
	if(a[i] == b[j])
		dp[i][j] = max(dp[i][j], 1 + LCS(i - 1,  j - 1));
	return dp[i][j];
}

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

	cin >> a >> b;
	memset(dp, -1, sizeof(dp));
	ll d = LCS(a.length() - 1, b.length() - 1);   
    pair<ll,ll> temp = mp(a.length() - 1, b.length() - 1);
    while(1)
    {
    	if(temp.first < 0 || temp.second < 0) break;
    	if(a[temp.first] == b[temp.second])
    	{	
    		ans += a[temp.first];
    		temp.first -= 1;
    		temp.second -= 1;
    		continue;
    	}
    	ll t1 = 0, t2 = 0;
    	if(temp.second != 0)
    		t1 = dp[temp.first][temp.second - 1];
    	if(temp.first != 0)
    		t2 = dp[temp.first - 1][temp.second];
    	if(t1 > t2)
    		temp.second -= 1;
    	else
    		temp.first -= 1;
    	if(temp.first == 0 && temp.second == 0) 
    	{	
    		if(a[0] == b[0]) ans += a[0];
    		break;
    	}	
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 71424
#include <bits/stdc++.h>
#define pb push_back
#define sp " "
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (int a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
int n;
string a,b,c,d;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>a;
	n=sz(a);
	d=a;
	bool t=true;
	reverse(all(d)); 
	if (d!=a) t=false;
	n/=2;
	fo(i,0,n-1) b+=a[i];
	reverse(all(b)); 
	fo(i,0,n-1) if (b[i]!=a[i]) t=false;
	fo(i,n+1,sz(a)-1) c+=a[i];
	reverse(all(c));
	fo(i,n+1,sz(a)-1) if (c[i-n-1]!=a[i]) t=false;
	if (t) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>
#include<list>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

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; }



i64 n, d, a, x[202020], h[202020];
P p[202020];
i64 imos[202020];
void solve(){
	cin >> n >> d >> a;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> h[i];
		p[i] = P(x[i],h[i]);
	}
	sort(p,p+n);
	p[n] = P(LINF,LINF);
	
	i64 cnt = 0;
	for(int i = 0; i < n; i++){
		if(i != 0) imos[i] += imos[i-1];
		int m = (p[i].second - imos[i] + a - 1) / a;
		if(m <= 0) continue;
		cnt += m;
		imos[i] += m * a;
		int pos = upper_bound(p, p+n+1, P(p[i].first+2*d,LINF)) - p;
		imos[pos] -= m * a;
	}
	
	cout << cnt << endl;
}

int main(){
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,q;
  cin >> n >> q;
  vector<pair<ll,pair<int,ll>>> a;
  rep(i,n){
    int s,t,x; cin >> s >> t >> x;
    a.push_back({s-x,{-1,x}});
    a.push_back({t-x,{0,x}});
  }
  rep(i,q){
    int d; cin >> d;
    a.push_back({d,{1,i}});
  }
  sort(a.begin(),a.end());

  vector<ll> res(q,-1);
  multiset<int> st;
  for(auto it:a){
    if(it.S.F == -1){
      st.insert(it.S.S);  
    } else if(it.S.F == 0){
//      st.erase(it.S.S);   //同じ数字を全部消してしまう
      st.erase(st.lower_bound(it.S.S)); //1つだけ消したい
    } else {
      if(!st.empty()) res[it.S.S] = *st.begin();
    }
  }

  for(auto ans:res){
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 27236
#include<bits/stdc++.h>
using namespace std;int n,a[2<<18],B[1<<18],s,c,m,A,i,j,L;main(){for(cin>>n;cin>>a[A++];);for(;i<29;s|=c<<i++){m=1<<i+1;for(c=j=0;j<n;j++)B[j]=a[j+n]%m;sort(B,B+n);for(j=0;j<n;c^=(a[j++]&m/2?n-L:L)&1)A=a[j]%(m/2),L=lower_bound(B,B+n,m-A)-lower_bound(B,B+n,m/2-A);}cout<<s<<endl;}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep0(i,n) for(i=0;i<n;i++)
using namespace std;
int main(){
    FAST;
    string s;
    int n,i;
    cin>>n;
    cin>>s;
    int l=s.size();
    if(l<=n){
        cout<<s<<endl;
    }
    if(l>n){
            for(i=0;i<n;i++){
                cout<<s.at(i);
            }
            cout<<"..."<<endl;
    }

}



Measured memory_bytes: 3640
#include <stdio.h>

struct point{
    int x;
    int y;
};

int main(int argc, const char * argv[]) {
    struct point poi[10];
    
    scanf("%d%d%d%d", &poi[0].x, &poi[0].y, &poi[1].x, &poi[1].y);
    
    printf("%d %d %d %d\n",poi[1].x - (poi[1].y - poi[0].y), poi[1].y + (poi[1].x - poi[0].x),
           poi[0].x - (poi[1].y - poi[0].y) , poi[0].y + (poi[1].x - poi[0].x));
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    
    if (((A+B) % 2) == 1){
      System.out.println("IMPOSSIBLE");
    }else{
      int K = (A+B)/2;
      System.out.println(K);
    }
  }
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

string S;

signed main() {
    cin >> S;
    ll ans = 0;
    char pre = S[0];
    FOR(i, 1, S.length()) {
        if(pre != S[i]) ans++;
        pre = S[i];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 512
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
 
public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			long a[] = new long[n];
			long b[] = new long[n];
			
			long suma = 0;
			long sumb = 0;
			
			for (int i=0; i<n; i++) {
				a[i] = sc.nextInt();
				suma += a[i];
			}
			for (int i=0; i<n; i++) {
				b[i] = sc.nextInt();
				sumb += b[i];
			}
			
			if (suma < sumb) {
				System.out.println(-1);
				return;
			}
			
			int count = 0;
			long husoku = 0;
			int kajo_count = 0;
			List<Long> kajo_list = new ArrayList<Long>();

			for (int i=0; i<n; i++) {
				if (a[i] < b[i]) {
					count++;
					husoku += b[i] - a[i];
				} else if (a[i] > b[i]) {
					kajo_count++;
					kajo_list.add(a[i] - b[i]);
					
				}
			}
			
			if (count == 0) {
				System.out.println(count);
				return;
			}
			
			Collections.sort(kajo_list, Collections.reverseOrder());
			long kajo_sum = 0;
			for(int i=0;i<kajo_list.size();i++){
				kajo_sum += kajo_list.get(i);
				count++;
				if (husoku <= kajo_sum) {
					break;
				}
				
			}
			
			System.out.println(count);

		}
	}
}

Measured memory_bytes: 86968
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
#define m_p make_pair

long long n;

long long rec(long long a, long long b)
{
	if ((a % 2) == (b % 2))
		return abs(a - b) / 2;
	if (a == 1)
	{
		return 1 + rec(1, b - 1);
	}
	if (b == n)
	{
		return 1 + rec(a + 1, n);
	}
	long long q = min(a - 1, b - 1);
	long long yans = q + rec(a - q, b - q);
	q = min(n - a, n - b);
	yans = min(yans, q + rec(a + q, b + q));
	return yans;
}

int main()
{
	cin >> n;
	long long a, b;
	cin >> a >> b;
	cout << rec(a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		int c[][] = new int[10][10];
		for(int i=0; i<10; i++) {
			for(int j=0; j<10; j++) {
				c[i][j]=sc.nextInt();
			}
		}

		for(int k=0; k<10; k++) {
			for(int i=0; i<10; i++) {
				if(c[i][k]==-1)continue;
				for(int j=0; j<10; j++) {
					if(c[k][j]==-1)continue;
					c[i][j] = Math.min(c[i][j], c[i][k]+c[k][j]);
				}
			}
		}

		int a[][] = new int[h][w];
		for(int i=0; i<h; i++) {
			for(int j=0; j<w; j++) {
				a[i][j]=sc.nextInt();
			}
		}
		long ans = 0;
		for(int i=0; i<h; i++) {
			for(int j=0; j<w; j++) {
				if(a[i][j]==-1)continue;
				if(a[i][j]==1)continue;
				ans += c[a[i][j]][1];
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 58368
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);



ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}


#define comuse Comuse()

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}




/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

void Solve(){
  ll n;
    cin>>n;
  ll few=1000000;
  ll ans=0;
  FOR(i,0,n){
    ll now;
      cin>>now;
    if(now<few){
      ans++;
      few=now;
    }
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
  char buf[1000];
  int x, y, z, tmp;

  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d %d %d\n", &x, &y, &z);

  tmp = x;
  x = y;
  y = tmp;

  tmp = x;
  x = z;
  z = tmp;

  printf("%d %d %d\n", x, y, z);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,k;
  cin>>n>>k;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0;i<k;i++){
    ans+=p[i];
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
	char s[4];
	for (int i = 0; i < 4; i++) cin >> s[i];
	bool falg = false;
	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i + 1])falg = true;
	}
	if (falg) cout << "Bad" << endl;
	else cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = [[0] * N for i in range(N)]
mod = 10 ** 9 + 7
for i in range(N):
    B = [int(i) for i in input().split()]
    for j in range(N):
        A[i][j] = B[j]


def dot(X, Y):
    Z = [[0] * N for i in range(N)]
    for i in range(N):
        for j in range(N):
            t = 0
            for k in range(N):
                t += X[i][k] * Y[k][j]
                t %= mod
            Z[i][j] = t
    return Z

#print(A)
x = K
T = A
ans = [[0]*N for i in range(N)]
for i in range(N):
    ans[i][i]=1
while x > 0:
    if x % 2 == 1:
        ans = dot(ans, T)
    T = dot(T, T)
    #print(T)
    x = x // 2
num = 0
for i in range(N):
    num += sum(ans[i])
    num %= mod
print(num)
#print(ans)

Measured memory_bytes: 45672
#!/usr/bin/env python3
import sys


def solve(X: int):
    n = 100
    e =  0
    while (n < X):
        n = int(1.01*n)
        e += 1
    print(e)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n, m; cin >> n >> m;

	if ((n + m) % 2 == 0) {
		cout << (n + m) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
left = [0 for _ in range(n+1)]
right = [0 for _ in range(n+1)]

tmp = 0
for i in range(n):
    if s[i] == '<':
        tmp += 1
    else:
        tmp = 0
    left[i+1] = tmp

tmp = 0
for i in range(n-1, -1, -1):
    if s[i] == '>':
        tmp += 1
    else:
        tmp = 0
    right[i] = tmp

ans = 0
for i in range(n+1):
    ans += max(right[i], left[i])

print(ans)

Measured memory_bytes: 27944
import itertools
import sys
readline = sys.stdin.readline
# readlines = sys.stdin.readlines
N = int(readline())
ds = list(map(int,readline().split()))

ans = 0
for v in itertools.combinations(ds, 2):
    #print(v)
    ans += v[0] * v[1]
    
print(ans)

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    string s;
    cin >> s;
    int n=s.size();
    int rcount=0;
    for(int i = 0; i < n; i++) {
        if(s[i]=='0') rcount++;
    }
    int bcount=n-rcount;
    cout << min(rcount,bcount)*2 << "\n";


    return 0;
}

Measured memory_bytes: 512