akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
constexpr ll P = 1e9+7;

ll modpow(ll b, ll e) {
  if(e==0) return 1;
  if(e%2==0) {
    ll t = modpow(b,e/2);
    return (t*t)%P;
  }
  return (modpow(b,e-1)*b)%P;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  vector<ll> cnt(n);
  rep(i,n) cnt[a[i]]++;
  if(n%2==0) {
    ll m = 1;
    ll c = 0;
    while(m<=n-1) {
      if(cnt[m]!=2) {
        cout << 0 << endl;
        return 0;
      }
      c+=cnt[m];
      m+=2;
    }
    if(c!=n) {
      cout << "0" << endl;
      return 0;
    }
    cout << modpow(2,n/2) << endl;
    return 0;
  }
  // n%2==1
  if(cnt[0]!=1) {
    cout << "0" << endl;
    return 0;
  }
  ll c = 1;
  ll m = 2;
  while(m<=n-1) {
    if(cnt[m]!=2) {
      cout << 0 << endl;
    }
    c+=cnt[m];
    m+=2;
  }
  if(c!=n) {
    cout << "0" << endl;
    return 0;
  }
  cout << modpow(2,n/2) << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <tuple>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, h;
  cin >> n >> h;
  vector<int> a(n), b(n);
  int cnt = 0;
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  sort(b.begin(), b.end(), greater<int>());
  for (int i = 0; i < n; ++i)
  {
    if (h <= 0)
      break;
    if (b[i] > a[0])
    {
      cnt++, h -= b[i];
    }
  }
  if (h > 0)
    cnt += (h - 1) / a[0] + 1;
  cout << cnt << endl;

  return 0;
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;

vector<ll> indices[26];

void solve(std::string s, std::string t){
  ll sSize=s.size();
  REP(i,(int)sSize){
    int c=s[i]-'a';
    indices[c].push_back(i);
  }
  ll tSize=t.size();
  ll count=0;
  ll last=0;
  REP(i,(int)tSize){
    int c=t[i]-'a';
    if(indices[c].size()==0){
      cout<<"-1"<<endl;
      return;
    }
    auto idx=lower_bound(indices[c].begin(),indices[c].end(),last);
    if(idx==indices[c].end()){
      count++;
      idx=indices[c].begin();
    }
    last=*idx;
    last++;
  }
  cout<<count*sSize+last<<endl;
}

int main(){_;
  std::string s;
  std::cin >> s;
  std::string t;
  std::cin >> t;
  solve(s, t);
  return 0;
}


Measured memory_bytes: 1744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;ll k;cin>>s>>k;
    string ss;ss=s;sort(ss.begin(),ss.end());
    if(ss[0]==ss[ss.size()-1]){
        cout<<(k*ss.size())/2<<endl;return 0;
    }
    vector<int> v;
    char now=0;
    int js=1;
    for(int i=0;i<s.size();i++){
        if(s[i]==now){
            js++;
        }else{
            if(i!=0)v.push_back(js);
            js=1;
            now=s[i];
        }
    }
    v.push_back(js);
    ll sum=0;
    if(v[0]%2==0||v[v.size()-1]%2==0||s[s.size()-1]!=s[0]){
        for(int i=0;i<v.size();i++){
            sum+=v[i]/2;
        }
        cout<<sum*k<<endl;return 0;
    }
    for(int i=0;i<v.size();i++){
            sum+=v[i]/2;
    }
    cout<<sum*k+k-1<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 55;
double C[MAXN+1][MAXN+1];
const int N = 110;
int n, m;
int l, t[N], v[N];
double p[N];
void init()
{
    memset(C, 0, sizeof C);
    for(int i=0; i<=MAXN; ++i)
    {
        C[0][i] = 0.0;
        C[i][0] = 1.0;
    }
    for(int i=1; i<=MAXN; ++i)
    {
        for(int j=1; j<=MAXN; ++j)
        C[i][j] = C[i-1][j] + C[i-1][j-1];
    }
}
double work(int x)
{
    double ans = 0.0;
    for(int i = 0; i <= m; i++)
    {
        double pp = C[m][i] * pow(p[x], i) * pow(1.0-p[x], m-i);
        for(int j = 1; j <= n; j++)
        {
            if(j == x)continue;
            double siz = 0;
            for(int k = m; k >= 0; k--)
            {
                if(l*v[j] + i*t[x]*v[j]*v[x] < l*v[x] + k*t[j]*v[x]*v[j])
                    siz += C[m][k] * pow(p[j], k) * pow(1.0-p[j], m-k);
                else break;
            }
            pp *= siz;
        }
        ans += pp;
    }
    return ans;
}
int main()
{
    //freopen("in.txt","r",stdin);
    init();
    while(cin>>n>>m>>l)
    {
        for(int i = 1; i <= n; i++)
        {
            cin>>p[i]>>t[i]>>v[i];
            p[i] /= 100.0;
        }
        for(int i = 1; i <= n; i++)
            printf("%.10f\n", work(i));
    }
    return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
 
using namespace std;
 
const unsigned mod = 1e9 + 7;
unsigned power[234567], lad[26][234567];
 
struct SegmentTree
{
  vector< unsigned > hashed;
  vector< int > lazy;
  int sz;
 
  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    hashed.assign(2 * sz - 1, 0);
    lazy.assign(2 * sz - 1, -1);
  }
 
  void push(int k, int l, int r)
  {
    if(~lazy[k]) {
      hashed[k] = lad[lazy[k]][r - l];
      if(k < sz - 1) {
        lazy[2 * k + 1] = lazy[k];
        lazy[2 * k + 2] = lazy[k];
      }
      lazy[k] = -1;
    }
  }
 
  void add(int a, int b, int x, int k, int l, int r)
  {
    push(k, l, r);
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      lazy[k] = x;
      push(k, l, r);
    } else {
      add(a, b, x, 2 * k + 1, l, (l + r) >> 1);
      add(a, b, x, 2 * k + 2, (l + r) >> 1, r);
      hashed[k] = hashed[2 * k + 1] * power[(r - l) >> 1] + hashed[2 * k + 2];
    }
  }
 
  void add(int a, int b, int x)
  {
    add(a, b, x, 0, 0, sz);
  }
 
  pair< unsigned, int > get(int a, int b, int k, int l, int r)
  {
    push(k, l, r);
    if(a >= r || b <= l) return {0, 0};
    if(a <= l & r <= b) return {hashed[k], r - l};
    auto ll = get(a, b, 2 * k + 1, l, (l + r) >> 1);
    auto rr = get(a, b, 2 * k + 2, (l + r) >> 1, r);
    return {ll.first * power[rr.second] + rr.first, ll.second + rr.second};
 
  }
 
  unsigned get(int a, int b)
  {
    return (get(a, b, 0, 0, sz).first);
  };
 
  void set(int k, int x)
  {
    hashed[k + sz - 1] = lad[x][1];
  }
 
  void build(int k, int l, int r)
  {
    if(l + 1 == r) return;
    build(2 * k + 1, l, (l + r) >> 1);
    build(2 * k + 2, (l + r) >> 1, r);
    hashed[k] = hashed[2 * k + 1] * power[(r - l) >> 1] + hashed[2 * k + 2];
  }
 
  void build()
  {
    build(0, 0, sz);
  }
 
  char idx(int k)
  {
    return (hashed[k + sz - 1]);
  }
};
 
