akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15)+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
using pli=pair<llint,int>;
using daic=priority_queue<pli,vector<pli>,greater<pli>>;
int main(void){
	int x,a,b;cin>>x>>a>>b;
	cout<<(x-a)%b<<endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	lower := max(a, c)
	upper := min(b, d)

	fmt.Println(max(0, upper-lower))
}


Measured memory_bytes: 512
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let n = parse!(it);
    let mut q = vec![0; n];
    for i in 0..n {
        let p: usize = parse!(it);
        q[p - 1] = i;
    }
    let mut m = 1;
    let mut c = 1;
    for i in 1..n {
        if q[i - 1] < q[i] {
            c += 1;
            m = std::cmp::max(m, c);
        } else {
            c = 1
        }
    }
    println!("{}", n - m);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x, y;
  cin >> x >> y;
  if (x == 0){
    if (y >= 0){
      cout << y << endl;
    } else {
      cout << 1 - y << endl;
    }
  } else if (y == 0){
    if (x <= 0){
      cout << -x << endl;
    } else {
      cout << x + 1 << endl;
    }
  } else if (x <= y){
    if (x >= 0 && y >= 0){
      cout << y - x << endl;
    } else if (x <= 0 && y <= 0){
      cout << y - x << endl;
    } else if (abs(x) <= abs(y)){
      cout << y + x + 1 << endl;
    } else {
      cout << -x - y + 1 << endl;
    }
  } else {
    if (x >= 0 && y >= 0){
      cout << x - y + 2 << endl;
    } else if (y <= x && x <= 0){
      cout << x - y + 2 << endl;
    } else if (abs(x) <= abs(y)){
      cout << -x - y + 1 << endl;
    } else {
      cout << x + y + 1 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <stack>
#include <vector>

typedef long long ll;
using namespace std;



int main()
{
	int H, W;
	cin >> H >> W;

	char image[150][150];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> image[i][j];
		}
	}

	for (int i = 0; i < 2 * H; i++) {
		for (int j = 0; j < W; j++) {
			cout << image[i / 2][j];
		}
		cout << endl;
	}

	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int n,m,q,nx[200005],pr[200005],r=0;
bool ex[200005];
void odd(int x){
    if(x%2==1){
        for(int i=0;i<x;i++){
            r=pr[r];
        }
    }else{
        for(int i=0;i<x;i++){
            r=nx[r];
        }
    }
    nx[pr[r]]=nx[r];
    pr[nx[r]]=pr[r];
    ex[r]=true;
    r=nx[r];
}
int main(void){
    scanf("%d%d%d",&n,&m,&q);
    for(int i=0;i<n;i++){
        nx[i]=(i+1)%n;
    }
    for(int i=0;i<n;i++){
        pr[nx[i]]=i;
    }
    for(int i=0;i<m;i++){
        int a;
        scanf("%d",&a);
        odd(a);
    }
    for(int i=0;i<q;i++){
        int a;
        scanf("%d",&a);
        if(ex[a])printf("0\n");
        else printf("1\n");
    }
}



Measured memory_bytes: 4928
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   int n,m;
   cin>>n>>m;
   int x=0;
   x=(1900*m+(n-m)*100)*pow(2,m);
   cout<<x<<endl;
   
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	bool a[27],ok;
	char s[105];
	while(~scanf("%s",s + 1)){
		ok = true;
		for(int i = 1;i <= 26;i++) a[i] = 1;
		for(int i = 1;i <= strlen(s + 1);i++) a[s[i] - 'a' + 1] ^= 1;
		for(int i = 1;i <= 26;i++) ok &= a[i];
		if(ok) printf("Yes\n");
		else printf("No\n");
	}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
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; }
const ll INF = 1e18;

// auto mod int
// depends on Template

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

mint dp[2010][2010];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //input
    ll n;
    cin >> n;
    vector<ll>p,m;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        p.push_back(x+y);
        m.push_back(x-y);
    }
    ll ans = 0;
    sort(p.begin(),p.end());
    sort(m.begin(),m.end());
    chmax(ans,abs(p[n-1]-p[0]));
    chmax(ans,abs(m[n-1]-m[0]));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 38244
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<stack>
#include<set>
#include<cmath>

