akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n,m;
  cin>>n>>m;
  vector<long> v(n);
  rep(i,n) cin>>v[i];

  vector<long> acc(n);
  acc[0] = v[0];
  rep(i,1,n) acc[i] = acc[i-1] + v[i];

  map<int,int> cnt;
  rep(i,n) cnt[acc[i]%m]++;

  long ans = cnt[0];
  // dbg(cnt);
  rep(i,n){
    cnt[acc[i]%m]--;
    ans += cnt[acc[i]%m];
    // dbg(cnt,ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4736
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += B[A[i]-1]
    if i >= 1 and A[i]-A[i-1] == 1:
        ans += C[A[i-1]-1]

print(ans)

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int a, b, k;

void read() {
  cin >> a >> b >> k;
}

vi d;

void solve() {
  int l = min(a, b), i;
  for(i = 1; i <= l; ++i)
    if (a % i == 0 && b % i == 0)
      d.pb(i);

  cout << d[d.size() - k];
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
//  cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int x  = sc.nextInt();
      	if(x == 0) {
      		System.out.println("1");
        }
      	else {
      		System.out.println("0");
        }
    }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - One Clue
            var line = ReadLine();
            int k = line[0];
            int x = line[1];

            var coords = new List<int>() { x };

            for(int i = 1; i < k; i++)
            {
                coords.Add(x + i);
                coords.Add(x - i);
            }

            Console.WriteLine(String.Join(" ", coords.OrderBy(a => a)));
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13396
def divisor(N):
    div = []
    for i in range(1, int(N ** 0.5 + 1)):
        if N % i == 0:
            div.append(i)
            if i * i != N:
                div.append(N // i)
    return sorted(div)


N = int(input())
ans = set()
divN = divisor(N)
for d in divN:
    p = N // d
    while d % p == 0 and p != 1:
        d = d // p
    if (d - 1) % p == 0:
        ans.add(p)
for d in divisor(N - 1):
    ans.add(d)
print(len(ans) - 1 if 1 in ans else len(ans))


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll n;
  cin >> n;
  cout << "A";
  if(n < 1200)
    cout << "B";
  else if(n < 2800)
    cout << "R";
  else
    cout << "G";
  cout << "C" << endl;

  return 0;
}

Measured memory_bytes: 256
program flipping_signs
  implicit none
  integer :: n, i, k
  integer(8) :: a(100000), m
  a = 0_8
  read(*,*) n
  read(*,*) a(1:n)
  m = 10000000000_8
  k = 0
  do i = 1, n
    if (m.gt.abs(a(i))) m = abs(a(i))
    if (a(i).lt.0_8) k = k + 1
  end do
  if (mod(k,2).eq.0) then
    m = sum(abs(a(1:n)))
  else
    m = sum(abs(a(1:n))) - 2_8*m
  end if
  write(*,'(i0)') m
  stop
end program flipping_signs

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

int main(){

	int n,b,f,r,v,mane[13][10]={0};
	cin >> n;

	for(int i=0; n>i; i++){ //0???????????????????????§?????????????????????
		cin >> b >> f >> r >> v;
		mane[(b-1)*3+f][r-1]+=v; //??????????????¨??°????????????        
	}

	for(int i=1; 12>=i; i++){
		if(i%3 == 1 && i != 1)cout << "####################" << endl;
		
		for(int j=0; 10>j; j++){
			cout << " " << mane[i][j];
		}

		cout << endl;
	}
	
	return 0;
}

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

T = []
X = []
Y = []
T.append(0)
X.append(0)
Y.append(0)

for _ in range(N):
    t,x,y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

for i in range(1, N+1, 1):
    dt = T[i]-T[i-1]
    dl = abs((X[i]+Y[i])-(X[i-1]+Y[i-1]))
    if dt<dl:
        print("No")
        exit()
    if dt%2!=dl%2:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 11808
# -*- coding: utf-8 -*-

sx, sy, tx, ty = map(int, input().split())

x = tx - sx
y = ty - sy

ans = "R" * x + "U" * y \
      + "L" * x + "D" * y \
      + "D" + "R" * (x + 1) + "U" * (y + 1) + "L" \
      + "U" + "L" * (x + 1) + "D" * (y + 1) + "R"

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(7);

    double n;
    while (scanf("%lf", &n) != EOF)
    {
        double sum = n;
        for (int i = 2; i <= 10; ++i)
        {
            if (i % 2 == 0)
            {
                n *= 2.0;
            }
            else
            {
                n /= 3.0;
            }
            sum += n;
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3252
def c_to_int(char):
    return ord(char)-65

def solve(s):
    count = 0
    table=[]
    for str in s:
        if str=='+':
            count +=1
        elif str =='-':
            count -=1
        elif str=='[':
            table.append(str)
        elif str==']':
            table.append(str)
        elif str=='?':
            table.append(str)
            count =0
        else:
            table.append((c_to_int(str) +count)%26)
            count = 0

    for i in range(len(table)):
        if table[i]=='?':
            table[i] = 0
#    print(table)
    return(table)

def rev(table):
    ret = "" 
    i =0
    while i <  len(table):
        if table[i] == '[':
            c  = 1
            i_=i+1
            while c>0:
                if table[i_] =='[':
                    c += 1
                if table[i_] ==']':
                    c -= 1
                i_ += 1
 #           print(reversed(table[i+1:i_-1]))
            ret += rev(table[i+1:i_-1])[::-1]
            i = i_-1
        elif table[i] ==']':
            pass
        else:
#            print(chr(table[i]+65))
            ret += chr(table[i]+65)
        i+=1

    return ret


while True:
    S = input()
    if S[0]=='.':
        break
    ans = rev(solve(S))
    print(ans)



Measured memory_bytes: 5580
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
int main ()
{
	char s[4];
	scanf("%s",&s);
	if(s[0]=='S' && s[1]=='U') printf("7");
	if(s[0]=='M') printf("6");
	if(s[0]=='T' && s[1]=='U') printf("5");
	if(s[0]=='W') printf("4");
	if(s[0]=='T' && s[1]=='H') printf("3");
	if(s[0]=='F') printf("2");
	if(s[0]=='S' && s[1]=='A') printf("1");
	return 0;
}


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

// 剰余シリーズ
ll mod = 1000000007;
#define SIZE 500000

// a^b（on Z^mod) : O(log(b))
ll modpow(ll a, ll b){
	if (b == 0)return 1;
	ll z = modpow(a, b / 2);
	z = z*z%mod;
	if (b % 2 == 1)z = z*a%mod;
	return z;
}

// a^-1 (on Z^mod) : O(log(mod))
ll modinv(ll a) {
    return modpow(a, mod-2);
}

ll inv[SIZE + 1]; // a^-1 (on Z^mod)のテーブル : O(SIZE)
ll kai[SIZE + 1]; // (a)! (on Z^mod)のテーブル : O(SIZE)
ll invkai[SIZE + 1]; // (a)!^(-1) (on Z^mod)のテーブル : O(SIZE)
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}

	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}


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

    invinit();
    int N, a, b, c;
    cin >> N >> a >> b >> c;
    ll aa = (a * (modinv(a+b)))%mod;
    ll bb = (b * (modinv(a+b)))%mod;

    ll asum = 0;
    ll bsum = 0;
    for (int k=0;k<N;k++){
        asum +=(((((((kai[N+k-1]*invkai[k])%mod)*invkai[N-1])%mod)*(N+k)%mod)*modpow(aa,N))%mod)*modpow(bb,k)%mod;
        asum %= mod;
        bsum +=(((((((kai[N+k-1]*invkai[k])%mod)*invkai[N-1])%mod)*(N+k)%mod)*modpow(bb,N))%mod)*modpow(aa,k)%mod;
        bsum %= mod;
    }

    cout << (((asum+bsum) *100)%mod * modinv(100-c))%mod << endl;

}

