akhauriyash/Code-Regression huggingface dataset:
def main():
    from sys import stdin
    input = stdin.readline
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]

    g = [set() for _ in [0]*n]
    [g[a-1].add(b-1) for a, b in ab]
    [g[b-1].add(a-1) for a, b in ab]

    mod = 10**9+7
    fact = [1, 1]
    inv = [pow(i, mod-2, mod) for i in range(n+1)]
    for i in range(2, n+1):
        fact.append(fact[-1]*i % mod)

    def Reroot():
        # merge:頂点aにbをマージするときのモノイド
        # adj_bu:ボトムアップ時の調整（a:値,i:頂点）
        # adj_td:トップダウン時の調整（a:値,i:頂点,p:親）
        # （根方向への調整と考えるとわかりやすい）
        # adj_fin:最終調整（a:値,i:頂点）
        def merge(a, b): return a * b % mod
        def adj_bu(a, i): return a * inv[size[i]] % mod
        def adj_td(a, i, p): return a * inv[n-size[i]] % mod
        def adj_fin(a, i): return a * fact[n-1] % mod

        # トポロジカルソートをする
        # T:木の隣接グラフ表現をset化
        # P:親
        # q:キュー
        # order:トポソしたもの
        T = g
        P = [-1]*n
        q = [0]
        ini = 1
        order = []
        while q:
            i = q.pop()
            order.append(i)
            for a in T[i]:
                if a != P[i]:
                    P[a] = i
                    T[a].remove(i)
                    q.append(a)

        T = [list(i) for i in T]

        # サイズの処理を先に行う
        # size[i]:0を根とする根付き木における、iを根とする部分木の大きさ
        size = [1]*n
        for i in order[1:][::-1]:
            size[P[i]] += size[i]

        # ボトムアップ処理をする
        # ME:マージした値を一時保存
        # DP:DP値、MEを調整したもの
        ME = [ini]*n
        DP = [0]*n
        for i in order[1:][::-1]:
            DP[i] = adj_bu(ME[i], i)
            p = P[i]
            ME[p] = merge(ME[p], DP[i])
        DP[order[0]] = adj_fin(ME[order[0]], order[0])
        TD = [ini]*n

        # トップダウン処理をする
        for i in order:
            # 左からDP（結果はTDに入れている）
            ac = TD[i]
            for j in T[i]:
                TD[j] = ac
                ac = merge(ac, DP[j])
            # 右からDP（結果はacに入れている、一度しか使わないのでacで問題ない）
            # 例えばjが1から4だったとすると、TD[j]にはそれぞれ
            # TD[1] = 無、TD[2] = DP[1]、TD[3] = DP[1]*DP[2]、TD[4] = DP[1]*DP[2]*DP[3]
            # が入っている。
            # ここでacにそれぞれ無、DP[4]、DP[3]*DP[4]、DP[2]*DP[3]*DP[4]を
            # 順に入れていくといい感じになることがわかる。
            # 最後にTDに欠けているのは本来の根方向への補正なので、
            # jの部分木以外のサイズの逆数を掛けてやる必要がある。
            # これで、TDには根方向、MEにはそれ以外の方向のDP値が入っている状態になっているので
            # あとは掛けてやるだけでよい。
            ac = ini
            for j in T[i][::-1]:
                TD[j] = adj_td(merge(TD[j], ac), j, i)
                ac = merge(ac, DP[j])
                DP[j] = adj_fin(merge(ME[j], TD[j]), j)
        for i in DP:
            print(i)
    Reroot()


main()


Measured memory_bytes: 144868
h,w=map(int,input().split());m=["."];l=[m*(w+2)];p=l+[m+list(map(str,input()))+m for i in range(h)]+l
print("Yes"if all([any([p[i+x[0]][I+x[1]]=="#"for x in [[0,1],[0,-1],[1,0],[-1,0]]])for I in range(1,w+1)for i in range(1,h+1)if p[i][I]=="#"])else"No")

Measured memory_bytes: 3064
import java.util.*;

public class Main {
 public static void main(String[] args) {
   // read the data from input files
   Scanner sc = new Scanner(System.in);
   
   // Define variables
   int a = sc.nextInt();
   int b = sc.nextInt();
   
   // if (a - k >= 0 && b - k >= 0) || (a - k < 0 && b - k < 0)
   // => a = b
   // No answers
   
   // if (a - k >= 0 && b - k < 0) || (a - k < 0 && b - k >= 0)
   // => a - k = -b + k
   // => 2k = a + b
   // => k = (a + b) / 2
   // => k must be an integer, so if a + b is an odd number, k gets to be IMPOSSIBLE
   if ( (a + b) % 2 == 0 ) {
     int kInt = (a + b) / 2;
     System.out.println(kInt);
   } else {
     String kStr = "IMPOSSIBLE";
     System.out.println(kStr);
   }
 }
}