#define REP(i,s,e) for(int i=int(s);i<int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

#define EPS 1e-6

using namespace std;

int main(){

	stack<int>cars;

	int a;
	while(true){

	cin >> a;
	if(cin.fail()) break;

	if(a!=0) cars.push(a);
	else{
	     cout << cars.top() << endl;
	     cars.pop();
	}
	}

	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



ll dfs(ll a, ll b, ll c, ll d, ll n) {
	map<ll, ll> m;

	min_priority_queue<pair<ll, ll>> q;

	q.push({ 0,n });
	if (n == 1)return d;


	ll ans = INFL;

	if (n < 5e9)ans = d * n;
	while (!q.empty()) {
		auto k = q.top();
		q.pop();
		if (k.first >= ans)break;
		//cerr << k.first << ' ' << k.second << endl;
		//cerr << q.size() << endl;
		if (m[k.second] != k.first)continue;
		if (k.second == 1) {
			ans = min(ans, k.first + d);
			continue;
		}
		if (k.second < 5e9)ans = min(ans, d*k.second + k.first);

		for (ll i = -4; i <= 4; i++) {
			ll cost = abs(i*d);

			if (k.second + i <= 0)continue;
			
			if ((k.second + i) % 2 == 0 && abs(i) < 2) {
				if (m[(k.second + i) / 2] > k.first + cost + a || m[(k.second + i) / 2] == 0) {
					q.push({ k.first + cost + a,(k.second + i) / 2 });
					m[(k.second + i) / 2] = k.first + cost + a;
				}
			}
			if ((k.second + i) % 3 == 0 && abs(i) < 3) {
				if (m[(k.second + i) / 3] > k.first + cost + b || m[(k.second + i) / 3] == 0){
					q.push({ k.first + cost + b,(k.second + i) / 3 });
					m[(k.second + i) / 3] = k.first + cost + b;
				}
			}
			if ((k.second + i) % 5 == 0) {
				if (m[(k.second + i) / 5] > k.first + cost + c || m[(k.second + i) / 5] == 0) {
					q.push({ k.first + cost + c,(k.second + i) / 5 });
					m[(k.second + i) / 5] = k.first + cost + c;
				}
			}
		}

	}
	return ans;


}




int main() {

	ll t;
	cin >> t;

	REP(_, t) {
		ll n, a, b, c, d;
		cin >> n >> a >> b >> c >> d;
		cout << dfs(a, b, c, d, n) << endl;
	}



}

Measured memory_bytes: 4256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static long[] ans;
	static boolean[] seen;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int Q = in.nextInt();
		ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>() {
			{
				for (int i = 0; i < N; i++) {
					add(new ArrayList<Integer>());
				}
			}
		};
		for (int i = 0; i < N - 1; i++) {
			int a = in.nextInt() - 1;
			int b = in.nextInt() - 1;
			list.get(a).add(b);
			list.get(b).add(a);
		}
		ans = new long[N];
		seen = new boolean[N];
		for (int i = 0; i < Q; i++) {
			ans[in.nextInt() - 1] += in.nextInt();
		}
		dfs(list, 0, -1);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < ans.length; i++) {
			if (i == ans.length - 1) {
				sb.append(ans[i]);
			} else {
				sb.append(ans[i]);
				sb.append(" ");
			}
		}
		System.out.println(sb.toString());
		in.close();
	}

	static void dfs(ArrayList<ArrayList<Integer>> list, int v, int p) {
		seen[v] = true;
		if (p != -1) {
			ans[v] += ans[p];
		}
		for (Integer nv : list.get(v)) {
			if (seen[nv] == true) {
				continue;
			}
			dfs(list, nv, v);
		}
	}
}

Measured memory_bytes: 218056
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <assert.h>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>                                    
#include <deque>                                    
#include <queue>
#include <iomanip>
#include <ctime>
#include <random>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;

 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)1e6 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[N], used[N], lp[N];
vector <int> pr;
 
