akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

int main() {
  long long N;
  cin >> N;
  long long sum = 0;
  long long cnt = 0;
  rep(i, N+1) {
    if(i == 0) continue;
    if(i % 3 == 0 || i % 5 == 0) continue;
    sum += i;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007

using namespace std;

int n, x, a, b;

int main() {
	cin >> n;
	for (int i = 1; i <= n;i++) {
		cin >> x;
		if (x % 4 == 0) a++;
		if (x % 2 == 1) b++;
	}
	if (a + 1 >= b && a + b == n) cout << "Yes" << endl;
	else if (a == b) cout << "Yes" << endl;
	else cout <<"No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    LL A, B, N;
    scanf("%lld %lld %lld", &N, &A, &B);
    LL dif = B - A;
    if ((dif % 2) == 0) return !printf("%lld\n", dif / 2);
    LL ans1 = A + (dif - 1) / 2;
    LL ans2 = (N - B + 1) + (dif - 1) / 2;
    printf("%lld\n", min(ans1, ans2));
    return 0;
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$M) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
//$a = array_map('intval',explode(" ",trim(fgets(STDIN))));

if ($N==$M) {
  printf("Yes\n");
}
else {
  printf("No\n");
}


Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <functional>
#include <string>
#include <stack>
#include <map>

using namespace std;
using ll = long long;
ll mod = 1e9 + 7;


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

	char c;
	map<char, int> m;

	for (int i = 0; i < n; i++)
	{
		
		cin >> c;
		m[c] ++;
	}
	
	ll ret = 1;
	for (auto itr = m.begin(); itr != m.end(); itr++)
	{
		ret *= (itr->second + 1);
		ret %= mod;
	}

	ret--;
	cout << ret % mod << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

int P[10010];
void init(int N){
    for(int i=0;i<=N;i++)
        P[i] = i;
}
int root(int a){
    if(P[a]==a)
        return a;
    return(P[a] = root(P[a]));
}
bool is_same_set(int a, int b){
    return root(a) == root(b);
}
void unit(int a, int b){
    P[root(a)] = root(b);
}

int main(){
    int n; cin >> n;
    pair<int, pair<int,int> > a;
    vector< pair<int, pair<int,int> > > e;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            int x; cin >> x;
            if(x!=-1){
                e.push_back(make_pair(x, make_pair(i,j)));
            }
        }
    }
    sort(e.begin(),e.end());
    int ans = 0;
    init(n);
    for(vector< pair<int, pair<int,int> > >::iterator it = e.begin();it != e.end();it++){
        int s = it->second.first;
        int g = it->second.second;
        if(!is_same_set(s,g)){
            unit(s,g);
            ans += it->first;
        }
    }
    cout << ans << endl;
}

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

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define fr(i,n) for(i=1;i<=n;i++)

typedef pair<int, int> II;
typedef vector< II > VII;
typedef vector<int> VI;

ll dp[110];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll i, n;
    cin>>n;
    dp[0]=1;
    for(i=0;i<=n;i++)
        if(dp[i]==1)
            dp[i+4]=1, dp[i+7]=1;
    if(dp[n]==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
string s;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  cin >> s;
  char prev = ' ';
  for (char& c : s) {
    if (c == '?') {
      c = 'D';
    }
    prev = c;
  }
  cout << s << "\n";
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  int A,B;
  cin>>A>>B;
  string S;
  cin>>S;
  bool ok = true;
  rep(i,A+B+1){
    if(i<A||i>A){
      int t = S[i] - '0';
      if(t<0||t>=10) ok = false;
    }
    else {
      if(S[i]!='-') ok = false;
    }
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            for(int[] v; ((v = Array.ConvertAll(Console.ReadLine().Split(), int.Parse))[0] | v[1]) != 0;) {
                int count = 0;
                for(int i = 1; i <= v[0] - 2; ++i) {
                    for(int l = i + 1;l <= v[0] - 1; ++l) {
                        for(int m = l + 1; m <= v[0]; ++m) {
                            if(i + l + m == v[1]) {
                                ++count;
                            }
                        }
                    }
                }
                Console.WriteLine(count);
            }
        }
    }
}

Measured memory_bytes: 5632
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <list>
using namespace std;
#include <stdio.h>
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <cstdio>
#include <cinttypes>


int main()
{
	int N, M;
	cin >> N;

	if (N >= 30) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}