Measured memory_bytes: 21332
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i <= 100; i++){
		for (int j = 0; j <= 100; j++){
			if (i * 4 + j * 7 == N){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

int main() {
	int n, a, L, R, eat;
	cin >> n >> a;
	L = a;
	R = n + a - 1;
	
	if (L >= 0) {
		eat = L;
	}
	else if (R <= 0) {
		eat = R;
	}
	else {
		eat = 0;
	}

	int answer = (R + L) * (R - L + 1) / 2 - eat;

	cout << answer << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n, a, b;
  scanf("%d %d %d", &n, &a, &b);

  vector<int> v;
  SV(n,v);

  llong ans = 0;
  REP(i,n - 1){
    ans += min(b, (v[i + 1] - v[i]) * a);
  }

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



Measured memory_bytes: 892
#include <stdio.h>
#define REP(i, n) for(i = 0; i < n; ++i)
#define FOR(i, a, b) for(i = a; i < b; ++i)
#define BORDER 400

void yes_or_no(char boolean){
    if(boolean){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}

int main(){
    int sx, sy, tx, ty;
    scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

    int dx = tx -sx, dy = ty -sy;
    int i;

    for(i = 0; i < dx; ++i){
        printf("R");
    }
    for(i = 0; i < dy; ++i){
        printf("U");
    }
    for(i = 0; i < dx; ++i){
        printf("L");
    }
    for(i = 0; i < dy; ++i){
        printf("D");
    }
    printf("D");
    for(i = 0; i < dx + 1; ++i){
        printf("R");
    }
    for(i = 0; i < dy + 1; ++i){
        printf("U");
    }
    printf("L");
    printf("U");
    for(i = 0; i < dx + 1; ++i){
        printf("L");
    }
    for(i = 0; i < dy + 1; ++i){
        printf("D");
    }
    printf("R\n");

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		ArrayList<Integer> diviser_list = divise(M);
		Collections.reverse(diviser_list);
		for (int i=0;i<diviser_list.size();i++) {
			if (M/diviser_list.get(i)>=N) {
				System.out.println(diviser_list.get(i));
				break;
			}
		}
	}

    static ArrayList<Integer> divise(int n) {
    	ArrayList<Integer> list = new ArrayList<Integer>();
        for (int i=1;i<=Math.sqrt(n);i++) {
            if (n%i==0) {
                list.add(i);
                if (i*i!=n) {
					list.add(n/i);
                }
            }
        }
        Collections.sort(list);
                return list;
    }
}

Measured memory_bytes: 23764
N, A = map(int, input().split())
X = list(map(int, input().split()))

dp = [[[0]*(2501) for i in range(51)] for j in range(51)]
dp[0][0][0] = 1
for i in range(N):
    value = X[i]
    for j in range(i+2):
        for k in range(2501):
            if i >= j:
                dp[i+1][j][k] += dp[i][j][k]
            if j >= 1 and k >= value:
                dp[i+1][j][k] += dp[i][j-1][k-value]

ans = sum(dp[N][x][A*x] for x in range(1,N+1))

print(ans)



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

using namespace std;

int n;
vector<int> v;

void swap(int &a, int &b){
	int tmp = a;
	a = b;
	b = tmp;
}

int BubbleSort(){
	int cnt = 0;
	int i = 0;
	while(true){
		if(i == n)break;
		for(int j=n-1;j > i;--j){
			if(v[j] < v[j-1]){
				swap(v[j], v[j-1]);
				cnt++;
			}

		}
		i++;
	}
	return cnt;
}

int main(){
	cin >> n;
	int vin;
	for(int i=0; i<n; ++i){
		cin >> vin;
		v.push_back(vin);
	}

	int ans = BubbleSort();
	for(int k=0;k < n;++k){
		cout << v[k];
		if(k != n-1) cout << " ";
	}
	cout <<endl;
	cout << ans << endl;

	return 0;
}


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

#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int i, j;
  int C[VMAX+1];
  int n;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i=0;i<n;i++)scanf("%hu",&A[i+1]);


  for(i=0;i<=VMAX;i++)C[i] = 0;
  for(j=1;j<=n;j++) C[A[j]]++;
  for(i=1;i<=VMAX;i++)C[i] = C[i] + C[i-1];
  for(j=n;j>=1;j--){
    B[C[A[j]]] = A[j];
        C[A[j]]--;
  }

  for(i=1;i<n;i++)printf("%d ",B[i]);
  printf("%d\n",B[n]);


  return 0;
}


Measured memory_bytes: 9548
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
using namespace std;

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read_n(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> void write(const T &t) { cout << t << endl; }
struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

/// template end ///

int main()
{
	while (true)
	{
		READ(int, n, r);
		if (!n && !r) { break; }
		deque<int> deck;
		REP(i, n) deck.push_back(n - i);

		REP(i, r)
		{
			READ(int, p, c); p--;
			vector<int> cut(RANGEOF(deck, p, c));
			deck.erase(RANGEOF(deck, p, c));
			deck.insert(deck.begin(), ALLOF(cut));
		}
		write(deck.at(0));
	}
	return 0;
}

Measured memory_bytes: 1224
@in1=in();
$n=$in1[0];
for($i=0;$i<$n;$i++){
@in2=in();
$ary[$i]=$i;
$l[$i]=$in2[0];
$r[$i]=$in2[1];
}
@sl=sort {$l[$b] <=> $l[$a]} @ary;
@sr=sort {$r[$a] <=> $r[$b]} @ary;
$now=0;
$sum=0;
while(1){
while(defined $done{$sl[$lidx]}){
$lidx++;
if($lidx>=$n){last;}
}
if($lidx>=$n){last;}
$done{$sl[$lidx]}=1;
if($now<$l[$sl[$lidx]]){
$sum+=$l[$sl[$lidx]]-$now;
$now=$l[$sl[$lidx]];
}else{last;}
while(defined $done{$sr[$ridx]}){
$ridx++;
if($ridx>=$n){last;}
}
if($ridx>=$n){last;}
$done{$sr[$ridx]}=1;
if($now>$r[$sr[$ridx]]){
$sum+=$now-$r[$sr[$ridx]];
$now=$r[$sr[$ridx]];
}else{last;}
}
$sum+=abs($now);

$now=0;
$ans=0;
$lidx=0;
$ridx=0;
while(1){
while(defined $done2{$sr[$ridx]}){
$ridx++;
if($ridx>=$n){last;}
}
if($ridx>=$n){last;}
$done2{$sr[$ridx]}=1;
if($now>$r[$sr[$ridx]]){
$ans+=$now-$r[$sr[$ridx]];
$now=$r[$sr[$ridx]];
}else{last;}
while(defined $done2{$sl[$lidx]}){
$lidx++;
if($lidx>=$n){last;}
}
if($lidx>=$n){last;}
$done2{$sl[$lidx]}=1;
if($now<$l[$sl[$lidx]]){
$ans+=$l[$sl[$lidx]]-$now;
$now=$l[$sl[$lidx]];
}else{last;}

}
$ans+=abs($now);
if($ans<$sum){$ans=$sum;}

print "$ans";

sub in{
$t=<STDIN>;
$t=~s/[¥r¥n]+//;
return split / /, $t;
}


Measured memory_bytes: 54128
#include <stdio.h>
#include <string.h>
#include <ctype.h>
// #include <math.h>

long long abss(long long k) {
	if (k < 0){
		return -k;
	}else{
		return k;
	}
}
double Mdis (int x1, int y1, int x2, int y2) {
	long long a = x2-x1;
	long long b = y2-y1;

	return abss(a)+abss(b);
}

int main(){
	int N,M,a[60],b[60],c[60],d[60];
	scanf("%d %d", &N, &M);

	for (int i = 0;i < N;i++) {
		scanf("%d %d", &a[i], &b[i]);
	}
	for (int i = 0;i < M;i++) {
		scanf("%d %d", &c[i], &d[i]);
	}

	for (int i = 0;i < N;i++) {
		int pos;
		double dis = 1e9;
		for (int j = 0;j < M;j++){
			if (Mdis(a[i],b[i],c[j],d[j]) < dis){
				pos = j;
				dis = Mdis(a[i],b[i],c[j],d[j]);
			}
		}
		printf("%d\n", pos+1);
	}
	return 0;
}


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

int main(){
    int N, D, X;
    int A[100];
    cin >> N;
    cin >> D >> X;
    for (int i=0; i<N; i++) cin >> A[i];
    for (int i=0; i<N; i++){
        int day=1;
        while(day <= D){
            X++;
            day += A[i];
        }
    }
    cout << X << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] head = br.readLine().split(" ");
    int ans = 0;
    int n = Integer.parseInt(head[0]);
    long d = Long.parseLong(head[1]);
    long d2 = d * d;
    for(int i = 0; i < n; i++){
      String[] data = br.readLine().split(" ");
      long x = Long.parseLong(data[0]);
      long y = Long.parseLong(data[1]);
      if(d2 >= (x * x) + (y * y)){
        ans++;
      }
    }
    br.close();
    System.out.println(ans);
  }
}

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

typedef struct{
  int time;
  char name[10];
}process;


int main(void){
  int n,q,head=0,tail,cnt=0,cnt_time=0;
  process *data,*out;
  int i;

  //n=プロセス数,q=クオンタム
  scanf("%d %d",&n,&q);

  //動的にプロセスを格納する配列を作る
  data=(process *)malloc(sizeof(process)*(n+1));
  out=(process *)malloc(sizeof(process)*n);

  //ゆかいなプロセスたちを格納
  for(i=0;i<n;i++){
    scanf("%s %d",data[i].name,&data[i].time);
  }

  //メイン処理
  tail=n;

  while(head!=tail){
    data[head].time-=q;

    if(data[head].time>0){
      data[tail]=data[head];
      tail++;
      if(tail>n) tail=0;
      cnt_time+=q;
    }
    else{
      cnt_time+=(q+data[head].time);
      out[cnt]=data[head];
      out[cnt].time=cnt_time;
      cnt++;
    }
    
    head++;
    if(head>n) head=0;
    
  }

  //出力
  for(i=0;i<n;i++) printf("%s %d\n",out[i].name,out[i].time);

  //配列を解放
  free(data);
  free(out);

  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

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

    int n;
    cin >> n;

    vector<int> a(n + 1);
    for (int i = 1; i <= n; ++i) cin >> a[i];

    vector<int> l(n + 1), r(n + 1);
    for (int i = 1; i <= n; ++i)
        l[i] = max(l[i - 1], a[i - 1]);
    for (int i = n - 1; 1 <= i; --i)
        r[i] = max(r[i + 1], a[i + 1]);

    for (int i = 1; i <= n; ++i)
        cout << max(l[i], r[i]) << '\n';

    return 0;
}


Measured memory_bytes: 3968
#include<stdio.h>
int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        
        switch(op){
            case '?':
                goto goodbye;    
            case '+':
                printf("%d\n",a+b);
                break;
            case '-':
                printf("%d\n",a-b);
                break;
            case '*':
                printf("%d\n",a*b);
                break;
            case '/':
                printf("%d\n",a/b);
                break;
        }
    }
    goodbye:
    return 0;
}


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