int gcd (int a, int b) {
   if (!b) return a;
   return gcd (b, a % b);
}

inline void boost () {
   ios_base :: sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
}

inline void Solve () {
   cin >> n;
   for (int i = 2; i <= 1000000; i ++) {
      if (!lp[i]) {
         lp[i] = i;
         pr.pb (i);
      }
      for (int j = 0; j < sz (pr) && pr[j] <= lp[i] && i * pr[j] <= 1000000; j ++)
         lp[i * pr[j]] = pr[j];
   }
   bool ok = 1;
   int G = 0;
   for (int i = 1; i <= n; i ++) {
      cin >> a[i];
      G = gcd (G, a[i]);
      int x = a[i];
      while (x > 1) {
         if (used[lp[x]])   
            ok = 0;
         x /= lp[x];
      }
      x = a[i];
      while (x > 1) {
         used[lp[x]] = 1;
         x /= lp[x];
      }
   }
   if (ok) cout << "pairwise coprime";
   else if (G == 1) cout << "setwise coprime";
   else cout << "not coprime";
}               
 
signed main () {                                       
   //#ifdef QWERTY
   //   freopen("input", "r", stdin);
   //#endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                 



Measured memory_bytes: 15396
n = int(input())

int_list = []
for i in range(1, n+1):
    x = i
    if x % 3 == 0:
        int_list.append(i)
    else:
        while x != 0:
            if x % 10 == 3:
                int_list.append(i)
                break
            x //= 10

print(' '+' '.join(list(map(str, int_list))))



Measured memory_bytes: 6104
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    A = int(input())
    print(A + A ** 2 + A ** 3)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9612
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){

  int h,w;
  int memo[111][111]={{0}};

  scanf("%d %d",&h,&w);

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int c;
      scanf(" %c",&c);
      if(c=='c') memo[i][j]=0;
      else memo[i][j]=-1;
      
      if(memo[i][j]==-1 && j>0 && memo[i][j-1]!=-1){
	memo[i][j]=memo[i][j-1]+1;
      }
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      printf("%d ",memo[i][j]);
    }
    printf("%d\n",memo[i][w-1]);
  }

  return 0;
}

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

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

    for (int i = 0; i < n; i++) {
        int h = 0;
        if (i != 0) {
            h = t[i-1];
            k ^= a[i-1];
        }
        while (h < n && (k & a[h]) == 0) {
            k ^= a[h];
            h++;
        }
        t[i] = h;
    }

    unsigned long long c = 0;
    for (int i = 0; i < n; i++) {
        c += t[i] - i;
    }
    std::cout << c << std::endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18
#define PI 3.1415926535

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
  int N; cin >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];

  ll ans1 = 0;
  ll ans2 = 0;
  ll sum1 = 0;
  ll sum2 = 0;
  rep(i,N){ // 最初が正の場合
    if(i % 2 == 0){
      if(sum1 + a[i] <= 0){
        ans1 += abs(sum1 + a[i] - 1);
        sum1 = 1;
      }
      else sum1 += a[i];
    }
    if(i % 2 == 1){
      if(sum1 + a[i] >= 0){
        ans1 += abs(sum1 + a[i] + 1);
        sum1 = -1;
      }
      else sum1 += a[i];
    }
  }
  rep(i,N){ // 最初が負の場合
    if(i % 2 == 1){
      if(sum2 + a[i] <= 0){
        ans2 += abs(sum2 + a[i] - 1);
        sum2 = 1;
      }
      else sum2 += a[i];
    }
    if(i % 2 == 0){
      if(sum2 + a[i] >= 0){
        ans2 += abs(sum2 + a[i] + 1);
        sum2 = -1;
      }
      else sum2 += a[i];
    }
  }
  ll ans = min(ans1,ans2);
  cout << ans << endl;
}
   

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

string s; 

inline int qr()
{
	int x=0,w=1;char a=0;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a<='9'&&a>='0'){x=(x<<3)+(x<<1)+(a^48);a=getchar();}
	return x*w;
}