Measured memory_bytes: 3128
from math import floor, sqrt
n,d=map(int,input().split())
X = []
def f(i,j):
    sm = 0
    for k in range(d):
        sm += (X[i][k]-X[j][k])**2
    return floor(sqrt(sm))**2 == sm
for _ in range(n):
    X.append(list(map(int,input().split())))
ans = 0
for i in range(n):
    for j in range(i+1,n):
        if f(i,j):
            ans += 1
print(ans)

Measured memory_bytes: 9088
#include <iostream>

using namespace std;

main(){
    int r,D,x_0;
    int x[11];

    cin >> r >> D >> x_0;
    x[0] = x_0;

    for(int i=1;i<11;i++)
    {
        x[i] = r*x[i-1] - D;
        cout << x[i] << endl;
    }
}

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

using namespace std;

void add(string &a, string &b) {
	if (a.size() > 80 || b.size() > 80) {
		cout << "overflow" << endl;
		return;
	}

	string aa = a;
	string bb = b;
	reverse(aa.begin(), aa.end());
	reverse(bb.begin(), bb.end());
	string cc;
	int carry = 0;
	int sa = a.size();
	int sb = b.size();
	int ss = sa>sb ? sa : sb;
	for (int i = 0; i < ss; i++) {
		char ca = i < sa ? aa[i] : '0';
		char cb = i < sb ? bb[i] : '0';
		char code = ca + cb + carry - '0';
		if (code > '9') {
			code -= 10;
			carry = 1;
		} else
			carry = 0;
		cc += code;
	}

	if (carry)
		cc += '1';

	if (cc.size() > 80)
		cout << "overflow" << endl;
	else {
		reverse(cc.begin(), cc.end());
		cout << cc << endl;
	}
}

int main() {
	int n;
	string a, b;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		add(a, b);
	}
	return 0;
}

