akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;

typedef pair<int, int> P;
const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int H, W, sx, sy, gx, gy;
    cin >> H >> W;
    char s[H][W];
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cin >> s[i][j];
            if(s[i][j] == 's'){
              sx = i, sy = j;
            }
            if(s[i][j] == 'g'){
              gx = i, gy = j;
            }
        }
    }

    bool ok = true;
    sx = 0, sy = 0;
    gx = H-1, gy = W-1;
    int dist[H][W];
    fill(dist[0], dist[H], INF);
    deque<P> que;
    if(s[0][0] == '#'){
      dist[sx][sy] = 1;
      sx -= 200, sy -= 200;
    }
    else dist[0][0] = 0;
    que.emplace_front(sx,sy);
    while(!que.empty()){
        P p = que.front();
        que.pop_front();
        int x = p.first;
        int y = p.second;

        if(x < 0){
          x += 200, y += 200;
          ok = false;
        }
        else ok = true;
        
        for(int i = 0; i < 2; ++i){
            int nx = x + dx[i], ny = y + dy[i];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W)  continue;
            if(s[nx][ny] == '#' && ok == false){
                  if(dist[nx][ny] > dist[x][y]){
                    dist[nx][ny] = dist[x][y];
                    que.emplace_front(nx-200,ny-200);
                  }
            }
            else if(s[nx][ny] == '#' && ok){
                  if(dist[nx][ny] > dist[x][y] + 1){
                    dist[nx][ny] = dist[x][y] + 1;
                    que.emplace_back(nx-200,ny-200);
                  }
            }
            if(s[nx][ny] == '.'){
              if(dist[nx][ny] > dist[x][y]){
                    dist[nx][ny] = dist[x][y];
                    que.emplace_front(nx,ny);
              }
            }
            if(s[nx][ny] == 's') continue;
            if(s[nx][ny] == 'g'){
              if(dist[nx][ny] > dist[x][y]){
                    dist[nx][ny] = dist[x][y];
              }
            }
            
        }
        
    }
    cout << dist[gx][gy] << endl;
}

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

int n,a[200010],ans=0;
bool f[2000010]={};



int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	int i,j;
	for(i=1;i<=n;++i)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(i=1;i<=n;++i){
		if(!f[a[i]]){
			++ans;
			for(j=1;j*a[i]<=a[n];++j)
				f[a[i]*j]=1;
			if(a[i]==a[i+1])
				--ans;
		}
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 5404
import sys
import heapq

input = sys.stdin.readline
N, M = map(int, input().split())

A = []
for x in input().split():
    heapq.heappush(A, int(x) * (-1))

for _ in range(M):
    max_n = heapq.heappop(A) * (-1)
    heapq.heappush(A, (max_n // 2) * (-1))
    
print(sum(A) * (-1))

Measured memory_bytes: 14168
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());
            if (X <= 599) Console.WriteLine(8);
            else if (X >= 600 && X <= 799) Console.WriteLine(7);
            else if (X >= 800 && X <= 999) Console.WriteLine(6);
            else if (X >= 1000 && X <= 1199) Console.WriteLine(5);
            else if (X >= 1200 && X <= 1399) Console.WriteLine(4);
            else if (X >= 1400 && X <= 1599) Console.WriteLine(3);
            else if (X >= 1600 && X <= 1799) Console.WriteLine(2);
            else if (X >= 1800) Console.WriteLine(1);
        }
    }
}


Measured memory_bytes: 27520
n, t = STDIN.gets.split(/\s+/).map { |s| s.to_i }

sum = 0
tis = STDIN.gets.split(/\s+/).map { |s| s.to_i }
last = tis.shift

tis.each { |ti|
  if last + t > ti
    sum += ti - last
  else
    sum += t
  end
  last = ti
}
sum += t
puts sum


Measured memory_bytes: 15996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int main() {
  int a,b;
  cin >> a >> b;
  if (a * b == 15) {
    cout << "*" << endl;
  } else if (a + b == 15) {
    cout << "+" << endl;
  } else {
    cout << "x" << endl;
  }
  return 0;
}


Measured memory_bytes: 3568
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*
n
a1... an

