akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double l, r;
    int s[4] = {}, t[4] = {};
    while(cin >> l >> r)
    {
        if(l >= 1.1) s[0]++;
        else if(l >= 0.6) s[1]++;
        else if(l >= 0.2) s[2]++;
        else s[3]++;
        if(r >= 1.1) t[0]++;
        else if(r >= 0.6) t[1]++;
        else if(r >= 0.2) t[2]++;
        else t[3]++;
    }
    for(int i = 0; i < 4; i++)
    {
        cout << s[i] << " " << t[i] << endl;
    }
    return 0;
}




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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x * y / GCD(x, y);
}


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

    if(n == 1) {
        cout << "Yes" << endl;
        return 0;
    }

    for(int i=n-2; i>=0; i--) {
        if(h[i] <= h[i+1]) continue;
        else if(h[i] - h[i+1] >= 2) {
            cout << "No" << endl;
            return 0;
        }
        else h[i] --;
    }
    cout << "Yes" << endl;
}


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

class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int num = 0;
        
        for (int i=a; i<=b; i++) {
            if (c % i == 0) {
                num++;
            }
        }
        
        System.out.println(num);
    }
}



Measured memory_bytes: 26388
N=int(input())
LIST=list(map(int,input().split()))
COUNT=0

#print(LIST)
#print(LIST[0])

for i in range(N):
  COUNT=COUNT+LIST[i]*((-1)**(i%2))
print(COUNT,end=" ")  

for j in range(N-1):
  print(LIST[j]*2-COUNT,end=" ")
  COUNT=LIST[j]*2-COUNT
  
  


Measured memory_bytes: 14028
#!/usr/bin/env python3
# coding: utf-8

# def debug(arg):
#     if __debug__:
#         pass
#     else:
#         import sys
#         print(arg, file=sys.stderr)
        
def main():
    N, K, C = map(int, input().split())
    S = dict(enumerate(str(input()), 1))

    sr = list(k for k, v in S.items() if v == 'o')
    sl = list(reversed(sr.copy()))

    l = [sl.pop()]
    r = [sr.pop()]
    
    for x in range(1, K):
        while True:
            ll = sl.pop()
            if ll > l[x - 1] + C:
                l.append(ll)
                break
        while True:
            rr = sr.pop()
            if rr < r[x - 1] - C:
                r.append(rr)
                break

    for ll, rr in zip(l, reversed(r)):
        if ll == rr:
            print(ll)

if __name__ == "__main__":
    main()

Measured memory_bytes: 30744
#include <iostream>
#include <vector>
#include <cstring>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <climits>

using namespace std;
#define inf 0m3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define sz(v) (int)v.size()
#define all(m) (m).begin(), (m).end()
#define rall(m) (m).rbegin(), (m).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vi;
//const int mod=1e9+7;
const int N=1e5+7;