ll p( ll a, ll b){ 
  if(b == 0){ return a;}
  return a*p(a,b-1);}

int main(){
 ll N;  cin >> N;
 ll c = N; ll d = 0;
  //まず、Nが何桁なのかを調べる
  while(c > 0){ c /= 10; d++;}
  if( d == 1){ cout << N << endl; return 0;}
 
  ll sum = 9*(d-1); //ここまでは確定、
 
  for(int i = 0; i <= 10; i++){
    if( (i+1)*p(10,d-2)-1 <= N){ sum = i+9*(d-1);}}
 
  
  cout << sum << endl; return 0;}
  
  

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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll no_of_div(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }

return ans;
}







int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);


ll a,b,c;cin>>a>>b>>c;

cout<<max((ll)0,(c+b-a))<<"\n";





  return 0;


}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin>>n;
	int maxi=1e9;
	for(ll i=1;i<=min((ll)1e5,n);i++)
	{
		if(n%i==0)
		{
			ll a=n/i;
			ll b=i;
			int br1=0;
			int br2=0;
			while(a>0)
			{
				br1++;
				a/=10;
			}
			while(b>0)
			{
				br2++;
				b/=10;
			}
			maxi=min(maxi,max(br1,br2));
		}
	}
	cout<<maxi<<endl;
		return 0;
}