Measured memory_bytes: 0
/**
 *      ABC 100 A
 *      author  : kyomukyomupurin
 *      created : 2018/08/21
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    if (A <= 8 && B <= 8){
        cout << "Yay!";
    }
    else {
        cout << ":(";
    }

    return 0;
    
}



Measured memory_bytes: 256
while True:
	a, op, b = input().split()
	if op == "?": break
	a = int(a)
	b = int(b)

	if (op == "+"):
		print(a + b)
	elif (op == "-"):
		print(a - b)
	elif (op == "*"):
		print(a * b)
	elif (op == "/"):
		print(a // b)

Measured memory_bytes: 7596
def main():
    from builtins import int, map, list, print
    from collections import defaultdict
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    A = input_number_list()
    d = defaultdict(lambda: 0)
    for a in A:
        d[a]+=1
    for i in range(N):
        print(d[i+1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 37328
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
using namespace std;

int main()
{
	int n, k, m = 1;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		if (m * 2 > m + k) {
			m += k;
		}
		else {
			m *= 2;
		}
	}
	cout << m << endl;
	return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

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


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<int> A(N); cin >> A;
        int ans = INF;
        auto f = [&]() {           
            int cnt = 1;
            int inc = 0;
            rep(i, N - 1) {
                if(inc > 0 and A[i + 1] < A[i]) {
                    cnt++;
                    inc = 0;
                } else if(inc < 0 and A[i + 1] > A[i]){
                    cnt++;
                    inc = 0;
                } else if(inc == 0 and A[i + 1] != A[i]) {
                    inc = A[i + 1] > A[i] ? 1 : -1; 
                }
            }
            return cnt;
        };
        set_min(ans, f());
        reverse(all(A));
        set_min(ans, f());
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>

using namespace std;


int main()
{
    int k;
    char s[101];
    cin >> k;
    cin.ignore();
    cin.getline(s, sizeof(s));
    if(strlen(s) > k){
        s[k] = '\0';
        cout << s << "...";
        return 0;
    }
    cout << s;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = 100010;
const int inf = 0x0fffffff;
#define LL long long
const long long mod = 1000000007;

vector <int> edge[maxn];
bool vis[maxn];

void dfs(int v, vector<int> &path)
{
	vis[v] = true;
	path.push_back(v);
	int m = edge[v].size();
	for (int i = 0; i < m; i ++)
		if (!vis[edge[v][i]])
		{
			dfs(edge[v][i], path);
			break;
		}
}

int main()
{
	int n, i, m, v, w;
	vector<int> path1, path2;
	path1.clear();
	path2.clear();
	cin >> n >> m;
	for (v = 1; v <= n; v ++)
		edge[v].clear();
	for (i = 0; i < m; i ++)
	{
		cin >> v >> w;
		edge[v].push_back(w);
		edge[w].push_back(v);
	}
	memset(vis, false, sizeof(vis));
	for (v = 1; v <= n; v ++)
		if (edge[v].size() > 0)
		{
			dfs(v, path1);
			for (i = 0; i < edge[v].size(); i ++)
				if (!vis[edge[v][i]])
				{
					dfs(edge[v][i], path2);
					break;
				}
			break;
		}
	cout << path1.size() + path2.size() << endl;
	m = path2.size() ;
	for (i = m - 1; i >= 0; i --)
			cout << path2[i] << " ";

	for (i = 0; i < path1.size(); i ++)
			cout << path1[i] << " ";
	return 0;
}

Measured memory_bytes: 9848
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = "";
        for(int i = 0;i < n;i++){
            s += sc.next();
        }
        boolean p = false;
        boolean w = false;
        boolean g = false;
        boolean y = false;
        for(int i = 0;i < n;i++){
            if(s.charAt(i) == 'P'){
                p = true;
            }
            if(s.charAt(i) == 'W'){
                w = true;
            }
            if(s.charAt(i) == 'G'){
                g = true;
            }
            if(s.charAt(i) == 'Y'){
                y = true;
            }
        }
        if(p & w & g & y){
            System.out.println("Four");
        }
        else if(p & w & g & !y){
            System.out.println("Three");
        }
    }
}


Measured memory_bytes: 22996
#include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long   llong;
typedef vector<int> vi;

template<class Type>//long long推奨.
Type pow_mod(Type n,Type k,Type m){//n^k(mod m).
	if(k==0) return 1;
	else if(k%2) return n*pow_mod(n,k-1,m)%m;
	else{
		Type tmp=pow_mod(n,k/2,m);
		return tmp*tmp%m;
	}
}

//pow_mod.
int main(){
	llong mod=998244353;
	
	int n;
	cin>>n;
	
	vi d(n);
	int p=0;
	vi cnt(n,0);
	REP(i,n){
		cin>>d[i];
		p=max(p,d[i]);//point.
		cnt[d[i]]++;
	}
	
	if(d[0]==0 and cnt[0]==1){}//point.
	else{
		cout<<0<<endl;
		return 0;
	}
	
	llong ans=1;
	REP(i,p){
		if(cnt[i]==0){
			cout<<0<<endl;
			return 0;
		}
		ans*=pow_mod((llong)cnt[i],(llong)cnt[i+1],mod);//point.
		ans%=mod;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
program reconciled
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer(8) :: n, m, i, x = 1_8
  read(*,*) n, m
  if (abs(n-m) > 1_8) then
    write(*,'(i0)') 0
  else
    if (n == m) x = 2_8
    do i = 1_8, n
      x = mod(i*x,md)
    end do
    do i = 1_8, m
      x = mod(i*x,md)
    end do
    write(*,'(i0)') x
  end if
end program reconciled

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

vector<int>v[11];
int main() {
	string s; 
	while (cin >> s) {
		rep(i, 11)v[i].clear();
		int cnt = 0;
		rep(i, 10)v[0].push_back((int)s[i] - 48);
		for (int i = 1; i <= 10; i++) {
			rep(j, v[i - 1].size() - 1)
				v[i].push_back((v[i - 1][j] + v[i - 1][j + 1]) % 10);
		}
		cout << v[9][0] << endl;
	}
	return 0;
}

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



int main(){
    ll n,m,ans,len;
    cin >> n >> m;
    //vector<string> s(n);
    if(n==1&&m==1) ans=1;
    if(n==1&&m!=1) ans=m-2;
    if(n!=1&&m==1) ans=n-2;
    if(n!=1&&m!=1) ans=(n-2)*(m-2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    
    int ans1 = 0;
    int ans2 = 0;
    for(int i = 0; i < s.length(); i++) {
      char c = s.charAt(i);
      if (i%2==0) {
        if (c == '0') {
          ans1++;
        } else {
          ans2++;
        }
      } else {
        if (c == '1') {
          ans1++; 
        } else {
          ans2++;
        }
      }
    }
    System.out.println(Math.min(ans1, ans2));
  }
}

Measured memory_bytes: 27580
#include <bits/stdc++.h>
using namespace std;
int main(){ 
  double a,b,x;cin>>a>>b>>x;
  if(a*a*b<2*x)printf("%lf\n",180*atan((a*a*b-x)*2/a/a/a)/acos(-1));
  else printf("%lf\n",180*atan(a*b*b/2/x)/acos(-1));
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10000000)

from fractions import gcd
def lcm(a,b):
    return int(a*b/gcd(a,b))


def div(n,divn):
    #1からnまでの中で、divnで割り切れる数の数を示す
    return n//divn

def divor(n,div1,div2):
    #1からnまでの中で、div1,div2のどちらかで割り切れる数の数を示す
    return div(n,div1)+div(n,div2)-div(n,lcm(div1,div2))
def nondivor(n,div1,div2):
    #１からnまでの中で、div1,div2のどちらでも割り切れない数の数を示す
    return n-divor(n,div1,div2)


a,b,c,d=[int(i) for i in input().split()]


print(nondivor(b,c,d)-nondivor(a-1,c,d))

Measured memory_bytes: 5844
#include<bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;

int main(void){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            if((h < B) ^ (w < A)) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
    return 0;    
}


Measured memory_bytes: 1280
// Palindromic Number
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;


int main()
{
  int N, ai;
  cin >> N;
  vector<int> a;
  for (int i = 1; i <= N; i++) {
    cin >> ai;
    a.push_back(ai);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  int asum = 0, bsum = 0;
  for (int i = 0; i < N; i+=2) {
    asum += a[i];
    if(i+1 < N)
      bsum += a[i+1];
  }
  cout << asum - bsum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(void){
    int i,num,sum;
    double hansamu,bunsan,ave,hensa;
    int *a;
    while(1){
            hansamu = 0;
            sum = 0;
        scanf("%d",&num);
        if(num == 0) break;
        a = (int *)malloc(sizeof(int) * num);
        for(i = 0;i<num;i++){
            scanf("%d",&a[i]);
            sum += a[i];
        }
        ave = (double) sum / num;
        for(i=0;i<num;i++){
            hansamu = hansamu + pow(a[i]-ave,2);
        }
        bunsan = (double)(hansamu / num);
        hensa = sqrt(bunsan);
        printf("%f\n",hensa);
        free(a);
    }
return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

ll sum() { return 0; }
template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define OUTH(x) cout << x << " "
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl;

void solve() {

}

int main()
{
    FAST_INP;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
//    freopen("output.txt","w", stdout);
//    #endif

//    int tc; cin >> tc;
//    TC(tc) solve();
	int n, x, y;
	cin >> n;
//	vector<pll> v;
//	REP(i,n){
//		cin >> x >> y;
//		v.pb({x,y});
//	}
//	ll r0=INFF, c0=INFF;
//	sort(ALL(v), [r0,c0](pll& a, pll& b){
//		return abs(r0-a.fi)+abs(c0-a.se) < abs(r0-b.fi)+abs(c0-b.se);
//	});
//	ll ans=0;
//	REP(i,n){
//		FOR(j,i+1,n){
//			MAX(ans, (abs(v[i].fi-v[j].fi)+abs(v[i].se-v[j].se)));
//		}
//	}
//	OUT(ans);
//	cout << v[n-1].fi << " " << v[n-1].se << endl;
//	OUT((abs(v[0].fi-v[n-1].fi)+abs(v[0].se-v[n-1].se)));
	int miA=INT_MAX, miB=INT_MAX, mxA=INT_MIN, mxB=INT_MIN;
	REP(i,n){
		cin >> x >> y;
		MIN(miA,x+y);
		MAX(mxA,x+y);
		MIN(miB,x-y);
		MAX(mxB,x-y);
	}
	OUT(max({
		abs(mxA-miA),
		abs(mxB-miB),
		miB,
		mxB
	}));
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
int main(){
    char a[5][5];
    for(int i=0; i<3; i++)
        scanf("%s", &a[i]);
    for(int i=0; i<3; i++)
        for(int j=0; j<3; j++)
            if(i==j)
                printf("%c", a[i][j]);
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashSet;
import java.util.Set;


class Main {
    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        int num = scn.nextInt();
        Set<String> set = new HashSet<>();

        for(int i = 0; i <= num; i++){

            if(i == num) break;

            String str = scn.next();
            String str2 = scn.next();

            if(str.equals("insert")) set.add(str2);
            else if(str.equals("find")){
                if(set.contains(str2)) System.out.println("yes");
                else System.out.println("no");
            }
        }
    }
}


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

int main(void) {
    int N; cin >> N;
    int P[N+10] = {0};
    int count = 1;
    for(int i=0; i<N; i++) {
        cin >> P[i];
    }
    int min = P[0];
    for(int i=1; i<N; i++) {
        if(P[i]<min) {
            min = P[i];
            count++;
        }
    }
    cout << count << endl;
}

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

int main()
{
	int x,y;
	cin>>x>>y;
	if(x*y*1%2==1)
	{
		cout<<"Yes"<<endl;
		return 0; 
	}
	if(x*y*2%2==1)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(x*y*3%2==1)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    ll A,B,C;
    cin >> A >> B >> C;
    cout << C << " " << A << " " << B << endl;
   return 0;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.*;
import java.util.Scanner ; 
import java.math.BigInteger;
import java.util.Arrays;
import java.text.DecimalFormat;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);    
        String s;
        s = sc.nextLine();
        StringBuffer sb;
        sb = new StringBuffer(s);
        s = sb.reverse().toString();
        System.out.println(s);

    }
}

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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int ab_buy = min(x, y) * 2 * c;
  int a_buy = (max(x, y)-min(x, y)) * a;
  int b_buy = (max(x, y)-min(x, y)) * b;
  if(x>=y){
    int mn = min(ab_buy + a_buy, (a*x + b*y));
    int ans = min(mn, c*max(x,y)*2);
    cout  << ans << endl;
    return 0;
  }
  else if(x<=y){
    int mn = min(ab_buy + b_buy, (a*x + b*y));
    int ans = min(mn, c*max(x,y)*2);
    cout  << ans << endl;
 }


}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define mp(a,b)	make_pair(a,b)
#define fst	first
#define scn second

const ll inf = (ll)1e9 + 7;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;

int main() {
	while (true) {
		int n, m;	cin >> n >> m;
		if (n == 0)	break;
		vint h(n), w(m);
		rep(i, n)	cin >> h[i];
		rep(i, m)	cin >> w[i];
		vint hsum(n + 1, 0), wsum(m + 1, 0);
		rep(i, n)	hsum[i + 1] = hsum[i] + h[i];
		rep(i, m)	wsum[i + 1] = wsum[i] + w[i];
		n++;	m++;
		map<int, int> ls;
		rep(i, n)	rep(j, i) {
			ls[hsum[i] - hsum[j]]++;
		}
		int ret = 0;
		rep(i, m)	rep(j, i) {
			ret += ls[wsum[i] - wsum[j]];
		}
		cout << ret << endl;
	}
	return 0;
}

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

#define int long long
#define endl '\n'

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int n; cin>>n;
    if (n>=30) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>

int main(){
char S[11],T[11],U[11];
  int A,B;
  scanf("%s %s",&S,&T);
  scanf("%d %d",&A,&B);
  scanf("%s",&U);
  if(strcmp(S,U)==0)printf("%d %d\n",A-1,B);
 else printf("%d %d\n",A,B-1);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
A_int_list = list(map(int, input().split()))

money = 1000
stock = 0

for i in range(N - 1):
    if A_int_list[i] < A_int_list[i + 1]:
        stock = money // A_int_list[i]
        money = money % A_int_list[i]
        money += stock * A_int_list[i + 1]
        stock = 0

print(money)


Measured memory_bytes: 9028
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
s = list(input())
baf = s.count('B')
raf = s.count('R')
gaf = s.count('G')
bbf = 0
rbf = 0
gbf = 0
ans = 0
for i,item in enumerate(s):
    if item == 'B':
        baf -= 1
        bbf += 1
        ans += rbf*gaf
        ans += raf*gbf
    elif item == 'R':
        raf -= 1
        rbf += 1
        ans += bbf*gaf
        ans += baf*gbf
    else:
        gaf -= 1
        gbf += 1
        ans += rbf*baf
        ans += raf*bbf
cnt = 0
for i in range(n):
    num = min(i,n-1-i)
    for j in range(1,num+1):
        if s[i-j] != s[i+j] and s[i-j] != s[i] and s[i+j] != s[i]:
            cnt += 1
print(ans-cnt)


Measured memory_bytes: 9272
#include<bits/stdc++.h>
using namespace std;
  int n=100005;
 
 
   vector<int> v(n);

int main()
{
  
   int n;
   cin>>n;
   int W,w[n],val[n];
   cin>>W;
   for(int i=0;i<n;i++)
   {
       cin>>w[i]>>val[i];
   }
  
  long long int dp[W+1][n+1]={0};
   for(int i=0;i<=n;i++)
   {
       for(int S=0;S<=W;S++)
       {
           if(i==0||S==0)
           dp[S][i]=0;
           else if(w[i-1]<=S)
       dp[S][i]=max(dp[S-w[i-1]][i-1]+val[i-1],dp[S][i-1]);
       else
       {
           dp[S][i]=dp[S][i-1];
       }
       
   }
   }
   
  

cout<<dp[W][n];

}

Measured memory_bytes: 79488
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long a[200001], n = 0, ans = 0;
char c;
int main() {
	for (c = getchar(); c<'A' || c>'C'; c = getchar());
	for (n = 0; c <= 'C'&&c >= 'A'; c = getchar(), n++) a[n] = c - 'A';
	for (int i = n - 1ll, sumb = 0ll; i >= 0ll; i--) {
		if (!a[i]) {
			ans += sumb;
			continue;
		}
		if (a[i] == 2ll && a[i - 1] == 1ll) {
			sumb++; i--; 
			continue;
		}
		sumb = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

vll nums;
string res;

void solve(ll n){
    if(n == 0) return;
    int i = (int)(lower_bound(_all(nums), n) - begin(nums));
    string d;
    res  = string(i, ')');
    res += string(i, '(');

    swap(res[i - (nums[i] - n)], res[i]);
}

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

    {
        nums.emplace_back(0);
        int i = 1;
        while(true){
            if(nums.back() > 1e9) break;
            nums.emplace_back(nums.back() + i);
            i++;
        }
    }
    ll n; cin >> n;

    solve(n);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  string a,b;
  cin >>a>>b;
  
  cout << b << a << endl; 
  
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;

  int A[(int)1e5 + 1];

  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int b = 0;
  bool f = true;
  int ans = 0;
  for (int i = 1; i < N; i++) {
    if (f) {
      if (A[i] <A[i - 1]) {
        b = 1;
        f = false;
      } else if (A[i] > A[i - 1]) {
        b = -1;
        f = false;
      }
    } else {
      if (b == 1 && A[i] > A[i - 1]) {
        ans++;
        b = 0;
        f = true;
      } else if (b == -1 && A[i] < A[i - 1]) {
        ans++;
        b = 0;
        f = true;
      }
    }
  }




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

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
const long long mod=1e9+7;
ll a[100005],b[100005];
ll c[100005],d[100005];
int main(){
    ll n,m,i,j;
    scanf("%lld%lld",&n,&m);
    for(i=0;i<n;i++){
        scanf("%lld",&c[i]);
    }
    for(i=0;i<m;i++){
        scanf("%lld",&d[i]);
    }
    sort(c,c+n);
    sort(d,d+m);

    for(i=1;i<n;i++){
        a[i]=c[i]-c[i-1];
    }
    for(i=1;i<m;i++){
        b[i]=d[i]-d[i-1];
    }
    /*for(i=1;i<n;i++){
        printf("%lld ",a[i]);
    }
    printf("\n");
    for(i=1;i<m;i++){
        printf("%lld ",b[i]);
    }
    printf("\n");*/
    ll ans1=0,ans2=0;
    ll k=n,x=0;
    for(i=1;i<=(n-1)/2;i++){
        a[i]%=mod;
        x+=(n-1-(i-1)*2);
        ans1+=(x*a[i]);ans1%=mod;
        a[n-i]%=mod;
        ans1+=(x*a[n-i]);ans1%=mod;
    }
    if((n-1)%2){
        x++;
        a[(n-1)/2+1]%=mod;//printf("(%lld ",x);
        ans1+=x*a[(n-1)/2+1];//printf("%lld )",a[n/2+1]);
        ans1%=mod;
    }
    k=m,x=0;
    for(i=1;i<=(m-1)/2;i++){
        b[i]%=mod;x+=(m-1-(i-1)*2);
        ans2+=(x*b[i]);ans2%=mod;
        b[m-i]%=mod;
        ans2+=(x*b[m-i]);ans2%=mod;
    }
    if((m-1)%2){
        x++;
        b[(m-1)/2+1]%=mod;
        ans2+=x*b[(m-1)/2+1];
        ans2%=mod;
    }
    if(ans1==0){
        ans1+=mod;
    }
    if(ans2==0){
        ans2+=mod;
    }
    printf("%lld\n",ans1*ans2%mod);
    return 0;
}
//622259192 993828220


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll N;cin>>N;
    char S[N];
    rep(i,N)cin>>S[i];
    ll count=0;
    vl value(N);
    rep(i,N){
        if(S[i]=='(')count++;
        else count--;
        value.push_back(count);
    }
    sort(all(value));
    rep(i,max(0LL,-value[0]))cout<<'(';
    rep(i,N)cout<<S[i];
    rep(i,count-value[0])cout<<")";
    cout<<endl;;
    return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
    }
    const M:usize = 1_000_000_007;
    let mut dp =vec![vec![vec![vec![0;4];4];4];n+1];
    dp[0][3][3][3]=1;
    for i in 0..n{
        for a in 0..4 {
            for b in 0..4 {
                for c in 0..4 {
                    for d in 0..4 {
                        // ACGT
                        if b==0 && c==2 && d==1
                            || b==0 && c==1 && d==2
                            || b==2 && c==0 && d==1
                            || a==0 && c==2 && d==1
                            || a==0 && b==2 && d==1
                            {
                                continue;
                            }
                        dp[i+1][b][c][d] += dp[i][a][b][c];
                        dp[i+1][b][c][d]%=M;
                    }        
                }
            }
        }
    }
    let mut ans=0;
    for a in 0..4 {
        for b in 0..4 {
            for c in 0..4 {
                ans+=dp[n][a][b][c];
                ans%=M;
            }
        }
    }
    println!("{}", ans);

}