int main()
{
  power[0] = 1;
  for(int i = 0; i < 234566; i++) power[i + 1] = power[i] * mod;
  for(int i = 0; i < 26; i++) {
    const char cc = 'a' + i;
    for(int j = 0; j < 234566; j++) lad[i][j + 1] = lad[i][j] * mod + cc;
  }
 
 
  int N, Q;
  char U[234567];
 
  scanf("%d", &N);
  getchar();
  scanf("%s", U);
  SegmentTree tree(N);
  for(int i = 0; i < N; i++) tree.set(i, U[i] - 'a');
  tree.build();
 
  scanf("%d", &Q);
  while(Q--) {
    getchar();
    scanf("%s", U);
    if(*U == 's') {
      int x, y;
      char z;
      scanf("%d %d %c", &x, &y, &z);
      tree.add(--x, y, z - 'a');
    } else {
      int a, b, c, d;
      scanf("%d %d %d %d", &a, &b, &c, &d);
      --a, --c;
      int ok = 0, ng = min(d - c, b - a) + 1;
      while(ng - ok > 1) {
        int mid = (ok + ng) >> 1;
        if(tree.get(a, a + mid) == tree.get(c, c + mid)) ok = mid;
        else ng = mid;
      }
 
      if(ok == d - c && ok == b - a) {
        puts("e");
      } else if(b - a == ok || (d - c != ok && tree.idx(a + ok) < tree.idx(c + ok))) {
        puts("s");
      } else {
        puts("t");
      }
    }
  }
 
}

Measured memory_bytes: 31820
s = input()
s_list = [s[i] for i in range(len(s))]
t = input()
t_list = [t[i] for i in range(len(t))]
s_list.sort()
t_list.sort(reverse=True)
n = min(len(s), len(t))