int main()
{
	cin>>s;
	int len=s.length();
	for(int i=1;i<=len;i++)
		cout<<'x';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int min(int x, int y, int z)
{
  int w;
  w=x;
  if(w>=y) w=y;
  if(w>=z) w=z;
  return w;
}
 
int main(void)
{
    int i,j,H,W,S=0;
    int dp[2][1400];
    int a[1400][1400];
 
    scanf("%d%d",&H,&W);
    for(i=0;i<=H-1;i++)
    {
        for(j=0;j<=W-1;j++)
        {
           scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<=W-1;i++)
    {
        if(a[0][i]==0)
        {
            dp[0][i]=1;
        }
        else
        {
            dp[0][i]=0;
        }
        if(S<dp[0][i])
        {
            S=dp[0][i];
        }
    }
    for(i=1;i<=H-1;i++)
    {
        for(j=0;j<=W-1;j++)
        {
            if(j==0)
            {
                if(a[i][j]==0)
                {
                    dp[1][j]=1;
                }
                else
                {
                    dp[1][j]=0;
                }
            }
            else
            {
                if(a[i][j]==0)
	        {
                    dp[1][j]=min(dp[0][j-1],dp[0][j],dp[1][j-1])+1;  
                }
                else
                {
                   dp[1][j]=0;
                }
            }
            if(S<dp[1][j])
            {
                S=dp[1][j];
            }
        }
        for(j=0;j<=W-1;j++)
        {
            dp[0][j]=dp[1][j];
        }
    }
  printf("%d\n",S*S);
  return 0;
}

Measured memory_bytes: 8268
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,M;
vector<int>v[100010];
vector<int>w[2];
bool used[100010];
void dfs(int x,int num){
	w[num].push_back(x);
	used[x]=true;
	REP(i,v[x].size()){
		if(used[v[x][i]]==false){
			dfs(v[x][i],num);
			break;
		}
	}
}

int main(){
	cin>>N>>M;
	REP(i,M){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	REP(i,N){
		used[i]=false;
	}
	dfs(0,0);
	dfs(0,1);
	reverse(w[0].begin(),w[0].end());
	cout<<w[0].size()+w[1].size()-1<<endl;
	REP(i,w[0].size()-1){
		cout<<w[0][i]+1<<" ";
	}
	REP(i,w[1].size()){
		cout<<w[1][i]+1;
		if(i==w[1].size()-1){
			cout<<endl;
		}else{
			cout<<" ";
		}
	}
	return 0;
}

Measured memory_bytes: 9720
import java.util.Scanner;

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

		int s = sc.nextInt();
		int w = sc.nextInt();

		if (s <= w) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}

		sc.close();

	}
}


Measured memory_bytes: 27032
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

ll X, K, D;
int main(void){
    cin >> X >> K >> D;
    X = abs(X);
    if(X / D >= K) {
        cout << X - K*D << endl;
        return 0;
    }

    ll cnt = X / D;
    ll a = X % D;
    ll b = abs(a-D);
    if ((cnt%2) == (K%2)) cout << a << endl;
    else cout << b << endl;

    return 0;
}



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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,d,x;
    cin>>n>>d>>x;
    //cout<<n<<d<<x;
    int total=0;
    while(n--)
    {
        int a;
        cin>>a;
        int temp=1;
        for(int i=1;(i*a+1)<=d;i++)
        {
            temp++;
        }
        total+=temp;
    }
    cout<<total+x<<"\n";
}

Measured memory_bytes: 3568
import sys


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    a, b, c = _ia()
    k = _i()

    cnt = 0
    while b <= a:
        b *= 2
        cnt += 1

    while c <= b:
        c *= 2
        cnt += 1

    return "Yes" if cnt <= k else "No"


if __name__ == "__main__":
    print(main())


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

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n,k;cin>>n>>k;
  vector<int> a(n);rep(i,n)cin>>a[i];
  --n;--k;
  int ans = (n+k-1) / k;
  print(ans);
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <math.h>
#include <map>
#include <queue>

#define say(s) cout << s << endl
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define vec vector