Measured memory_bytes: 256
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 3e5+5 ;

int n ,l[N] ,r[N] ;
string str ;
int main(){
    cin >> n >> str ;
    int cur = 0 ;
    for(int i=0;i<str.size();++i){
        if(str[i]=='W') ++cur ;
        l[i+1] = cur ;
    }
    cur = 0 ;
    for(int i=str.size()-1;i>=0;--i){
        if(str[i]=='E') ++cur ;
        r[i+1] = cur ;
    }
    int ans = 1e9 ;
    for(int i=1;i<=n;++i){
        ans = min(ans ,l[i-1]+r[i+1]);
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,K;
    cin >> A >> B;
    if((A+B)%2 == 0){
    K = (A+B)/2;
    cout << K << endl;
    }
    else if((A+B)%2 != 0)
    cout << "IMPOSSIBLE" << endl;
 }

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

using namespace std;


int main()
{
	string s;
	cin >> s;
	if (s == "SUN")
	{
	 cout << 7 << endl;
	}
	else if (s == "MON")
	{
		cout << 6 << endl;
	}
	else if (s == "TUE")
	{
		cout << 5 << endl;
	}
	else if (s == "WED")
	{
		cout << 4 << endl;
	}
	else if (s == "THU")
	{
		cout << 3 << endl;
	}
	else if (s == "FRI")
	{
		cout << 2 << endl;
	}
	else
	{
		cout << 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,a;
  cin>>n;
  int ans=0;
  rep(i,n){
    cin>>a;
    if(a%2==0) ans++;
  }
  cout<<ans<<endl;


  return 0;
}






Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FORR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)
#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define ALL(x) begin (x), end (x)
using namespace std;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  char b; cin >> b;
  if (b == 'A' || b == 'T') b ^= 'A' ^ 'T';
  else b ^= 'C' ^ 'G';
  cout << b << endl;
}


Measured memory_bytes: 256
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
#define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N 			1e5+5
#define M           1000000007
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j;
void Anon_mouS(){
	int n;
	cin>>n;
	cout<<n/2+n%2;
}
int32_t main(){
    fastio;
    // file;
    // sieve();
    int q=1;
    // cin>>q;
    while(q--)Anon_mouS();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l = a + b, r = c + d;
    string ans;
    if (l == r) ans = "Balanced";
    else ans = (l < r) ? "Right" : "Left"; 
    cout << ans << endl;
    return 0;
}


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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




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

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;


#define pb push_back
#define ff first
#define ss second
#define INF int(2e9) + 9
#define BIG_INF ll(9e18)
#define SIZE 1001
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define len(v) int((v).size())
#define BACK(v) ll((v).back())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout);


