akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main(){
  string s;
  while(true){
    cin >> s;
    if(s == "#")
      break;

    int rule[26] = {0, 0, 0, 0, 0,
                    0, 0, 1, 1, 1,
                    1, 1, 1, 1, 1,
                    1, 0, 0, 0, 0,
                    1, 0, 0, 0, 1, 0};
    
    int ans = 0;
    for(int i=0; i<s.size()-1; i++){
      if(rule[s[i] - 'a'] != rule[s[i+1] - 'a'])
        ans++;
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3196
# coding: utf-8
height, width = list(map(int, input().split(" ")))
answer = [[0 for _ in range(width + 1)] for _ in range(height + 1)]

for row in range(height):
    column = 0
    sumOfColumn = 0
    for value in list(map(int, input().split(" "))):
        answer[row][column] = value
        sumOfColumn += value
        column += 1
    answer[row][column] = sumOfColumn
    
for columnIndex in range(width + 1):
    sumOfRow = 0
    for rowIndex in range(height):
        value = answer[rowIndex][columnIndex]
        sumOfRow += value
    answer[height][columnIndex] = sumOfRow

for row in answer:
    print(" ".join(map(str, row)))

Measured memory_bytes: 7724
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int x;
   cin >> x;

   if(x==3 || x == 5 || x == 7) cout << "YES" << endl;
   else cout << "NO" << endl;




   return 0;
}

Measured memory_bytes: 256
N=int(input())
listA=[[0,0,0]] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;        
        
def main():
  for i in range(N):
    Manhattan_distance=abs(listA[i+1][1]-listA[i][1])+abs(listA[i+1][2]-listA[i][2])
    #print("Manhattan_distance",Manhattan_distance)
    #print("")
    
    # 偶奇での不可と可能
    if listA[i+1][0]%2!=(listA[i+1][1]+listA[i+1][2])%2:
      #print("listA[i+1][0]%2",listA[i+1][0]%2)
      #print("(listA[i+1][1]+listA[i+1][2])%2",(listA[i+1][1]+listA[i+1][2])%2)
      return "No"
    
    if (listA[i+1][0]-listA[i][0])%2!=Manhattan_distance%2: #時間差%2 != マンハッタン距離
      #print("(listA[i+1][0]-listA[i][0])%2",(listA[i+1][0]-listA[i][0])%2)
      
      return "No"
    
    # 距離的制約
    if (listA[i+1][0]-listA[i][0])<Manhattan_distance:
      return "No"
  
  return "Yes"



print(main())

Measured memory_bytes: 27312
#include<iostream>
using namespace std;
int main(){
    int n;
 cin>>n;
 int h[n];
 int v[n];
 for(int i=0;i<n;i++){
     cin>>h[i];
   v[i]=0;
 }    

if(n==1){
    cout<<0;
    return 0;
}
v[0] = h[0]>=h[1];
for(int i=1;i<n-1;i++){
    if(h[i]>=h[i+1]){
        v[i] = v[i-1]+1; 
    } else{
        v[i] = 0;
    }
}
int ans=0;
for(int i=0;i<n;i++){
    if(v[i]>ans){
        ans =v[i];
    }
  // cout<<v[i]<<", ";
}
//cout<<endl;
cout<<ans;

}

Measured memory_bytes: 1024
N,M=map(int,input().split())
S=input()
S=S[::-1]
count=0
count_1=0
count_2=0
answer=[]
ans=0

for i,s in enumerate(S):
    #print(i)
    if i==0:
        pass
    elif i==N:
        count_1+=1
        answer.append(count_1)
        #print("g")
    elif s=="0"and count_1<M-1:
        count_1+=1
        count=count_1
        count_2=0
        #print("a")
    elif s=="0" and count_1==(M-1):
        count_1+=1
        count_2=0
        answer.append(count_1)
        count=0
        count_1=count
        #print("b")
    else:
        if count_1<M-1 and count_2<M-1:
            count_1+=1
            count_2+=1
            #print("c")
        elif count_2==M-1:
            ans=-1
            #print("d")
            break
        elif count_1==M-1:
            count_2+=1
            answer.append(count)
            count_1=count_2
            count=count_1
            #print("e")
if ans==-1:
    print(-1)
else:
    print(" ".join(map(str,answer[::-1])))


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

int insertionSort(int A[], int N){
	for (int i=1; i<N; i++){
		int v,j;
		v = A[i];
		j = i-1;
		while (j>=0 && A[j]>v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;

		for (int j=0; j<N; j++){ 
			if (j) cout << " ";
			cout << A[j];
		}
		cout << endl;
	}
}

int main(){
	int A[100], N;
	cin >> N;
	for (int i=0; i<N; i++) cin >> A[i];
	
	for (int j=0; j<N; j++){ 
		if (j) cout << " ";
		cout << A[j];
	}
	cout << endl;
	insertionSort(A,N);
}

Measured memory_bytes: 1160
s=input()
l=len(s)
cnt=0
if l%2==0:
  for i in range(l//2):
    if s[i]!=s[l-i-1]:
      cnt+=1
else:
  for i in range((l-1)//2):
    if s[i]!=s[l-i-1]:
      cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <algorithm>
#include <stdio.h>
#include <deque>
#include <set>
using namespace std;
using ll = long long;

class Int2 {
public:
	int chara, count;
	Int2(int chara, int count) {
		this->chara = chara;
		this->count = count;
	}
};
int n, a[200000];
bool incr(deque<Int2>& c, int x) {
	if (c.back().chara + 1 < x) {
		if (c.back().count == 1)
			c.back().chara += 1;
		else {
			c.back().count -= 1;
			c.emplace_back(c.back().chara + 1, 1);
		}
	}
	else {
		if (c.size() == 1)
			return false;
		int up = c.back().count;
		c.pop_back();
		if (!incr(c, x))
			return false;
		c.emplace_back(0, up);
	}
	return true;
}
bool able(int x) {
	deque<Int2> c;
	c.emplace_back(0, a[0]);

	for (int i = 1; i < n; i++) {
		if (a[i - 1] < a[i]) {
			if (c.back().chara == 0)
				c.back().count += a[i] - a[i - 1];
			else
				c.emplace_back(0, a[i] - a[i - 1]);
		}
		if (a[i - 1] >= a[i]) {
			int rem = a[i - 1] - a[i];
			while (rem) {
				if (c.back().count <= rem) {
					rem -= c.back().count;
					c.pop_back();
				}
				else {
					c.back().count -= rem;
					rem = 0;
				}
			}

			if (!incr(c, x))
				return false;
		}
	}
	return true;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	int low = 0, upp = n, cen = (low + upp) / 2;
	while (2 <= (upp - low)) {
		if (able(cen))
			upp = cen;
		else
			low = cen;
		cen = (low + upp) / 2;
	}
	printf("%d\n", upp);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
   int n,x;
   cin>>n>>x;
   int arr[n+1];
   repre(i,1,n)cin>>arr[i];
   int ans=0;
   int i;
   for(i=1;i<=n;i++)
   {
     ans+=arr[i];
     if(ans>x)break;
   }
   cout<<i<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define INF 1e9+5
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define popf pop_front
#define popb pop_back

ll x, yen=100, ans;

int main(){
	scanf("%lld", &x);
	for(; yen<x; ++ans)yen+=yen/100;
	printf("%lld", ans);

	return 0;
}


Measured memory_bytes: 3812
#include <iostream>

using namespace std;

int main() {
    int a, b,c;
    cin >> a>>b>>c;
    if(a!=b&&a!=c&&b!=c){
        cout<<"No";
    }
    else{
        if(a==b&&b==c){
            cout<<"No";
        }
        else{
            cout<<"Yes";
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
	public class Main{
		public static void main(String args[]){
			Scanner sc = new Scanner(System.in);
			int weight[] = {1,2,4,8,16,32,64,128,256,512};
			List<Integer> list = new ArrayList<Integer>();
			while(sc.hasNext()){
				int target = sc.nextInt();
				for(int i = 9; i > -1 ; i--){
					if(target>=weight[i]){
						target-=weight[i];
						list.add(weight[i]);
					}
				}
				for(int i = list.size();i>1;i--){
					System.out.print(list.get(i-1)+" ");
				}
				System.out.println(list.get(0));
				list.clear();
			}
		}
	}		

Measured memory_bytes: 26248
#include <iostream>
#include <stdio.h>

#include <vector>

using namespace std;

int main()
{
    int m, r, f;

    while (cin >> m >> r >> f) {
       
        if (m==-1 && r == -1 && f == -1) {
            break;
        }

        if (m==-1 || r == -1) {
            cout << "F" << endl;
        }
        else if (m + r >= 80) {
            cout << "A" << endl;
        }
        else if (m + r >= 65 && m + r < 80) {
            cout << "B" << endl;
        }
        else if (m + r >= 50 && m + r < 65) {
            cout << "C" << endl;
        }
        else if (m + r >= 30 && m + r < 50) {
            if (f >= 50) {
                cout << "C" << endl;
            }
            else {
                cout << "D" << endl;
            }
        }
        else if (m+r<30) {
            cout << "F" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
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; }
using namespace std;

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

    int n,a,b; cin>>n>>a>>b;
    cout<<min<int>(n*a,b)<<endl;

}

Measured memory_bytes: 256
// start: 1:45
// AC: 2:34
#include <cmath>
#include <iostream>
#include <vector>

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

using namespace std;

int main() {
    int n;
    
    while(cin >> n, n) {
        vector<vector<int> > inp(n, vector<int>(n+1, 0));

        REP(i, n) REP(t, n+1) cin >> inp[i][t];

        /**
        bdp[ステージフラグ|装備フラグ...] = 最短時間
        */

        vector<int> bdp(1<<n, 1<<29);

        bdp[0] = 0;

        REP(i, (1<<n)) {
            // 挑むステージ
            REP(to, n) {
                // 未クリアなら
                if ( (to & (1 << to)) == 0 ) {
                    int mint = inp[to][0];
                    // 使う装備
                    for ( int eq = 1; eq < n + 1; eq++ ) {
                        // このステージに使える装備があるとき
                        if ( (i & (1 << (eq-1))) > 0 ) mint = min(mint, inp[to][eq]);
                    }
                    bdp[i|(1<<to)] = min(bdp[i] + mint, bdp[i|(1<<to)]);
                    // cout << (1<<to) << " " << bdp[1<<to] << endl;
                }
            }
        }

        // 全フラグが立っている時
        cout << bdp[(1<<n)-1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1476
package main
import "fmt"
func main(){
	var n ,  max , min , sum , fn int
	max = -1000000
	min = 1000000
	sum = 0
	fmt.Scan(&n)
	a := []int{}
	for i := 0; i < int(n) ; i++{
		fmt.Scan(&fn)
		a = append(a, fn)
		if a[i] > max {
			max = a[i]
		}
		if a[i] < min { 
			min = a[i]
		}
		sum = sum + a[i]
	}
	fmt.Print(min)
	fmt.Print(" ")
	fmt.Print(max)
	fmt.Print(" ")
	fmt.Println(sum)
}


Measured memory_bytes: 2172
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
    n, k, q = map(int, input().strip().split())
    d = [0] * n
    for _ in range(q):
        i = int(input().strip()) - 1
        d[i] += 1
    for c in d:
        if k - q + c > 0:
            print('Yes')
        else:
            print('No')
            
if __name__ == '__main__':
    main()


Measured memory_bytes: 46940
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int conb(int x, int y, int z){
    int ans = 3;
    if(x == y && y == z){
        ans = 1;
    }else if(x == y){
        ans = 2;
    }else if(y == z){
        ans = 2;
    }else if(x == z){
        ans = 2;
    }
    return ans;
}
int main(){
    int K, S;
    cin >> K >> S;
    int x, y, z;
    long long ans = 0;
    for(x = 0; x <= K; x++){
        int tmp = S - x;
        if(tmp < 0){
            break;
        }
        for(y = 0; y <= K; y++){
            int z = tmp - y;
            if(z > K || z < 0){
                continue;
            }else{
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
main :: IO()
main = do
    [n,m] <- map read . words <$> getLine
    print $ getsolve n m

getsolve :: Integer -> Integer -> Integer
-- Sの個数→Cの個数→SCCのできる個数
getsolve _ 0 = 0
getsolve _ 1 = 0
getsolve 0 cnum = div cnum 4
getsolve snum cnum = makescc + getsolve (snum - makescc) (cnum - (makescc * 2))
    where makescc = min snum (div cnum 2)


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

int main(){
  int r;
  int D;
  int x2000;

  cin >> r >> D >> x2000;

  int xi = x2000;
  for(int i = 1; i <= 10; i++){
    xi = r * xi - D;
    cout << xi << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))

print(' '.join(map(str, a_list)))
for i in range(1, n):
    v = a_list[i]
    j = i-1
    while j >= 0 and a_list[j] > v:
        a_list[j+1] = a_list[j]
        j -= 1
    a_list[j+1] = v
    print(' '.join(map(str, a_list)))



Measured memory_bytes: 5596
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

# 愚直に考えるとO(QN)で間に合わないので、以下のような操作に置き換える
# 開始時点の全員のポイントはK-Qとする
# Q回の正解それぞれに対し、正解者のポイントを1増やす
# するとO(Q+N)で解け、間に合う
p = [K-Q]*N
for i in range(Q):
  p[A[i]-1] += 1
  
for i in range(N):
  if p[i] > 0: print('Yes')
  else: print('No')

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;
    cin>>N;
    vpint v;
    rep(i,N){
        int a,b;cin>>a>>b;v.pb({a,b});
    }
    sort(all(v));
    reverse(all(v));
    cout<<v[0].fi+v[0].se<<endl;
    return 0;
}


Measured memory_bytes: 2420
S = input()
N = len(S)
ans = [1]*N

for i in range(N-1):
  if S[i] == S[i+1] == "R":
    ans[i+2] += ans[i]
    ans[i] = 0
    
for j in range(N-1,0,-1):
  if S[j] == S[j-1] == "L":
    ans[j-2] += ans[j]
    ans[j] = 0
    
print(*ans)

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

constexpr int max(int a, int b) {
  return (a>b)?a:b;
}
int main(int argc, char** argv) {
  int a, b;
  std::cin >> a >> b;
  int t_max = max(a, b);
  int t_min = (a+b)-t_max;
  for (auto i = 0;i < t_max;++i) {
    std::cout << t_min;
  }
  std::cout << '\n';
}


Measured memory_bytes: 888
#166
#Peaks

N,M=map(int,input().split())
H=list(map(int,input().split()))
L=[1]*N
R=[]
for i in range(M):
    A,B=map(int,input().split())
    R.append([A,B])

for l in R:
    a=l[0]-1
    b=l[1]-1
    if H[a]<H[b]:
        L[a]=0
    elif H[a]>H[b]:
        L[b]=0
    else:L[a]=L[b]=0
print(L.count(1))


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

string s,t;
set<int> st[26];

bool solve();

int main(){
    cin >> s >> t;
    if(solve())cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

bool solve(){
    int n = s.size();
    for(int i = 0;i < n;++i){
        st[s[i]-'a'].insert(t[i]);
        if(st[s[i]-'a'].size()>1)return 0;
    }
    for(int i = 0;i < 26;++i)st[i].clear();
    for(int i = 0;i < n;++i){
        st[t[i]-'a'].insert(s[i]);
        if(st[t[i]-'a'].size()>1)return 0;
    }
    return 1;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;

int di[] = {-1, 0, 1, 0};
int dj[] = {0, -1, 0, 1};
int h, w, c;

void draw(vector<vector<int> > &p, int color) {
    vector<vector<bool> > used(h, vector<bool>(w, false));
    queue<pii> que;
    que.push(pii(0, 0));
    int nowc = p[0][0];
    p[0][0] = color;
    while (!que.empty()) {
        int ci = que.front().first;
        int cj = que.front().second;
        que.pop();
        for (int i = 0; i < 4; i++) {
            int ni = ci + di[i];
            int nj = cj + dj[i];
            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (used[ni][nj] == false) {
                used[ni][nj] = 1;
                if (p[ni][nj] == nowc) {
                    p[ni][nj] = color;
                    que.push(pii(ni, nj));
                }
            }
        }
    }
}

int count(vector<vector<int> > p) {
    vector<vector<bool> > used(h, vector<bool>(w, false));
    queue<pii> que;
    que.push(pii(0, 0));
    used[0][0] = true;
    int res = 1;
    while (!que.empty()) {
        int ci = que.front().first;
        int cj = que.front().second;
        que.pop();
        for (int i = 0; i < 4; i++) {
            int ni = ci + di[i];
            int nj = cj + dj[i];
            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (used[ni][nj] == false) {
                used[ni][nj] = 1;
                if (p[ni][nj] == c) {
                    res++;
                    que.push(pii(ni, nj));
                }
            }
        }
    }
    return res;
}

int ans;
int dfs(int cnt, vector<vector<int> > &p) {
    auto t = p;
    if (cnt == 4) {
        draw(p, c);
        ans = max(ans, count(p));
    } else {
        for (int i = 1; i <= 6; i++) {
            draw(p, i);
            dfs(cnt + 1, p);
            p = t;
        }
    }
    return ans;
}

int main() {
    while (cin >> h >> w >> c) {
        if (h + w + c == 0) break;
        vector<vector<int> > p(h, vector<int>(w, 0));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> p[i][j];
            }
        }
        ans = 0;
        cout << dfs(0, p) << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main (void)
{
  int a[5], val;
  for (int i = 0; i < 5; i++)
    {
      cin >> a[i];
      if (a[i] == 0)
	{
	  val = i;
	}
    }
  cout << val + 1;
  return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define ll long long
#define N 100010
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
struct Info{int nu,ne;}a[N*2];
int b[N],num,d[N],n,m,x,y;
void jb(int x,int y){a[++num].nu=y;a[num].ne=b[x];b[x]=num;}
void dfs(int p,int fa){
	if (p==x&&fa) return ;
	if (p==y){num++;return ;}
	for (int y=b[p];y;y=a[y].ne)if(a[y].nu!=fa){dfs(a[y].nu,p);}
}
int main(){
	read(n);read(m);
	for (int i=1;i<=m;i++){read(x);read(y);d[x]++;d[y]++;jb(x,y);jb(y,x);}
	for (int i=1;i<=n;i++)if(d[i]%2==1){puts("No");return 0;}
	x=y=num=0;
	for (int i=1;i<=n;i++){
		if (d[i]>=6){puts("Yes");return 0;}else{if (d[i]==4){num++;if(x)y=i;else x=i;}}
	}
	if (num>=3)puts("Yes");else{
		if (num<=1)puts("No");
		else{
			num=0;dfs(x,0);
			if (num==2)puts("Yes");else puts("No");
		}
	}
	return 0;
}

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

def num_withdraw_ll(N):
    dp = [N] * (N + 1)
    dp[0] = 0
    for n in range(0, N):
        dp[n + 1] = min(dp[n + 1], dp[n] + 1)
        coin = 6
        while n + coin <= N:
            dp[n + coin] = min(dp[n + coin], dp[n] + 1)
            coin *= 6
        coin = 9
        while n + coin <= N:
            dp[n + coin] = min(dp[n + coin], dp[n] + 1)
            coin *= 9
    return dp[N]

print(num_withdraw_ll(N))


Measured memory_bytes: 3828
#include <string>
#include <iostream>

int main(void)
{
  int a, z;
  std::string s;
  std::cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i]=='A') {
      a = i;
      break;
    }
  }
  for (int i = s.size()-1; i > 0; i--) {
    if (s[i]=='Z'){
      z = i;
      break;
    }
  }
  std::cout << z-a+1 << '\n';

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int tate, yoko;
  cin >> tate >> yoko;
  for (int i = 0; i < yoko + 1; i++) {
    cout << "#";
  }
  cout << "#" << endl;
  for (int i = 0; i < tate; i++) {
    string a;
    cin >> a;
    cout << "#" << a << "#" << endl;
  }
  for (int i = 0; i < yoko + 2; i++) {
    cout << "#";
  }
}

Measured memory_bytes: 256
PROGRAM Lamps
      implicit none
      integer,parameter :: p = 16
      integer(p) :: n,k
      integer(p), allocatable :: a(:)
      
      integer(p) :: i,j, left,right
      integer(p), allocatable :: ant(:),post(:)
      
      
      read*,n,k
      allocate( a(n),ant(n),post(n+1) )
      read*,a(1:n)
      
      ant = a
      do j = 1,k
        post = 0
        do i = 1,n
          left  = max( 1,i-ant(i) )
          right = min( n,i+ant(i) )
          
          right = right + 1
          post(left) = post(left) + 1
          post(right) = post(right) - 1
        end do
        
        do i = 2,n
          post(i) = post(i) + post(i-1)
        end do
        
        if( all(ant(1:n)==post(1:n)) ) exit
        
        ant = post
        
      end do
      
      print'(*(i0,x))',post(1:n)
      
      
      
      END PROGRAM

Measured memory_bytes: 13940
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9 + 7;

int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	string arr[h];
	vector<vector<int>>dp(h, vector<int>(w, 0));
	
	for(int row = 0; row < h; ++row) {
        cin>>arr[row];
    }
   
	
        dp[0][0]=1;
        
        for(int i=1;i<w;i++) {
        	if(arr[0][i] != '#')
            	dp[0][i]=1;
            else
            	break;
        }    	
        
        for(int i=1;i<h;i++) {
        	if(arr[i][0] != '#')
        		dp[i][0]=1;
        	else
        		break;
        }		
        
        for(int i=1;i<h;i++) {
            for(int j=1;j<w;j++) {
            	
            	if(arr[i][j] == '#')
            		dp[i][j]=0;
            		
            	else 
            		dp[i][j]=dp[i-1][j]+dp[i][j-1];
            		
            	if(dp[i][j] >= mod)	
            		dp[i][j]-=mod;
            		
            	//cout<<dp[i][j]<<" ";	
            	}    	
               
            
            //cout<<endl;
		}    
            
        
        cout<<dp[h-1][w-1]<<"\n";		
			
			
}

Measured memory_bytes: 5248
N = int(input())
a = list(map(int,input().split()))
multipleOf2 = 0
multipleOf4 = 0
odd = 0
for i in range(N):
    if a[i] % 2 == 0:
        if a[i] % 4 == 0:
            multipleOf4 += 1
        else:
            multipleOf2 += 1 
    else:
        odd += 1

if multipleOf2 + multipleOf4 == N:
    print('Yes')
    exit()
elif multipleOf2 == 0:
    if multipleOf4 >= odd-1:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
elif multipleOf2 >= 1:
    if multipleOf4 >= odd:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
    
# print(multipleOf2, multipleOf4, odd)

Measured memory_bytes: 14252
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ans = 0
for i in [a, b, c, d, e]:
    ans += i//10*10 + (i%10>0)*10

for i in range(1, 10):
    for j in [a, b, c, d, e]:        
        if str(j)[-1] == str(i):
            ans += i - 10
            print(ans)
            exit()
print(ans)

Measured memory_bytes: 9096
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i += 2) {
		cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 512
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                        ll n,a,b;
                        cin>>n>>a>>b;
                        if(a>b)
                                swap(a,b);
                        if((b-a)&1){
                                if(a-1<n-b)
                                        cout<<a-1+(b-(a-1))/2;
                                else
                                        cout<<n-b+(n-a-(n-b)+1)/2;
                        }
                        else
                                cout<<(b-a)/2;
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //printf("Case #%d: ", i);
                                solve();
                         }
        return 0; 
}         
 

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())

    for h in range(1, 3501):
        for n in range(1, 3501):
            a = h * n * N
            b = 4 * h * n - (n + h) * N
            if b > 0 and a % b == 0:
                w = a // b
                print(h, n, w)
                exit()


if __name__ == "__main__":
    main()


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

int main(){
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L == R) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
H,W = map(int,input().split())
figure = [input() for _ in range(H)]
D = [(1,0), (-1, 0), (0,1), (0,-1)]

for h in range(H):
  for w in range(W):
    if figure[h][w] == '#':
      for dh,dw in D:
        nh, nw = h+dh, w+dw
        if not (0 <= nh <H and 0 <= nw < W):
          continue
        if figure[nh][nw] == '#':
          break
      else:
        print('No')
        exit()
print('Yes')



Measured memory_bytes: 9028
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  int m,f,r;
  while(cin>>m>>f>>r,m+f+r!=-3){
    int sum = m+f;
    if(!(m+1&&f+1)){
      puts("F");
      continue;
    }
    if(sum>=80) puts("A");
    else if(sum >= 65) puts("B");
    else if(sum >= 50) puts("C");
    else if(sum >= 30){
      if(r>=50) puts("C");
      else puts("D");
    }
    else puts("F");
  }
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  deque<ll> dq;
  bool fr = true;
  rep(i, n) {
    if (fr) dq.push_front(a[i]);
    else
      dq.push_back(a[i]);
    fr = !fr;
  }
  if(n%2==0)rep(i,n)cout << dq[n-1-i] << " ";
  else rep(i,n) cout << dq[i] << " ";
  cout  << endl;
  return 0;
}

Measured memory_bytes: 6356
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const int N = 3;


template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}


int g[N][N];

bool isBingo() {
	int r, c;
	for (int i = 0; i < N; ++i) {
		r = c = 0;
		for (int j = 0; j < N; ++j) {
			r += g[i][j];
			c += g[j][i];
		}
		if (r == 0 || c == 0)
			return true;
	}

	return g[0][0] + g[1][1] + g[2][2] == 0
		|| g[2][0] + g[1][1] + g[0][2] == 0;
}

void mark(int num) {
	for(int i=0; i<N; ++i)
		for(int j=0; j<N; ++j)
			if (g[i][j] == num) {
				g[i][j] = 0;
				return;
			}
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, x;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; ++j)
			cin >> g[i][j];
	cin >> n;
	while (n--) {
		cin >> x;
		mark(x);
	}
	if (isBingo()) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
}


Measured memory_bytes: 3664
#include<stdio.h>

int main(){
	long n,a,c=0;
	scanf("%ld",&n);
	while(n-->0){
		scanf("%ld",&a);
		c+=a%2;
	}
	if(c%2==0)puts("YES");
	else if(n%2==1)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
long long a,b,k,z,t;
int main()
{
     cin>>a>>b;
	 t=b;
	 for(int i=t;i>0;i/=10)k++;
	 t=1;
	 for(int i=0;i<k;i++)t*=10;
	 a*=t;
	 a+=b;
	 z=sqrt(a);
	 if(z*z==a)cout<<"Yes";
	 else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
// A.

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

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	LL ans = 0;
	string s;
	cin >> s;
	int len = (int)s.length(), w = 0;
	for (int i = len - 1; i >= 0; --i) {
		if (s[i] == 'W') {
			++w;
		} else {
			ans += w;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
main()
{
    int S;
    scanf("%d", &S);
    int h, m, s;
    h=S/3600;
    m=(S-3600*h)/60;
    s=S%60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


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

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		a%=500;
		a-=b;
		String ans = "Yes";
		if(a>0){
			ans = "No";
		}System.out.println(ans);
	}
}

Measured memory_bytes: 23636
using System;

class Program {
    public static void Main() {
        var s = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        var heteNums = Console.ReadLine().Split(' ');
        string useNums = "0123456789";
        for (int i = 0; i < s[1]; i++) {
            useNums = useNums.Replace(heteNums[i], "");
        }

        for (int i = s[0]; i < 100000; i++) {
            var placeStr = i.ToString();
            for (int j = 0; j < placeStr.Length; j++) {
                bool match = false;
                for (int k = 0; k < useNums.Length; k++) {
                    if (placeStr[j] == useNums[k]) {
                        match = true;
                        break;
                    }
                }

                if (!match) {
                    break;
                }
                if (j == placeStr.Length - 1) {
                    Console.WriteLine(i);
                    return;
                }
            }
        }
    }
}

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

int main() {
	// your code goes here
	int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum = 0;
    while(k--){
      if(a>0){
        sum+=1;
        a--;
      }else if(b>0){
        sum+=0;
        b--;
      }else{
        sum+=-1;
        c--;
      }
    }
    cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3548
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
using CostType = long long;
struct Edge {
  int src, dst; CostType cost;
  Edge(int src, int dst, CostType cost = 0) : src(src), dst(dst), cost(cost) {}
  inline bool operator<(const Edge &rhs) const {
    return cost != rhs.cost ? cost < rhs.cost : dst != rhs.dst ? dst < rhs.dst : src < rhs.src;
  }
  inline bool operator<=(const Edge &rhs) const { return cost <= rhs.cost; }
  inline bool operator>(const Edge &rhs) const {
    return cost != rhs.cost ? cost > rhs.cost : dst != rhs.dst ? dst > rhs.dst : src > rhs.src;
  }
  inline bool operator>=(const Edge &rhs) const { return cost >= rhs.cost; }
};

struct Dijkstra {
  using Pci = pair<CostType, pair<int, int> >;

  Dijkstra(const vector<vector<Edge> > &graph, const CostType CINF = LINF) : graph(graph), CINF(CINF) {}

  vector<vector<CostType> > build(int s) {
    int n = graph.size();
    vector<vector<CostType> > dist(n, vector<CostType>(3, LINF));
    dist[s][0] = 0;
    priority_queue<Pci, vector<Pci>, greater<Pci> > que;
    que.push({0, {s, 0}});
    while (!que.empty()) {
      Pci pr = que.top(); que.pop();
      int ver = pr.second.first, mod = pr.second.second;
      if (dist[ver][mod] < pr.first) continue;
      for (Edge e : graph[ver]) {
        if (dist[e.dst][(mod + 1) % 3] > dist[ver][mod] + e.cost) {
          dist[e.dst][(mod + 1) % 3] = dist[ver][mod] + e.cost;
          // prev[e.dst] = ver;
          que.push({dist[e.dst][(mod + 1) % 3], {e.dst, (mod + 1) % 3}});
        }
      }
    }
    return dist;
  }

  vector<int> build_path(int t) {
    vector<int> res;
    for (; t != -1; t = prev[t]) res.emplace_back(t);
    reverse(ALL(res));
    return res;
  }

private:
  vector<vector<Edge> > graph;
  const CostType CINF;
  vector<int> prev;
};

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vector<vector<Edge> > graph(n);
  while (m--) {
    int u, v; cin >> u >> v; --u; --v;
    graph[u].emplace_back(Edge(u, v, 1));
  }
  int s, t; cin >> s >> t; --s; --t;
  Dijkstra dij(graph);
  auto dist = dij.build(s);
  cout << (dist[t][0] == LINF ? -1 : dist[t][0] / 3) << '\n';
  return 0;
}


Measured memory_bytes: 16640
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll a, b, c,x, y;
	cin >> a >> b >> c >> x >> y;
	ll ans = 0;
	if (a + b > c * 2) {
		ans += min(x, y) * 2*c;
		if (x >= y) {
			ans += min((x - y) * a, (x - y) * 2 * c);
		}
		else {
			ans += min((y - x) * b, (y - x) * 2 * c);
		}

	}
	else {
		ans += x * a + b * y;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int R, C, K;
ll DP[3005][3005][4], A[3005][3005];

int main(){
  cin >> R >> C >> K;
  for (int i = 0; i < K; i++){
    int r, c; ll v; cin >> r >> c >> v;
    A[r][c] = v;
  }

  for (int i = 1; i <= R; i++){
    for (int j = 1; j <= C; j++){
      for (int k = 0; k <= 3; k++){
        DP[i][j][0] = max(DP[i][j][0], DP[i-1][j][k]);
        DP[i][j][1] = max(DP[i][j][1], DP[i-1][j][k] + A[i][j]);
        DP[i][j][k] = max(DP[i][j][k], DP[i][j-1][k]);
      }

      for (int k = 1; k <= 3; k++){
        DP[i][j][k] = max(DP[i][j][k], DP[i][j-1][k-1] + A[i][j]);
      }
    }
  }

  ll ans = 0;
  for (int k = 0; k < 4; k++){
    ans = max(ans, DP[R][C][k]);
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 355708
#include<stdio.h>
int main(){

    int x,y,c;

    while(1){
        scanf("%d %d",&x,&y);
        if(x == 0 && y == 0)
            break;

        if(x>y){
            c = x;
            x = y;
            y = c;
        }
            printf("%d %d\n",x,y);


    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    int ans = 0;
    Rep(i, 1, N-1){
        string s1 = S.substr(0,i);
        string s2 = S.substr(i,N-i);
        SORT(s1);
        SORT(s2);
        s1.erase(unique(ALL(s1)),s1.end());
        s2.erase(unique(ALL(s2)),s2.end());
        int t = 0;
        REP(j, s1.size()){
            REP(k, s2.size()){
                if(s1[j]==s2[k])t++;
            }
        }
        ans = max(ans, t);
    }
    pr(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#include<string.h>
#define inf 1000000000000000000
#define maxn 1000001
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<" "<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define mp make_pair
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	ll k,n;
	cin>>k>>n;
	ll a[n];
	rep(i,n)
		cin>>a[i];
	ll minn=a[n-1]-a[0];
	repeat(i,1,n)
		minn=min(minn,k-(a[i]-a[i-1]));
	cout1(minn);
}
int main(){
    int t=1;
	//cin>>t;
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int n,m,x,y,max=-1000,min=1000,i;
  int xa,ya;
  scanf("%d%d%d%d",&n,&m,&x,&y);
  for(i=0;i<n;i++){
    scanf("%d",&xa);
    if(max<xa)max=xa;
  }
  for(i=0;i<m;i++){
    scanf("%d",&ya);
    if(min>ya)min=ya;
  }
  if(min>max && x<min && max<y)puts("No War");
  else puts("War");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)-v.begin()
#define lb(v,val) lower_bound(v.begin(),v.end(),val)-v.begin()
#define sortv(vec) sort(vec.begin(),vec.end())
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mt make_tuple
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9+7;
int ll_max=1e6;
v<ll> fact;
//factorial
void factorial(ll n)
{
    fact[0] = 1;
    for (ll i = 1; i <=n; i++)
    {
        fact[i] = i * fact[i - 1];
        fact[i] %= M;
    }
}
// modular exponentiation 
ll binpow(ll val, ll deg)
{
    if (!deg)
        return 1 % M;
    if (deg & 1)
        return binpow(val, deg - 1) * val % M;
    ll res = binpow(val, deg >> 1);
    return (res * res) % M;
}
//combination
ll C(ll n, ll i)
{
    if(n<i) return 0;      
    ll res = fact[n]; 
    ll div = fact[n - i] * fact[i];
    div %= M;
    // using fermat little theorum
    div = binpow(div, M - 2); // modular inverse  
    return (res * div) % M; 
}

int main() {
	//your code goes here
	IOS;
	ll n,m;       
	ll j,y,z,t,x,i,q;      
	cin>>n;
	ll a=0,b=0,c=0,d=0;
	while(n--){
	      string s;
	      cin>>s;
	      if(s=="AC")
	      a++;
	      if(s=="TLE")
	      c++;
	      if(s=="WA")
	      b++;
	      if(s=="RE"){
	            d++;
	      }
	}
	cout<<"AC x "<<a<<"\nWA x "<<b<<"\nTLE x "<<c<<"\nRE x "<<d;
	
	
	return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int pop(void);
void push(int);

int array[1000],top;

int main()
{
  int a,b;
  char s[100];
  top=0;

  while(scanf("%s ", s)!= EOF){
    if (s[0]=='+')
      {
        a=pop();
        b=pop();
        push(a+b);
      }
    else if(s[0]=='-')
      {
        b=pop();
        a=pop();
        push(a-b);
      }
    else if(s[0]=='*')
      {
        a=pop();
        b=pop();
        push(a*b);
      }
    else    push(atoi(s));
  }

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

int pop(void)
{
  top--;
  return array[top+1];
}

void push(int x)
{
  array[++top]=x;
}

Measured memory_bytes: 556
function main(arg) {
	arg = arg.trim().split('\n');
  	arg = arg.map(str => parseInt(str, 10));
  	var a = arg[0], b = arg[1];
  	if(a != 1 && b != 1) {
    	console.log('1');
    } else if (a != 2 && b != 2) {
    	console.log('2');
    } else if (a != 3 && b != 3) {
    	console.log('3');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
double PI=acos(-1);
double deg(double rd)
{
	return rd/PI*180.0000;
}
double x,y,a,b,h;
int main()
{
	scanf("%lf%lf%lf",&a,&b,&x);
	h=x/(a*a);
	if((b-h)*2.000<=b)
	{
		y=atan(a/((b-h)*2.000));
		printf("%.9lf\n",deg(PI/2-y));
	}
	else
	{
		y=2*x/(a*b);
		printf("%.9lf\n",deg(PI/2-atan(y/b)));
	}
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int n, k, i;
    char a[10];

    scanf("%d", &n);
    scanf("%s", a);
    scanf("%d", &k);

    for(i=0;i<n;i++){
        if(a[i] != a[k-1]){
            printf("*");
        }else{
            printf("%c", a[k-1]);
        }
    }

    printf("\n");

    return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	int minn = a[n-1] - a[0];
	for(int i = 0; i < n-k+1; i++)
	{
		minn = min(a[i+k-1]-a[i],minn);
	}
	cout << minn << endl;
	return 0;
}

Measured memory_bytes: 640