Measured memory_bytes: 4352
/*
    Vishal Raj 
    IIT Kharagpur
*/

#include <bits/stdc++.h>

using namespace std;

#define li long long int

int main() {
    li n; cin>>n;
    vector<li> dp(n,LLONG_MAX);
    dp[0] = 0;
    vector<li> h(n,0); 
    for( int i = 0; i < n; i++ ) cin>>h[i];
    for( int i = 1; i < n ; i++ ) {
        if( i-2 >= 0 ) dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
        dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp.back()<<"\n";
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int m = sc.nextInt();
      int f = sc.nextInt();
      int r = sc.nextInt();
      if(m == -1 && f == -1 && r == -1)
      break;
      else{
        if(m == -1 || f == -1)
        System.out.println("F");
        else if(m+f>=80)
        System.out.println("A");
        else if(m+f>=65)
        System.out.println("B");
        else if(m+f>=50)
        System.out.println("C");
        else if(m+f>=30){
          if(r >= 50)
          System.out.println("C");
          else
          System.out.println("D");
        }
        else
        System.out.println("F");
      }
}
}
}


Measured memory_bytes: 26300
[N,M,X] = list(map(int,input().split()))
A = list(map(int,input().split()))

dammy = [0]*(N+1)

for i in A:
    dammy[i]=1
    if i==X:
        dammy[i]=0