for i in range(n):
    if s_list[i] < t_list[i]:
        print('Yes')
        exit(0)
    elif s_list[i] == t_list[i]:
        if i != n - 1:
            continue
        else:
            if len(s) >= len(t):
                print('No')
            else:
                print('Yes')
            exit(0)

    else:
        print('No')
        exit(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 55;

int a[N], b[N], c[N], d[N];

int main ()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0 ;i  < n ; i++) {
		cin >> a[i] >> b[i];
	}
	
	for (int i =0 ; i < m; i++) {
		cin >> c[i] >> d[i];
	}
	
	for (int i = 0; i < n ; i++) {
		
		int dis = 1e9, chose = 0;
		for (int j = 0; j < m; j++) {
			if (abs(a[i]-c[j]) + abs(b[i]-d[j]) < dis) {
				dis = (abs(a[i]-c[j]) + abs(b[i]-d[j]));
				chose = j + 1;
			}
		}
		cout << chose << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#include<list>
#include<algorithm>
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr(a,b,c) for(a=b-1;a>=c;a--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define PQ priority_queue
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define EF else if
const double pi  =3.141592653589793238463;
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define UMP unordered_map
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define test4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define test5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define test6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
/*
    //string with spaces
    std::string str;
    std::getline(std::cin >> std::ws, str);
*/
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
    fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;
    // cin>>t;
    t=  1;
    while(t--){
        long double d,t,s;
        cin>>d>>t>>s;
        long double time = d/s;
        if(time <= t) cout<<"Yes";
        else cout<<"No";
        // cout<<'\n';
    }
}

Measured memory_bytes: 3772
import java.io.*;
import java.util.StringTokenizer;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    out = new PrintWriter(new BufferedOutputStream(System.out));
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
    out.close();
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    String s = sc.next();
    char[] letters = s.toCharArray();
    int ans = 0;
    for (char c: letters) {
      if (c=='+'){
        ans++;
      }else {
        ans--;
      }
    }
    out.println(ans);
  }

  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,D;
int X[101][101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	set<int> S;
	for(i=0;i<=1010;i++) S.insert(i*i);
	
	cin>>N>>D;
	FOR(y,N) FOR(x,D) cin>>X[y][x];
	
	int ret=0;
	FOR(y,N) FOR(x,y) {
		int tot=0;
		FOR(i,D) tot+=(X[x][i]-X[y][i])*(X[x][i]-X[y][i]);
		if(S.count(tot)) ret++;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
def check(a, b, S):
    animal = [a, b]
    for s in S[1:]:
        if s == "o" and animal[-1]:
            animal.append(animal[-2])
        elif s == "o" and not animal[-1]:
            animal.append(animal[-2] ^ 1)
        elif s == "x" and animal[-1]:
            animal.append(animal[-2] ^ 1)
        else:
            animal.append(animal[-2])

    if animal[:2] != animal[-2:]:
        return False

    ans = ""
    for x in animal[:-2]:
        if x:
            ans += "S"
        else:
            ans += "W"
    print(ans)
    return True


if __name__ == "__main__":
    N = int(input())
    S = input()
    S += S[0]
    for i in range(2):
        for j in range(2):
            if check(i, j, S):
                exit()
    print(-1)

Measured memory_bytes: 4980
char W[9],V[9];Z[2*24*60],S,N,T,P,M;main(){
	int i,j,k,l,r,d;
	for(;scanf("%d%d%d%s%s%d%d",&S,&N,&T,W,V,&P,&M),S;printf("%.9f\n",1-pow(1-1.0/P,N*r))){
		memset(Z,0,sizeof(Z));
		l=*W=='A'?2:1;
		d=24*60*(*W=='A'?1:7);
		if(*V=='A')for(i=0;i<l;i++)for(j=0;j<24*60;j++)Z[i*24*60+j]=1;
		if(*V=='D')for(i=0;i<l;i++)for(j=0;j<12*60;j++)Z[(i*24+6)*60+j]=1;
		if(*V=='N')for(i=0;i<l;i++)for(j=0;j<6*60;j++)Z[i*24*60+j]=Z[(i*24+18)*60+j]=1;
		for(r=j=0;j<24*60;r=r>l?r:l,j++)for(k=j,l=i=0;i<M;i++){
			if(k<24*60)l+=Z[(k+S)%(2*24*60)]&Z[k];
			k=(k+T)%(d);
		}
}exit(0);}

Measured memory_bytes: 704
import Control.Applicative
    
import Data.List
    (intersperse)
    
type Shuffles = [Int]

type Problem = [(String, Shuffles)]

type Result = [String]

shuffle :: String -> Int -> String

shuffle text index
    = (drop index text) ++ (take index text)
    
solve :: Problem -> Result

solve problem
    = map (\(t, s) -> foldl shuffle t s) problem

output :: Result -> String

output result
    = concat $ intersperse "\n" result
    
input :: IO Problem

input
    = inputProblem []
        
inputProblem :: Problem -> IO Problem

inputProblem problem
    = do
        text <- getLine
        if text == "-"
            then return problem
            else do
                n <- read <$> getLine
                shuffles <- inputShuffles n []
                inputProblem $ problem ++ [(text, shuffles)]
        
inputShuffles :: Int -> Shuffles -> IO Shuffles

inputShuffles 0 shuffles
    = return shuffles
    
inputShuffles n shuffles
    = do
        index <- read <$> getLine
        inputShuffles (n - 1) $ shuffles ++ [index]

main :: IO ()

main
    = putStrLn.output =<< solve <$> input

Measured memory_bytes: 4212
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int timeLimit = sc.nextInt();
        int minCost = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int c = sc.nextInt();
            int t = sc.nextInt();
            if (t <= timeLimit && c < minCost) {
                minCost = c;
            }
        }
        sc.close();

        if (minCost != Integer.MAX_VALUE) {
            System.out.println(minCost);
        } else {
            System.out.println("TLE");
        }
    }

}


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