int main(){
    fast;
    int t=1;
    //cin>>t;
    while(t--){
        ll n,x,a[N],ans=0;
        cin>>n>>x;
        forn(i,n) cin>>a[i];
        
        if(a[0]>x) ans+=a[0]-x, a[0]=x;
        
        for1(i,n-1){
            ll drop = max(a[i]+a[i-1],x) - x;
            ans+=drop;
            a[i]-=drop;
        }
        cout<<ans<<endl;
        
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
    int time,s,m,h,a,b;
    scanf("%d",&time);
    a=time/60;
    s=time%60;
    h=a/60;
    m=a%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


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

int main(){
    int n;
    int a[100];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int count=0;
    bool flag=true;
    while(flag){
        flag=false;
        for(int i=n-1;i>0;i--){
            if(a[i]<a[i-1]){
                int z=a[i];
                a[i]=a[i-1];
                a[i-1]=z;
                flag=true;
                count++;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<a[i];
        if(i==n-1)cout<<endl;
        else cout<<' ';
    }
    cout<<count<<endl;
    return 0;
}


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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define debug(x) cerr<<#x<<"="<<x<<'\n'

const ll inf=1e15;

int read() {
  int x=0,w=1;
  char ch=0;
  while (ch<'0'||ch>'9') {
    if (ch=='-') w=-1;
    ch=getchar();
  }
  while (ch>='0'&&ch<='9') {
    x=(x<<3)+(x<<1)+(ch-'0');
    ch=getchar();
  }
  return x*w;
}

const int maxn=2e5+10;

int n;
int a[maxn];

int calc(int x,int op) {
	if (op==0) return (x-1)/2;
	else return (x+1)/2;
}

ll f[maxn*4][2][2][2];


ll getf(int c,int l,int r,int op,int fl,int fr) {
	if (f[c][op][fl][fr]!=-1) return f[c][op][fl][fr];
	if (l==r) {
		if (op==0) {
			if (fl==0&&fr==0) return 0ll;
			else return -inf;
		}
		else {
			if (fl==1&&fr==1) return (ll)a[l];
			else return -inf;
		}
	}
	int mid=(l+r)/2;
	int tmp=calc(r-l+1,op);
	ll &res=f[c][op][fl][fr];
	res=-inf;
	for (int i=0;i<2;i++)
		for (int j=0;j<2;j++) {
			if (calc(mid-l+1,i)+calc(r-mid,j)==tmp) {
				for (int a=0;a<2;a++) {
					if (getf(c*2,l,mid,i,fl,a)==-inf) continue;
					for (int b=0;b<2;b++) {
						if (a==1&&b==1) continue;
						res=max(res,getf(c*2,l,mid,i,fl,a)+getf(c*2+1,mid+1,r,j,b,fr));
					}
				}
			}
		} 
//	printf("l=%d r=%d op=%d fl=%d fr=%d res=%lld\n",l,r,op,fl,fr,res);
	return res;
}

int main(){
	for (int i=0;i<maxn*4;i++)
		for (int j=0;j<2;j++)
			for (int a=0;a<2;a++)
				for (int b=0;b<2;b++) f[i][j][a][b]=-1; 
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	ll ans=-inf;
	for (int i=0;i<2;i++)
		for (int j=0;j<2;j++) 
			ans=max(ans,getf(1,1,n,(n%2)^1,i,j));
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 54552
n,m,q = map(int,input().split())

lr = [[0 for i in range(n+1)] for j in range(n+1)]


for i in range(m):
    l,r = map(int,input().split())
    lr[l][r] += 1

#pq = [[int(i) for i in input().split()]for j in range(q)]

dp = [[0 for i in range(n+1)] for j in range(n+1)]

for i in range(1,n+1):
    for j in range(i,n+1):
        dp[i][j] = dp[i][j-1]+lr[i][j]

ans_dp = [[0 for i in range(n+1)] for j in range(n+1)]

for i in range(1,n+1):
    for j in range(i,n+1):
        tmp = 0
        for k in range(j-i+1):
            tmp += dp[i+k][j]
        ans_dp[i][j] = tmp

for i in range(q):
    p,q = map(int,input().split())
    print(ans_dp[p][q])


Measured memory_bytes: 62936
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
int main()
{
    int W,H;
    int x,y;
    int r;
    cin >> W >> H >> x >> y >> r;
    if(x-r<0 || x+r>W || y-r <0 || y+r > H) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
using namespace std;
#define REP(m,n) for(int i=m;i<n;++i)
#define REPj(m,n) for(int j=m;j<n;++j)
#define ll long long
#define mp make_pair

int main() {
	int a, b, c, d, ans;
	cin >> a >> b >> c >> d;
	ans = min(b, d) - max(a, c);
	if (ans < 0) {
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int power(int x,int y){
    int res=1LL;
    while(y){
        if(y&1){
            res=(res*x)%MOD;
        }
        x=(x*x)%MOD;
        y=(y>>1);
    }
}
int n,m,k;
vector <int> frnd[N];
vector <int> enmy[N];
int arr[N];
int sz[N];
 
 int root(int i){
    while(arr[i]!=i){
        arr[i]=arr[arr[i]];
        i=arr[i];
    }
    return i;
 }
 void uni(int a,int b){
    int ra=root(a);
    int rb=root(b);
    if(ra==rb)return;
    if(sz[ra]<sz[rb])swap(ra,rb);
    arr[rb]=ra;
    sz[ra]+=sz[rb];
 }
signed main()
{
    
    speed
    cin>>n>>m>>k;
    rep(i,1,n){
        arr[i]=i;
        sz[i]=1;
    }
    rep(i,1,m){
        int x,y;cin>>x>>y;
        uni(x,y);
        enmy[x].pb(y);
        enmy[y].pb(x);
        
    }
    rep(i,1,k){
        int x,y;cin>>x>>y;
        enmy[x].pb(y);
        enmy[y].pb(x);
    }

    rep(i,1,n){
        int ri=root(i);
        int ans=sz[ri]-1;
        for(auto it:enmy[i]){
            if(ri==root(it))ans--;
        }
        cout<<ans<<" ";
    }
    





    
 


  



    

    
    
    
    return 0;
}

Measured memory_bytes: 19072
#include <stdio.h>
#include <iostream>
using namespace std;

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

    int ans = A + (A - 1);
    ans = max(ans, A+B);
    ans = max(ans, B + (B-1));

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


Measured memory_bytes: 760
N = int(input())

p_names = []
p_count = []
for n in range(N):
    p_count.append(0)

for n in range(N):
    tmp = input()
    if tmp in p_names:
        index = p_names.index(tmp)
        p_count[index] += 1
    else:
        p_names.append(tmp)
        index = p_names.index(tmp)
        p_count[index] += 1
        
M = int(input())
for m in range(M):
    tmp = input()
    if tmp in p_names:
        index = p_names.index(tmp)
        p_count[index] -= 1
    else:
        continue

if max(p_count)>0:
    print(max(p_count))
else:
    print(0)

Measured memory_bytes: 9196
#include <stdio.h>
int main(void){
    int i,j,H,W;
 
    while(1){
        scanf("%d %d",&H,&W);
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
              printf("#");
            }
        printf("\n");
        }
        if(H!=0||W!=0){
        printf("\n");}
        if(H==0 &&W==0) 
            break;
    }
 
    return 0;
}



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

using namespace std;

class Dice{
private:
  void roll(int a,int b,int c,int d){
    swap(x[a],x[b]);
    swap(x[b],x[d]);
    swap(x[c],x[d]);
  }
public:
  int x[6];
  void roll_N(){ roll(0,1,4,5); }
  void roll_E(){ roll(0,3,2,5); }
  void roll_S(){ roll(0,4,1,5); }
  void roll_W(){ roll(0,2,3,5); }
  void rotation(){ roll(1,2,3,4); }
  void roll(int top,int front){
    for(int i = 0 ; i < 2 ; i++){
      for(int j = 0 ; j < 4 ; j++){
        roll_N();
        if(top == x[0]){ goto next; }
      }
      roll_E();
    }
     next:
    for(int i = 0 ; i < 4 ; i++){
      rotation();
      if(front == x[1]){ break; }
    }
  }
};

int main(){
  Dice die;
  for(int i = 0 ; i < 6 ; i++){
    cin >> die.x[i];
  }
  int q,t,f;
  cin >> q;
  while(q--){
    cin >> t >> f;
    die.roll(t,f);
    cout << die.x[2] << endl;
  }
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
typedef long long ll;


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n;
    cin >> n;
    vector <ll> height(n);
    rep(i, n) {
        cin >> height.at(i);
    }
    for (int i = n - 1; i > 0; i--) {
        if (height.at(i) + 1 < height.at(i - 1)) {
            cout << "No" << endl;

            return 0;
        }
        if (height.at(i) + 1 == height.at(i - 1)) {
            height.at(i - 1)--;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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


def solve(S: int, W: int):
    print("unsafe" if S<=W else "safe")
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 61752
//
//  main.cpp
//  CPP
//
//  Created by chemistrae on 02/12/2018.
//  Copyright © 2018 chemistrae. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    int n, k;
    cin >> n >> k;
    
    vector<int> h;
    
    for (int i=0; i<n; i++) {
        int hi;
        cin >> hi;
        h.push_back(hi);
    }
    
    sort(h.begin(), h.end());
    
    int ret = 1<<30;
    
    for (int i=0; i<n-k+1; i++) {
        ret = min(ret, h[i+k-1]-h[i]);
    }
    
    cout << ret << '\n';
    
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <time.h>
#include <assert.h>


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(3);
    srand(time(NULL));

    ll n;
    cin>>n;
    map<ll,ll> fre;
    ll a[n];
    ll sum = 0;
    For(i,0,n){
    	cin>>a[i];
    	sum += a[i];
    	fre[a[i]]++;
    }
    ll q;
    cin>>q;
    // deb1(sum);
    while(q--){
    	ll x,y;
    	cin>>x>>y;
    	if(fre.find(x) == fre.end()){
    		cout<<sum<<"\n";
    		continue;
    	}
    	ll remcost = fre[x]*x;
    	// deb2(remcost,fre[x]*y);
    	sum -= remcost;
    	sum += fre[x]*y;
    	fre[y] += fre[x];
    	fre.erase(fre.find(x));
    	cout<<sum<<"\n";
    }
    
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


Measured memory_bytes: 8352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < k; i++) {//お菓子の種類の回数だけ、回す
			int d = sc.nextInt();//dでお菓子の個数を受け取り、その回数だけ回す。
			for (int j = 0; j < d; j++) {
				a[sc.nextInt() - 1]++;//お菓子の個数
			}
		}
		int count = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] == 0) {
				count++;
			}
		}
		System.out.println(count);

	}

}

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

int main(){
  char a,b,c,d,e,k;
  int s[55];
  cin>>b;
  if(b=='A')cout<<"T";
  if(b=='C')cout<<"G";
  if(b=='G')cout<<"C";
  if(b=='T')cout<<"A";
}

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

#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define REP(i,a,n) for (ll i=a;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define show(x) cout<<(x)<<endl
#define UM unordered_map
#define PB push_back
#define V vector
#define EPS 1e-8
typedef unsigned long long int ll;
typedef string str;
/*FIN*/

int main() {
	FAST;
	ll n,y;
	cin>>n;
	ll ans = 0;
	REP(i,1,n+1) {
		y = n/i;
		ans += (i*y*(y+1))>>1;
	}
	show(ans);
	return 0;
}


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

using namespace std;

int main() {
  int N, M;
  int cnt[31];

  cin >> N >> M;

  for(int i=0; i<M; ++i) cnt[i] = 0;

  for(int i=0; i<N; ++i) {
    int K;
    cin >> K;
    for(int j=0; j<K; ++j) {
      int A;
      cin >> A;
      cnt[A-1] += 1;
    }
  }

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

Measured memory_bytes: 256
S = input()
ans = 'No'
 
if len(S)%2 == 0:
    for i in range(len(S)//2):
        if S[2*i] + S[2*i+1] != 'hi':
            break
        elif i == (len(S)//2)-1:
            ans = 'Yes'
print(ans)

Measured memory_bytes: 2940
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                String S = sc.next();
                boolean f = true;
                for (char i = 'a'; i <= 'z'; i++) {
                        int count = 0;
                        for (int j = 0; j < S.length(); j++) {
                                if(S.charAt(j) == i) {
                                        count++;
                                }
                        }
                        if (count % 2 != 0) {
                                f = false;
                        }
                }
                if (f) {
                        System.out.println("Yes");
                } else {
                        System.out.println("No");
                }
        }
}

Measured memory_bytes: 9424
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	io_init;
	int N;
	cin >> N;
	vector<int> A(N), B(N), p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		p[i]--;
		A[i] = i + 1;
		B[i] = N - i;
	}
	for (int i = 0; i < N; i++) {
		for (int j = p[i]; j < N; j++) {
			A[j] += i;
		}
		for (int j = 0; j <= p[i]; j++) {
			B[j] += i;
		}
	}
	for (int i = 0; i < N; i++) {
		cout << A[i] << " ";
	}
	cout << endl;
	for (int i = 0; i < N; i++) {
		cout << B[i] << " ";
	}
	cout << endl;
}

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

def main():
    input = sys.stdin.readline
    n = int(input())
    flag = False
    for _ in range(n):
        a, b = map(int, input().split())
        if flag:
            if a == b:
                cnt += 1
                if cnt >= 3:
                    print("Yes")
                    exit()
            else:
                flag = False
                cnt = 0
        else:
            if a == b:
                flag = True
                cnt = 1
    print("No")
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 61932
/**


  ######                                                                     ######   #     #  #######
  #     #    ##    #####   #    #  #    #  #    #  #   ####   #    #  #####  #     #  #     #       #
  #     #   #  #   #    #  #   #   #   #   ##   #  #  #    #  #    #    #    #     #  #     #      #
  #     #  #    #  #    #  ####    ####    # #  #  #  #       ######    #    ######   #######     #
  #     #  ######  #####   #  #    #  #    #  # #  #  #  ###  #    #    #    #   #    #     #    #
  #     #  #    #  #   #   #   #   #   #   #   ##  #  #    #  #    #    #    #    #   #     #   #
  ######   #    #  #    #  #    #  #    #  #    #  #   ####   #    #    #    #     #  #     #  #######



**/
/*

    BismiLLAHIR RAHMANIR RAHIM
    It's not how you look or who you are underneath, it's what you do that defines you

                                ------********-------

    Status : ;
    TC: xxx/xxx;
    DOS: ;
    OJ: ;

*/

#include <bits/stdc++.h>

using namespace std;

#define test        cout<<"thiq ase boss"<<endl;
#define PB          push_back
#define PF          push_front
#define PII         pair <int,int>
#define MII         map <int,int>
#define MSI         map <string,int>
#define MIS         map <int,string>
#define MLI         map <long long int,int>
#define MIL         map <int,long long int>
typedef long long int           LL;
typedef vector <string>         VS;
typedef vector <int>            VI;
typedef vector <char>           VC;
typedef vector <LL>             VLL;

const int INF = 1e9;
const int MX = 1e9;
const double PI = acos(-1);

/* Functions */

int main() {
    #ifdef LU_SERIOUS
        //freopen("get.txt","r",stdin);
    #endif // LU_SERIOUS
    LL a,b,c,lo,hi;
    while (cin >>a>>b>>c) {
        if (a) lo = (a-1) / c;
        else lo = -1;
        hi = b/c;
        cout << hi - lo << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import collections

N = int(input())
l = []
 
for _ in range(N):
    s = str(input())
    l.append(s)

c = collections.Counter(l)
c = c.most_common()
 
most_count = c[0][1]
c.sort()
 
for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])

Measured memory_bytes: 45116
/*
 * @Author: Kaizyn
 * @Date: 2020-04-04 20:17:16
 * @LastEditTime: 2020-04-04 21:31:36
 */
#include <bits/stdc++.h>

using namespace std;

const int N = 1e6+7;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;

int k;
int f[20][12], s[20];
// f[i][j] start with j, length i
int res[20];

void dfs(const int &u, const int &val)
{
    if (!u) return;
    int v = (val < k), nex = val;
    for (int i = 1; i <= 9; ++i) {
        if (nex+f[u][i] < k) {
            nex += f[u][i];
            v = i+1;
        } else if (nex+f[u][i] == k) {
            nex += f[u][i];
            v = i;
        }
    }
    res[u] = v;
    dfs(u-1, nex);
}

inline void solve()
{
    cin >> k;
    if (k < 10) return void(cout << k << endl);
    for (int i = 0; i <= 9; ++i) f[1][i] = 1;
    s[1] = 9;
    for (int i = 2; i <= 12; ++i) {
        f[i][0] += f[i-1][0]+f[i-1][1];
        f[i][9] += f[i-1][9]+f[i-1][8];
        s[i] = s[i-1]+f[i][9];
        for (int j = 1; j <= 8; ++j) {
            f[i][j] += f[i-1][j-1]+f[i-1][j]+f[i-1][j+1];
            s[i] += f[i][j];
        }
    }
    #ifdef DEBUG
    for (int i = 1; i <= 12; ++i) {
        for (int j = 0; j <= 9; ++j) {
            cout << f[i][j] << " \n"[j==9];
        }
    }
    for (int i = 1; i <= 12; ++i) cout << s[i] << " \n"[i==12];
    #endif
    int len = 0, u = 1;
    while (s[len] < k) ++len;
    // dfs(len, s[len-1]);
    k -= s[len-1];
    while (k > f[len][u]) {
        k -= f[len][u];
        ++u;
    }
    res[len] = u;
    for (int i = len-1, l, r; i; --i) {
        l = max(0, res[i+1]-1);
        r = min(9, res[i-1]+1);
        u = l;
        while (k > f[i][u]) {
            k -= f[i][u];
            ++u;
        }
        res[i] = u;
    }
    for (int i = len; i; --i) cout << res[i];
    cout << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	string s;cin>>s;
	bool ok=1;
	rep(i,1,sz(s))if(s[i]==s[i-1])ok=0;
	if(!ok)cout<<"Bad";
	else cout<<"Good";
	
	
	
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int p = sc.nextInt();
		// 出力
		System.out.println( ( ( a * 3 + p ) / 2) );
				
		}
	}


Measured memory_bytes: 22356
#include <stdio.h>

void put_sharp(int h, int w)
{
    int i, j;

    for (i = 1; i <= h; i++)
    {
        for (j = 1; j <= w; j++)
        {
            putchar('#');
        }
        putchar('\n');
    }
}

int main(void)
{
    int h, w;

    while (1)
    {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0)
        {
            break;
        }
        else
        {
            put_sharp(h, w);
            putchar('\n');
        }
    }

    return 0;
}


