akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/
 
int main(){
  string s;
  cin>>s;
  if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3]))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

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--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int H,W;
vector <string > S;





int main()
{

	cin >> H >> W;

	S.resize(H);


	REP(i,H){
		cin >> S[i];
	}

	int s['z'-'a'+1];
	REP(i,'z'-'a'+1){
		s[i]=0;
	}

	REP(i,H){
		REP(j,W){
			s[S[i][j]-'a']++;
		}
	}

	bool ansflag = false;
	int n4=(int)(H/2)*(int)(W/2);
	int n2=(H%2)*(int)(W/2)+(W%2)*(int)(H/2);
	int n1=(H%2)*(W%2);

		REP(i,'z'-'a'+1){
			if(n4>0){
			int p4 = s[i]/4;
			if(n4>p4){
				s[i]-=p4*4;
				n4-=p4;
			}else{
				s[i]-=n4*4;
				n4=0;
			}
			}
			if(n2>0){
				int p2 = s[i]/2;
				if(n2>p2){
					s[i]-=p2*2;
					n2-=p2;
				}else{
					s[i]-=n2*2;
					n2=0;
				}
			}
			if(n1==1 && s[i]>0){
				s[i]--;
				n1=0;
			}


			if(n4==0&&n2==0&&n1==0){
				ansflag=true;
				break;
			}

	}
	if(ansflag){
		cout << "Yes";
	}else{
		cout << "No";
	}


	return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=1010,M=1000010,P=1e9+7;
const int inf=0x3f3f3f3f;
const int INF=0xcfcfcfcf;
const double eps=1e-9,pi=asin(1)*2;
inline ll read();
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
inline int ADD(int a,int b) { return a+b>=P?a+b-P:a+b; }
inline int MINUS(int a,int b) { return a-b<0?a-b+P:a-b; }
#define plus(a,b) a=ADD(a,b)
#define minus(a,b) a=MINUS(a,b)
#define mul(a,b) a=(1ll*a*(b))%P
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)

int n,m;
vector< pii > G1[N],G2[N];

bool visit[N],ans[M];
inline void dfs(int x)
{
	visit[x]=true;
	int sz=G1[x].size();
	for(int i=0;i<sz;i++)
	{
		int y=G1[x][i].first;
		if(visit[y]) continue;
		dfs(y);
	}
}

#ifdef FILE
const int READ_SIZE=1<<20;
char buf[READ_SIZE],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,READ_SIZE,stdin),p1==p2)?EOF:*p1++
#endif
inline ll read()
{
	ll s=0;
	bool flag=false;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') flag=true;
	for(;'0'<=ch&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+(ch^'0');
	if(flag) return -s;
	return s;
}

int main()
{
#ifdef FILE
	freopen(FILE ".in","r",stdin);
	freopen(FILE ".out","w",stdout);
#endif
	n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		G1[x].push_back(mp(y,i));
		G2[y].push_back(mp(x,i));
	}
	for(int x=1;x<=n;x++)
	{
		mem(visit,false);
		visit[x]=true;
		int sz=G1[x].size();
		for(int i=0;i<sz;i++)
		{
			int y=G1[x][i].first,id=G1[x][i].second;
//			cerr<<x<<" "<<y<<"\n";
//			for(int i=1;i<=n;i++) cerr<<visit[i]<<" ";
//			cerr<<"\n";
			if(visit[y]) ans[id]=true;
			dfs(y);
		}
		
		mem(visit,false);
		visit[x]=true;
		for(int i=sz-1;i>=0;i--)
		{
			int y=G1[x][i].first,id=G1[x][i].second;
//			cerr<<x<<" "<<y<<"\n";
//			for(int i=1;i<=n;i++) cerr<<visit[i]<<" ";
//			cerr<<"\n";
			if(visit[y]) ans[id]=true;
			dfs(y);
		}
	}
//	for(int i=1;i<=m;i++) cerr<<ans[i]<<" ";
//	cerr<<"\n";
	for(int x=1;x<=n;x++)
	{
		mem(visit,false);
		dfs(x);
		int sz=G2[x].size();
		for(int i=0;i<sz;i++)
		{
			int y=G2[x][i].first,id=G2[x][i].second;
			if(visit[y]) ans[id]^=1;
		}
	}
	for(int i=1;i<=m;i++)
		if(ans[i]) printf("diff\n");
		else printf("same\n");
	return 0;
}

Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s,ans="AC";
   cin >> s;
   int l= s.size();
   if(s[0] != 'A'){
       ans = "WA";
       //return 0;
   }
    int cnt = 0;
    for(int i = 1; i < l; ++i){
         if(isupper(s[i])){
             if(i == 1 || i == l- 1 || s[i] != 'C'){
                ans="WA";
             }
          ++cnt;
         }
     }
        if(cnt != 1){
        ans = "WA";
      }
     cout << ans << endl;
}