using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
  int n, k;
  cin >> n >> k;
  vec<int> h(n);
  rep(i, n) cin >> h[i];

  ll dp[100010];
  rep(i, 100010) dp[i] = INF;

  rep(i, n) {
    if (i == 0) {
      dp[i] = 0;
      continue;
    }
    for (int j=1; j<=k; j++) {
      if (i-j < 0) {
        break;
      }
      dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }
  }

  say(dp[n-1]);

  return 0;
}


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

using namespace std;

int check(int n){
    int a = 0;
    while(n){
        a += n % 10;
        n /= 10;
    }

    return a;
}

int mn = 99999999, n;

int main() {

cin >> n;

for (int i = 1; i <= n - 1; ++i){
        if (check(i) + check(n - i) < mn) {mn = check(i) + check(n - i);}
}

cout << mn;

return 0;

}


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

#include <math.h>
#include <stdio.h>
#include <string.h>
typedef long long int ll;

using namespace std;

int main(void) {
	ll n, m;
	scanf("%lld%lld", &n, &m);	

	ll ans = 0;
	if (n >= 2 && m >= 2) {
		ans = n * m - 2 * (n + m) + 4;
	} else if (n == 1 && m == 1) {
		ans = 1;
	} else {
		ans = n==1?m-2:n-2;
	}

	printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x;
	scanf("%d",&x);
	if(x>=400&&x<=599)
	{
		printf("8\n");
	}
	else if(x>=600&&x<=799)
	{
		printf("7\n");
	}
	else if(x>=800&&x<=999)
	{
		printf("6\n");
	}
	else if(x>=1000&&x<=1199)
	{
		printf("5\n");
	}
	else if(x>=1200&&x<=1399)
	{
		printf("4\n");
	}
	else if(x>=1400&&x<=1599)
	{
		printf("3\n");
	}
	else if(x>=1600&&x<=1799)
	{
		printf("2\n");
	}
	else
	{
		printf("1\n");
	}
	return 0;
}

Measured memory_bytes: 3684
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n,k;
	cin>>n>>k;
	vi a(n);
	for(int i=0;i<n;cin>>a[i++]);
	sort(a.begin(), a.end(), greater<int>());
	unsigned ll ans = 0;
	debug(a);
	for(int i=k;i<n;i++) ans += a[i];
	cout<<ans;
	return 0;
}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
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; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    ll a, b;
    cin >> a >> b;
    ll res = a * b;
    cout << res << endl;
    return 0;
}

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

int main()
{
    ll a, b, i, j, ans;
    string x,y;
    cin>>a>>b;

    for(i=1; i<=b; i++)
    {
        x+=to_string(a);
    }
     for(i=1; i<=a; i++)
    {
        y+=to_string(b);
    }
    if(x>y)cout<<y<<endl;
    else cout<<x<<endl;


}

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

namespace _20180319_AOJ
{
    class ALDS1_11A
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                int n = int.Parse(line);
                int[,] graph = new int[n + 1, n + 1];
                for(int i=0;i<n;i++)
                {
                    int[] vertex = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                   int u = vertex[0];
                    for(int k=0;k<vertex[1]; k++)
                    {
                        graph[u, vertex[k + 2]] = 1;
                    }
                }

                for(int i=1;i<n+1;i++)
                {
                    for(int j=1;j<n;j++)
                    {
                        Console.Write(string.Format("{0} ", graph[i, j]));
                    }
                    Console.WriteLine(graph[i, n]);
                }
            }
        }
    }
}



Measured memory_bytes: 9884
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    ll start = a / x, end = b / x, ans = end - start + 1;
    if(a%x != 0) ans--;
    cout << ans << endl;
    
    return 0;
}

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

#define ipr pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k; i--)
#define ll unsigned long long
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define cnt_ones(x) __builtin_popcountll(x)

#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

const int Maxn = (int)1e5 + 1;
const ld pi = acos(-1);
const int m = (int)1e9 + 7;
const int inf = (int)1e18;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A) {
    fr(i, 0, (int)A.size()) out << A[i] << " ";
    return out;
}