Measured memory_bytes: 2056
# Your code here!

a=gets.chomp.split("")
b=gets.chomp.split("")

lla=a.length
llb=b.length




array2=[]
if lla>=llb
array=Array.new(lla-llb+1).map{Array.new(lla,"?")}

j=0
(lla-llb+1).times{
    
      array[j][j..j+llb-1]=b
    
    
    j+=1
    
}

array=array.reverse
nn=0
loop{
    
      kk=0
    answer=0
       lla.times{
         
           if a[kk]!="?"  &&  array[nn][kk]!=a[kk]  && array[nn][kk]!="?"
               answer=0
              
              
           else 
              answer+=1
           end
           
        kk+=1   
       }
if answer==lla
    array2<<array[nn]
    kkkk=0
      lla.times{
          if a[kkkk]!="?"
          array2[-1][kkkk]=a[kkkk]
      end
          kkkk+=1
          
      }
break    
    
    
end  


if nn==lla-llb
 break
end
    
 nn+=1  
 
 
 
  
}



if array2.length==0
 puts "UNRESTORABLE"

else
ss=0
lla.times{
    if array2[0][ss]=="?"
     array2[0][ss]="a"
    
 end
    
    
    ss+=1
}

puts array2[0].join


end








else
 puts "UNRESTORABLE"