Measured memory_bytes: 12032
program prob1
    implicit none
    integer::h, w, i, j, tmp
    character(len=20)::x
    character(len=5), allocatable::s(:)
    read(*,*) h, w
    allocate(s(w))
    do i = 1, h
        read(*,*) s
        do j = 1, w
            if(s(j) .eq. "snuke") then
                write(x,*) i
                write(*,'(2a)') char(ichar("A") + j - 1), trim(adjustl(x))
                stop
            end if
        end do
    end do
    deallocate(s)
    contains
end program

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


int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> ac(n, 0), pn(n, 0);
    for (int i=0; i<m; ++i) {
        int p;
        string S;
        cin >> p >> S;
        if (S == "AC") ac[p-1]++;
        else if (ac[p-1] == 0) pn[p-1]++;
    }
 
    int ans1 = 0, ans2 = 0;
    for (int i=0; i<n; i++) {
        if (ac[i] > 0) {
            ans1++;
            ans2 += pn[i];
        }
    }
 
    cout << ans1 << " " << ans2 << "\n";
    return 0;
}

Measured memory_bytes: 4008
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int ans=0;
  int i=0,j=0;
  while(R*i <= N){
    while(R*i+G*j <= N){
      if((N-(R*i+G*j))%B == 0 || R*i+G*j == N){
        ans++;
      }
      j++;
    }
    i++;
    j=0;
  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
if (x+y)%3:
    print(0)
    exit()
x,y=min(x,y),max(x,y)
sa=y-x
wa=y+x
z=(x+y)//3
if sa>x:
    print(0)
    exit()


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

def mod_comb(n,k,mod):
    return fact[n]*fact_inv[k]%mod*fact_inv[n-k]%mod

print(mod_comb(z,x-z,mod))


Measured memory_bytes: 108220
//ABC158

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

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

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

  if(s=="AAA"||s=="BBB") cout << "No";
  else cout << "Yes";
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

// union-find
struct union_find {
    vector<int> data;

    union_find(int size) {data.resize(size,-1);}

    int find(int x) {
        if (data[x] < 0) {return x;}
        return data[x] = find(data[x]);
    }

    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) {return false;}
        if (data[x] > data[y]) swap(x,y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int size(int x) {return -data[find(x)];}
};


int main() {
    int n, m, k; cin >> n >> m >> k;
    union_find uf(n);
    map<int,int> mp;
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        mp[a]++; mp[b]++;
        uf.unite(a,b);
    }
    rep(i,k) {
        int c, d; cin >> c >> d;
        c--; d--;
        if (uf.find(c) == uf.find(d)) {
            mp[c]++; mp[d]++;
        }
    }
    rep(i,n) {
        printf("%d ",uf.size(i)-mp[i]-1);
    }
    cout << endl;
}

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