int32_t main() {
    IOS int Q = 1;
    // cin >> Q;
    while (Q--) {
         int n;
     cin>>n;
    int temp=n;
    int ans1=1,ans2=1;
    int ans=1;
     while(temp--!=0){
         ans1=(ans1*9)%m;
         ans2=(ans2*8)%m;
         ans=(ans*10)%m;
         
     }
     int a=(ans-(2*ans1)%m)%m;
    a=(a+ans2)%m;
     cout<<(a+m)%m<<endl;
     
    }
    return 0;
}


Measured memory_bytes: 3628
import functools

N = int(input())

@functools.lru_cache(maxsize=None)
def find_lyuka(x):
    if x == 0:
        return 2
    elif x == 1:
        return 1
    else:
        return find_lyuka(x-1) + find_lyuka(x-2)

print(find_lyuka(N))


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll N; cin >> N;
    vector<string> A(N);
    REP(i, N) cin >> A[i];
    cout << "AC x " << count(A.begin(), A.end(), "AC") << "\n";
    cout << "WA x " <<  count(A.begin(), A.end(), "WA") << "\n";
    cout << "TLE x " <<  count(A.begin(), A.end(), "TLE") << "\n";
    cout << "RE x " <<  count(A.begin(), A.end(), "RE") << "\n";
}

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

ll dp[3001][3001];
ll sum[3001][3001];

ll slimes(vector<ll>& v,int i,int j){
    if(i==j){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    ll minCost = 1000000000000000;
    for(int k=i;k<j;k++){
        minCost = min(minCost,sum[i][j] + slimes(v,i,k) + slimes(v,k+1,j));
    }
    return dp[i][j] = minCost;
}

int main(){
    int n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    vector<ll> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i;j<n;j++)
        {
            sum[i][j] = v[j] + ((j==i) ? 0 : sum[i][j-1]);
        }
    }
    cout<<slimes(v,0,n-1);
    return 0;
}


Measured memory_bytes: 80128
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//ここから始めよう