ll binpow(ll a, ll b, ll MOD = BIG_INF)
{
    ll res = 1;

    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= MOD;
        res %= MOD;
    }

    return res % MOD;
}

const ll mod = 1e9 + 7;

int T = 1;
int n, m;
char a[SIZE][SIZE];

int ans[SIZE][SIZE];

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct comp
{
    bool operator()(const pair<pii, int>& x, const pair<pii, int>& y)
    {
        return x.ss > y.ss;
    }

};


void solve()
{
    int sx, sy, ex, ey;
    cin >> n >> m >> sx >> sy >> ex >> ey;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            ans[i][j] = INF;
    sx--; sy--; ex--; ey--;


    priority_queue<pair<pii, int>, vector<pair<pii, int> >, comp > q;
    q.push({{sx, sy}, 0});

    while(q.size())
    {
        pair<pii, int> cur = q.top();
        q.pop();
        int x = cur.ff.ff, y = cur.ff.ss;
        int d = cur.ss;
        if(d >= ans[x][y]) continue;

        ans[x][y] = d;

        for(int i = 0; i < 4; i++)
        {
            int curx = x + dx[i], cury = y + dy[i];

            if(curx < 0 || curx >= n || cury < 0 || cury >= m || a[curx][cury] == '#') continue;

            int curans = 0;
            curans += ans[x][y];

            if(curans < ans[curx][cury])
            {
                q.push({{curx, cury}, curans});
            }

        }

        for(int i = -2; i <= 2; i++)
        {
            for(int j = -2; j <= 2; j++)
            {
                int curx = x + i, cury = y  + j;
                if(curx < 0 || curx >= n || cury < 0 || cury >= m || a[curx][cury] == '#') continue;
                int curans = 1;
                curans += ans[x][y];

                if(curans < ans[curx][cury])
                {
                    q.push({{curx, cury}, curans});
                }
            }
        }


    }
//    for(int i = 0; i < n; i++)
//    {
//        for(int j = 0; j < m; j++)
//            cout << ans[i][j] << ' ';
//        cout << "\n";
//    }

    if(ans[ex][ey] == INF) ans[ex][ey] = -1;
    cout << ans[ex][ey];
    return;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
//    filein;fileout;
//
//    cin >> T;

    while(T--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 9744
#include <iostream>
#include <iomanip>
#include <cmath>


class Vector {
  public:
    Vector() {}
    Vector(double x, double y): x(x), y(y) {}
    Vector operator+(Vector vec) { return Vector(x + vec.x, y + vec.y); }
    Vector operator-(Vector vec) { return Vector(x - vec.x, y - vec.y); }
    Vector operator*(double val) { return Vector(x * val, y * val); }
    Vector operator/(double val) { return Vector(x / val, y / val); }


    double dot(Vector vec) { return x * vec.x + y * vec.y; }
    double norm() {
        return std::sqrt(x * x + y * y);
    }
    Vector normalize() {
        return *this / this->norm();
    }

    double x, y;
};


class Line {
  public:
    Line() {}
    Line(Vector p0, Vector p1): p0(p0), p1(p1) {
        direction = p1 - p0;
    }

    Vector p0, p1;
    Vector direction;
};

int main() {
    Vector p1, p2;
    std::cin >> p1.x >> p1.y >> p2.x >> p2.y;
    Line l(p1, p2);
    Vector dir = l.direction.normalize();

    int q;
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        Vector p;
        std::cin >> p.x >> p.y;

        Line ql(p1, p);
        auto x = p1 + dir * ql.direction.dot(dir);
        std::cout << std::fixed << std::setprecision(10) << x.x << " " << x.y << std::endl;
    }
}



Measured memory_bytes: 3268
#include <stdio.h>

int list_len;
int list[100000];
int last_color;

int main(void) {
	int n,i;
	int now;
	int result;
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		scanf("%d",&now);
		list_len=1;
		list[0]=1;
		last_color=now;
		for(i=2;i<=n;i++) {
			scanf("%d",&now);
			if(i%2) {
				if(now==last_color)list[list_len-1]++;
				else list[list_len++]=1;
			} else {
				if(now==last_color)list[list_len-1]++;
				else {
					if(list_len<=1) {
						list[0]++;
						list_len=1;
					} else {
						list[list_len-2]+=list[list_len-1]+1;
						list_len--;
					}
				}
			}
			last_color=now;
		}
		result=0;
		for(i=((last_color==0)?list_len-1:list_len-2);i>=0;i-=2) {
			result+=list[i];
		}
		printf("%d\n",result);
	}
	return 0;
}

Measured memory_bytes: 0
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

string S;