int main() {
  string s;
  cin>>s;
  if(s[0]==s[1] && s[1]==s[2]) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int x, y;

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

        else if (y < x)
        {
            printf("%d %d\n", y, x);
        }
        else if (x < y)
        {
            printf("%d %d\n", x, y);
        }
        else
        {
            printf("%d %d\n", x, y);
        }
    }
    return 0;
}


Measured memory_bytes: 2684
import sys
from collections import defaultdict

input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    d = defaultdict(int)
    for _ in range(M):
        B, C = map(int, input().split())
        d[C] += B
    
    for a in A:
        d[a] += 1

    sort_d = sorted(d.items(),reverse = True)
    
    cnt = 0
    ans = 0
    for i,j in sort_d:
        if cnt + j < N:
            ans += i * j
            cnt += j
        elif cnt + j >= N:
            if cnt == N:
                break
            ans += i * (N - cnt)
            break 

    print(ans)

main()

Measured memory_bytes: 88240
def main():
    n = int(input())
    aa = sorted(list(map(int, input().split())))
    i = 0
    while i < n - 1 and aa[i] != aa[i + 1]:
        i += 1
    if i == n - 1:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 25172
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)1e9+1
#define MOD (long long)1e9+7
#define INF64 (long long)1e18+1

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
  //INPUT
  string S,T;
  cin >> S >> T;


  //SOLVE
  llint ans;
  ans = 0;
  if(S[0] == T[0]) ans++;
  if(S[1] == T[1]) ans++;
  if(S[2] == T[2]) ans++;


  //OUTPUT
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
int N,M,tmp;
int sum=0;
int i=0;

//日数//
cin >> N;

//問題数//
cin >> M;
for(i=0;i<M;i++){
cin >> tmp;
sum += tmp;
}

if(N-sum<0)
cout << -1;

else
cout << N-sum << endl;

return 0;
}