signed main(){
    int n;cin>>n;
    string s[3];
    rep(i,0,3)cin>>s[i];
    int ans=0;
    rep(j,0,n){
        int cnt=0;
        rep(i,0,3){
            rep(k,0,3){
                if(i==k)continue;
                if(s[i][j]==s[k][j])cnt++;
            }
        }
        if(cnt==0)ans+=2;
        else if(cnt==2)ans++;
    }cout<<ans<<endl;return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  string a = s.substr(0, n / 2);
  string b = s.substr(n / 2);
  if (a == b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
	long long a, b, x; cin >> a >> b >> x;
	if (a == 0)cout << b / x + 1 << endl;
	else cout << b / x - (a - 1) / x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vint l(q);
	vint r(q);
	int ans=0;
	bool f;
	vint are(n+1);
	are[0] = 0;

	for (int i = 0;i < q;i++)
	{
		cin >> l[i] >> r[i];
	}

	for (int i = 0;i < n;i++)
	{
		if (s[i] == 'A')
		{
			f = true;
			are[i + 1] = are[i];
		}
		else if (s[i] == 'C'&&f)
		{
			f = false;
			ans++;
			are[i + 1] = are[i] + 1;
		}
		else
		{
			f = false;
			are[i + 1] = are[i];
		}

	}
	f = false;
	ans = 0;

	for (int i = 0;i < q;i++)
	{
		ans = are[r[i]]-are[l[i]];

		cout << ans << endl;
	}

	
}

Measured memory_bytes: 2256
n,c = map(int,input().split())
stc = [[int(i) for i in input().split()] for j in range(n)]

ans = 0

stc.sort(key=lambda x:(x[2],x[1],x[0]))

time = 10**5+1

c_imos = [[0 for i in range(time)] for j in range(c)]

for i in range(n):
    for j in range(stc[i][1]-stc[i][0]+1):
        c_imos[stc[i][2]-1][stc[i][0]-1+j] = 1


"""
for i in range(n):
    c_imos[stc[i][2]-1][stc[i][0]-1] += 1
    c_imos[stc[i][2]-1][stc[i][1]] -= 1
"""
#nd_v = [[0 for i in range(time)] for j in range(c)]
"""
for i in range(c):
    for j in range(time):
        if j == 0:
            if c_imos[i][j] == 1:
                nd_v[i][j] = 1
        else:
            nd_v[i][j] = nd_v[i][j-1] + c_imos[i][j]
"""
"""
for i in range(c):
    for j in range(time):
        if nd_v[i][j] >= 2:
            nd_v[i][j] = 1
"""
ans = 1

#print(c_imos)

for i in range(time):
    tmp = 0
    for j in range(c):
        tmp += c_imos[j][i]
    #print(i,tmp)
    ans = max(tmp,ans)

print(ans)

exit()
    
c_num = stc[0][2]
t_num = stc[0][1]
idx = 0
print(stc)
for i in range(1,n):
    print(t_num,i)
    if stc[idx+i][2] == c_num:
        if stc[idx+i][0] == t_num:
            stc[idx+i-1][1] = stc[idx+i][1]
            t_num = stc[idx+i][1]
            del stc[idx+i]
            idx -= 1
        else:
            print(t_num,t_num,t_num)
            c_num = stc[idx+i][2]
            t_num = stc[idx+i][1]

stc.sort(key=lambda x:x[1])
print(stc)
exit()
tmp = stc[0][1]

ans = 1
ans_tmp = 1

for i in range(1,len(stc)):
    for j in range(i+1,len(stc)):
        if tmp >= stc[j][0]:
            ans_tmp += 1
        else:
            tmp = stc[j][0]
            ans = max(ans_tmp,ans)

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

using namespace std;
int x, k, q, t, a, low, up, add, delta, now, ans, r[100007];
bool flag;

int cal(int tt, int lower = 0, int upper = x) {
    if (tt < lower) return lower;
    if (tt > upper) return upper;
    return tt;
}

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

    cin >> x >> k;
    for (int i = 1; i <= k; i++) cin >> r[i];
    cin >> q;

    low = x, now = 1;
    while (q--) {
        cin >> t >> a;
        while (t >= r[now] && now <= k) {
            delta = (flag ? 1 : -1) * (r[now] - r[now - 1]), add += delta;
            up = cal(delta + up), low = cal(delta + low);
            flag = !flag, now++;
        }
        ans = cal((flag ? 1 : -1) * (t - r[now - 1]) + cal(a + add, up, low));
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 1664
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

const long mod = 1_000_000_007;

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	long b = read.to!long;
	long w = read.to!long;
	
	long x = 0, y = 1, z = 0;
	
	long powerinv2 = 1;
	foreach(i; 0 .. b + w){
		
		if(i >= b){
			// x += (pascal(i - b, b) - pascal(i - b - 1, b)) / 2^i
			long temp = pascal(i - b, b);
			if(i - 1 >= b) temp += (mod - pascal(i - b - 1, b)), temp %= mod;
			temp *= powerinv2, temp %= mod;
			x += temp, x %= mod;
			print!1("x += ", temp);
		}
		if(i >= w){
			// z += (pascal(i - w, w) - pascal(i - w - 1, w) / 2^i
			long temp = pascal(i - w, w);
			if(i - 1 >= w) temp += (mod - pascal(i - w - 1, w)), temp %= mod;
			temp *= powerinv2, temp %= mod;
			z += temp, z %= mod;
			print!1("z += ", temp);
		}
		
		y = (1 + (mod - x) + (mod - z)) % mod;
		
		print!1("i:", i, " b:", b, " w:", w, " x:", x, " y:", y, " z:", z);
		
		long ans = y * inv(2) + z;
		ans %= mod;
		
		ans.writeln;
		
		powerinv2 *= inv(2), powerinv2 %= mod;
	}
	
}

/*

i回目をやる直前について

・黒しかない。 x[i]
・両方とも残っている。 y[i]
・白しかない。 z[i]

とすると、(i - 1)回目でちょうど黒が終わる確率は
(C(i - 1, b) - C(i - 2, b)) / 2^(i -1)
なので
x[i] = x[i - 1] + それ
同様に
z[i] = z[i - 1] + それ

なお n < k のときは C(n, k) = 0

y[i] = 1 - x[i] - z[i]


求めるものは x[i] + y[i] / 2

*/

// mod p における乗法逆元
long inv(long x){
	assert(x > 0);
	assert(x < mod);
	static long[] _inv = [0, 1];
	while(x >= _inv.length){
		_inv ~= _inv[mod % $] * (mod - mod / _inv.length) % mod;
	}
	return _inv[x];
}

// mod p における階乗
long perm(long x){
	assert(x >= 0);
	assert(x < mod);
	static long[] _perm = [1];
	while(x >= _perm.length){
		_perm ~= _perm[$ - 1] * _perm.length % mod;
	}
	return _perm[x];
}

// mod p における階乗の逆元
long invperm(long x){
	assert(x >= 0);
	assert(x < mod);
	static long[] _invperm = [1];
	while(x >= _invperm.length){
		_invperm ~= _invperm[$ - 1] * inv(_invperm.length) % mod;
	}
	return _invperm[x];
}

// mod p における二項係数（定義に注意：(a + b)! / a! / b! ）
long pascal(long a, long b){
	assert(a >= 0 && b >= 0);
	assert(a < mod && b < mod);
	long res = perm((a + b) % mod);
	res *= invperm(a), res %= mod;
	res *= invperm(b), res %= mod;
	return res;
}


Measured memory_bytes: 9724
<STDIN>;
my @cards = map {$_-0} split / /, <STDIN>;
@cards = sort { $b - $a } @cards;
my $t = 0;
my $a = 0, $b = 0;
foreach(@cards) {
    if($t == 0) {
        $a += $_;
        $t=1;
    }else{
        $b += $_;
        $t=0;
    }
}

print $a - $b;

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	static String[] dic = {"dream","dreamer","erase","eraser"};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
//		System.out.println(s.matches("(dream|dreamer|erase|eraser)*") ? "YES" : "NO");
		int n = s.length();
		boolean[] dp = new boolean[n+1];
		dp[0] = true;
		for(int i=0;i<n;i++) {
			if (!dp[i]) {
				continue;
			}
			for(String t: dic) {
				int m = t.length();
				if (s.length() < i + m) {
					continue;
				}
				if (s.substring(i,i+t.length()).equals(t)) {
					dp[i+t.length()] = true;
				}
			}
		}
		System.out.println(dp[n] ? "YES" : "NO");
	}

}