end







Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int H, W, N;
	int sr, sc;
	string S, T;
	cin >> H >> W >> N >> sr >> sc >> S >> T;
	--sr; --sc;
	
	map<char, int> mm;
	{
		string s = "LRUD";
		REP(i, s.size()) mm[s[i]] = i;
	}
	
	bool ok = true;
	REP(dir, 2) {
		vector<pii> liv(N);
		int mn = 0, mx = dir == 0 ? W - 1 : H - 1;
		int l = mn, r = mx;
		
		for (int i = liv.size() - 1; i >= 0; --i) {
			int d = mm[T[i]];
			if (dir == 1 ^ d < 2) {
				int p = d & 1 ? 1 : -1;
				l = min(l, max(l - p, mn));
				r = max(r, min(r - p, mx));
			}
			d = mm[S[i]];
			ok &= l <= r;
			if (dir == 1 ^ d < 2) {
				int p = d & 1 ? 1 : -1;
				l = max(l, l - p);
				r = min(r, r - p);
			}
			ok &= l <= r;
		}
		
		int cx = dir == 0 ? sc : sr;
		ok &= l <= cx && cx <= r;
	}
	
	puts([&] {
		return ok;
	}() ? "YES": "NO");
	return 0;
}


Measured memory_bytes: 2312
N = gets.to_i
Pair = Struct.new(:a, :i)