int main(){
	map<int,int> mp;
	map<int,int>::iterator it;
	int a,b;
	while(cin>>a>>b){
		mp.clear();
		++mp[a];
		++mp[b];
		while(cin>>a>>b,a||b){
			++mp[a];
			++mp[b];
		}
		bool ok=true;
		for(it=mp.begin();it!=mp.end();++it){
			int a,n;
			a=it->first;
			n=it->second;
			if(  !( a<=2&&n%2 || 2<a&&n%2==0 ) ){
				ok=false;
				break;
			}
		}
		cout<<(ok?"OK":"NG")<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>

int main(void)
{
	int n, m, sum, hit, i;
	
	while (scanf("%d", &n), n != 0){
		sum = 0;
		for (i = 0; i < n / 4; i++){
			scanf("%d", &hit);
			sum += hit;
		}
		printf("%d\n", sum);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
    int N;
    cin >> N;
    Graph G(N);
    vint dist(N,-1);
    queue<int> que;

    REP(i,N){
        int u,k,v;
        cin >> u >> k;
        u--;
        REP(j,k){
            cin >> v;
            v--;
            G[u].pb(v);
        }
    }

    dist[0] = 0;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(auto nv:G[v]){
            if(dist[nv] != -1)continue;
            dist[nv] = dist[v]+1;
            que.push(nv);
        }
    }

    REP(i,N){
        cout << (i+1) << " " << dist[i] << endl;
    }


}


Measured memory_bytes: 3160
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll N;
    cin >> N;
    if (N/10 == 9 || N%10 == 9) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

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

    int a[100] = {};

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

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

}



Measured memory_bytes: 3088
#include <vector>
#include <iostream>
#include <functional>
using namespace std;
const int mod = 1000000007;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> cs;
	for (int i = 2; i * i <= M; ++i) {
		int cnt = 0;
		while (M % i == 0) {
			M /= i;
			++cnt;
		}
		if (cnt >= 1) cs.push_back(cnt);
	}
	if (M != 1) cs.push_back(1);
	vector<int> inv(32);
	inv[1] = 1;
	for (int i = 2; i < 32; ++i) inv[i] = (long long)inv[mod % i] * (mod - mod / i) % mod;
	function<int(int, int)> comb = [&](int n, int m) {
		int mul = 1;
		for (int i = n; i > n - m; --i) {
			mul = (long long)mul * i % mod;
		}
		for (int i = 1; i <= m; ++i) {
			mul = (long long)mul * inv[i] % mod;
		}
		return mul;
	};
	int ans = 1;
	for (int i : cs) {
		int subans = comb(N + i - 1, i);
		ans = (long long)ans * subans % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

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

int N, M;
int ball[100005];
bool red[100005];

int main() {
  cin >> N >> M;
  red[1] = true;

  rep(i, N) {
    ball[i+1] = 1;
  }

  rep(i, M) {
    int x, y;
    cin >> x >> y;
    ball[x]--;
    ball[y]++;
    if (red[x]) {
      red[y] = true;
    }
    if (ball[x] == 0) {
      red[x] = false;
    }
  }

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


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N), b(N), c(N);
  for (int i=0; i<N; i++)
    cin >> a.at(i) >> b.at(i) >> c.at(i);
  
  vector<vector<int>> dp(N, vector<int> (3));
  dp.at(0).at(0) = a.at(0);
  dp.at(0).at(1) = b.at(0);
  dp.at(0).at(2) = c.at(0);
  
  for(int i=1; i<N; i++){
    for(int j=0 ;j<3; j++){
    if(j==0)
      dp.at(i).at(j) = max(dp.at(i-1).at(1), dp.at(i-1).at(2)) + a.at(i);
    if(j==1)
      dp.at(i).at(j) = max(dp.at(i-1).at(0), dp.at(i-1).at(2)) + b.at(i);
    if(j==2)
      dp.at(i).at(j) = max(dp.at(i-1).at(0), dp.at(i-1).at(1)) + c.at(i);
    }
  }
  cout << max(max(dp.at(N-1).at(0), dp.at(N-1).at(1)), dp.at(N-1).at(2)) << endl;
}

Measured memory_bytes: 6912
def main():
    N = input()
    len_N = len(N)
    K = int(input())
    dp = [[[0] * (K+5) for _ in range(2)] for _ in range(len_N + 5)]
    dp[0][0][0] = 1
    for i in range(1,len_N+1):
        for smaller in range(2):
            for k in range(K+1):
                if smaller == 0:
                    for x in range(int(N[i-1])+1):
                        if int(N[i-1]) == x:
                            if x == 0:
                                dp[i][smaller][k] += dp[i-1][smaller][k]
                            else:
                                dp[i][smaller][k+1] += dp[i-1][smaller][k]
                        else:
                            if x == 0:
                                dp[i][1][k] += dp[i-1][smaller][k]
                            else:
                                dp[i][1][k+1] += dp[i-1][smaller][k]
                else:
                    for x in range(10):
                        if x == 0:
                            dp[i][smaller][k] += dp[i-1][smaller][k]
                        else:
                            dp[i][smaller][k+1] += dp[i-1][smaller][k]


    print(dp[len_N][0][K] + dp[len_N][1][K])







if __name__ == "__main__":
    main()

Measured memory_bytes: 40048
#include<stdio.h>

int main(){
  int N,i,j,c,key;
  int A[1000];
  scanf("%d",&N);
  if((1<=N)&&(N<=100)){
  for(i=0;i<N;i++){
  scanf("%d",&A[i]);
}
}
  for(i=0;i<N-1;i++)
  printf("%d ",A[i]);

  printf("%d",A[i]);

  printf("\n");
  
  for(j=1;j<N;j++){
  key=A[j];
  i=j-1;
  while((i>=0)&&(A[i]>key)){
  A[i+1]=A[i];
  i--;
}
  A[i+1]=key;
  for(c=0;c<N-1;c++)
  printf("%d ",A[c]);
  printf("%d",A[c]);
  printf("\n");
}
  return 0;
}



Measured memory_bytes: 2112
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();
		int C = sc.nextInt();
		sc.close();
		if(A > B) {
			System.out.println(0);
		}else {
			int cnt = 0;
			int num = B;
			while(cnt < C) {
				num -= A;
				cnt++;
				if(num < A) {
					break;
				}
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 22612
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();
        int c = sc.nextInt();
        int d = sc.nextInt();

        for(;;) {
            c -= b;
            if(c <= 0){
                System.out.println("Yes");
                return;
            }
            a -= d;
            if(a <= 0){
                System.out.println("No");
                return;
            }
        }
    }
}


Measured memory_bytes: 35532
// by adiforluls
#pragma GCC optimize ("-O2")
#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 FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul             1000000007
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define mod             998244353 
#define pll             pair<ll,ll>
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
    string s; cin>>s;
    int n = s.size();
    vi v, ans(n,0);
    rep(i,0,n-1)
    {
        if(s[i] == 'R') v.pb(i);
        if(s[i] == 'R' and s[i+1] == 'L')
        {
            while(v.size())
            {
                if((i-v.back())%2 == 0) ans[i]++;
                else ans[i+1]++;
                v.pop_back();
            }
        }
    }
    v.clear();
    rfor(i,n,1)
    {
        if(s[i] == 'L') v.pb(i);
        if(s[i] == 'L' and s[i-1] == 'R')
        {
            while(v.size())
            {
                if((v.back()-i)%2 == 0) ans[i]++;
                else ans[i-1]++;
                v.pop_back();
            }
        }
    }
    for(int i:ans) cout<<i<<" ";
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; /*cin>>t;*/ t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1480
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N, M = LI()
ps = [0 for i in range(M)]
for i in range(M):
    p,s = input().split()
    p = int(p)
    p -= 1
    s = str(s)
    ps[i] = [p,s]

# ACs = [0 for i in range(N)]
tmp = 0
ans = [[0,0] for i in range(N)] # AC, WA
for i in range(M):
    p, s = ps[i]
    if ans[p][0]:
        pass
    else:
        if s == "AC":
            ans[p][0] = 1
        else:
            ans[p][1] += 1

anss = [0, 0]
for i in range(N):
    if ans[i][0]:
        anss[0] += 1
        anss[1] += ans[i][1]

print(anss[0], anss[1])


Measured memory_bytes: 34544
n = gets.to_i
a = []
n.times do |i|
  x,y = gets.chomp.split(" ").map(&:to_i)
  a.push([x,y])
end
a = a.sort{|a, b| a[1] <=> b[1] }
sum = 0
a.each do |x|
  sum += x[0]
  if sum > x[1]
    puts "No"
    exit
  end
end
puts "Yes"


Measured memory_bytes: 30588
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int, Int> pii;
typedef pair<Int, double> pid;
typedef pair<double, double> pdd;
typedef pair<Int, pii> pip;
typedef pair<pii, Int> ppi;
typedef pair<double, Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<ppi> vecppi;
typedef vector<veci> mati;
typedef vector<vecll> matll;
typedef vector<vecd> matd;
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i, a, b) for(int i = (a);i <= (b);i++)
#define FORO(i, n) REP(i,0,(int)n-1)
#define FORI(i, n) REP(i,1,(int)n)
#define FORIT(i, t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a, _b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DEBUG 1
#if DEBUG
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
#else
#define DUMP(a)
#define DUMPLN(a)
#endif
template<typename T, typename U>
inline void getMin(T &a, U b) { if (a > b) a = b; }
template<typename T, typename U>
inline void getMax(T &a, U b) { if (a < b) a = b; }
template<typename T>
vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T>
vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T>
vector<T> getEmptyVector() { return vector<T>(); }
template<typename T>
void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1 << 17;
const int inf = 1 << 27;
const ll llinf = 1LL << 50;
const int NIL = -inf;
int popcount(int x) { return __builtin_popcount(x); }