n 2*10^5
ai -10^9 10^9
 */

int n;
ll b[200001];

int main(){
  cin >> n;
  b[0] = 0;
  FOR_IN(i,1,n+1){
    cin >> b[i];
    b[i] += b[i-1];
  }
  
  sort(b,b+n+1);
  
  ll ans=0;
  ll pre = b[0];
  int cnt = 0;
  FOR_IN(i,1,n+1){
    if(pre==b[i])
      cnt++;
    else
      cnt = 0;

    ans+=cnt;
    pre = b[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <unordered_set>

using namespace std;

// https://qiita.com/EqualL2/items/b4683db7ab4e90545bb2
int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

template <typename T>
T tmpl_abs(T n) {
    return n < 0 ? -n : n;
}

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

    unordered_set<int> as;
    as.insert(s);

    int a_prev = s;
    for(int i = 2; ; i++) {
        int a_next = a_prev%2 == 0 ? a_prev/2 : 3*a_prev+1;
        if (as.find(a_next) != as.end()) {
            cout << i << endl;
            return 0;
        }
        as.insert(a_next);
        a_prev = a_next;
    }
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

#define MOD (long long int)(1e9+7)
#define ll long long
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()


int main(void) {
	ll H, W;
	cin >> H >> W;
	ll ans = 0;
	ll tmp1, tmp2;
	tmp1 = (W + 1) / 2;
	tmp2 = W / 2;
	ans = ((H + 1) / 2)*tmp1 + (H / 2)*tmp2;
	if (H == 1 || W == 1) cout << 1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int main(){
    int n,m,i,j,k,ans=0;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++){
      if(i%10>=2&&i/10>=2){
      	if((i%10)*(i/10)<=n)ans++;
      }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
// finish date: 2018/07/16
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


//足し算
int add(int a, int b) {
    return (int)(((ll)a + b) % bigmod);
}

//引き算
int sub(int a, int b) {
    return (int)(((ll)a - b) % bigmod);
}

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int makeSum(vi a) {
    int ans = 0;
    int n = a.size();
    rep(i, n) {
        ans = add(ans, mul(a[i], i + 1));
        ans = sub(ans, mul(a[i], n - i));
    }
    return ans;
}

int main() {
    int n, m;
    cin >> n >> m;
    vi x(n), y(m);
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];

    cout << mul(makeSum(x), makeSum(y)) << endl;

    return 0;
}



Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  ll n, k;
  cin >> n >> k;
  vector<int> S(n + 1, 0);
  S[0] = 0;
  rep(i, n) {
    int a;
    cin >> a;
    a--;
    S[i + 1] = (S[i] + a) % k;
  }

  map<int, int> M;
  ll ans = 0;
  rep(i, n + 1) {
    if (M.find(S[i]) == M.end()) M[S[i]] = 0;
    if (i >= k) M[S[i - k]]--;
    ans += M[S[i]];
    M[S[i]]++;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 10368
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        string inpt = Reader.ReadLine();
        int ans = inpt.LastIndexOf('Z') - inpt.IndexOf('A') + 1;
        Console.WriteLine(ans);
    }





    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"

1000

";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

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

using namespace std;

typedef long long int ll;

const ll MAXN = 1e5 + 5;

vector < vector < ll > > adj(MAXN, vector < ll > ());

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

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

  map < ll, ll > cnt;
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    ans += cnt[i - a[i]];
    cnt[a[i] + i]++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 29756
#include <bits/stdc++.h>
#define _boost ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fi first
#define se second
#define clz __builtin_clz
#define clzll __builtin_clzll
#define bp __builtin_popcount
#define _unique(x) sort((x).begin(),(x).end()),(x).erase(unique((x).begin(), (x).end()),(x.end()))
#define all(x) (x).begin(),(x).end()
#define _rand(i,j) uniform_int_distribution<int>(i, j)(rng___)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;
template < typename _T, typename _T2> string to_string(pair<_T,_T2> x) {return "<"+to_string(x.fi)+", "+to_string(x.se)+">";}
template < typename _T> string to_string(vector<_T> vec) {string s="[ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]=']';s[s.size()-2]=' '; return s;}
string to_string(string s) {return s;}
template < typename _T> string to_string(set<_T> vec) {string s="{ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T, typename _T2> string to_string(map<_T,_T2> vec) {string s="{ "; for(auto el:vec)s+="mp["+to_string(el.fi)+"]= "+to_string(el.se)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T > inline void _DBG(const char *s, _T x){cerr << s << " = " << to_string(x) << "\n";}
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a){while(*s != ',') cerr << *s++;cerr << " = " << to_string(x) << "\n";_DBG(s + 1, a...);}
#ifdef LOCAL
#define _print(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define _print(...) ;//cout<<2;//(__VA_ARGS__)
#endif
mt19937 rng___(chrono::steady_clock::now().time_since_epoch().count());


const LL MOD = 1e9+7;//998244353;
const LL LLINF = 1e18+7;
const int N=1e5+8;


int main()
{
    _boost;
    int n,k;
    cin>>n>>k;
    vector<LL> vec(n);
    for(int i=0;i<n;i++)cin>>vec[i];
    vector<vector<LL>> dp(n,vector<LL>(k+1,0));
    dp[0][0]=1;
    for(int i=1;i<=k;i++)
    {
        dp[0][i]=dp[0][i-1]+(i<=vec[0]);
    }
    for(int i=1;i<n;i++)
    {
        dp[i][0]=1;
        for(int j=1;j<=k;j++)
        {
            dp[i][j]=(dp[i][j-1]+MOD+dp[i-1][j]-(j-vec[i]-1<0?0:dp[i-1][j-vec[i]-1]))%MOD;
        }
    }
    //_print(dp);
    if(k==0)cout<<1;
    else
    {
        cout<<(dp[n-1][k]+MOD-dp[n-1][k-1])%MOD;
    }
}




Measured memory_bytes: 79488
#include<bits/stdc++.h>
#define For(i, j, k) for(int i = j; i <= k; ++i)
using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') p = -1; c = getchar(); }
	while(isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return x *= p;
}

inline void File() {
#ifndef ONLINE_JUDGE
	freopen("ARC059A.in", "r", stdin);
	freopen("ARC059A.out", "w", stdout);
#endif
}

const int N = 1e2 + 10, inf = 0x3f3f3f3f;
int A[N], n;

int main() {
	n = read();
	int ave = 0;
	For(i, 1, n) A[i] = read(), ave += A[i];
	ave /= n;
	
	int ans = inf;
	For(bas, ave - 2, ave + 2) {
		int res = 0;
		For(i, 1, n) res += (A[i] - bas) * (A[i] - bas);
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
import itertools

n = int(input())
x = []
for i in range(n):
  x.append(sorted(input()))
  
x_sort = sorted(x)
ans = 0

counter = Counter(map(tuple, x_sort))
for word, cnt in counter.most_common():
  ans += (cnt*(cnt-1))//2
  
print(ans)

Measured memory_bytes: 52288
A, B, C, D = [int(n) for n in input().split()]

def calc(N):
    return B//N - (A-1)//N

def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a*b//gcd(a, b)

print(B - A + 1 - calc(C) - calc(D) + calc(lcm(C, D)))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<string> a(n),b(m);
	rep(i,n){
		cin>>a[i];
	}
	rep(i,m){
		cin>>b[i];
	}
	rep(i,n-m+1)rep(j,n-m+1){
		bool flag=true;
		FOR(k,i,i+m)FOR(l,j,j+m){
			if(a[k][l]!=b[k-i][l-j]) flag=false;
		}
		if(flag){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(int(x) for x in input().split())

num = 0

for i in range(n - 2):
    if (p[i] < p[i+1] and p[i+1] < p[i+2]) or (p[i] > p[i+1] and p[i+1] > p[i+2]):
        num += 1

print(num)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
   int a,b,c,d,e,k;
  scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&k);
  if(e-a>k){
  printf(":(");
  }else{
    printf("Yay!");
  }
  return 0;
}

Measured memory_bytes: 128
//package com.company;
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        char[] days = br.readLine().toCharArray();
        int max = 0;
        int curr = 0;
        for (char c : days) {
            if (c == 'S') {
                max = Math.max(max, curr);
                curr = 0;
            } else if (c == 'R') {
                ++curr;
            }
        }
        max = Math.max(curr, max);
        pw.println(max);
        pw.close();
    }
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			long[] nk = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			long n = nk[0];
			long k = nk[1];
			long[] h = new long[(int)n];
			for (int i = 0; i < n; i++) {
				h[i] = long.Parse(Console.ReadLine());
			}

			Array.Sort(h);
			long ans = h[n - 1] - h[0];
			for (int i = 0; i <= n - k; i++) {
				long temp = h[i + k - 1] - h[i];
				ans = Math.Min(ans, temp);
			}

			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 18140
from collections import Counter
INF = 114514191981036436433-4
n = int(input())
s = input()

b = Counter(s)
ans = b["."]

cur = b["."]

for i in range(n):
    if s[i] == "#":
        cur += 1
    else:
        cur -= 1
        
    ans = min(ans,cur)
    
print(ans)

Measured memory_bytes: 40416
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	string s; cin >> s;
	int ans = 0, cur = 0;
	s += 'W';
	set<char> agct = {'A','G','C','T'};
	for(char c : s){
		if(agct.find(c) != agct.end()){
			++cur;
		} else{
			ans = max(ans,cur);
			cur = 0;
		}
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

char g[12] = {'a', 'c', 'a', 'b', 'a', 'b', 'a', 'a', 'b', 'a', 'b', 'a'};

int main(){
  int x, y;
  cin >> x >> y;
  if (g[--x] == g[--y]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
n, q = map(int, input().split())
A = [[] for i in range(n)]
for i in range(q):
    tmp = input().split()
    tmp[1] = int(tmp[1])
    if tmp[0] == "0":
        A[tmp[1]].append(tmp[2])
    elif tmp[0] == "1" and len(A[tmp[1]]) != 0:
        print(A[tmp[1]][-1])
    elif tmp[0] == "2" and len(A[tmp[1]]) != 0:
        A[tmp[1]].pop()


Measured memory_bytes: 19844
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/abc146/tasks/abc146_b

alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

n_txt = input()
n = int(n_txt)

s_txt = input()


for s_chr in s_txt:
    pos = alphabets.find(s_chr)
    print(alphabets[pos + n], end='')
print()


Measured memory_bytes: 4468
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int a, b, c;
  cin >> a >> b >> c;

  int ans = min(b / a, c);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline long long read(){
	long long x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(long long a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(long long a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const long long N=500005;
long long vis[N],n,m;
long long nextt[N],son[N],ed[N],flag,nedge,sum;
inline void dfs(long long p,long long color){
	if(vis[p]==-1)vis[p]=color; else if(vis[p]!=color){
		flag=1; return;
	}else return;
	for(long long i=son[p];i;i=nextt[i])dfs(ed[i],color^1);
}
inline void aedge(long long a,long long b){
	nextt[++nedge]=son[a]; son[a]=nedge; ed[nedge]=b;
}
int main(){memset(vis,-1,sizeof(vis));
    n=read(); m=read();
    for(long long i=1;i<=m;i++){
    	long long s1=read(),s2=read();
    	aedge(s1,s2); aedge(s2,s1);
	}
	dfs(1,0);
	if(flag){
		cout<<n*(n-1)/2-m<<endl;
	}else{
		for(long long i=1;i<=n;i++)sum+=vis[i];
		cout<<sum*(n-sum)-m<<endl;
	}
}

Measured memory_bytes: 15616
import math
import sys

N,K = list(map(int,input().split(" ")))
As = list(map(int,input().split(" ")))

dp = [False] * (K + 1)
for i in range(K + 1):
    for a in As:
        if i + a <= K:
            dp[i + a] |= (not dp[i])
        else:
            break
ans = "First" if dp[K] else "Second"
print(ans)



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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(c-a)<=d||(abs(b-a)<=d&&abs(b-c)<=d))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
# ai<=biなので基本的にbiが強い。最強のaiより弱いbiは使う必要がない
# 順番は関係ないので選びぬかれたbiを強いほうか使っていって、倒せなかったら最強のaiをHがなくなるまで使う
# これだとPypyでギリギリ間に合わん...

n, h = map(int, input().split())
a, b = 0, []
for _ in range(n):
    ai, bi = map(int, input().split())
    a = max(a, ai)
    b.append(bi)
b = list(sorted(b))

l, r = 0, n
while r-l > 0:
    mid = (l + r) // 2
    if b[mid] >= a:
        r = mid
    else:
        l = mid + 1
b = b[r:][::-1]
count = 0
for bi in b:
    h -= bi
    count += 1
    if h <= 0:
        break

if h > 0:
    count += h // a if h % a == 0 else h // a + 1

print(count)


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first



typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    char x,y;
    cin >>x>>y;

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(x > y)cout << ">" <<endl;
    else if(x == y)cout << "=" <<endl;
    else cout << "<" <<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 22 22:26:22 2020

@author: NEC-PCuser
"""
import math

N = int(input())

li = []
ans = 1
for i in range(N):
    t = int(input())
    ans = (ans * t) // math.gcd(ans, t)

print(ans)
    

Measured memory_bytes: 9072
h, w = map(int, input().split())
def choco(H, W):
    ans = float("inf")
    a, b, c = 0, 0, 0
    for i in range(1, H):
        a = i*W
        for j in range(2):
            if j == 0:
                b = (H-i)//2 * W
                c = H*W - a - b 
            else:
                b = (H-i)*(W//2)
                c = H*W - a - b
            ans = min(ans, max(a, b, c) - min(a, b, c))
    return ans

print(min(choco(h, w), choco(w, h)))

Measured memory_bytes: 3316
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
max_a = A[-1]

dp = [0] * (K+1)

for a in A:
    dp[a] = 1

for i in range(1, K + 1):
    bl = False
    for a in A:
        if i - a < 0:
            break
        if dp[i - a] == 0:
            bl = True
            break
    dp[i] = 1 if bl else 0


ans = "First" if dp[K] else "Second"
print(ans)


Measured memory_bytes: 42860
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  if (N == 1){
    cout << "Hello World" << endl;
  }
  else{
    int a, b; cin >> a >> b;
    cout << a + b << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	ll c[n];
	zep(i, 0, n){
		cin >> c[i];
	}
	sort(c, c+n);
	
	ll fac = 1;
	zep(i, 0, n){
		fac *= 2;
		fac %= MOD;
	}

	ll ans = 0;
	zep(i, 0, n){
		ans += c[i]*((fac*modinv(2, MOD)%MOD)+(((n-1-i)*fac%MOD)*modinv(4, MOD)%MOD))%MOD;
		ans %= MOD;
	}
	print(ans*fac%MOD)
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    char a,b,c,d;
    cin >>S;
    a = S.at(0);
    b = S.at(1);
    c = S.at(2);
    d = S.at(3);
    if((a==b)||(b==c)||(c==d)){
        cout << "Bad"<<endl;
    }
    else{
        cout <<"Good"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define rep1(i,n) for (int i=1; i<=(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fst first
#define scd second
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s; cin >> s;
  int n = s.size(), ans = 0;
  stack<char> S;
  rep(i,n) {
    if (S.empty() || S.top() == s[i]) S.push(s[i]);
    else {
      ans += 2;
      S.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3812
#include<iostream>
#include<cstdio>
const int N=2e5+5;
char s[N];
typedef long long ll;
const ll mod=1e9+7;
int d[N];
int main() {
    int n;
    scanf("%d",&n);
    scanf("%s",s+1);
    if(s[1]=='W') return !printf("0");
    d[1]=0;
    for(int i=2;i<=n+n;i++) {
        if(s[i]==s[i-1]) d[i]=d[i-1]^1;
        else d[i]=d[i-1];
    }
    int num[2]={0,0};
    for(int i=1;i<=n+n;i++) num[d[i]]++;
    if(num[0]!=n) return !printf("0");
    ll ans=1;
    int cnt=0;
    for(int i=1;i<=n+n;i++) {
        if(d[i]) ans=ans*cnt%mod,cnt--;
        else cnt++;
        if(cnt<0) return !printf("0");
    }
    for(int i=1;i<=n;i++) ans=ans*i%mod;
    printf("%lld\n",ans);
    return 0;
}


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

static long long int MOD = 1000000007;

int main(){
  string s;
  int s_num;
  int n;
  vector<vector<long long int>> dp;
  dp.assign(100005, vector<long long int>(13, 0));
  cin >> s;
  n = s.size();
  dp[0][0] = 1;
  for(int i=0; i<n; i++){
      if(s.at(i)=='?'){
          s_num = -1;
      }else{
          s_num = s.at(i) - '0';
      }
      for(int j=0; j<10; j++){
          if(s_num != -1 && s_num !=j)continue;
          for(int k=0; k<13; k++){
              dp[i+1][((k*10)+j)%13] += dp[i][k]; 
          }
      }
      for (int k=0; k<13; k++) dp[i+1][k] %= MOD;
  }

  cout << dp[n][5] << endl;
}

Measured memory_bytes: 13696
import fractions


def factorize(n):
    l = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            l.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        l.append((n, 1))
    return l


# input
a = int(input())
# calc
for i in range(a, 1, -1):
    out = factorize(i)
    t = []
    for j in out:
        t.append(j[1])
    fn = t[0]
    for k in range(1, len(t)):
        fn = fractions.gcd(fn, t[k])
    if fn > 1:
        print(i)
        exit()
print(1)


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N;
    cin >> N;
    vector<string> vS(N);

    for(int i = 0; i < N; i++) cin >> vS[i];

    for(int i = 0; i < N; i++){
        sort(vS[i].begin(), vS[i].end());
    }

    sort(vS.begin(), vS.end());

    ll ans = 0;
    ll cnt = 1;
    for(int i = 1; i < N; i++){
        if(vS[i] == vS[i-1]){
            cnt += 1;
        }else{
            if(cnt > 1){
                ans += cnt * (cnt -1) / 2;
                cnt = 1;
            }
        }
    }
    if(cnt > 1){
        ans += cnt * (cnt - 1) / 2;
    }
    
    cout << ans << endl;


    return 0;
}



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

#define INX(x) (cin >> x)
#define INXV(vec, cnt) for(ll i; i < cnt; i++) INX(vec[i])
#define OUTX(x) (cout << x << endl)
#define OUTXV(vec) for(ll i; i < (ll)vec.size(); i++) OUTX(vec[i])

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll X, N;
    cin >> X >> N;

    vector<bool> pbl(102, false);
    for (ll i = 0; i < N; i++)
    {
        ll tmp;
        INX(tmp);
        
        pbl[tmp] = true;
    }

    for (ll i = 0; i <= 101; i++)
    {
        if(X - i >= 0 && !pbl[X - i])
        {
            OUTX(X - i);
            break;
        }
        if(X + i <= 101 && !pbl[X + i])
        {
            OUTX(X + i);
            break;
        }
    }
    
        
    return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string t = "NWSE";
	vi cnt(4, 0);
	REP(i, s.size()) {
		REP(j, t.size()) {
			if (s[i] == t[j])cnt[j]++;
		}
	}
	REP(j, 4)if (cnt[j] > 0)cnt[j] = 1;
	int f = 1;
	REP(i, 2)if (cnt[i] ^ cnt[i + 2] != 0)f = 0;
	if (f)cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))

adj = [list() for _ in range(N)] # 頂点の個数
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    adj[A].append(B)
    adj[B].append(A)


def is_higher(i):
    for j in adj[i]:
        if H[i] <= H[j]:
            return False
    return True

cnt = 0
for i in range(N):
    if is_higher(i):
        cnt += 1
print(cnt)



Measured memory_bytes: 93064
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
string s;
int k;
int main(){
    scanf("%d",&k);
    cin>>s;
    if(s.size()<=k) cout<<s;
    else {for(int i=0;i<k;++i) cout<<s[i];printf("...");}
    return 0;
}

Measured memory_bytes: 3868
h, w = map(int, input().split())

a = []

for i in range(h):
    a.append(list(map(int, input().split())))

d = 1
x = 0

moving = 0

ans = []

st = []

prev_y = 0
prev_x = 0

for y in range(h):
    while 0 <= x < w:
        if moving == 0 and a[y][x] % 2 != 0:
            moving = 1
        elif moving == 1 and a[y][x] % 2 != 0:
            st.append(' '.join(list(map(str, [prev_y+1, prev_x+1, y+1, x+1]))))
            moving = 0
            ans += st
            st = []
        elif moving == 1 and a[y][x] % 2 == 0:
            st.append(' '.join(list(map(str, [prev_y+1, prev_x+1, y+1, x+1]))))
        prev_y = y
        prev_x = x

        x += d

    d *= (-1)
    x += d

print(len(ans))

for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 16468
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(if (a * b % 2 == 0) "Even" else "Odd")
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34320
use proconio::{fastout, input};

use std::cmp::{max, min};

#[fastout]
fn main() {
    input! {
        n: usize, k: usize,
        a: [usize; n],
    }
    let mut a = a;
    for _ in 0..k {
        let mut s = vec![0isize; n + 1];
        for i in 0..n {
            s[max(a[i], i) - a[i]] += 1;
            s[min(n, i + a[i] + 1)] -= 1;
        }
        let mut b = vec![0; n];
        let mut t = 0;
        let mut m = n;
        for i in 0..n {
            t += s[i];
            b[i] = t as usize;
            m = min(m, t as usize);
        }
        a = b;
        if m == n {
            break;
        }
    }
    for i in 0..n {
        print!("{} ", a[i]);
    }
    println!();
}


Measured memory_bytes: 7880
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

//#define int ll


const int N = 5e3 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string s;
main() {
    file("threesum");
    ios;
    int n;
    cin >> n;
    map <int, bool> was;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (was[x]) return !(cout << "NO");
        was[x] = 1;
    }
    cout << "YES";
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**

*/


Measured memory_bytes: 9600
/*
Loading:{
        https://codeforces.com/problemset/problem/1234/F
}
*/
#include <bits/stdc++.h>

using namespace std;

#define ll int // optimize with int
#define endl '\n'
const int N = 1e6 + 5;
ll a[305];
ll dp[305][305][305]; // id, used to donate, used to receive;
ll mod = 998244353; // fucking mod 1e9 + 7
ll n, k, cnt = 0;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        if (fopen("GUARDS.INP", "r")){
                freopen("GUARDS.INP", "r", stdin);
                freopen("GUARDS.OUT", "w", stdout);
        }
        string s;
        cin >> s;
        n = s.length();
        cin >> k;
        ll cur = 0;
        ll cnt1 = 0;
        for (int i = s.length() - 1; i >= 0; i--){
                if (s[i] == '1') {
                        cur++;
                        cnt1++;
                }
                else {
                        cnt++;
                        a[cnt] = cur;
                        cur = 0;
                }
        }
        cnt++;
        a[cnt] = cur;
        //memset(dp, -1, sizeof(dp));
        k = min(k, cnt1);
        for (int i = a[1]; i >= max(0, a[1] - k); i--){
                dp[1][a[1] - i][0] = 1;
        }
        ll sum = a[1];
        for (int i = 1; i < cnt; i++){
                for (int j = 0; j <= sum; j++){
                        for (int t = 0; t <= j; t++){
                                dp[i + 1][j][t] = (dp[i + 1][j][t] + dp[i][j][t]) % mod;
                                for (int x = a[i + 1] - 1; x >= max(0, (a[i + 1] - (k - j))); x--){
                                        dp[i + 1][j + a[i + 1] - x][t] = (dp[i + 1][j + a[i + 1] - x][t] + dp[i][j][t]) % mod;
                                }
                                for (int x = a[i + 1] + 1; x <= a[i + 1] + (j - t); x++){
                                        dp[i + 1][j][t + x - a[i + 1]] = (dp[i + 1][j][t + x - a[i + 1]] + dp[i][j][t]) % mod;
                                }
                        }
                }
                sum += a[i + 1];
        }
        ll ans = 0;
        for (int i = 0; i <= k; i++) {
                ans = (ans + dp[cnt][i][i]) % mod;
                //cout << dp[cnt][i][i] << " ";
        }
        cout << ans;
}


Measured memory_bytes: 30588
using namespace std;

#define visual

#ifdef visual
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>
#endif
#ifndef visual
#include <bits/stdc++.h>
#endif

typedef long long ll;


int SZ = 0; //the number of sccs
vector<int> ID; //id[v] is the scc id of v
int LS = 0;
vector<int> L;
vector<vector<int>> R, g;

void dfs1(int v) {
	if (ID[v]) return;
	ID[v] = 1;
	for (auto u : g[v])
		dfs1(u);
	L[LS++] = v;
}

void dfs2(int v, int r) {
	if (~ID[v]) return;
	ID[v] = r;
	for (int u : R[v])
		dfs2(u, r);
}

//First: list of vertices in each components, in topological order.
//second: graph shrinking each SCC to a vertex, should be a DAG in topological order.
pair<vector< vector<int> >, vector<vector<int> > > scc() {
	int n = g.size();
	R.resize(n), ID.resize(n), L.resize(n);
	for (int i = 0; i < n; i++) {
		for (auto u : g[i]) {
			R[u].push_back(i);
		}
	}
	for (int v = 0; v < n; ++v)
		dfs1(v);
	fill(ID.begin(), ID.end(), -1);
	int mx = 0;
	for (int i = n - 1; i >= 0; --i) {

		if (ID[L[i]] == -1)
			dfs2(L[i], SZ++);
	}
	for (int i = 0; i < n; i++) {
		mx = max(mx, ID[i]);
	}
	vector<vector<int>> A(mx+1);
	vector<vector<int>> B(mx+1);
	for (int u = 0; u < n; ++u) {
		A[ID[u]].push_back(u);
		for (int v : g[u])
			if (ID[u] != ID[v])
				B[ID[u]].push_back(ID[v]);
	}
	for (int i = 0; i < SZ; ++i) {
		sort(B[i].begin(), B[i].end());
		B[i].erase(unique(B[i].begin(), B[i].end()), B[i].end());
	}
	return { A, B };
}


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

	int n, m;
	cin >> n >> m;
	g = vector<vector<int> >(n);
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
	}
	auto ans = scc().first;
  cout << ans.size() << endl;
	for (auto v : ans) {
		cout << v.size() << " ";
		for (int i = 0; i < v.size(); i++) {
			cout << v[i] << " ";
		}
		cout << endl;


	}


}


Measured memory_bytes: 148260
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "YES";
const string NO = "NO";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long a, long long v, long long b, long long w, long long t){
    if(v <= w){
        cout << NO << endl;
        return;
    }
    else{
        i64 diff = (v - w) * t;
        assert(v - w > 0);
        cout << (abs(a - b) <= diff ? YES : NO) << endl;
    }
}


signed main(){
    long long A;
    scanf("%lld",&A);
    long long V;
    scanf("%lld",&V);
    long long B;
    scanf("%lld",&B);
    long long W;
    scanf("%lld",&W);
    long long T;
    scanf("%lld",&T);
    solve(A, V, B, W, T);
    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<int> ans;
  for (int i = 11; i <= 55555; i++) {
    bool f = true;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        f = false;
        break;
      }
    }
    if (f && (i % 5) == 1) {
      ans.push_back(i);
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i];
    if (i != n - 1) cout << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int result = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '+') {
                result++;
            } else {
                result--;
            }
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 23764
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long ll;
static const long double pi = 3.141592653589793238;
int main() {
    int  a,b,h,m;
    cin >> a >> b >> h >> m;
    int minute = h * 60 + m;
    //長針何度動いたか
    long double lon = double(minute)/2;
    long double sho = double(((minute)*6)%360);
    long double dif = sho - lon;
    long double ans = sqrt(a * a + b * b - 2 * a * b * cos(pi/180*dif));
    cout << setprecision(11) << ans << endl;
    return 0;
}

Measured memory_bytes: 4168
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int ans = 0;
  for (int i = 1; i <= n / 100; ++i) {
    int a = n - i * 100;
    if (a <= 5 * i) {
      ans = 1;
      break;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    sc.close();
    
    if (s.equals("ABC")) {
    	System.out.println("ARC");
    } else {
    	System.out.println("ABC");
    }
    
  }
}

Measured memory_bytes: 35676