top2 = [Pair.new(0, 0), Pair.new(0, 0)]
N.times{|_| i = _+1
	a = gets.to_i
	if top2.first.a <= a
		top2[0], top2[1] = Pair.new(a, i), top2.first
	elsif top2.last.a < a
		top2[0], top2[1] = top2.first, Pair.new(a, i)
	end
}

(1..(top2.first.i-1)).each{|i|
	p top2.first.a
}
p top2.last.a
((top2.first.i+1)..N).each{|i|
	p top2.first.a
}


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

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string,int,int>> vt(N);
  rep(i, N){
    string S;
    int P;
    cin >> S >> P;
    vt.at(i) = make_tuple(S, -P, i+1);
  }
  sort(vt.begin(), vt.end());
  rep(i, N){
    cout << get<2>(vt.at(i)) << endl;
  }
}

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

#define int long long

const int N = 101;

int n , a[N] ,sum;

void read() {
	scanf("%lld",&n);
	for(int i = 1;i <= n;i ++) scanf("%lld",&a[i]);
}

bool pd() {
	for(int i = 1;i <= n;i ++) if((a[i] + sum) > n - 1) return 0;
	return 1;
}

main() {
	read();
	while(1) {
		for(int i = 1;i <= n;i ++) {
			if((a[i] + sum) > n - 1) {
				int p = (a[i] + sum) / n;
				a[i] -= p * n + p;
				sum += p;
			}
		}
		if(pd()) break;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] a = ReadIntArray();
	int[] b = ReadIntArray();
	int[] c = ReadIntArray();

	int ans = 0;
	for (int i = 0; i < n; i++)
	{
	    int ai = a[i];
	    ans += b[ai-1];
	    if (i > 0 && a[i] == a[i-1] + 1)
	    {
		ans += c[a[i-1]-1];
	    }
	}
	WriteLine(ans);
    }
}