Measured memory_bytes: 3672
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int[] s = new int[999];
		int count = 0;
		for (int i=0; i<999; i++) {
			count =+ count+i+1;
			s[i] = count;
		}
		for (int i=1; i<998; i++) {
			if ( A-s[i] == B-s[i+1] ) {
				System.out.println(s[i]-A);
				return;
			}
		}
	}		
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main (){
int a,b,t=0,t1=0;
int ar[7]{1,3,5,7,8,10,12};
int as[7]{4,6,9,11,0,0,0};
cin>>a>>b;
for (int i=0;i<7;i++)
{
if (a==ar[i]||b==ar[i])t++;
if (a==as[i]||b==as[i])t1++;
}
if (t==2||t1==2)
    cout<<"Yes";
else
cout<<"No";


return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
bool isincluded(char x, string str) {
	bool f = 0;
	for (size_t i = 0; i < str.size(); i++) {
		if (str.at(i) == x)f = 1;
	}
	return f;
}
int ctoi(char c) {
	if ('0' <= c && c <= '9') {
		return c - '0';
	}
	return 0;
}



int main(void) {
	ll n; cin >> n; n--;
	cout << (1 + n) * n / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>> ab(n);
    rep(i,n)cin>>ab[i].first>>ab[i].second;
    sort(ab.begin(),ab.end());
    ll ans=0;
    rep(i,n){
        if(m>=ab[i].second){
            ans+=ab[i].second*ab[i].first;
            m=m-ab[i].second;
        }else{
            ans+=m*ab[i].first;
            m=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4812
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
void solve(){
	string s;
	cin>> s ;
	if(s.length()&1){
		cout<<"No"<<endl;
		return ;
	}
	for(ll i=0;i+1<s.length() ;i+=2){
		if(s[i]=='h' && s[i+1]=='i')continue;
		cout<<"No"<<endl;
		return ;
	}
	cout<<"Yes"<<endl;
}
int main(){
	//mahakal(),fast;
	solve();
	return 0;
}

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

using tap = std::tuple<unsigned long, unsigned long, unsigned long>; // (val, 10^n, 111...)
constexpr unsigned long MOD = 998244353;

tap op(tap a, tap b){
    const auto& [av, at, ar] = a;
    const auto& [bv, bt, br] = b;
    return {(av * bt + bv) % MOD, at * bt % MOD, (ar * bt + br) % MOD};
}

tap e(){
    return {0, 1, 1};
}

tap mapping(unsigned long v, tap x){
    if(v == 0)return x;
    const auto& [xv, xt, xr] = x;
    return {xr * v % MOD, xt, xr};
}

unsigned long composition(unsigned long f, unsigned long g){
    if(f == 0)return g;
    return f;
}

unsigned long id(){
    return 0;
}

int main(){
    using namespace std;
    using namespace atcoder;
    unsigned long N;
    cin >> N;
    lazy_segtree<tap, op, e, unsigned long, mapping, composition, id> sgt(vector<tap>(N, {1, 10, 1}));
    unsigned long Q;
    cin >> Q;
    for(unsigned long i{0}, L, R, D; i < Q; ++i){
        cin >> L >> R >> D;
        sgt.apply(L - 1, R, D);
        cout << get<0>(sgt.all_prod()) << endl;
    }
    return 0;
}


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

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define V vector<int>

using namespace std;
using ll = long long;

int main() {
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    int count = 0;
    REP(i, N) {
        if(A[i] == B[i]) {
            if(A[i] != C[i]) {
                count++;
            }
        }
        else if(A[i] == C[i]) {
            if(A[i] != B[i]) {
                count++;
            }
        }
        else if(B[i] == C[i]) {
            if(A[i] != B[i]) {
                count++;
            }
        }
        else {
            count += 2;
        }
    }
    OUT(count);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
int main()
{
    fastio();
  
    string s,t;
    cin>>t>>s;
    int n = t.size(),m=s.size();
    int ans = n+m;
    for(int i=0;i+m<=n;i++)
    {
        int temp=0;
        for(int j=0;j<m;j++)
        {
            if(t[i+j]!=s[j])
                temp++;
        }
        ans=min(ans,temp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>

typedef long long ll;
#define REP(i,n) for(int (i)=0;(i) < (n);(i)++)
using namespace std;


int main(){
  int H,W;
  while(true){
    cin >> H >> W;
  if (H == 0 && W == 0) break;
  else{
    REP(i,H){
      REP(j,W){
        if(j==0 || j==W-1){
          printf("#");
        }
        else if(i==0 || i==H-1){
          printf("#");
        }
        else printf(".");
    }
    printf("\n");
  }
  printf("\n");
  }
}



  return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N, M;
const int INF = 100000000;
vector<vector<int>> dist(201, vector<int>(201, INF));
map<P, int> mp;

void Warshallfloyd(int n = N){ //nは頂点数
    for(int i = 1; i <= n; i++){      // 経由する頂点
        for(int j = 1; j <= n; j++){    // 開始頂点
            for(int k = 1; k <= n; k++){  // 終端
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    return;
}

bool Solve(int from, int to, int cost, int n = N){
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) if(dist[i][j] == (dist[i][from] + cost + dist[to][j])) return false;
    return true;
}

int main(void){
    
    scanf("%d %d", &N, &M);
    for(int i = 0; i <= N; i++) dist[i][i] = 0;
    for(int i = 0; i < M; ++i){
        int a, b, c; scanf("%d %d %d", &a, &b, &c);
        dist[a][b] = dist[b][a] = mp[{a, b}] = mp[{b, a}] = c;
    }
    
    Warshallfloyd();
    int ans = 0;
    for(auto m : mp) if(Solve(m.first.first, m.first.second, m.second)) ++ans;
    printf("%d\n", ans / 2);
    
    return 0;
}

Measured memory_bytes: 512
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def calc_cumsum(l):
    cumsum = [l[0]]
    for i in l[1:]:
        cumsum.append(cumsum[-1] + i)
    return cumsum


n = I()
s = S()
ruiseki_e = [0] * n
ruiseki_w = [0] * n
if s[0] == 'E':
    ruiseki_e[0] += 1
else:
    ruiseki_w[0] += 1
for i in range(1, n):
    if s[i] == 'E':
        ruiseki_e[i] = ruiseki_e[i - 1] + 1
        ruiseki_w[i] = ruiseki_w[i - 1]
    else:
        ruiseki_w[i] = ruiseki_w[i - 1] + 1
        ruiseki_e[i] = ruiseki_e[i - 1]
ans = ruiseki_e[-1] - ruiseki_e[1]  # 一番左端をリーダーにした時
for i in range(1, n):
    ans = min(ans,
              ruiseki_w[i - 1] + (ruiseki_e[-1] - ruiseki_e[i]))
print(ans)


Measured memory_bytes: 23436
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using int128 = __int128;
using cint = cpp_int;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define input(a) scanf("%lld", &(a))
#define output(a) printf("%lld\n", (a))
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

signed main() {
    ll N, T, C, D, A = INF;
    cin >> N >> T;
    rep(i, N) {
        cin >> C >> D;
        if (D <= T && C < A) A = C;
    }
    if (A == INF)
        cout << "TLE" << endl;
    else
        cout << A << endl;
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17


Measured memory_bytes: 256
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n = I()
p = LI()

ans = 1

m = p[0]
for i in range(1,n):
    if p[i]<=m:
        ans+=1
        m = p[i]

print(ans)

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

int main() {
    int x, tmp;
    cin >> x;
    tmp = 1;
    for (int i=1;i<=x;i++) {
        for (int j=2;pow(i, j) <= x && j <= x;j++) {
            tmp = max(tmp, (int)pow(i, j));
        }
    }
    cout << tmp << endl;
}


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

int main(){
  int n,now,next,ans=0;cin>>n;
  vector<int> x(n,0);
  REP(i,n) cin>>x.at(i);
  sort(x.begin(),x.end());
  now=x.at(0);
  REP(i,n-1){
    next=x.at(i+1);
    if(now==next) ans++;
    now=next;
  }

  cout<<n-2*((ans+1)/2)<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
bool f=0;
long long cal(long long x)
{
    long long y=abs(x),l=0,r=1000;
    while(l<r)
    {
        long long mid=(l+r)/2;
        long long p5=mid*mid*mid*mid*mid;
        if(p5>=y)r=mid;
        else l=mid+1;
    }
    if(l*l*l*l*l==y)
    {
        f=1;
        if(x<0)return -l;
        else return l;
    }
    return -1;
}
int main()
{
    long long x,a=1,b=-1;
    scanf("%lld",&x);
    while(1)
    {
        b=cal(a*a*a*a*a-x);
        if(f)break;
        else a++;
    }
    printf("%lld %lld\n",a,b);
    return 0;
}

Measured memory_bytes: 3828
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;  
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) 
{
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) 
{
	ll ans = 1;
	while (n) 
	{
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

void solve() 
{
	ll x,k,d; cin >> x >> k >> d;
	x = abs(x);
	ll steps = x/d;
	if (steps > k)
	{
		cout << x - d*k << endl;
		return;
	}
	k -= steps;
	x -= steps*d;
	if (k&1) cout << abs(x-d) << endl;
	else cout << x << endl;
}

int main() 
{
	fast_io();
	int t = 1;
	// cin >> t;
	while (t--) solve();
	return 0;
}

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

  char ch;
  int moji[30]={0};
  int i;
  char word = 97;



  while( scanf("%c", &ch) != EOF ){
    if(ch >= 'A' && ch <= 'Z'){
      moji[ch-'A'] += 1;
    }
    else if(ch >= 'a' && ch <= 'z'){
      moji[ch-'a'] += 1;
    }
  }


  for(i = 0;i < 26;i++){
    printf("%c : %d\n",word,moji[i]);
    word += 1;
  }

  return 0;
}

Measured memory_bytes: 540
neighbours = Array.new(100001).map { Array.new }
heights = [-1]
n, m = gets.split.map(&:to_i)

gets.split.map(&:to_i).each { |h| heights << h }
m.times do
  l, r = gets.split.map(&:to_i)
  neighbours[l] << heights[r]
  neighbours[r] << heights[l]
end

res = 0
# zp neighbours
1.upto(n) do |i|
  current = heights[i]
  if neighbours[i].empty?|| current > neighbours[i].max
    res += 1 
  end

end

puts res


Measured memory_bytes: 28384
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <limits.h>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    map<long, int> zatsu;
    vector<pair<long, long>> points;
    for (int i=0; i<n; i++) {
        long x, y;
        cin >> x >> y;
        zatsu[x] = zatsu[y] = 1;
        points.push_back({x, y});
    }
    int cnt = 0;
    vector<long> zinv(1, 0);
    for (auto &z:zatsu) {
        z.second = ++cnt;
        zinv.push_back(z.first);
    }
    int rui[105][105];
    fill(rui[0], rui[cnt+2], 0);
    for (auto &p:points)
        rui[zatsu[p.first]][zatsu[p.second]] = 1;
    
    for (int i=1; i<=cnt; i++)
        for (int j=1; j<=cnt; j++)
            rui[i][j] += rui[i-1][j] + rui[i][j-1] - rui[i-1][j-1];
    for (auto &r : rui) {
        for (auto &rij : r) cerr << rij << ' ';
        cerr << '\n';
    }
    long ans = LONG_MAX;
    for (int xi=1; xi<=cnt; xi++) {
        for (int yi=1; yi<=cnt; yi++) {
            for (int xj=xi; xj<=cnt; xj++) {
                for (int yj=yi; yj<=cnt; yj++) {
                    int inside = rui[xi-1][yi-1] + rui[xj][yj] - rui[xi-1][yj] - rui[xj][yi-1];
                    if (inside >= k)
                        ans = min(ans, (zinv[xj] - zinv[xi]) * (zinv[yj] - zinv[yi]));
                }
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>

using namespace std;

int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  
  string t;
  cin >> t;
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  if(t>s) cout << "Yes";
  else cout << "No";

return 0;
}

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

int main() {
  int N;
  cin >> N;
  int M = N;
  
  int sum = 0;
  
  while (M != 0) {
    sum += M % 10;
    M /= 10;
  }
  if (N % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;

constexpr int IMAX = ((1<<30)-1)*2+1 ;
constexpr int INF = 100000000;
double EPS = 1e-10 ;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,M = 0,N =0;
  char tmp;
  while(cin >> a >>tmp>> b>>tmp>> c){
    if(a == b){
      ++M;
    }
    else if(a*a+b*b==c*c){
      ++N;
    }
  }
  cout << N << endl << M << endl;
  return 0;
}

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

int main(void)
{
    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    vector<int> h_id, w_id;

    REP(i, h){
        bool flag = true;
        REP(j, w){
            char tmp;
            cin >> tmp;
            if(tmp == '#') {
                a[i][j]=1;
                flag = false;
            }
            else a[i][j]=0;
        }
        if(flag==true)h_id.pb(i);
    }

    REP(i, w){
        bool flag = true;
        REP(j, h){
            if(a[j][i]==1) flag = false;
        }
        if(flag==true)w_id.pb(i);
    }

    REP(i, h){
        if(FIND(h_id,i)) continue;
        REP(j, w){
            if(FIND(w_id,j)) continue;
            cout << (a[i][j]==1 ? '#' : '.');
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,a[5],max,min,sum[100],max_sum,min_sum,i;
  while (1){
    scanf("%d",&n);
    if(n==0)break;
    
    for(i=0;i<n;i++){
      scanf("%d %d %d %d %d",&a[1],&a[2],&a[3],&a[4],&a[0]);
      sum[i]=a[1]+a[2]+a[3]+a[4]+a[0];
    }
    
    max_sum=sum[0];
    min_sum=sum[0];
    
    for(i=0;i<n;i++){
      if(max_sum<sum[i])max_sum=sum[i];
      if(min_sum>sum[i])min_sum=sum[i];
    }
    printf("%d %d\n",max_sum,min_sum);
  }
  return 0;
}

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


int main () {
  int N , H , W ;
  cin >> N >> H >> W ;
  
  int ans = 0 ;
  
  for(int i = 0 ; i < N ; i++ ){
    int a , b ;
    cin >> a >> b ;
    if( a >= H && b >= W ) ans ++ ;
  }
  
  cout << ans << endl ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dout if(debug) cout
const int maxn = 1e5+1;
typedef long long ll;
using namespace std;
const ll MOD =1e9+7;
int a[1000];
ll dp[19][19];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    for(int msk=0; msk<(1<<n); ++msk){
        int R=0;//painted in red
        string red;
        int B=0;//painted in red
        string blue;
        for(int i=0; i<n; ++i){
            if (msk&(1<<i)){
                R++;
                red+=s[i];
            }
            else{
                B++;
                blue+=s[i];
            }
        }
        reverse(blue.begin(),blue.end());
        reverse(red.begin(),red.end());
        swap(blue,red);
       // cout<<msk<<" "<<red<<" "<<blue<<endl;

        for(int i=0; i<19; ++i)
            for(int j=0; j<19; ++j)
                dp[i][j]=0;
        dp[0][0]=1;
        for(int i=0; i<n; ++i){

            int ind=i+n;
            for(int rr=0; rr<=n-R && rr<=i; ++rr){
                int bb=i-rr;
                if (s[ind]==red[rr]){
                    dp[i+1][rr+1]+=dp[i][rr];
                }
                if (s[ind]==blue[bb]){
                    dp[i+1][rr]+=dp[i][rr];
                }
            }

        }
        ans+=dp[n][n-R];

    }
    cout<<ans;
//    int t;
//    cin>>t;
//    while(t--){
//        ll a,b,c,d;
//        cin>>a>>b>>c>>d;
//        if (a<b){
//            cout<<"No\n";
//            continue;
//        }
//        if (b>d){
//            cout<<"No\n";
//            continue;
//        }
//        if (c>=b){
//            cout<<"Yes\n";
//            continue;
//        }
//        ll k=(a-c)/b;
//        if ((a-c)%b==0)
//            --k;
//        k=max(k,0ll);
//        ll z=a-k*b;
//        if (z<b){
//            cout<<"No\n";
//            continue;
//        }
//        if (d%b==0){
//            cout<<"Yes\n";
//            continue;
//        }
//        ll i=(z-c)%b;
//        ll j=(d%b);
//
//    }
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nmk = readln.split.to!(int[]);
    auto N = nmk[0];
    auto M = nmk[1];
    auto K = nmk[2];

    foreach (y; 0..N+1) {
        auto b = 2*y - N;
        if (b == 0) {
            if (N*M == 2*K) {
                writeln("Yes");
                return;
            }
        } else {
            auto s = K + M*y - M*N;
            if (s % b != 0) continue;
            auto x = s / b;
            if (0 <= x && x <= M) {
                writeln("Yes");
                return;
            }
        }
    }
    writeln("No");
    return;
}

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

bool inc(char c){
    string acgt = "ACGT";
    for(int i = 0; i < 4; i++){
        if(c == acgt[i]) return true;
    }
    return false;
}

int main(){
    string S;
    cin >> S;
    int N = S.length();
    vector<int> lens;
    int tmp = 0;

    for(int i = 0; i < N; i++){
        if(inc(S[i])) tmp++;
        else{
            lens.push_back(tmp);
            tmp = 0;
        }
    }
    lens.push_back(tmp);

    int maxi = *max_element(lens.begin(), lens.end());

    cout << maxi << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n,m,b[101],c,a[101],i,j;
  while(1){
    scanf("%d%d",&n,&m);
     if(n==0&&m==0)break;
    for(i=0;i<100;i++){
      b[i]=0;
      a[i]=i+1;    
    
    } 
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	scanf("%d",&c);	
	if(c==1){
	  b[j]++;
	  c=0;
	}
      }
    }
    for(i=0;i<m;i++){
      for(j=m-1;j>i;j--){
	if(b[j-1]>b[j]){
	  c=b[j];
	  b[j]=b[j-1];
	  b[j-1]=c;
	  c=a[j];
	  a[j]=a[j-1];
	  a[j-1]=c;
	}
      }
    }
    for(i=0;i<m;i++){
      for(j=m-1;j>i;j--){
	if(b[j-1]==b[j]&&a[j]>a[j-1]){
	  c=a[j];
	  a[j]=a[j-1];
	  a[j-1]=c;
	}
      }
    }
    for(i=m-1;i>=0;i--){
      if(i==0)printf("%d",a[i]);
      else printf("%d ",a[i]);
    }
    printf("\n");
  }
  return 0;
}
 

Measured memory_bytes: 604
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int a=scan.nextInt();
    int b=scan.nextInt();
    if(a>b*2){
      System.out.println(a-b*2);
    }else{
      System.out.println(0);
    }
  }
}

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

using namespace std;

const int INF = 1e9;

int mx[1 << 26],dp[200005],cnt[26],i,j,n;
char s[200005];

int main(){
	scanf("%s", s);
	
	n = strlen(s);
	int cur = 0;
	
	for(i = 0; i < n; i++)
	dp[i] = INF;
	for(i = 1; i < (1 << 26); i++)
	mx[i] = INF;
	
	for(i = 0; i < n; i++){
		cnt[s[i] - 'a']++;
		if(cnt[s[i] - 'a'] & 1)
		cur += (1 << (s[i] - 'a'));
		else
		cur -= (1 << (s[i] - 'a'));
		
		int mask = cur ^ 0;
		
		dp[i] = min(dp[i], mx[mask] + 1);
		for(j = 0; j < 26; j++){
			mask = cur ^ (1 << j);
			dp[i] = min(dp[i], mx[mask] + 1);
		}
		
		mx[cur] = min(mx[cur], dp[i]);
	}
	
	printf("%d\n", dp[n - 1]);
}


Measured memory_bytes: 263424
#include "iostream"
#include "algorithm"
using namespace std;

int main()
{
  int n, d[110];
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> d[i];
  }
  sort(d, d + n);

  int ans = 1;
  for (int i = 1; i < n; i++)
  {
    if (d[i] != d[i - 1])
    {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

int main()
{
        string S;cin>>S;
        Int ans=0;
        for(auto x:S) ans+=(x=='o');
        cout<<700+ans*100<<"\n";
}

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

int n,m[51];
int x[51][10],y[51][10];

void slide(int id){
  for(int i=m[id]-1;i>=0;i--){
    x[id][i] -= x[id][0];
    y[id][i] -= y[id][0];
  }
}

void rot(int id){
  for(int i=0;i<m[id];i++){
    int tmp = x[id][i];
    x[id][i] = y[id][i];
    y[id][i] = -tmp;
  }
}

void rev(int id){
  reverse(x[id],x[id]+m[id]);
  reverse(y[id],y[id]+m[id]);
}

bool same(int id){
  for(int i=0;i<m[0];i++){
    if(x[id][i] != x[0][i] || y[id][i] != y[0][i])return false;
  }
  return true;
}

int main(){
  while(cin >> n,n){
    for(int i=0;i<=n;i++){
      cin >> m[i];
      for(int j=0;j<m[i];j++){
	cin >> x[i][j] >> y[i][j];
      }
    }

    slide(0);
    for(int i=1;i<=n;i++){
      bool f = false;
      if(m[i] != m[0])continue;
      for(int j=0;j<2;j++){
	slide(i);
	for(int k=0;k<4;k++){	  
	  if(same(i)){
	    f = true;
	    break;
	  }

	  rot(i);
	}
	if(f)break;
	rev(i);
      }
      if(f)cout << i << endl;
    }
    cout << "+++++" << endl;
  }
}

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

int PrimeNumber(int x);

int main() {
  int N,i,a=0;
  int X[10000];


  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    /* code */
    scanf("%d", &X[i]);
  }

  for ( i = 0; i < N; i++) {
    /* code */
    if(PrimeNumber(X[i])==1){
      a++;
    }
  }
  printf("%d\n", a);



  return 0;
}

int PrimeNumber(int x){
  int i=0;
  if(x == 2){
    return 1;
  }

  if(x<2 || x%2==0){
    return 0;
  }

  i=3;

  while (i<=sqrt(x)) {
    /* code */
    if(x%i == 0) return 0;
    i+=2;
  }
  return 1;
}



Measured memory_bytes: 2068
import itertools
import numpy as np

def main():
  n, k = [int(i) for i in input().split()]
  A = [None] + [int(i) for i in input().split()]

  slow = fast = 1

  for i in range(k):
    slow = A[slow]
    fast = A[A[fast]]
    if slow == fast:
      break
    if i == k-1:
      return slow

  slow = 1
  count = 0
  while slow != fast:
    slow = A[slow]
    fast = A[fast]
    count += 1

  branch = fast
  branch_num = count
  count = 1
  node = A[branch]
  while node != branch:
    node = A[node]
    count += 1
  
  idx = (k - branch_num) % count + branch_num
  ret = 1
  for _ in range(idx):
    ret = A[ret]
  return ret

print(main())
  

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

#define ll long long

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

  ll res = 0;
  res += (n / 500) * 1000;
  res += ((n % 500) / 5) * 5;

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 768