int main()
{
	cin >> S;
	REP(i, S.length() - 8) {
		cout << S[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    int L = 2*K;
    vector< vector<int> > white(2*L+1, vector<int>(2*L+1));
    vector< vector<int> > black(2*L+1, vector<int>(2*L+1));
    while(N--) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        x = x%L + 1;
        y = y%L + 1;
        if(c == 'W') {
            ++white[x][y];
            ++white[x][y+L];
            ++white[x+L][y];
            ++white[x+L][y+L];
        } else {
            ++black[x][y];
            ++black[x][y+L];
            ++black[x+L][y];
            ++black[x+L][y+L];
        }
    }

    for(int i=0; i<white.size(); i++) {
        partial_sum(white[i].begin(), white[i].end(), white[i].begin());
        partial_sum(black[i].begin(), black[i].end(), black[i].begin());
    }
    for(int j=0;j<=2*L; j++) {
        for(int i=1; i<=2*L; i++) {
            white[i][j] += white[i-1][j];
            black[i][j] += black[i-1][j];
        }
    }

    int ans = 0;
    for(int i=0; i<L; i++) {
        for(int j=0; j<L; j++) {
            int white_point = white[K+i][L+j] - white[K+i][K+j] - white[i][L+j] + white[i][K+j];
            white_point += white[L+i][K+j] - white[K+i][K+j] - white[L+i][j] + white[K+i][j];
            int black_point = black[K+i][K+j] - black[i][K+j] - black[K+i][j] + black[i][j];
            black_point += black[L+i][L+j] - black[K+i][L+j] - black[L+i][K+j] + black[K+i][K+j];
            ans = max(ans, white_point + black_point);
        }
    }

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


Measured memory_bytes: 125696
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++){
		if(a[i]=='C'){
			for(int j=i+1;j<a.size();j++){
				if(a[j]=='F'){
					cout<<"Yes"<<endl; return 0;
				} 
			} 
		} 
	}
	cout<<"No"<<endl; 
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int a[n],b[n],c[n];
  for(i=0;i<n;i++) cin>>a[i];
  for(i=0;i<n;i++) cin>>b[i];
  for(i=0;i<n;i++) c[i]=a[i]-b[i];
  int ans=0;
  for(i=0;i<n;i++)
  {
    if(c[i]>0) ans+=c[i];
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll pate[110], cnt[110];
ll dfs(int level, ll eat) {
	ll ans = 0;
	if (level == 0) return 1;

	if (eat >= 1) eat--;

	if (eat != 0) {
		if (eat >= cnt[level - 1]) {
			ans += pate[level - 1];
			eat -= cnt[level - 1];
		}
		else {
			ans += dfs(level - 1, eat);
			eat = 0;
		}
	}

	if (eat >= 1) {
		ans++;
		eat--;
	}

	if (eat != 0) {
		if (eat >= cnt[level - 1]) {
			ans += pate[level - 1];
			eat -= cnt[level - 1];
		}
		else {
			ans += dfs(level - 1, eat);
			eat = 0;
		}
	}

	if (eat >= 1) eat--;
	return ans;
}

int main()
{
	ll N, X;
	cin >> N >> X;
	pate[0] = 1;
	cnt[0] = 1;
	for (int i = 1; i <= N; i++) {
		pate[i] = pate[i - 1] * 2 + 1;
		cnt[i] = cnt[i - 1] * 2 + 3;
	}
	cout << dfs(N, X) << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

// Solution class
class Solution {
    public Solution() { }
    private static final InputReader scan = new InputReader();
    // solve method
    public void solve() throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        // code goes here...
        int a = scan.nextInt();
        int b = scan.nextInt();

        String disp = (a == b) ? "a == b" : (a < b) ? "a < b" : "a > b";
        out.println(disp);

        out.close();
    }
}

// InputReader class
class InputReader {
    private final BufferedReader br;
    private StringTokenizer st = new StringTokenizer("");
    public InputReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
    public String next() throws IOException {
        while (!st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException ie) { ie.printStackTrace(); }
        }
        return st.nextToken();
    }
    public String nextLine() throws IOException {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException ie) { ie.printStackTrace(); }
        return str;
    }
    public int nextInt() throws IOException { return Integer.parseInt(next()); }
    public long nextLong() throws IOException { return Long.parseLong(next()); }
    public double nextDouble() throws IOException { return Double.parseDouble(next()); }
}

// Main class
public class Main {
    public Main() { }
    // driver method
    public static void main(String[] args) throws IOException {
        new Solution().solve();
    }
}



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



signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int x; cin >> x;
    int n = 100;
    int cnt = 0;
    while(true){
        cnt++; n += n/100;
        if (n >= x) break;
    }
    cout << cnt << endl;
    return 0;
}

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

int contain3(int i){
    int mod;
    while(i>0){
        mod=i%10;
        if(mod==3){
            return 1;
        }
        i=i/10;
    }
    return 0;
}

int main(void){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3==0){
            printf(" %d",i);
        }
        else if(contain3(i)){
            printf(" %d",i);
        }
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 3216
package main

import (
	"fmt"
)

func main() {
	var A, B, K int
	fmt.Scanf("%d%d%d", &A, &B, &K)
	for i := A; i <= B; i++ {
		if i < A + K || i > B - K {
			fmt.Printf("%d\n", i)
		}
	}
	return
}