# print(dammy)


left = sum(dammy[0:X+1])
right = sum(dammy[X+1:N+1])
# print(left,right)

print(min(left,right))


Measured memory_bytes: 80520
N = int(input())
a = list(map(int, input().split()))

Sum = sum(a)
c = 0
difMin = 10**14

for i in range(N-1):
    c += a[i]
    dif = abs(Sum - c*2)
    if dif < difMin:
        difMin = dif

print(difMin)


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    cin >> S;
    int ans = 0;
    if (S == "SUN") ans = 7;
    else if (S == "MON") ans = 6;
    else if (S == "TUE") ans = 5;
    else if (S == "WED") ans = 4;
    else if (S == "THU") ans = 3;
    else if (S == "FRI") ans = 2;
    else if (S == "SAT") ans = 1;
    cout << ans << endl;
}

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


Measured memory_bytes: 256
n,a,b,c,d = map(int, input().split())
s = input()
ans = "Yes"
sharp = 0
dot = 0
for i in s[a-1:max(c,d)]:
    if i == ".":
        sharp = 0
    else:
        sharp += 1
        if sharp == 2:
            ans = "No"
            break
if c > d and ans == "Yes":
    ans = "No"
    for i in s[b-2:d+1]:
        if i == ".":
            dot += 1
            if dot == 3:
                ans = "Yes"
                break
        else:
            dot = 0
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