Measured memory_bytes: 20108
N = int(input())
restaurants = [input().split() for i in range(N)]
for i, restaurant in enumerate(restaurants):
    restaurant.append(i+1)

tmp = sorted(restaurants, key=lambda x: int(x[1]), reverse=True)
sorted_rest = sorted(tmp, key=lambda x: x[0])

for elem in sorted_rest:
    print(elem[2])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<100000;i++){
		if(a*i%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = []
ct = 0
su = 0
alpha2num = lambda c: ord(c) - ord('a') + 1
for i in range(n):
    su = 0
    li.append("".join(sorted(input())))

lll= 1
list.sort(li)
li.append("a")
for i in range(n):

    if li[i] == li[i+1]:
        lll += 1
    else:
        if lll != 1:
            for j in range(1, lll):
                ct += j
        lll = 1
print(ct)

Measured memory_bytes: 57560
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    
    int sum = 0;
    rep(i, n) {
        sum += min(2 * abs(x[i]), 2 * abs(k - x[i]));
    }
    put(sum)

    return 0;
}

Measured memory_bytes: 3580
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int X = sc.nextInt();
      	int Y = sc.nextInt();
      	int Z = sc.nextInt();
      
      	int[] S=new int[3];
        S[0]=X;
        S[1]=Y;
        S[2]=Z;
        
        int temp=S[0];
        S[0]=S[1];
        S[1]=temp;
        
        int tem=S[0];
        S[0]=S[2];
        S[2]=tem;
        
		for(int i=0;i<3;i++){
        System.out.println(S[i]);
        }
		
	}
}

Measured memory_bytes: 23764