void test_case() {
    int N, X, T;
    cin >> N >> X >> T;
    cout << ((N + X - 1) / X) * T << endl;
}

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

    int T = 1;
    while(T--) {
        test_case();
    }

    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int data[] = new int[26];
        String test = "abcdefghijklmnopqrstuvwxyz";
        String str,str2;
        int j,i;

        while(sc.hasNext()) {
            str = sc.nextLine();
            str2=str.toLowerCase();

            for(i=0;i<str2.length();i++){
            	for(j=0;j<26;j++) {
            		if(test.charAt(j)==str2.charAt(i)) {
            			data[j]++;
            		}
            	}
            }
            
        }
        for(i=0;i<26;i++){
        	System.out.println(test.charAt(i)+" : "+data[i]);
        }
        sc.close();
    }
}



Measured memory_bytes: 26188
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll a;
  cin >> a;
  string b;
  cin >> b;
  int b1, b2 = 0, b3 = 0;
  rep(i, b.size()){
    if(i == 0){
      b1 = b.at(i) - '0';
    }
    if(i == 1) continue;
    if(i == 2) b2 = b.at(i) - '0';
    if(i == 3) b3 = b.at(i) - '0';
  }
  // cerr << b1 << " " << b2 << " " << b3 << endl;
  ll ans = a * b1;
  // cerr << ans << endl;
  ans *= 10;
  ans += a * b2;
  // cerr << ans << endl;
  ans *= 10;
  ans += a * b3;

  ans /= 100;
  cout << ans << endl;
  return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