int main() {
    ll s, w;
    cin >> s >> w;

    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;

    return 0;
}


Measured memory_bytes: 3596
s=input()
l=[]
for i in s:
    l.append(i)
l.sort()
li=[]
for i in range(len(l)-1):
    if(l[i]!=l[i+1]):
        li.append(l[i])
li.append(l[-1])
alph="abcdefghijklmnopqrstuvwxyz"
for i in li:
    for j in range(len(alph)):
        if(i==alph[j]):
            alph=alph.replace(i,"")
            break
if(len(alph)==0):
    print("None")
else:
    print(alph[0])

Measured memory_bytes: 4408
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n, k, i;
	int h[100000];
	int x;
	x=0;
	scanf("%d %d", &n, &k);
	for(i=0;i<n;i++){
		scanf("%d", &h[i]);
		if(h[i]>=k){
			x=x+1;
		}
	}
	printf("%d", x);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  string s;
  cin>>s;
  char a=s[s.length()-1];
  if(a=='3'){
    cout<<"bon"<<endl;
  }else if(a=='0'||a=='1'||a=='6'||a=='8'){
    cout<<"pon"<<endl;
  }else{
    cout<<"hon"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3656
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const [n, m] = inputs[0].split(' ').map(Number);
  const highList = inputs[1].split(' ').map(Number);
  let result = new Array(n).fill(true);

  for (let i = 2; i < inputs.length; i++) {
    let [from, to] = inputs[i].split(' ').map((value) => Number(value) - 1);

    if (highList[from] < highList[to]) {
      result[from] = false;
    } else if (highList[from] > highList[to]) {
      result[to] = false;
    } else {
      // 標高が等しい時点で「良い展望台」対象外
      result[from] = false;
      result[to] = false;
    }
  }

  console.log(result.filter((value) => value).length);
}


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