Measured memory_bytes: 256
class _Dice:
    
    def __init__(self, nums):
        self.nums = list(nums)
        
    @property
    def top(self):
        return self.nums[0]
        
    def _shift(self, *pairs):
        for pair in pairs:
            num = self.nums[pair[0]]
            self.nums[pair[0]] = self.nums[pair[1]]
            self.nums[pair[1]] = num
            
    def get_matches(self, num):
        return [i for i, m in enumerate(self.nums) if m == num]
            
    def go(self, opes:str):
        for ope in opes:
            if ope == "N":
                self.go_north()
            elif ope == "E":
                self.go_east()
            elif ope == "W":
                self.go_west()
            else:
                self.go_south()
                
    def go_top(self, index):
        
        if index == 1:
            self.go_north()
        elif index == 2:
            self.go_west()
        elif index == 3:
            self.go_east()
        elif index == 4:
            self.go_south()
        elif index == 5:
            self.go_north()
            self.go_north()
            
    def go_ahead(self, index):

        if index == 2:
            self.go_cw()
        elif index == 4:
            self.go_cw()
            self.go_cw()
        elif index == 3:
            self.go_ccw()
            
        
    def go_north(self):
        self._shift((0, 1), (1, 5), (5, 4))
        
    def go_east(self):
        self._shift((0, 3), (3, 5), (5, 2))
        
    def go_west(self):
        self._shift((0, 2), (2, 5), (5, 3))
        
    def go_south(self):
        self._shift((0, 4), (4, 5), (5, 1))
        
    def go_ccw(self):
        self._shift((3, 4), (4, 2), (2, 1))
        
    def go_cw(self):
        self._shift((3, 1), (1, 2), (2, 4))
        
        
class Dice(_Dice):
    
    @classmethod
    def isequal(cls, a:_Dice, b:_Dice):
                
        for top in a.get_matches(b.nums[0]):
            a.go_top(top)
            for ahead in a.get_matches(b.nums[1]):
                a.go_ahead(ahead)
                
                for i, j in zip(a.nums, b.nums):
                    if i != j:
                        break
                else:
                    return True
            
        else:
            return False
        

dice_A = Dice(map(int, input().split()))
dice_B = Dice(map(int, input().split()))
print("Yes" if Dice.isequal(dice_A, dice_B) else "No")


Measured memory_bytes: 5620
import java.util.*;
import java.io.*;
import java.math.BigInteger;

 
public class Main implements Runnable {
  static Scanner in;
  // static FastReader in;
  static PrintWriter out;
  static int[][] dirs8 = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {-1, -1}, {-1, 1}, {1, -1}};
  static int[][] dirs = {{0, -1}, {1, 0}, {0, +1}, {-1, 0}};
 
  static int[][] E;
  // static List<int[]>[] adj;
  static List<Integer>[] adj;
  static int[] vis;
 
  static long INFL = (long) 1e15 + 7;
  static int INF = (int) 1e7 + 9;
 
  static int T, n, m, k, count;
  static boolean flag;
  static int[] a, b;
  static int[][] map;

  static int mod = 998244353;
 
  static void solve() throws Exception {
    int len = in.nextInt();
    String s = in.next();
    String t = in.next();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.length(); i++) {
      sb.append(s.charAt(i));
      sb.append(t.charAt(i));
    }
    out.println(sb);
  }


  public static void main(String[] args) throws Exception {
 
    in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    // in = new FastReader();
    out = new PrintWriter(System.out);
 
    // int T = in.nextInt();
    // for (int tt = 1; tt <= T; tt++) {
    //   // Thread t = new Thread(null, new Main(), "Main", 1 << 28);
    //   // t.start();
    //   // t.join();
    //   solve();
    // }
 
    // // Thread t = new Thread(null, new Main(), "Main", 1 << 28);
    // // t.start();
    // // t.join();
    solve();
 
    out.flush();
    out.close();
  }
 
  @Override
  public void run() {
    try {
      solve();
    } catch (Exception e) {
      e.printStackTrace(); 
    }
  }
 
  static class FastReader {
    public BufferedReader br; 
    StringTokenizer st; 
    public FastReader() {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; 
    }
  }

  static void as(boolean result) throws Exception {
    if (!result) {
      throw new Exception();
    }
  }

  static int modInverse(int a, int m) { 
    int m0 = m; 
    int y = 0, x = 1; 
    if (m == 1) {return 0;} 
    while (a > 1) { 
      // q is quotient 
      int q = a / m; 
      int t = m; 
      // m is remainder now, process 
      // same as Euclid's algo 
      m = a % m; 
      a = t; 
      t = y; 
      // Update x and y 
      y = x - q * y; 
      x = t; 
    } 
    // Make x positive 
    if (x < 0) 
      x += m0; 
    return x; 
  } 
} 

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

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

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

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

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans=0;
    ll cnt=0;
    cnt += b/c;
    cnt += b/d;
    cnt -= b/lcm(c,d);
    ans += b-cnt;

    cnt=0;
    cnt += (a-1)/c;
    cnt += (a-1)/d;
    cnt -= (a-1)/lcm(c,d);
    ans -= a-1-cnt;

    cout << ans << endl;
}

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