signed main() {
    cin>>A>>B>>C;
    int m=max({A,B,C});
    int ans=m*9+A+B+C;
    cout<<ans<<endl;
}


Measured memory_bytes: 768
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}


template<typename T> class segtree{
private:
    int n,sz;
    vector<T> node;
public:
    segtree(const vector<T>& v) : n(1), sz((int)v.size()){
        while(n < sz) n *= 2;
        node.resize(2*n-1, numeric_limits<T>::min());
        for(int i = 0; i < sz; i++){
            node[i+n-1] = v[i];
        }
        for(int i=n-2; i>=0; i--){
            node[i] = max(node[i*2+1], node[i*2+2]);
        }
    }
    void update(int k,T a){
        k += n-1;
        node[k] = a;
        while(k>0){
            k = (k-1)/2;
            node[k] = max(node[2*k+1],node[2*k+2]);
        }
    }
    T query(int a,int b,int k=0,int l=0,int r=-1){
        if(r < 0) r = n;
        if(r <= a || b <= l){
            return numeric_limits<T>::min();
        }
        if(a <= l && r <= b){
            return node[k];
        }else{
            T vl = query(a,b,2*k+1,l,(l+r)/2);
            T vr = query(a,b,2*k+2,(l+r)/2,r);
            return max(vl,vr);
        }
    }
    void print(){
        for(int i = 0; i < sz; i++){
            cout<<query(i,i+1)<< " ";
        }
        cout<<endl;
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<ll>v(400001);
    segtree<ll>seg(v);
    while(n--){
        int x;
        cin >> x;
        int l = max(0, x - k);
        int r = min(350000, x + k);
        ll hoge = seg.query(l, r+1);
        seg.update(x, hoge + 1);

    }
    ll ans = 0;
    rep(i,300001){
        ans = max(ans, seg.query(i, i + 1));
    }
    cout << ans << endl;
}


Measured memory_bytes: 14572
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

// off: この場所で繰り上がって「いない」ときの，枚数の最小値
// on: この場所で繰り上がって「いる」ときの，枚数の最小値
int off[1000020];
int on[1000020];
	
int main(){
	on[0] = 1;
	string s; cin >> s;
	int sz = s.size();
	vector<int> ans(sz+10, 0);
	for( int i = 0; i < sz; ++i ){
		int d = s[i]-'0';
		off[i+1] = min( off[i]+d, on[i]+(10-d) );
		on[i+1] = min( off[i]+d+1, on[i]+(10-d)-1 );
	}
	cout << off[sz] << endl;
}

Measured memory_bytes: 13060
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.{NumericRange, Queue}
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val N, M = sc.nextInt
    val uf = new IUnionFind(N)
    var citySet = mutable.Set[Int]()
    for (_ <- Range(0, M)) {
      val x, y = sc.nextInt - 1
      citySet += x
      citySet += y
      uf.union(x, y)
    }
    var city = 0
    var village = 0
    for (i <- Range(0, N)) (if (uf.root(i) == i) {
      village += 1
      if (citySet.contains(i)) (city += 1)
    })
    village -= city
    println(math.abs(city - village))

  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


Measured memory_bytes: 45376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }


int main() {
    int a,b; cin >> a >> b;
    if(a%2==0 || b%2==0) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int jud(char a){
  if(a=='A'||a=='G'||a=='T'||a=='C')return 1;
  else return 0;
}
int main(){
  int i,j,c,r=0;
  char s[11];
  scanf("%s",s);
  for(i=0;i<strlen(s);i++){
    c=0;
    if(jud(s[i]))for(j=i;jud(s[j]);j++)c++;
    if(r<c)r=c;
  }
  printf("%d",r);
  return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {
    public static MyScanner scan;
    public static PrintWriter out;
    public static void main(String[] args) {
        scan=new MyScanner();
        out=new PrintWriter(new BufferedOutputStream(System.out));

        int t=1;
//        int t=scan.nextInt();
        while(t-->0) {

            int n=scan.nextInt(),a=scan.nextInt(),b=scan.nextInt(),brank=0,passed=0;
            String s=scan.nextLine();
            for(int c=0;c<n;c++) {
                if(s.charAt(c)=='a') {
                    if(passed<a+b) {
                        passed++;
                        out.println("Yes");
                    } else out.println("No");
                } else if(s.charAt(c)=='b') {
                    brank++;
                    if(passed<a+b&&brank<=b) {
                        passed++;
                        out.println("Yes");
                    } else out.println("No");
                } else out.println("No");
            }

        }
        out.close();
    }

    //scanner
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 29396
#include <cstdio>
#include <algorithm>
int main() {
	int a[4], b[4];
	for(int i = 1; i <= 3; i++) 
		scanf("%d", &a[i]);
	b[1] = abs(a[1] - a[2]);
	b[2] = abs(a[2] - a[3]);
	b[3] = abs(a[1] - a[3]);
	std::sort(b+1, b+4);
	printf("%d", b[1] + b[2]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int h, w;
string s[100];

int main() {
	int i, j;
	
	cin >> h >> w;
	rep(i, h) cin >> s[i];
	
	rep(i, h + 2) {
		rep(j, w + 2) {
			if (i == 0 || i == h + 1 || j == 0 || j == w + 1) {
				cout << '#';
			}
			else {
				cout << s[i - 1][j - 1];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//ALDS1_10_C
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
	string X, Y;
	int q;
	vector<vector<int> > dp;

	cin>>q;
	for(int i=0;i<q;i++){
		cin>>X;
		cin>>Y;

		dp.resize(X.length()+1);
		for(int j=0;j<=X.length();j++)
			dp[j].resize(Y.length()+1);

		for(int j=0;j<=X.length();j++)
			dp[j][0] = 0;
		for(int k=0;k<=Y.length();k++)
			dp[0][k] = 0;

		for(int j=1;j<=X.length();j++){
			for(int k=1;k<=Y.length();k++){
				if(X[j-1] == Y[k-1])
					dp[j][k] = dp[j-1][k-1] + 1;
				else
					dp[j][k] = max(dp[j-1][k], dp[j][k-1]);
			}
		}

		cout<<dp[X.length()][Y.length()]<<endl;
	}

	return 0;
}

Measured memory_bytes: 4964
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int mod = (int)1e9 + 7;
        
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        long[][] dp = new long[1010][1010];
        dp[0][0] = 1;
        
        boolean[] kb = new boolean[1010101];
        for(int i=0; i<h; i++){
            char[] line = sc.next().toCharArray();
            for(int j=0; j<w; j++){
                if(line[j]=='#'){
                    kb[i*w+j] = true;
                }
            }
        }
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(i+1<h && !kb[(i+1)*w+j]){
                    dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
                }
                if(j+1<w && !kb[i*w+j+1]){
                    dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod;
                }
            }
        }
        
        System.out.println(dp[h-1][w-1]);
    }
}


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

struct UnionFind {
	vector<int> par;
	vector<int> rank;
	
	UnionFind(int N){
		rep(i,N){
			par.push_back(i);
			rank.push_back(0);
		}
	}
	
	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y){
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		if(rank[x] < rank[y]){
			par[rx] = ry;
		}else{
			par[ry] = rx;
			if(rank[rx] == rank[ry]) rank[rx]++;
		}
	}
	
	bool same(int x, int y){
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main(){
	int N,M;
	cin >> N >> M;
	vector<pair<int,int>> p(M);
	rep(i,M){
		int a,b;
		cin >> a >> b;
		a--;b--;
		p[i] = make_pair(a,b);
	}
	
	int ans = 0;
	
	//i番目の辺を取り除く
	rep(i,M){
		UnionFind tree(N);
		rep(j,M){
			if(j == i) continue;
			tree.unite(p[j].first, p[j].second);
		}
		bool ok = false;
		//グラフが連結かどうか調べる。
		for (int j = 0; j < N; ++j) {
			for (int k = j+1; k < N; ++k) {
				if(tree.same(j,k) == false){
					ok = true;
				}
			}
		}
		if(ok){
			ans++;
		}
	}
	
	cout << ans << endl;
	
    return 0;
}



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

/*map<pair<ll, ll>, ll> memorised;

ll rec_sol(ll l, ll r){
	cout << l << " " << r << endl;
	if (l > r){
		return 0ll;
	}
	if (l == r){
		return 1ll;
	}
	if (memorised.find(mp(l, r)) != memorised.end()){
		return memorised[mp(l, r)];
	}
	ll ind;
	for(ind = 62; ind >= 0; ind--){
		if ((l & (1ll << ind)) && (r & (1ll << ind))){
			l ^= (1ll << ind);
			r ^= (1ll << ind);
		}
		if ((l & (1ll << ind)) != (r & (1ll << ind))){
			break;
		}
	}
	if (memorised.find(mp(l, r)) != memorised.end()){
		return memorised[mp(l, r)];
	}
	ll mid = (1ll << ind) - 1;
	ll ans = rec_sol(l, mid) + rec_sol(mid + 1, r);
	return memorised[mp(l, r)] = ans;
}*/

void solve(){
	ll l, r;
	cin >> l >> r;
	//cout << rec_sol(l, r) << endl;
	if (l == r){
		cout << 1 << endl;
		return;
	}
	ll ind;
	for(ind = 62ll; ; ind--){
		if ((l & (1ll << ind)) && (r & (1ll << ind))){
			l ^= (1ll << ind);
			r ^= (1ll << ind);
		}
		if ((l & (1ll << ind)) != (r & (1ll << ind))){
			break;
		}
	}
	ll mid = (1ll << ind) - 1;
	
	ll ans = mid - l + 1;
	
	r ^= (1ll << ind);
	
	ll k;
	for(k = ind; k >= 0; k--){
		if (r & (1ll << k)){
			break;
		}
	}
	k++;
	ll v = (1ll << k) - 1ll;
	
	if (l <= v + 1){
		ans += (1ll << ind);
	} else {
		ans += (1ll << ind) - (l - v - 1);
	}
	
	//cout << l << " " << mid << " " << r << " " << v << endl;
	
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll v = (1 + n) * n / 2;
    ll suma = accumulate(all(a), 0LL);
    if (suma % v != 0) {
        cout << "NO" << endl;
        return 0;
    }
    ll k = suma / v;
    rep(i, n) {
        ll b = a[(i + 1) % n] - a[i] - k;
        if (b == 0) continue;
        if ((b > 0) || (b % n != 0)) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 4000