Measured memory_bytes: 13396
n = int(input())
s = input()

ruiseki_count_w = [0]*n
ruiseki_count_w[0] = 1 if s[0]=="W" else 0

for i in range(1,n):
  if s[i]=="W":
    ruiseki_count_w[i] = ruiseki_count_w[i-1] + 1  
  else:
    ruiseki_count_w[i] = ruiseki_count_w[i-1]

#print(ruiseki_count_w)
ans=300000

for i in range(n):
  
  if i ==0:
    ans = min(n-1-(ruiseki_count_w[n-1]-ruiseki_count_w[0]),ans)
  elif i ==n:
    ans = min(ruiseki_count_w[n-1],ans)
  else:
    left_side_w = ruiseki_count_w[i-1]
    rihgt_side_e = (n-1-i)-(ruiseki_count_w[n-1]-ruiseki_count_w[i])
    ans = min(left_side_w+rihgt_side_e,ans)

print(ans)


#計算量オーバーしそう
#for i in range(n):
#  ans = 0
#  for j in range(n):
#    if i < j and s[j]=="E":
#      ans += 1
#    if j < i and s[j]=="W":
#      ans += 1
#  print(ans)

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

int sortfnc(const void *a,const void *b){
	return *(int *)b-*(int *)a;
}

int main(void) {
	int i,n,a,b,c,t[128],nm,nc;
	scanf("%d%d%d%d",&n,&a,&b,&c);
	for(i = 0;i < n;i++){
		scanf("%d",&t[i]);
	}
	qsort(t,n,sizeof(int),sortfnc);
	nm = a;
	nc = c;
	for(i = 0;i < n;i++){
		if((nc/nm) > ((nc+t[i])/(nm+b))){break;}
		nc+=t[i];nm+=b;
	}
	printf("%d\n",nc/nm);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int N;
	cin >> N;
	int A[N];
	int ans = 1, yo = 1;
	rep(i,N){
		cin >> A[i];
		ans *= 3;
		if(A[i] % 2 == 0) yo *= 2;
	}
	cout << ans - yo << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
typedef long long ll;
using namespace std;
char str[10000000];
int main(void){

    ll n;
    char before[1000];
    char after[1000];

    while(cin>>n,n){
    for(int i=0;i<n;i++){
        cin >> before[i];
        cin >> after[i];
    }
    ll m;
    cin >> m;
    for(int i=0;i<m;i++){
        cin >> str[i];
    }
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(str[i]==before[j]){
                    str[i]=after[j];
                    break;
                }
            }
        }
        cout<<str<<endl;
    }
    return 0;
}

Measured memory_bytes: 1252
l = []
a = int(input())
a1 = a%10
a2 = a + (10-a1)%10
b = int(input())
b1=b%10
b2 = b + (10-b1)%10
c = int(input())
c1=c%10
c2 = c + (10-c1)%10
d = int(input())
d1=d%10
d2 = d + (10-d1)%10
e = int(input())
e1=e%10
e2 = e + (10-e1)%10
if a1 != 0:
    l.append(a1)
if b1 != 0:
    l.append(b1)
if c1 != 0:
    l.append(c1)
if d1 != 0:
    l.append(d1)
if e1 != 0:
    l.append(e1)

if max(a1,b1,c1,d1,e1) == 0:
    ans = a2+b2+c2+d2+e2
else:
    ans = a2+b2+c2+d2+e2 -10 +min(l)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x = 0, y = 0, t = 0, n, distance;
  cin >> n;
  vector<vector<int>> point(n, vector<int>(3));
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin >> point[i][j];
    }
  }
  for(int i=0;i<n;i++){
    distance = abs(x - point[i][1]) + abs(y - point[i][2]);
    if(
      (distance > (point[i][0] - t)) || 
      ((distance % 2) != ((point[i][0] - t) % 2))
    ){
      cout << "No" << endl;
      return 0;
    }
    t = point[i][0];
    x = point[i][1];
    y = point[i][2];
  }
  cout << "Yes" << endl;
}

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