Measured memory_bytes: 512
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
long long MAX(long long A,long long B){
    return A>B?A:B;
}
long long MIN(long long a,long long b){
    return a<b?a:b;
}
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return -1;
    return 1;
}
int main()

{   long long a[5],b,c,d,e,x,y,n,ans=0,i;
    scanf("%lld%lld%lld%lld%lld%lld",&n,&a[0],&a[1],&a[2],&a[3],&a[4]);
    qsort(a,5,sizeof(long long),compare);
    if(a[4]>=n){
        printf("5");
        return 0;
    }
        ans=n/a[4];
        if(n%a[4]>0){
            ans+=1;
        }
    ans+=4;
    
    
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(){
  int a[30],i,j,k,l,num1,num2[2],num3=0;
  for(i=0;i<30;i++){
    a[i]=0;
  }
  for(j=0;j<28;j++){
    scanf("%d",&num1);
    a[num1-1]=1;
  }
  for(k=0;k<30;k++){
    if(a[k]==0){
      num2[num3]=k+1;
      num3++;
    }
  }
  for(l=0;l<2;l++){
  printf("%d\n",num2[l]);
  }
  return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>

using namespace std;

int arr[110];

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);

    int n, i;
    scanf("%d", &n);
    for(i = 0; i < n; i++)
        scanf("%d", &arr[i]);

    sort(arr, arr + n);
    printf("%d\n", arr[n - 1] - arr[0]);
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int H, W, N;
int sr, sc;
string S, T;

void solve() {
    cin >> H >> W >> N >> sr >> sc >> S >> T;

    string ans = "YES";
    int u = 1, d = H, l = 1, r = W;
    for (int i = N - 1; i >= 0; --i) {

        if (T[i] == 'D')u = max(u - 1, 1);
        else if (T[i] == 'U')d = min(d + 1, H);
        else if (T[i] == 'R')l = max(l - 1, 1);
        else r = min(r + 1, W);

        if (S[i] == 'D')d--;
        else if (S[i] == 'U')u++;
        else if (S[i] == 'R')r--;
        else l++;

        if (u > d || l > r) {
            ans = "NO";
            break;
        }
    }
    if (ans == "YES" && (sr<u || sr>d || sc<l || sc>r))ans = "NO";

    cout << ans << endl;
}

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

Measured memory_bytes: 920
#include<iostream>
#include<queue>

using namespace std;

static const int N = 100;
static const int INFTY = (1 << 21);
//static const int WHITE = 0;
//static const int GRAY = 1;
//static const int BLACK = 2;

int n, M[N][N];
int d[N];

void bfs(int s) {
    queue<int> q;
    q.push(s);

    for (int i = 0; i < n; i++) d[i] = INFTY;

    d[s] = 0;

    int u;

    while (!q.empty()) {
        u = q.front();
        q.pop();

        for (int v = 0; v < n; v++) {
            if (M[u][v] == 0) continue;
            if (d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);

        }
    }

    for (int i = 0; i < n; i++) {
        cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << '\n';
    }
}
int main() {
    int u, v, k;

    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0);

    return 0;
}


Measured memory_bytes: 3176
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

lint dx[8] = { 0,1,1,1,0,-1,-1,-1 },
dy[8] = { 1,1,0,-1,-1,-1,0,1 };

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


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

	string s, t; cin >> s >> t;
	lint a = 0, b = 0;
	if (s.length() > t.length()) {
		a = 1;
	}
	else if (s.length() < t.length()) {
		b = 1;
	}
	else{
		a = s[0];
		b = t[0];
	}
	if (a > b)co("GREATER");
	else if (a == b)co("EQUAL");
	else co("LESS");
	gc();
}

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

int main() {
  int N; cin>>N;
  vector<int> vec(N); for(int i=0;i<N;i++) cin>>vec.at(i);
  sort(vec.begin(),vec.end());
  reverse(vec.begin(), vec.end());
  
  int count=1;
  for(int i=0; i<N-1; i++) if(vec.at(i)>vec.at(i+1)) count++;
  
  cout<<count<<endl;
}

Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val s = cin.next()
    var post = ' '
    var ok = true
    for (i in s) {
        if (post == i) {
            ok = false
            break
        }
        post = i
    }
    if (ok) {
        println("Good")
    } else {
        println("Bad")
    }
}

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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define gcda(x,y) gcd(abs(x),abs(y))

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n;
	cin >> n;
	
	if(n < 1200)
		cout << "ABC";
	else if(n < 2800)
		cout << "ARC";
	else
		cout << "AGC";

}