int main(){
  int a,b;
  int c;
  cin>>a>>b;
  c = a+b;
  if(c%2==0){
    cout<<c/2<<endl;
  }else{
    cout<<c/2+1<<endl;
  }
  
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

    vector<string> fi;
    fi.resize(H);

    REP(i, H){
        cin >> fi[i];
    }
    
    ll ans = INF;
    // 縦方向へは全探索
    for (int bit = 0; bit < (1<<(H-1)); ++bit) {
        bool gok = true; // そもそも不可能な場合もあるので判定
        // 境界が惹かれている本数
        ll N = 0;
        vector<int> ord(H, 0);

        // 境界が惹かれている行を格納
        for (int i = 0; i < H-1; ++i) {
            if (!(bit & (1<<i))){
                ord[i+1] = ord[i];
            }
            else{
                ord[i+1] = ord[i]+1;
                N++;
            }
        }

        ll add = 0;
        vector<int> nums(N+1, 0);
        // 横方向の線
        for (int w = 0; w < W; ++w) {
            vector<int> one(N+1, 0); // 実行する行の条件
            bool ok = true;
            for (int h = 0; h < H; ++h) {
                one[ord[h]] += fi[h][w] - '0';
                nums[ord[h]] += fi[h][w] - '0';
                if (one[ord[h]] > K) gok = false; // この縦の分割方法だと、不可能なことが確定している場合
                if (nums[ord[h]] > K) ok = false;
            }
            if (!ok){
                add++;
                nums = one;
            }
        }
        if (gok){
            ans = min(ans, N + add);
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> Pii;

void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}

string rot(string S){
    return S[S.size() - 1] + S.substr(0, S.size() - 1);
}

int main(){

    string S, T;
    cin >> S;
    cin >> T;

    for(int i = 0; i < S.size(); i++){
        if(S == T){
            cout << "Yes";
            return 0;
        }
        S = rot(S);
    }
    cout << "No";
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,a[200001];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=n-1;i>=0;i-=2){
    printf("%d ",a[i]);
  }
  i+=1+2*(n%2);
  for(;i<n;i+=2){
    printf("%d ",a[i]);
  }
}

Measured memory_bytes: 2816