int main() {
  ll n,m,q,sum=0,ans=0;
  cin>>n>>m>>q;
  vector<vector<int>> abcd(q,vector<int>(4));
  rep(i,q){
    cin>>abcd.at(i).at(0)>>abcd.at(i).at(1)>>abcd.at(i).at(2)>>abcd.at(i).at(3);
  }
  int suretu[10];
  for(int a=1;a<=m;a++){
    suretu[0]=a;
    for(int b=a;b<=m;b++){
      suretu[1]=b;
      for(int c=b;c<=m;c++){
        suretu[2]=c;
        for(int d=c;d<=m;d++){
          suretu[3]=d;
          for(int e=d;e<=m;e++){
            suretu[4]=e;
            for(int f=e;f<=m;f++){
              suretu[5]=f;
              for(int g=f;g<=m;g++){
                suretu[6]=g;
                for(int h=g;h<=m;h++){
                  suretu[7]=h;
                  for(int j=h;j<=m;j++){
                    suretu[8]=j;
                    for(int k=j;k<=m;k++){
                      suretu[9]=k;
                      
           sum=0;
           for(int i=0; i<q; i++){
            if(suretu[abcd[i][1]-1]-suretu[abcd[i][0]-1]==abcd[i][2]){
              sum+=abcd[i][3];
            }
           }
          
          if(sum>ans) ans=sum;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
 
  cout<<ans<<endl;   
  
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  if(s == "Sunny") cout << "Cloudy" << endl;
  else if(s == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
  
  return 0;
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int a;
	cin >> a;
	string s;
	cin >> s;
	cout << (a >= 3200 ? s : "red") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    string s; cin >> s;
    int cnt[3] = {0,0,0};
    for(int i = 0; i < s.size(); i++){
        cnt[s[i] - 'a']++;
    }

    bool f = true;
    if(abs(cnt[0] - cnt[1]) >= 2) f = false;
    if(abs(cnt[2] - cnt[1]) >= 2) f = false;
    if(abs(cnt[0] - cnt[2]) >= 2) f = false;

    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,o,p,q,cnt=0,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>m>>n>>o>>p>>q;
    cout<<o*60+p-m*60-n-q;
}

Measured memory_bytes: 10516
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] heights = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();

            for(int i = n - 1;i > 1;i--)
            {
                if(heights[i] - heights[i - 1] == -1)
                {
                    heights[i - 1]--;
                }
                else if(heights[i] < heights[i - 1])
                {
                    Console.WriteLine("No");
                    return;
                }
                else
                {
                    continue;
                }
            }
            Console.WriteLine("Yes");
            return;
        }
    }

    struct Vector2
    {
        public Vector2(int x,int y)
        {
            this.x = x;
            this.y = y;
        }
        public int x;
        public int y;
    }

    struct Vector3
    {
        public int x;
        public int y;
        public int z;
    }
}


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

int main(){
  string p[9]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  string s;
  int n;
  cin>>n;
  while(n--){
    cin>>s;
    for(int i=0;i<(int)s.size();i++)
      if(s[i]=='0') s[i]=' ';
    stringstream ss(s);
    while(ss>>s){
      cout<<p[s[0]-'1'][(s.size()-1) % p[s[0]-'1'].size()];
    }
    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define se second
#define fi first
using namespace std;
typedef pair<pair<double,int>,pair<int,int> >P;
struct edge{int to,lim;double dist;};
int n,m,st,go,a1,a2,a3,a4;
double d[31][31][31];
int dx[]={-1,0,1};
vector<edge> v[31];
int main(){
  while(cin>>n>>m,n){
    r(i,31)v[i].clear();
    r(i,31)r(j,31)r(k,31)d[i][j][k]=1e12;
    cin>>st>>go;
    r(i,m){
      edge e;
      cin>>a1>>a2>>a3>>a4;
      e.to=a2,e.dist=a3,e.lim=a4;
      v[a1].push_back(e);
      e.to=a1;
      v[a2].push_back(e);
    }
    priority_queue<P,vector<P>,greater<P> >q;
    P xt;xt.fi.fi=0,xt.fi.se=0,xt.se.fi=st,xt.se.se=-1;
    q.push(xt);
    while(!q.empty()){
      P p=q.top();q.pop();
      int cur=p.se.fi,pp=p.se.se;
      if(cur==go&&p.fi.se==1){
        printf("%.9f\n",p.fi.fi);
        goto L;
      }
      r(i,v[cur].size()){
        edge e=v[cur][i];
        if(e.to!=pp)r(j,3){
          int x=p.fi.se+dx[j];
          if(0<x&&x<=e.lim){
            double t=e.dist/x+p.fi.fi;
            if(d[e.to][pp][x]>t){
              d[e.to][pp][x]=t;
              P xt;xt.fi.fi=d[e.to][pp][x],xt.fi.se=x,xt.se.fi=e.to,xt.se.se=cur;
              q.push(xt);
            }
          }
        }
      }
    }
    cout<<"unreachable"<<endl;L:;
  }
}

Measured memory_bytes: 4416
#include <cstdio>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;

int main(){
	string str;
	int size,h;
	cin >> str;
	size = str.size();
	string mozi[size],ans = "";;
	for(int i = 0;size > i;i++){mozi[i] = str.substr(i,1);}
	for(int i = 1;size >= i;i++){ans.append(mozi[size - i]);}
	cout << ans << endl;


}

Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    int minn=100000000;
    long long total=0;
    long long total2=0;
    for(int i=0;i<n;i++){
        cin >> s[i];
        total+=s[i];
        if(s[i]%10!=0){
            if(minn>s[i]){
                minn = s[i];
            }
        }
    }
    total2 = total-minn;
    sort(s.begin(),s.end());
    for(int i=0;i<n;i++){
        if(total%10!=0){
            break;
        }else{
            total = total-s[i];
        }
    }
    cout << max(total,total2) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int ary[] = {1,2,4,8,16,32,64};
      	int ans = 0;
      	for(int i = 0; i < ary.length; i++)
        {
          if(ary[i] <= num)
          {
          		ans = ary[i];
          }
        }
      
        System.out.println(ans);
      
    }
}

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

#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long

#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>

#define infi INT_MAX
#define infl LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second

ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
ll gcdArray(ll arr[], ll n) 
{ 
    ll result = arr[0]; 
    for (ll i = 1; i < n; i++)
        result = gcd(arr[i], result); 
  
    return result; 
} 

//(x^y)%p
ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
 
 
ll lcm(ll a,ll b)
{
  ll ans=(a*b)/(gcd(a,b));
  return ans;
} 


/*
ll parent[(ll)1e6+7];
ll rank1[(ll)1e6+7]; 


ll find(ll i)
{
  if(parent[i]!=i)  parent[i]=find(parent[i]);
  return parent[i];
}

void union1(ll i,ll j)
{
    ll i_id=find(i);
    ll j_id=find(j);
    if(i_id==j_id)  return;

    if(rank1[i_id]>rank1[j_id]) parent[j_id]=i_id;
    else parent[i_id]=j_id;

    if(rank1[i_id]==rank1[j_id]) rank1[j_id]++;
}

*/

//list<ll>adj[1000007];
//ll p=1e9+7;
/*bool dfs(ll s,bool *visited,ll parent)
{
   visited[s]=1;
   for(auto i:adj[s])
   {
      if(!visited[i])  
      {
        if(dfs(i,visited,s))  return 1;
      }

      else if(i!=parent)  return 1;
   } 
   return 0;

}*/

/*void dfs(ll s,bool *visited,ll *count)
{
  visited[s]=1;
  (*count)++;
  for(auto i:adj[s])  if(!visited[i])  dfs(i,visited,count);
}*/


void func()
{
  string s;
  cin>>s;
  ll l=s.length(),cnt=0;
  //cout<<l<<" "<<(l/2)-1<<endl;
  f(i,0,(l/2))  if(s[i]!=s[l-1-i])  cnt++;
  cout<<cnt<<endl;
}
 
int main() 
{
    fast
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

    int q=1;
    //cin>>q;
    while(q)
    {
      func();
      q--;
    }

    return 0;
}

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

namespace B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = RInt();
            string s = RSt();

            int r = s.Count(x => x == 'R');
            int b = s.Count(x => x == 'B');

            Console.WriteLine(r > b ? "Yes" : "No");
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


Measured memory_bytes: 11220
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    if N % 1000 == 0:
        print(0)
    else:
        print(1000 - N % 1000)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9160
S = [int(x) for x in input()] # < 10**5

#print(S)
#print(odd)
#print(even)

odd =  [1 if i % 2 == 0 else 0 for i in range(len(S))]
even = [0 if i % 2 == 0 else 1 for i in range(len(S))]
print(min([
    sum(1 if i != j else 0 for i, j in zip(S, odd)),
    sum(1 if i != j else 0 for i, j in zip(S, even))
    ]))

Measured memory_bytes: 5532
import collections
N = int(input())
A = list(map(int, input().split()))

p = collections.Counter() # +
n = collections.Counter() # -
for i in range(N):
  p[i+A[i]] += 1
  n[i-A[i]] += 1
  
ans = 0
for i in p.keys():
  ans += p[i]*n[i]
print(ans)

Measured memory_bytes: 57636
#include <iostream>
    #include <algorithm>
    #include <string>
    #include <list>
    #include<vector>
    #include <sstream>
    #include <stdio.h>
    #include <utility>
    #include <unordered_set>
    #include <valarray>
    #include <iomanip>
    using namespace std;
     
     
    int main(void)
    {
    	int A, B = 0;
    	int TargetData=0;
     
    	cin >> TargetData;
     	bool BreakFlag=false;
      	for(int i=-1000;i<=2000;i++)
        {
          for(int z=-2000;z<=2000;z++)
          {
            if((pow(i,5)-pow(z,5))==TargetData)
            {
              A=i;
              B=z;
              cout << A<<" "<<B << endl;
              
              return 0;
            }
          }
        }
     
    	cout << A<<" "<<B << endl;
     
    	return 0;
    }

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

using namespace std;

int n = 0 , g = 0 , h = 0;
string s , t;
int main()
{
	cin >> n >> s >> t;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i + j == n)
			{
				break;      
			}
			if (t[j] != s[i+j])
			{
				break;
			}
			h++;
		}
		if (h > g)
		{
			g = h;
		}
		h = 0;
	}
	cout << 2 * n - g;
	return 0;
}


Measured memory_bytes: 256