Measured memory_bytes: 256
#include <stdio.h>
long long min(long long a,long long b){
    if(a<b) return a;
    else return b;
}
int main(void){
    long long n,k;
    scanf("%lld%lld",&n,&k);
    printf("%lld",min(n%k,k-n%k));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int size = 12;
//const int size = 14;
char a[size][size];
int cnt = 0;
void dfs(int x, int y){
    //現在地を０にする
    a[x][y] = 0;
    //4近傍を探索
    //x+1, y
    int nx = x+1, ny=y;
    if(0 <= nx and nx < 12 and 0 <= ny and ny < 12 and a[nx][ny] == '1') dfs(nx, ny);
    //x-1, y
    nx = x-1, ny = y;
    if(0 <= nx and nx < 12 and 0 <= ny and ny < 12 and a[nx][ny] == '1') dfs(nx, ny);
    //x, y+1
    nx = x, ny = y+1;
    if(0 <= nx and nx < 12 and 0 <= ny and ny < 12 and a[nx][ny] == '1') dfs(nx, ny);
    //x, y-1
    nx = x, ny = y - 1;
    if(0 <= nx and nx < 12 and 0 <= ny and ny < 12 and a[nx][ny] == '1') dfs(nx, ny);
    return;
}

int main(){
    while (1) {
    cnt = 0;
    //マップを入力
    for(int i=0; i < 12; i++){
        for(int j=0; j < 12; j++) if(!(cin >> a[i][j])) return 0;
    }


    //サーチ
    for(int i=0; i < 12; i++){
        for(int j=0; j < 12; j++){
            if(a[i][j] == '1'){
                cnt += 1;
                dfs(i, j);
            }
        }
    }

    cout << cnt << endl;
}
    return 0;
}



Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int N,Q;
  cin >> N>>Q;
  string s;
  cin >>s;
  int l[Q],r[Q];
  for(int i=0;i<Q;i++){
      cin >> l[i]>>r[i];
  }

  //累積和で解く。
  vector<int> AC(N+1,0);//AC[0]=0;
  int Acounter=0;
  //ACの数を数えて累積和としてAC[]に保存
  for(int i=0;i<N;i++){
      if(s[i]=='A'){
          Acounter=1;
          AC[i+1]=AC[i];
      }
      else if(s[i]=='C'&& Acounter==1){
          AC[i+1]=AC[i]+1;
          Acounter=0;  
      }
      else//ACの数に変化なし
      {
          Acounter=0;
          AC[i+1]=AC[i];
      }
      
  }
  
  for(int i=0;i<Q;i++){
cout <<AC[r[i]]-AC[l[i]]<<endl;
  }
  

return 0;
}


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

class Cmondai
{
    static void Main()
    {
        var S = Console.ReadLine();
        var zero = S.Count(x => x == '0');
        var one = S.Count(x => x == '1');
        Console.WriteLine((zero<one?zero:one)*2);
    }
}

Measured memory_bytes: 13268
#http://abc081.contest.atcoder.jp/
# -*- coding: utf-8 -*-

from collections import Counter

n,k = map(int,input().split())
a = Counter(list(map(int,input().split())))

b = len(a) - k

amount = 0
if b != 0:
    for i,v in enumerate(a.most_common()):
        if i+1 > k : amount += v[1]
    print(amount)

else:
    print(0)


Measured memory_bytes: 37780
/*
      author  : nishi5451
      created : 14.08.2020 14:59:22
*/

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


int main(){
    int n,k;
    cin >> n >> k;
    int ans = 0;
    rep(i,n){
        int x;
        cin >> x;
        ans += 2*min(x,k-x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    sx, sy, tx, ty = LI()
    tx -= sx
    ty -= sy
    x = abs(tx)
    y = abs(ty)
    r,l,u,d = "r","l","u","d"
    ans = ""

    if tx != 0 and ty != 0:
        ans = r*x+u*y+l*x+d*(y+1)+r*(x+1)+u*(y+1)+l+u+l*(x+1)+d*(y+1)+r

        if tx<0:
            ans = ans.replace(r, "L")
            ans = ans.replace(l, "R")
        if ty<0:
            ans = ans.replace(u,"D")
            ans = ans.replace(d,"U")
            
        ans = ans.upper()
        
    else:
        x = max(x,y)
        ans = r*x+u+l*x+d*2+r*x+u+r+u*2+l*(x+2)+d*2+r

        if ty>0:
            ans = ans.replace(r,"U").replace(l,"D").replace(u,"L").replace(d,"R")
        elif tx<0:
            ans = ans.replace(r,"L").replace(l,"R")
        elif ty<0:
            ans = ans.replace(r,"D").replace(l,"U").replace(u,"R").replace(d,"L")
        ans = ans.upper()

    print(ans)
main()


Measured memory_bytes: 73952
#include<iostream>
using namespace std;
int main()
{
    int n,ans;
    int all[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>n;
    
    
    cout<<all[n-1]<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n,m,q;
	cin>>n>>m>>q;
	int lr[n+1][n+1]={};
	int sum[n+1][n+1]={};
	for(int i=0;i<m;i++){
		int l,r;
		cin>>l>>r;
		lr[l][r]++;
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			sum[i][j]=sum[i][j-1]+lr[i][j];
		}
	}
	for(int i=0;i<q;i++){
		int a,b;
		cin>>a>>b;
		int res=0;
		for(int k=a;k<=b;k++){
			res+=(sum[k][b]-sum[k][a-1]);
		}
		cout<<res<<endl;
	}
	return 0;
}
			
		


Measured memory_bytes: 2944