using namespace std;

ll n;
int ans, p;

int main() {
    cin >> n;

    for(ll i=2; i * i <= n; ++i) {
        p = i;
        while(n % p == 0) {
            n /= p;
            ans++;
            p *= i;
        }
        while(n % i == 0) {
            n /= i;
        }
    }
    if(n != 1) {
        ans++;
    }
    cout << ans << endl;
        
    return 0;
}


Measured memory_bytes: 3608
import heapq
x,y,z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
q=[]
heapq.heappush(q,(-(A[0]+B[0]+C[0]),0,0,0))
S=set()

for n in range(K):
  p,i,j,k=heapq.heappop(q)
  print(-p)
  if i+1<x and ((i+1,j,k) not in S):
    S.add((i+1,j,k))
    heapq.heappush(q,(-(A[i+1]+B[j]+C[k]),i+1,j,k))
  if j+1<y and ((i,j+1,k) not in S):
    S.add((i,j+1,k))
    heapq.heappush(q,(-(A[i]+B[j+1]+C[k]),i,j+1,k))
  if k+1<z and ((i,j,k+1) not in S):
    S.add((i,j,k+1))
    heapq.heappush(q,(-(A[i]+B[j]+C[k+1]),i,j,k+1))

Measured memory_bytes: 4852
#include <iostream>
#include <cmath>
using namespace std;
long long n, m, s = 1, M = 1e9 + 7;
int main() {
	cin >> n >> m;
	if (abs(n - m) > 1) {cout << 0; return 0;}
	if (n == m) s = 2;
	while (n) s = (s * n--) % M;
	while (m) s = (s * m--) % M;
	cout << s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Jun 28 20:59:50 JST 2020
 **/

constexpr Int D = 365;
constexpr Int K = 26;
Int c[K], s[D][K];

signed main() {
    // input
    Int _;
    std::cin >> _;
    REP(i, K) std::cin >> c[i];
    REP(i, D) REP(j, K) std::cin >> s[i][j];

    // hoge
    std::vector<Int> ans(D);
    REP(i, D) ans[i] = i % K;

    // output
    for (Int x : ans) std::cout << x + 1 << "\n";
    std::cout << std::endl;
}


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

int main() {
    int n;
    cin>>n;
    vector<string> s(n);
    for(int i=0;i<n;i++) cin>>s.at(i);
    map<string,int> ans;
    for(int i=0;i<n;i++){
        if(ans.count(s.at(i))) ans.at(s.at(i))++;
        else ans[s.at(i)]=1;
    }
    cout<<ans.size();
}



Measured memory_bytes: 25172
#include<stdio.h>
int main(){
    int a,b,flag=0;
    int x,y;
    scanf("%d %d",&x,&y);
    for(a=0;a<=50;a++){
        for(b=0;b<=50;b++){
            if(a+b==x && 2*a+4*b==y){
                printf("Yes");
                flag=1;
                break;
            }
        }
    }
    if(flag==0){
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

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

const int inf1=2e9+9;
const ll inf2=8e18+9;
const ll mol=1e9+7;
const int maxn=2e5+9;
const ll maxx=1e12+9;



int main()
{
    int n;
    cin>>n;
    if(n>=30) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 3132
import sys
sys.setrecursionlimit(2*10**5)


def dfs(v, graph, memo):
    if memo[v] != -1:
        return memo[v]
    ret = 0
    for c in graph[v]:
        ret = max(ret, dfs(c, graph, memo) + 1)
    memo[v] = ret
    return ret


def main():
    N, M = map(int, input().split())
    graph = [[] for _ in range(N)]
    for _ in range(M):
        x, y = map(int, input().split())
        x, y = x - 1, y - 1
        graph[x].append(y)
    memo = [-1] * N
    ans = 0
    for i in range(N):
        ans = max(ans, dfs(i, graph, memo))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 59056
//
// Created on 2020/09/20.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



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

    int ans = x + (y/2);
    cout<<ans<<endl;
    return 0;
}


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

int main(void)
{

    int W, H, x, y, r;

    cin >> W >> H >> x >> y >> r;

    cout << ((0 <= x - r && x + r <= W &&
              0 <= y - r && y + r <= H) ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    bool ans = false;
    while (n != 0) {
        if (n % 10 == 9) {
            ans = true;
        }
        n /= 10;
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
"use strict"
function main(arg) {
    let [A,B,C,K] = arg.trim().split("\n")[0].split(" ").map(Number)
    let sum = 0
    // for (let i = 0; i < K; i++) {
    //     if (A > 0) {
    //         sum += 1
    //         A--
    //     } else if (B > 0) {
    //         B--
    //     } else if (C > 0) {
    //         sum -= 1
    //         C--
    //     }
    // }

    // A
    if (A >= K) {
        sum = K
        K = 0
    } else {
        sum = A
        K = K - A
    }
    // B
    if (B >= K) {
        // sum = K
        K = 0
    } else {
        // sum = A
        K = K - B
    }
    // C
    if (C >= K) {
        sum = sum - K
        // K = 0
    } else {
        sum -= C
        // K = K - B
    }
    // console.log([A,B,C,K])
    console.log(sum)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29860
# coding: UTF-8
# from collections import deque
#@document_it
def document_it(func):
    def new_function(*args,**kwargs):
        print('Running function:', func.__name__)
        print('Positional arguments:', args)
        print('Kewword arguments:', kwargs)
        result = func(*args,**kwargs)
        print('Result:', result)
        return result
    return new_function


def exe():
    n = int(input())
    a = int(input())
    if n % 500 <= a:
        print('Yes')
    else:
        print('No')
    

if __name__ == '__main__':
    exe()

Measured memory_bytes: 3316
import numpy as np
H, W = list(map(int, input().split()))

a = np.array([list(input()) for i in range(H)])

at = np.all(a == '.', axis = 1)
for i in reversed(range(len(at))):
  if at[i]:
    a = np.delete(a, i, 0)

at = np.all(a == '.', axis = 0)
for i in reversed(range(len(at))):
  if at[i]:
    a = np.delete(a, i, 1)
for i in a:
  print(''.join(i))

Measured memory_bytes: 12500
l = gets.to_i
n = gets.to_i
sum = 0
n.times{sum += gets.chomp.split.map(&:to_i).inject(:*)}
sum *= -1
if sum == 0
    puts 0
elsif sum > 0
    puts sum
    sum.times{puts "1 1"}
else
    puts -sum
    (-sum).times{puts "-1 1"}
end


Measured memory_bytes: 6876
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
//const long long MOD = 998244353;
long long MOD;

using namespace std;

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

    double a = (double)n / 3;
    printf("%.10lf\n", a*a*a);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


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

using namespace std;

const int INF = 1e9 + 5;

int main(){

  	int n, k, i, j;

  	cin >> n >> k;

  	vector<int>h(n);

  	for(i = 0; i < n; i++){

      	cin >> h[i];
    }
  	vector<int>dp(n, INF);

  	dp[0] = 0;

  	for(i = 0; i < n; i++){

      	for(j = i + 1; j <= i + k; j++){

          	if(j < n){

              	dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
  	cout << dp[n - 1];

  	return 0;
}

Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
a.sort()
mod=10**9+7
f=True
if n==1:
    if a[0]==0:
        print(1)
    else:
        print(0)
    exit()
if n%2==1:
    if a[0]!=0 or a[1]==0:
        f=False
    for i in range(1,n-1,2):
        if not (a[i]==i+1 and a[i+1]==i+1):
            f=False
else:
    for i in range(0,n,2):
        if not (a[i]==i+1 and a[i+1]==i+1):
            f=False
if f:
    print((2**(n//2))%mod)
else:
    print(0)


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

int main() {
  int n, m;
  cin >> n >> m;
  int city[50]={};

  for (int i=0; i<m; i++) {
    int a, b;
    cin >> a >> b;

    city[a-1]++;
    city[b-1]++;
  }

  for (int i=0; i<n; i++) {
    cout << city[i] << endl;
  }
}

Measured memory_bytes: 256
a[100],N,M,n,R,r,s;
main(i,j){
	for(scanf("%d%d",&N,&M);n<N;R+=r,n++){
		for(i=0;i<M;i++)scanf("%d",a+i),a[i]^=!!n;
		for(r=i=0;i<M;r=r>s?r:s,i++)for(s=j=0;j<M;j++)s+=a[j]^j!=0^j!=i^j!=M-1;
	}
	printf("%d\n",R);
	exit(0);
}

Measured memory_bytes: 600
n, m, c = map(int,input().split())
b = list(map(int,input().split()))
count = 0
def ok(l):
    s = 0
    for i in range(m):
        s += b[i]*l[i]
    if s+c>0:
        return 1
    else:
        return 0
        
for i in range(n):
    a = list(map(int,input().split()))
    count += ok(a)
print(count)

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int n, k;
vi g[2010];

void dfs(int v, int p, int d, int &cnt)
{
	if (d < 0) ++cnt;

	for (int to : g[v]) {
		if (to != p) {
			dfs(to, v, d - 1, cnt);
		}
	}
}

int main() {
	cin >> n >> k;
	vector<pii> es;

	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		es.eb(a, b);
		g[b].pb(a); g[a].pb(b);
	}

	int ret = 10000;

	rep(i, n) {
		int c = 0;
		dfs(i, -1, k / 2, c);
		ret = min(ret, c);
	}

	rep(i, n-1) {
		int c = 0;
		dfs(es[i].fi, es[i].se, (k-1)/2, c);
		dfs(es[i].se, es[i].fi, (k-1)/2, c);	
		ret = min(ret, c);			
	}

	cout << ret << endl;

	return 0;
}

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

int main() {
    long long int ans = 0;
    int n;
    vector<string> s;
    string t;
    cin >> n;
    for(int i= 0; i<n; i++){
        cin >> t;
        sort(t.begin(), t.begin()+t.size());
        s.push_back(t);
    }
    sort(s.begin(),s.begin()+n);
    long long int tmp = 0;
    for(int i= 1; i<n; i++){
        if(s[i] != s[i-1]) tmp = 0;
        else {
            tmp += 1;
            ans += tmp; 
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   string s, t;
   int a, b;
   string k;
   cin >> s >> t >> a >> b >> k;
   if(s.compare(k) == 0) {
       a--;
   } else {
       b--;
   }
   cout << a << " " << b << endl;
} 

Measured memory_bytes: 256
n = int(input())
cnt = [0]*(10**4+50)

for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = (i**2)+(j**2)+(k**2)+i*j+j*k+k*i
      if v<10**4+50:
        cnt[v] += 1
for i in range(1,n+1):
  print(cnt[i])

Measured memory_bytes: 9440
n=int(input())
s=[]
for i in range (n):
    s.append('a')
for i in range(n):
    s[i]= [j for j in input()]
flag=True
for i in range(n-1):
    k = len(s[i])
    if s[i][k-1]==s[i+1][0]:
        for j in range(n):
            if s[i]==s[j] and i!=j:
                flag=False
                break
    else:
        flag=False
        break
if flag :
    print("Yes")
else:
    print("No")


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int cnt = 0;
    for (int i = min(a, b); i > 0; i--) {
        if (a % i == 0 && b % i == 0) {
            cnt++;
            if (cnt == c) {
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
#define eps 1e-7
#define maxi 50000005
typedef long long ll;
int n,k,avc=0;
int a[5];
int b[5];
char x='+',y='-';
void dfs(int i,int step,int sum){
     if(step>4||avc) return;
     b[step]=i;
     //cout<<b[step]<<"  "<<sum<<endl;
     if(step==4&&sum==7)
     {
         for(int j=1;j<=4;j++)
            if(j==1) cout<<b[j];
         else if(j>1&&b[j]>=0) cout<<"+"<<b[j];
         else if(j>1&&b[j]<0) cout<<"-"<<-b[j];
         cout<<"=7";
         avc=1;
         cout<<endl;
         return ;
     }
     dfs(a[step+1],step+1,sum+a[step+1]);
     dfs(-a[step+1],step+1,sum-a[step+1]);

}
int main()
{
     cin>>n;
     a[1]=n/1000,a[2]=(n/100)%10,a[3]=(n%100)/10,a[4]=n%10;
     dfs(a[1],1,a[1]);
     return 0;
}


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

int main() {
  int N;
  long ans = 0;
  long t;

  cin >> N;
  vector<long> vec(N);
  cin >> vec.at(0);
  t = vec.at(0);
  for(int i=1;i<N;++i){
    cin >> vec.at(i);
    if(t >= vec.at(i)){
      ans += t - vec.at(i);
    }else{
      t = vec.at(i);
    }
  }

  cout << ans << endl;
  return 0;
}


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

const static int MAX = 1400;

int dp[MAX][MAX], G[MAX][MAX];

int getLargesetSquare(int H, int W){
    int maxWidth = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            dp[i][j] = (G[i][j] + 1) % 2;
            maxWidth |= dp[i][j];
        }
    }

    for(int i = 1; i < H; i++){
        for(int j = 1; j < W; j++){
            if(G[i][j]){
                dp[i][j] = 0;
            }else{
                dp[i][j] = std::min( dp[i-1][j-1], std::min( dp[i-1][j], dp[i][j-1] ) ) + 1;
                maxWidth = std::max(maxWidth, dp[i][j]);
            }
        }
    }

    return maxWidth * maxWidth;
}

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

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) scanf("%d", &G[i][j]);
    }

    printf("%d\n", getLargesetSquare(H, W));

    return 0;
}


Measured memory_bytes: 18504
import java.util.Scanner;

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

		int     N=sc.nextInt();
		int[][] dat =new int[N][3];
		int[] score =new int[N];
		
		for(int i=0; i<N; i++)
		for(int j=0; j<3; j++)
			dat[i][j]=sc.nextInt();
		
		for(int round=0; round<3; round++)
		{
			for(int no1=0; no1<N; no1++)
			{
				boolean isUnique=true;
				for(int no2=0; no2<N; no2++)
				{
					if(no1!=no2 && dat[no1][round]==dat[no2][round])
					{
						isUnique=false;
						break;
					}
				}
				if(isUnique)score[no1]+=dat[no1][round];
			}
		}
		for(int i=0; i<N; i++)
			System.out.println(score[i]);
	}
}

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

int main(){
//srandom((unsigned long)time(NULL));

long long n;
cin>>n;
long long a[n];
for(long long i=0;i<n;i++){
    a[i]=0;
}
for(long long i=2;i<=n;i++){
    long long x;
    cin>>x;
    a[x-1]++;
}
for(long long i=0;i<n;i++){
    cout<<a[i]<<endl;
}

return 0;
}



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

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  rep(i,b+1){
    if(a*i%b==c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 1e11;
const ll bits = 62;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;

ll solve(ll h){
    if(h==1){
        return 1;
    }

    return 1LL+2LL*solve(h/2);
}


int main(){
    FASTIO;
    PRECISION;

    ll h;
    cin>>h;

    cout<<solve(h)<<"\n";

}

Measured memory_bytes: 256
#include<iostream>

int main(void){
	using namespace std;
	int n, b, f, r, v;
	int array[4][3][10] = {0};
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		array[b-1][f-1][r-1] += v;
	}
	for(int a = 0; a < 4; a++){
		for(int b = 0; b < 3; b++){
			for(int c = 0; c < 10; c++){
				cout << " " << array[a][b][c];
			}
			cout << endl;
		}
		if(a != 3)
			cout << "####################" << endl;
	}
}


Measured memory_bytes: 3104
package main

// ---------- template start ----------
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
	"sort"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func bordersInt(in_map [][]int, invalid int) [][]int{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]int, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]int, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func bordersString(in_map [][]string, invalid string) [][]string{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]string, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]string, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func maxInt(arr... int) int {
	max := -10000007
	for _, v := range arr {
		if max < v {
			max = v
		}
	}
	return max
}

func minInt(arr... int) (int, int) {
	min, argmin := int(1e+9)+1, int(1e+5)+1
	for i, v := range arr {
		if min > v {
			min = v
			argmin = i
		}
	}
	return min, argmin
}



// ---------- template end ----------

type Shop struct {
	a, b int
}

type Shops []Shop

func (s Shops) Len() int {
	return len(s)
} 

func (s Shops) Swap(i, j int) {
	s[i].a, s[j].a = s[j].a, s[i].a
	s[i].b, s[j].b = s[j].b, s[i].b
}

func (s Shops) Less(i, j int) bool {
	return s[i].a < s[j].a
}


func main(){
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	var N, M, cnt, ans int
	fmt.Scan(&N, &M)
	shops := make(Shops, N)
	for i:=0; i<N; i++ {
		ab := scanIntSplit(2)
		shops[i] = Shop{a:ab[0], b:ab[1]}
	}
	sort.Sort(shops)
	for i:=0; i<M; i++ {
		for j:=0; j<shops[i].b; j++ {
			cnt++
			ans += shops[i].a
			if cnt == M {
				fmt.Println(ans)
				os.Exit(0)
			}
		}
	}
	
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int A, K;
    cin >> A >> K;
    
  	int n=1;
    int cnt=0;
    while(n<=A){
        cnt++;
        n=pow(K,cnt);
    }
    cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 256
fun main() {
    var n = readLine()!!.toInt()

    var d = Array(10050){0}

    for (i in 1..105){
        for(j in 1..105) {
            for(k in 1..105) {
                if(i * i + j * j + k * k + i * j + j * k + k * i < 10050) {
                    d[i * i + j * j + k * k + i * j + j * k + k * i]++
                }
            }
        }
    }
    for(i in 1..n) {
        println(d[i])
    }
}

Measured memory_bytes: 37472
#include <bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <string>
#include <list>
#include <limits>
#include <type_traits>

using namespace std;

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


int main(void) {

    double k;
    double p = 3.141592653589793238462643383279;
    
    cin >> k;

    k = 2 * k * p;
    
    cout << k;
}

Measured memory_bytes: 3788
# 三井住友信託銀行プログラミングコンテスト2019
# D - Lucky PIN
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d

N = int(input())
*S, = map(int, input())

# 最大でも000-999までの1000通り
# dp[i][j]: i(index)より左にあるj(0-9)で最も右にあるもののindex

dp = [[-1]*10 for _ in [0]*(N+1)]
for i, s in enumerate(S):
    for j in range(10):
        dp[i+1][j] = dp[i][j]
    dp[i+1][s] = i

cnt = 0
for i in range(1000):
    a = i//100 % 10
    b = i//10 % 10
    c = i % 10

    ci = dp[N][c]
    if ci != -1:
        bi = dp[ci][b]
        if bi != -1:
            ai = dp[bi][a]
            if ai != -1:
                cnt += 1

print(cnt)


Measured memory_bytes: 9100
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
asum=0
bsum=0
pointer=0
while pointer<m and bsum+b[pointer]<=k:
	bsum+=b[pointer]
	pointer+=1
ans=pointer
for i in range(n):
	asum+=a[i]
	while asum+bsum>k and pointer>=0:
		pointer-=1
		bsum-=b[pointer]
	if asum+bsum>k:
		break
	ans=max(ans,(i+1)+pointer)
print(ans)

Measured memory_bytes: 117720
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt()-1;
    int b = sc.nextInt()-1;
    int c = sc.nextInt()-1;
    int d = sc.nextInt()-1;
    String s = sc.next();
    
    boolean ans = true;
    boolean ju1 = false;
    boolean ju2 = false;
    
    //空欄
    for(int i = b-1 ; i < d ; ++i){
      if(i+2 >= n) break;
      if(s.charAt(i)=='.' && s.charAt(i+1)=='.' && s.charAt(i+2)=='.') {
        ju1 = true;
        break;
      }
    }
    //岩
    for(int i = a ; i < c ; ++i){
      if(i+1 >= n) break;
      if(s.charAt(i)=='#' && s.charAt(i+1)=='#') {
        ju2 = true;
        break;
      }
    }
    
    for(int i = b ; i < d ; ++i){
      if(i+1 >= n) break;
      if(s.charAt(i)=='#' && s.charAt(i+1)=='#') {
        ju2 = true;
        break;
      }
    }
    
    //追い越すとき3マス空欄必要
    if(d<c && ju1==false) ans = false;
    //岩2マス並んでたらアウト
    else if(ju2) ans = false;
    
    if(ans) System.out.println("Yes");
    else System.out.println("No");
    
  }
}

Measured memory_bytes: 41604
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        
        int m = scan.nextInt();//
        int f = scan.nextInt();//
        int b = scan.nextInt();//
        
        if (m + f < b) {
            System.out.println("NA");
        } else {
            if (m > b) {
                System.out.println(0);
            } else {
                System.out.println(b - m);
            }
        }
        return;
    }
}



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

int main() {
  char c;
  cin >> c;
  if(c =='a'|| c =='i'|| c =='u'|| c =='e'|| c =='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


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

int main() {
  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  for (int i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());
  
  bool can = true;
  for (int i = 0; i < S.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; j++) {
      string d = divide[j];
      if (S.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size();
      }
  	}
    if (!can2) {
      can = false;
      break;
    }
  }
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int n, x;
int main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        if (x % 2 == 0 && x % 3 && x % 5) {
            cout << "DENIED";
            PLEC
        }
    }
    cout << "APPROVED";
    PLEC
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
using namespace std;
struct node {
	int v,d;
}f[N*4];
int i,j,k,l,s,n,m,v[N],tot,q[N];
long long ans;
set<int>GT[27];
set<int>::iterator GTW;
char c[N];
inline int ask(int o,int l,int r,int ll) {
	if (l==ll&&r==ll) return f[o].v;
	int mid=(l+r)>>1;
	f[o*2].v+=f[o].d;
	f[o*2].d+=f[o].d;
	f[o*2+1].v+=f[o].d;
	f[o*2+1].d+=f[o].d;
	f[o].d=0;
	if (ll<=mid) return ask(o*2,l,mid,ll);
	else return ask(o*2+1,mid+1,r,ll);
}
inline void change(int o,int l,int r,int ll,int rr) {
	if (l==ll&&r==rr) {
		f[o].v++,f[o].d++;
		return ;		
	}
	int mid=(l+r)>>1;
	f[o*2].v+=f[o].d;
	f[o*2].d+=f[o].d;
	f[o*2+1].v+=f[o].d;
	f[o*2+1].d+=f[o].d;
	f[o].d=0;
	if (rr<=mid) change(o*2,l,mid,ll,rr);
	else if (ll>mid) change(o*2+1,mid+1,r,ll,rr);
	else change(o*2,l,mid,ll,mid),change(o*2+1,mid+1,r,mid+1,rr);
	f[o].v=f[o*2].v+f[o*2+1].v;
}
int main() {
	scanf("%s",c+1);
	n=strlen(c+1);
	for (i=n;i;i--) GT[c[i]-96].insert(i);
	for (i=1;i<=26;i++) if (GT[i].size()&1) q[++tot]=i;
	if (tot>1) return puts("-1"),0;
	j=1;
	for (i=1;i<=n/2;i++) {
		while (v[j]) j++;
		if (GT[c[j]-96].size()==1) {
			ans+=abs(((n+1)>>1)-i);//,change(1,1,n,1,n);
			
			j++;
			while (v[j]) j++;
		}
		GT[c[j]-96].erase(j);
		GTW=GT[c[j]-96].end();
		GTW--;
		int y=(*GTW);
		int pp=y;
		v[y]=1;
		GT[c[j]-96].erase(y);
		y=y-ask(1,1,n,y);
		ans+=abs(n-i+1-y);
		change(1,1,n,pp,n);
		j++;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 14464
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [u64; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }
 
// https://practice.contest.atcoder.jp/tasks/practice_1
fn main() {
    input! { n:usize, s: chars }
    let mut ans = vec![0; n+1];
    let mut l: i64 = 0;
    let mut r: i64 = s.iter().filter(|&e| *e == '.').count() as i64;
    ans[0] = l + r;
    for i in 1..n+1 {
        let e = s[i-1];
        if e == '#' { l += 1; }
        if e == '.' { r -= 1; }
        ans[i] = l+r;
    }
    println!("{}", ans.iter().min().unwrap());
}

Measured memory_bytes: 6396
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {

	int i, j, k;
	int n;
	char ch[101];

	cin >> n;

	for (i = 0; i < n; i++) {
	cin >> ch[i];
	}

	for (i = 0; i < n; i++) {
	if (ch[i] == 'Y') {
	cout << "Four" << endl;

	getchar();
	getchar();
	return 0;
	}
	}
	
	cout <<"Three"<< endl;




	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static int[][] c;
	static boolean[] passed;
	static int maryoku;
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt();
		c = new int[10][10];
		for(int i = 0; i < 10; i++) {
			for(int j = 0; j < 10; j++) {
				c[i][j] = sc.nextInt();
			}
		}
		int[][] a = new int[h][w];
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		passed = new boolean[10];
		int[] m = new int[10]; 
		for(int i = 0; i <= 9; i++) {
			Arrays.fill(passed, false);
			maryoku = 10000;
			dfs(i, 0);
			m[i] = maryoku;
		}
		int ans = 0;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(a[i][j] != -1) ans += m[a[i][j]];
			}
		}
		System.out.println(ans);
	}
	
	public static void dfs(int now, int count) {
		if(now == 1) {
			maryoku = Math.min(maryoku, count);
			return;
		}
		passed[now] = true;
		for(int i = 0; i <= 9; i++) {
			if(!passed[i] && now != i) {
				dfs(i, count + c[now][i]);
				passed[i] = false;
			}
		}
		return;
	}
}


Measured memory_bytes: 47556
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int w, a, b; cin >> w >> a >> b;

    if (abs(a - b) <= w) {
        cout << 0 << endl;
    } else {
        cout << abs(a - b) - w << endl;
    }
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

namespace {

	int cnt;
	void InsertionSort(vector<int>& A, int n, int g)
	{
		for (int i = g; i < n; ++i)
		{
			int v = A[i];
			int j = i - g;

			while (j >= 0 && A[j] > v) {
				A[j + g] = A[j];
				j -= g;
				cnt++;
			}

			A[j + g] = v;
		}
	}

	void ShellSort(vector<int>& A, int n)
	{
		int m;
		cnt = 0;
		vector<int> G;
		G.push_back(1);
		for (int i = 1; i <= n; ++i)
		{
			int g = pow(4, i) + 3 * pow(2, i - 1) + 1;
			if (g <= n) G.push_back(g);
			else { m = i; break; }
		}

		for (int i = m - 1; i >= 0; --i)
			InsertionSort(A, n, G[i]);

		cout << m << endl;
		for (int i = m - 1; i >= 0; --i) {
			cout << G[i];
			i != 0 ? cout << " " : cout << endl;
		}
		cout << cnt << endl;
		for (int i = 0; i < n; ++i)
			cout << A[i] << endl;
	}
}

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

	int n;
	cin >> n;

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

	ShellSort(A, n);

	return 0;
}

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

//閏年問題を捻ったもの
// n % m を使って大の月か小の月かを判定する

int main(){
	int y, m, d;
	int n;
	int ans;

	cin >> n;
	for(int p=0; p < n; p++){
		cin >> y >> m >> d;

		for(int i=0; i < n; i++){
			if(y % 3 == 0 || m % 2 == 1) ans = 20 - d + 1;
			else ans = 19 - d + 1;

			for(int j=y; j < 1000; j++){
				for(int k = 1; k <= 10; k++){
					if(j == y && k <= m) continue;

					if(j % 3 == 0 || k % 2 == 1) ans += 20;
					else ans += 19;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
S = input()

if S[0] == 'W':
    count = 0
    f = 0
    for i in range(len(S)):
        if S[i] == 'W' and f == 1:
            f = 0
            count += 1
        elif S[i] == 'B' and f == 0:
            f = 1
            count += 1
else:
    f = 0
    count = 0
    for i in range(len(S)):
        if S[i] == 'B' and f == 1:
            f = 0
            count += 1
        elif S[i] == 'W' and f == 0:
            f = 1
            count += 1

print(count)

Measured memory_bytes: 3188
#include<iostream>
using namespace std; //or std::cin et al.

int main() {
	int a,b;
	char op;
	while (1) {
	    cin >> a >> op >> b;
	    if ( op == '?' ) {
	    	break;
	    } else if ( op == '+' ) {
	    	cout << a + b << endl;
	    } else if ( op == '-' ) {
	    	cout << a - b << endl;
	    } else if ( op == '*' ) {
	    	cout << a * b << endl;
	    } else if ( op == '/' ) {
	    	cout << a / b << endl;
	    }
	}
	
	return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	vector<int> vct(n);	
	int a,b;
	cin>>a>>b;
	if((a+b) % 2 == 0)
	cout<<(a+b)/2<<endl;
	else{
		cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
s=[int(input()) for i in range(N)]
s.sort()
Su=0
for i in range (N):
    Su+=s[i]
if Su%10==0:
    m=s[0]
    i=0
    while m%10==0 and i<N:
        if s[i]%10!=0:
            m=s[i]
        else:
            i+=1
    if i==N and m%10==0:
        print (0)
    else:
        Su-=m
        print (Su)
else:
    print (Su)



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstring>
#include <map>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); ++i) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

using namespace std;


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

  ll res = 700;

  REP(i,3)
  {
    if(S[i] == 'o')res+=100;
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256