akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll h,w,d;
 cin>>h>>w>>d;

 vector<vector<ll> > t(h+2,vector<ll>(w+2,0) );
 vector<vector<ll> > y = t;
 vector<vector<bool> > tizu(h+2,vector<bool>(w+2,false) );

 for(ll i=1;i<=h;i++){
  for(ll j=1;j<=w;j++){
   char tmp;
   cin>>tmp;
   if( tmp == '.') tizu[i][j] = true;
  }
 }
 for(ll i=1;i<=h;i++){
  ll cnt = 0;
  for(ll j=0;j<=w;j++){
   if( tizu[i][j] ){
    cnt++;
    y[i][j] = cnt;
   }else{
    cnt = 0;
   }
  }
 }

 for(ll i=1;i<=w;i++){
  ll cnt = 0;
  for(ll j=0;j<=h;j++){
   if( tizu[j][i] ){
    cnt++;
    t[j][i] = cnt;
   }else{
    cnt = 0;
   }
  }
 }

 ll res = 0;
 for(ll i=1;i<=h;i++){
  for(ll j=1;j<=w;j++){
   if( y[i][j] >= d ) res++;
   if( t[i][j] >= d ) res++;
  }
 }
 cout<<res<<endl;

    return 0;
}



Measured memory_bytes: 3284
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define ll long long
using namespace std;
const int N=205,mo=998244353;
int n,b[N][N];
int ans,c[N];
int h[N],d[N];
int ksm(int x,int y){
	int t=1;
	for(;y;y>>=1,x=(ll)x*x%mo)if(y&1)t=(ll)t*x%mo;
	return t;
}
bool pd(int x){
	fo(i,1,n)if(b[x][i]){
		if(c[i]){
			if(c[i]+c[x]!=3)return 0;
		}else{
			c[i]=3-c[x];
			if(!pd(i))return 0;
		}
	}
	return 1;
}
int main(){
//	freopen("a.out","w",stdout);
	cin>>n;
	fo(i,1,n){
		scanf("\n");
		fo(j,1,n)b[i][j]=getchar()-'0';
	}
	if(c[1]=1,!pd(1)){
		cout<<-1;return 0;
	}
	fo(i,1,n){
		int l=0,r=1;
		fo(j,1,n)h[j]=0;
		d[1]=i;h[i]=1;
		for(int x;x=d[++l],l<=r;)	
			fo(j,1,n)if(b[x][j]&&!h[j])
				d[++r]=j,h[j]=h[x]+1;
		ans=max(ans,h[d[n]]);
	}
	cout<<ans;
}

Measured memory_bytes: 384
s = int(input())
f = set()
f_now = s
i = 1
while True:
    f.add(f_now)
    
    if f_now%2==0:
        f_next = int(f_now/2)
    else:
        f_next = int(f_now*3 + 1)
    
    
    f_and = f&{f_next} 
    if len(f_and)==0:
        f_now = f_next
        i+=1
    else:
        break

print(i+1)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int fib(int n);

int memo[45];

int main(){
  int n;

  cin >> n;
  cout << fib(n) << endl;
}

int fib(int n){
  if(n == 0){
    return 1;
  }else if(n == 1){
    return 1;
  }else if(memo[n] != 0){
    return memo[n];
  }else{
    return memo[n] = fib(n-1) + fib(n-2);
  }
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  vector<int> primes(n+1,0);
  int i,j,k;
  for(i=2;i<=n;i++)
  {
    int left=i;
    for(j=2;j*j<=i;j++)
    {
      while(left%j==0)
      {
        primes[j]++;
        left/=j;
      }
    }
    if(left!=1)primes[left]++;
  }
  int ans=0;
  for(i=2;i<=n;i++)if(primes[i]>=74)ans++;
  for(i=2;i<=n;i++)
  {
    for(j=2;j<=n;j++)
    {
      if(i==j)continue;
      if(primes[i]>=2&&primes[j]>=24)ans++;
      if(primes[i]>=4&&primes[j]>=14)ans++;
    }
  }
  for(i=2;i<=n;i++)
  {
    for(j=2;j<=n;j++)
    {
      for(k=j+1;k<=n;k++)
      {
        if(i==j||i==k||j==k)continue;
        if(primes[i]>=2&&primes[j]>=4&&primes[k]>=4)ans++;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

const ll mod = 1007;

int main(){
    ll n; cin >> n;
    vector<string> s(n); rep(i,n) cin >> s[i];
    sort(all(s),[&](string a, string b){ return a.size() > b.size(); } );
  
    vector<vector<ll>> sub(n,vector<ll>(26,0));
    vector<ll> abc(26,0);
    rep(i,n){
        rep(j,s[i].size()) sub[i][s[i][j]-'a']++;
        rep(j,26) if(sub[i][j]) abc[j]++;
    }

    ll ans = 0, num = 1, save = n;
    vector<ll> hash(n,0);
    unordered_map<ll,ll> mp;
    rep(i,26) mp[i] = abc[i];

    while(save > 1){
        unordered_map<ll,ll> nmp;
        rrep(i,save){
            if(s[i].size() == num){
                char c = s[i][0];
                ans += mp[hash[i]*26+(c-'a')]-1;
                n--;
            }
            else{
                char c = s[i][s[i].size()-num];
                hash[i] *= mod;
                hash[i] += c-'a';
                sub[i][c-'a']--;
                rep(j,26) if(sub[i][j]) nmp[hash[i]*26+j]++;
            }
        }
        mp = nmp;
        save = n;
        num++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80148
S = input()
Q = int(input())
lst_query = [input().split() for i in range(Q)]

def make_reverse(S):

    if len(S) == 1:
        return S

    reversedS = ""
    for i in range(len(S)-1, -1, -1):
        reversedS += S[i]
    else: return reversedS

def main(S, Q, lst_query):

    cnt_reverse = 0
    leftS  = ""
    rightS = ""

    for i in range(Q-1, -1, -1):
        
        query = lst_query[i]

        if int(query[0]) == 1:
            cnt_reverse += 1
        else:
            if cnt_reverse % 2 == 0:
                if int(query[1]) == 1: leftS  = leftS + query[2]
                else                 : rightS = query[2] + rightS
            else:
                if int(query[1]) == 1: rightS = query[2] + rightS
                else                 : leftS  = leftS + query[2]

    if cnt_reverse % 2 == 1: S = make_reverse(S)
    return leftS + S + rightS


if __name__ == "__main__":

    answer = main(S, Q, lst_query)
    print(answer)
    

Measured memory_bytes: 40300
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;
const long long LM = 1LL << 60;

int dd[] = { 0, 1, 0, -1 };

inline bool inside(int i, int j, int h, int w) {
    return 0 <= i && i < h && 0 <= j && j < w;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int h, w, k, sx, sy, gx, gy;
    cin >> h >> w >> k >> sx >> sy >> gx >> gy;
    --sx;
    --sy;
    --gx;
    --gy;
    vector<string> s(h);
    vector<vector<vector<long long>>> dist(h, vector<vector<long long>>(w, vector<long long>(4, LM)));
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
    dist[sx][sy][0] = 0;
    q.push({ 0LL, (sx * w + sy) * 4 });
    while (!q.empty()) {
        pair<long long, int> p = q.top();
        q.pop();
        int i = p.second / 4 / w;
        int j = p.second / 4 % w;
        int d = p.second % 4;
        if (dist[i][j][d] < p.first) continue;
        if (i == gx && j == gy) {
            cout << (p.first + k - 1) / k << '\n';
            return 0;
        }
        int ti = i + dd[d], tj = j + dd[d ^ 1];
        if (inside(ti, tj, h, w) && s[ti][tj] != '@' && dist[ti][tj][d] > p.first + 1) {
            dist[ti][tj][d] = p.first + 1;
            q.push({ dist[ti][tj][d], (ti * w + tj) * 4 + d });
        }
        long long ndis = (p.first + k - 1) / k * k;
        int nd = (d + 1) % 4;
        if (dist[i][j][nd] > ndis) {
            dist[i][j][nd] = ndis;
            q.push({ dist[i][j][nd], (i * w + j) * 4 + nd });
        }
    }
    cout << -1 << '\n';
    return 0;
}


Measured memory_bytes: 143908
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		Stack s = new Stack();

		for(int i = 0; i < input.length; i++){

			int x = 0;
			int y = 0;

			switch(input[i]){

				case "+":
					y = s.pop();
					x = s.pop();
					s.push(x + y);
					break;
				case "-":
					y = s.pop();
					x = s.pop();
					s.push(x - y);
					break;
				case "*":
					y = s.pop();
					x = s.pop();
					s.push(x * y);
					break;
				default:
					s.push(Integer.parseInt(input[i]));

			}

		}

		System.out.println(s.pop());

	}

}

class Stack{

	public static int size = 0;
	private int[] array;

	public Stack(){

		array = new int[100];

	}

	public void push(int n){

		array[size] = n;
		size++;

	}

	public int pop(){

		size--;

		return array[size];

	}

}

Measured memory_bytes: 24316
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <unordered_map>
#include <map>
#include <bitset>
#include <string>
#include <cstring>

#define pb push_back
#define mp make_pair
#define l(x) x << 1
#define r(x) x << 1 | 1
#define scan(x) do {while((x=getchar())<'0') ; for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0') ; } while(0)
char _;
#define x first
#define y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<float, float> pff;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;

const int MOD = 1e9 + 7;

// last == 1 => |, last == 2 => =
int N, last = 0;
string s[2];
ll ans = 1;

int main() {
    cin >> N;
    cin >> s[0] >> s[1];
    for (int i = 0; i < N; i++) {
        if (s[0][i] == s[1][i]) {
            // |
            if (last == 0) {
                ans = ans * 3 % MOD;
            } else if (last == 1) {
                ans = ans * 2 % MOD;
            } 
            last = 1;
        } else {
            // =
            if (last == 0) {
                ans = ans * 6 % MOD;
            } else if (last == 1) {
                ans = ans * 2 % MOD; 
            } else {
                ans = ans * 3 % MOD;
            }
            last = 2;
            i += 1;
        }
    }    
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int a, b;

    cin >> a >> b;

    string answer = "";

    if(b<=a){
        char num = '0' + b;
        for(int i=0; i<a; i++){
            answer+=num;
        }
    }else{
        char num = '0' + a;
        for(int i=0; i<b; i++){
            answer+=num;
        }
    }

    cout << answer<< endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),n.end()
#define PI acos(-1)
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int e=0;
    int co=0;
    vector<int>in;
    rep(i,n){
      int tmp;
      cin>>tmp;
      if(tmp)co++;
      if(e<tmp)e=tmp;
      pb(in,tmp);
    }
    if(1<e)cout<<co+1<<endl;
    else cout<<"NA"<<endl;
  }

}

Measured memory_bytes: 1320
#include<stdio.h>
#include<stdlib.h>
int cmpfunc (const void * a, const void * b)
{
    return ( ((int*)a)[1] - ((int*)b)[1] );
}
int main(void){
    
    int i,ans=0,h=0,k=-1;
    
    int a[5][2];
    
    for(i=0;i<5;i++){
        scanf("%d",&a[i][0]);
        a[i][1] = a[i][0]%10;
    }
    
    qsort(a,5,sizeof(int)*2,cmpfunc);
    
    for(h=0;h<5;h++){
        if(a[h][1]==0){
            ans = ans+a[h][0];
            //printf("%d\n",a[h][0]);
            k=h;
        }
    }
    if(k==-1){
        for(h=4;h>=0;h--){
            ans = ans+a[h][0];
            //printf("%d\t",a[h][0]);
            if(h!=0){
                
                ans = ((ans/10)+1)*10;
                //printf("%d\n",ans);
                
            }
        }
    }else{
        for(h=4;h>k;h--){
            ans = ans+a[h][0];
            //printf("%d\n",a[h][0]);
            if(h-k!=1)
                ans = ((ans/10)+1)*10;
        }
    }
    
    
    printf("%d",ans);
    
    //system("pause");
    return 0;
    
}


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

using namespace std;

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

    string s;
    cin >> s;

    int Rcounter = 0;

    for(int i = 0; i < N; i++) {
        if(s[i] == 'R') Rcounter++;
    }
    
    if(Rcounter > N - Rcounter) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;

vector<int> z_algorithm(const string& s){
    int n = s.size();
    vector<int> z(n, 0);
    int c = 0;
    for(int i = 1; i < n; i++){
        if(i + z[i - c] < c + z[c]){
            z[i] = z[i - c];
        }else{
            int j = max(0, c + z[c] - i);
            while(i + j < n && s[j] == s[i + j]) j++;
            z[i] = j;
            c = i;
        }
    }
    z[0] = n;
    return z;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    string w = t + '$' + s + s;
    vector<int> z = z_algorithm(w);
    rep(i, t.size() + 1, w.size()){
        if(z[i] == t.size()){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define COUT(x) cout << (x) << endl
#define VIEW(x) do{cout << "--" << #x << "--" << endl; view(x);}while(0)
template<typename T> void view(T e){COUT(e);}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define _GLIBCXX_DEBUG

int main(){
  
  int h, w;
  cin >> h >> w;

  vector<vector<char>> field(h, vector<char>(w));
  int y = 0, x = 0;
  vector<vector<int>> dist(h, vector<int>(w, -1));
  queue<pair<int, int>> q;
  dist[y][x] = 0;
  q.push(make_pair(y, x));
  int blocks = 0;

  rep(i, h){
    rep(j, w){
      cin >> field[i][j];
      if (field[i][j] == '#') blocks++;
    }
  }

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

  int res = -1;
  while (!q.empty()){
    auto p = q.front();
    q.pop();
    y = p.first;
    x = p.second;
    bool f = false;
    rep(t, 4){
      int yy = y+dy[t];
      int xx = x+dx[t];
      if (yy < 0 || yy >= h || xx < 0 || xx >= w) continue;
      if (dist[yy][xx] == -1 && field[yy][xx] != '#'){
        q.push(make_pair(yy, xx));
        dist[yy][xx] = dist[y][x] + 1;
        if (yy == h-1 && xx == w-1){
          res = dist[yy][xx];
          f = true;
          break;
        }
      }
    }
    if (f) break;
  }

  if (res == -1){
    cout << -1 << endl;
    return 0;
  }
  else {
    cout << h * w - (res+1) - blocks;
  }


}

Measured memory_bytes: 256
n=int(input())  #数値入力 「N」だけの入力のとき
h=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

for i in range(n-1):
    if h[i]>h[i+1]:
        h[i+1] += 1
ans = "Yes"
for i in range(n-1):
    if h[i]>h[i+1]:
        ans = "No"
print(ans)

Measured memory_bytes: 14396
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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;
}

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

const int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int n) : par(n , -1), rank(n, 1) { }
    void init(int n) { par.assign(n, -1), rank.assign(n, 1); }

    int find(int x) {
        if (par[x] == -1) return x;
        else return par[x] = find(par[x]);
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }

    bool merge(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        rank[x] += rank[y];
        par[y] = x;
        return true;
    }

    vector<int> roots(){
        vector<int> d;
        rep(i,par.size()){
            if(par[i]<0) d.emplace_back(i);
        }
        return d;
    }

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

    int count_group(){
        return roots().size();
    }
};

int main(){
    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<pair<int,int>> ed(m);
    rep(i,m){
        cin >> ed[i].first >> ed[i].second;
        ed[i].first--;
        ed[i].second--;
    }
    int ans = 0;
    rep(i,m){
        UnionFind uf(n);
        rep(j,m){
            if(i==j) continue;
            uf.merge(ed[j].first,ed[j].second);
        }
        if(!uf.is_same(ed[i].first,ed[i].second)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = 1000000

# エラトステネスの篩
# 指定された整数以下の全ての素数を発見するための単純なアルゴリズム
ns = (n**0.5).to_i + 1
is_prime = [false, false] + [true]*(n-1)
2.upto(ns) do |i|
  next if !is_prime[i]
  (i*i).step(n, i) do |j|
    is_prime[j] = false
  end
end

count = 0
list = (0..n).map do |i|
  count += 1 if is_prime[i]
  count
end

while gets
  puts list[$_.to_i]
end

Measured memory_bytes: 29732
S=input()
N=len(S)
zen=(N-1)//2
kou=(N+3)//2
T=S[::-1]

T2=S[:zen]
T2=T2[::-1]

T3=S[kou-1:]
T3=T3[::-1]

#print(T,T2,T3)
#print(S,S[:zen],S[kou-1:])
if T==S:
    if S[:zen]==T2:
        if S[kou-1:]==T3:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    seika s;
    cin >> s;
    int n = s.size() + 1;
    akari<i64> xs(n, -1);
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] == '<')
        {
            i64 cur = 0;
            while (i < n - 1 && s[i] == '<')
            {
                xs[i] = cur;
                i++, cur++;
            }
            xs[i] = cur;
        }
    }
    for (int i = n - 2; i >= 0; i--)
    {
        if (s[i] == '>')
        {
            i64 cur = 1;
            xs[i + 1] = 0;
            while (i >= 0 && s[i] == '>')
            {
                if (xs[i] != -1)
                {
                    xs[i] = max(cur, xs[i]);
                }
                else
                {
                    xs[i] = cur;
                }
                i--, cur++;
            }
        }
    }
    // for (int x : xs)
    // {
    //     cout << x << ' ';
    // }
    // cout << endl;
    cout << accumulate(xs.begin(), xs.end(), i64(0)) << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 4740
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

  int N;
  cin >> N;

  vector<bool> table(N);
  for (int i = 0; i < N; i++) {
    int D1, D2;
    cin >> D1 >> D2;
    table[i] = (D1 == D2);
  }

  for (int i = 0; i < N - 2; i++) {
    if (table[i] && table[i + 1] && table[i + 2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3644
#!/usr/bin/env python3
# coding: utf-8
import collections
def debug(arg):
    if __debug__:
        pass
    else:
        import sys
        print(arg, file=sys.stderr)

def main():
    pass
    N, *A = map(int, open(0).read().split())
    a = dict(enumerate(A, 1))
    dp = collections.defaultdict(lambda: -float("inf"))
    dp[0, 0] = 0 
    dp[1, 0] = 0 
    dp[1, 1] = a[1]
    for i in range(2, N + 1):
        jj = range(max(i // 2 - 1, 1), (i + 1) // 2 + 1)
        for j in jj:
            x = dp[i - 2, j - 1] + a[i]
            y = dp[i - 1, j]
            dp[i, j] = max(x, y)
    print(dp[N, N // 2])

if __name__ == "__main__":
    main()

Measured memory_bytes: 155584
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <memory.h>
#include <algorithm>
#include <cassert>

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(c) (c).begin(), (c).end()
#define sz(c) int((c).size())
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fst first
#define snd second

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;

#define FNAME "a"

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr);
#else
#define eprintf(args...) ;
#endif

string s;

bool read() {
    if  (!getline(cin, s)) {
        return 0;
    }
    return 1;
}

const int A = 26;

void solve() {
    string ans;

    ford(pos, sz(s) + 1) {
        vi was(A, 0);
        forn(i, pos) {
            was[s[i] - 'a'] = 1;
        }
        const int cur = pos == sz(s) ? -1 : (s[pos] - 'a');
        for (int c = cur + 1; c < A; ++c) {
            if  (was[c]) {
                continue;
            }
            string cand = s.substr(0, pos);
            cand += 'a' + c;
            if  (ans.empty() || cand < ans) {
                ans = cand;
            }
        } 
    }

    if  (ans.empty()) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

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

#ifdef LOCAL
    freopen(FNAME ".in", "r", stdin);
    freopen(FNAME ".out", "w", stdout);
#endif

    while (read()) {
        solve();
    }

    return 0;
}


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

using namespace std;
char s[200010];

int main(){
    cin>>s;
    int len=strlen(s);
    int sum =0;
    for(int i=0;i<len;i++)sum+=(s[i]-'0');
    if(sum%9==0){
    cout<<"Yes";}
    else{
    cout<<"No";
    }
    


    
}

Measured memory_bytes: 3744
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include<cmath>

using namespace std;

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  printf("%.10f %d\n", double(w)*double(h)/2, (x*2 == w)&&(y*2==h)?1:0);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int n, i, j, v, m, k, count=0;
  int a[1000000] = {0};
  int g[100] = {0};

  scanf("%d",&n);

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

  i=0;
  g[0]=1;

  while(1){
    if(g[i]>n){
      m=i;
      break;
    }else{
      g[i+1]=3*g[i]+i;
      i++;
    }
  }

  for(i=0; i<m; i++){
    for(j=g[m-1-i]; j<n; j++){
      v=a[j];
      k=j-g[m-1-i];
      while(k>=0 && a[k]>v){
        a[k+g[m-i-1]]=a[k];
        k=k-g[m-i-1];
        count++;
      }
      a[k+g[m-i-1]]=v;
    }
  }

  printf("\n%d\n" ,m);

  for(i=0; i<m; i++){
    if(i==m-1) printf("%d\n", g[m-i-1]);
    else printf("%d ", g[m-i-1]);
  }

  printf("%d\n", count);

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

  return 0;
}

Measured memory_bytes: 4516
#!/usr/bin/env python3
import sys
try:
    from typing import List, Optional
except ImportError:
    pass


def solve(N: int, a: "List[int]"):
    amx = amn = None  # type: Optional[int]
    imx = imn = -1
    for i, ai in enumerate(a):
        if amn is None or ai < amn:
            imn = i
            amn = ai
        if amx is None or ai > amx:
            imx = i
            amx = ai

    assert amx is not None and amn is not None

    if amx * amn < 0:
        print(2 * N - 1)
        if amx < -amn:
            for j in range(N):
                print(1 + imn, 1 + j)
            d = amn
        else:
            for j in range(N):
                print(1 + imx, 1 + j)
            d = amx
    else:
        print(N - 1)
        d = 0

    assert (amx + d) * (amn + d) >= 0

    if amx + d >= 0 and amn + d >= 0:
        for i in range(N - 1):
            print(1 + i, 1 + i + 1)
    else:
        for i in reversed(range(N - 1)):
            print(1 + i + 1, 1 + i)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


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

int main(int argc, char const *argv[])
{
    int n, m, l;
    vector<vector<int>> a, b;
    vector<vector<long long>> c;

    cin >> n >> m >> l;

    a.resize(n, vector<int>(m));
    b.resize(m, vector<int>(l));
    c.resize(n, vector<long long>(l));

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cin >> b[i][j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            for (int k = 0; k < m; k++)
            {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            if (j == l - 1)
            {
                cout << c[i][j] << endl;
            }
            else
            {
                cout << c[i][j] << " ";
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3292
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    ll div = 2 * 5;

    ll ans = 0;

    if(n % 2 != 0){
        cout << 0 << endl;
        return 0;
    }

    while(true){
        ans += n / div;
        div *= 5;
        if(div > n){
            break;
        }
    }

    cout << ans << endl;
}

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


int main() {
	int N, K;
    cin >> N >> K;
    int output = 0;
  
  for(int n = 0; n<N; n++){
 	int ball;
    cin >> ball;
    
    if((K - ball) > ball){
    //
      output += ball *2;
      
    }else{
      output += (K-ball) *2;
    
    }    
  }
  cout << output << endl; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,Q;
string s;
string t[200001];
string d[200001];

bool checkl(int x){
	int now=x;
	REP(i,Q){
		//cout<<now<<" "<<s[now]<<" "<<t[i][0]<<endl;
		if(s[now]==t[i][0]){
			if(d[i][0]=='L'){
				now--;
			}else{
				now++;
			}
			if(now<0)return true;
			if(now>=N)return false;
		}
	}
	return false;
}

bool checkr(int x){
	int now=x;
	REP(i,Q){
		if(s[now]==t[i][0]){
			if(d[i][0]=='L'){
				now--;
			}else{
				now++;
			}
			if(now<0)return false;
			if(now>=N)return true;
		}
	}
	return false;
}

int main(){
	cin>>N>>Q;
	cin>>s;
	REP(i,Q){
		cin>>t[i]>>d[i];
	}
	//cout<<checkl(0)<<endl;
	
	int ans=0;
	int lb=-1;
	int ub=N;
	while(ub-lb>1){
		int mid=(lb+ub)/2;
		if(checkl(mid)){
		//	cout<<"a"<<mid<<endl;
			lb=mid;
		}else{
			ub=mid;
		//	cout<<"b"<<mid<<endl;
		}
	}
	
	ans=lb;
	int ans2=0;
	lb=-1;
	ub=N;
	//cout<<"ub"<<ub<<endl;
	while(ub-lb>1){
		int mid=(lb+ub)/2;
		//cout<<"mid"<<mid<<lb<<ub<<endl;
		if(checkr(mid)){
			//cout<<"a"<<mid<<endl;
			ub=mid;
		}else{
			//cout<<"b"<<mid<<endl;
			lb=mid;
		}
	}
			//cout<<"ans"<<ans<<ans2<<endl;
	ans2=ub;
	if(ans2<=ans){
		cout<<0<<endl;
	}else{
		int a=ans+1;
		int b=(N-1)+1-ans2;

		cout<<N-a-b<<endl;
	}
}

Measured memory_bytes: 22276
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

string S;

int main() {

	cin >> S;

	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[(1 << 12)];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    int a[1010], b[1010];
    int c[1010][15];
    rep(i, M) {
        cin >> a[i] >> b[i];
        rep(j, b[i]) {
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    rep(i, (1 << 12)) dp[i] = INF;
    dp[0] = 0;
    rep(bit, (1 << 12)) {
        rep(i, M) {
            int S = bit;
            rep(j, b[i]) {
                S |= (1 << c[i][j]);
            }
            dp[S] = min(dp[S], dp[bit] + a[i]);
        }
    }
    if (dp[(1 << N) - 1] == INF) {
        cout << -1 << endl;
    } else {
        cout << dp[(1 << N) - 1] << endl;
    }
    


    return 0;
}


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

int main(){
    int n, now, p=0, pre = -1;
    string out, temp;
    cin >> n;
    now = (n+ 1)/2;
    cout << p << endl;
    cin >> temp;
    if(temp == "Vacant"){
        cout << 0 << endl;
        return 0;
    }
    cout << now << endl;
    cin >> out;
    while(out != "Vacant"){
        if(temp == out && now%2==0){
            p = now;
        }
        else if(temp != out && now%2!=0){
            p = now;
        }
        else{
            n = now;
        }
        now = (n + p)/2;
        if(pre == now){
            n++;
            now = (n+p)/2;
        }
        pre = now;
        cout << now << endl;
        cin >> out;
    }
    cout << now << endl;
    return 0;
}

Measured memory_bytes: 852
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

void solve()
{
	int n,x;
	cin >> n >>x;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	int ans =0;
	for(int i=1;i<n;i++)
	{
		int cur = a[i] + a[i-1];
		if(cur <= x) continue;
		int extra = cur - x;
		ans += extra ;
		if(extra<=a[i]) a[i]-=extra;
		else a[i] = 0;
	}
	cout << ans ;
}

int32_t main()
{
	FastIO;
	Fast_D;
	solve();
	return 0;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << ' ' << a << ' ' << b;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		printTestCases();

	}
	
	public static void printTestCases() {
		
		Scanner sc = new Scanner(System.in);
		int i = 1;
		while (true) {
			int x = sc.nextInt();
			
			if (x == 0) {
				break;
			} else {
				System.out.println("Case " + i + ": " + x);
				i++;
			}
		}
	}
}


Measured memory_bytes: 41816
#include<stdio.h>
int main(){
  int a[105];
  int N,i,max,min;
  scanf("%d",&N);
  for(i = 0;i < N;i++){
    scanf("%d",&a[i]);
  }
  max = a[0];
  min = a[1];
  for(i = 0;i < N;i++){
    if(a[i] > max) max = a[i];
    if(a[i] < min) min = a[i];
  }
  printf("%d",max - min);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;  
typedef long long LL;  
char s[15];  
int pos[15];  
LL num(int l,int r)  
{  
    LL ans=0;   
    for(int i=l;i<=r;i++)  
    {  
        ans=ans*10+s[i]-'0';  
    }  
    return ans;  
}  
LL solve(int n)  
{  
    int l=-1,r=0;  
    LL ans=0;  
    pos[n]=1;  
    for(int i=0;i<=n;i++)  
    {  
        if(pos[i]==0)  
            r++;  
        else  
        {  
            ans+=num(l+1,i);  
            l=i;  
        }  
    }  
    return ans;  
}  
int main()  
{  
     cin>>s;
      
         int n=strlen(s);  
         long long ans=0;  
         int R= (1<<(n-1))-1 ;   
        for(int i=0;i<=R;i++)  
        {  
            memset(pos,0,sizeof(pos));  
            int tot=0;  
            int temp=i;  
            while(temp)  
            {  
                pos[tot++]=temp%2;  
                temp=temp/2;  
            }  
            //cout<<solve(n-1)<<endl;  
            ans+=solve(n-1);    
        }  
        printf("%lld\n",ans);  
      
    return 0;  
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
using namespace std;

int N,M,x,y,gx,gy,dir;
bool visit[4][55][55];
char field[55][55];
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};

int main(){
	cin>>N>>M;
	REP(i,1,N+1){
		REP(j,1,M+1){
			cin>>field[i][j];
			if(field[i][j] == 'G'){
				gy = i;	gx = j;
			}
			else if(field[i][j] != '.' && field[i][j] != '#'){
				y = i;
				x = j;
				if(field[i][j] == '^') dir = 0;
				else if(field[i][j] == '>') dir = 1;
				else if(field[i][j] == 'v') dir = 2;
				else if(field[i][j] == '<') dir = 3;
			}
		}
	}
	REP(i,0,M+2) field[0][i]=field[N+1][i]='#';
	REP(i,0,N+2) field[i][0]=field[i][M+1]='#';
	int ans=-1;
	while(1){
		if(visit[dir][y][x])break;
		visit[dir][y][x]=true;
		if(y==gy&&x==gx){//goal
			ans=0;
			REP(i,1,N+1) REP(j,1,M+1) ans+=(visit[0][i][j] || visit[1][i][j] || visit[2][i][j] || visit[3][i][j]);
			break;
		}

		int rdir=(dir+1)%4;//turn right
		int ry=y+dy[rdir], rx=x+dx[rdir];

		if(field[ry][rx]=='#'){//right wall
			if(field[y+dy[dir]][x+dx[dir]]=='#'){//front wall
				dir=(dir+3)%4;//turn left
			}else{
				x+=dx[dir];y+=dy[dir];//straight
			}
		}else{// no right wall
			dir = rdir;//turn right
			x=rx;y=ry;//and go
		}
	}
	p(ans);

	return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>

int main() {
	char str[100001];
	int acs[100000];
	int N, Q, i,init, end,ct=0,flag=0;
	scanf("%d %d", &N, &Q);
	scanf("%s", str);
	for (i = 0; i < N; i++) {
		if (str[i] == 'A') { flag = 1; }
		else { if (str[i] == 'C'&&flag == 1) { ct++; }flag = 0; }
		acs[i] = ct;
	}
	for (i = 0; i < Q; i++) {
		scanf("%d %d", &init, &end);
		printf("%d\n", acs[end-1] - acs[init-1]);
	}
	return 0;
}

Measured memory_bytes: 1280
# D
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ans = []
for index_i, i in enumerate(a):
    for index_j, j in enumerate(b):
        for index_l, l in enumerate(c):
            if ((index_i+1)*(index_j+1)*(index_l+1) <= k):
                ans.append(i+j+l)
            else:
                break
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

int N, X, h[51], p[51];

void init(){
    cin >> N >> X;
    h[0] = p[0] = 1;
    rep(i,50){
        h[i+1] = 2 * h[i] + 3;
        p[i+1] = 2 * p[i] + 1;
    }
}

int eat(int lv, int x){
    if(x <= 0)     return 0;
    if(h[lv] <= x) return p[lv];
    if(x == 1)     return 0;
    
    int mid = (x-h[lv-1]-1 > 0 ? 1 : 0);
    return eat(lv-1,x-1) + mid + eat(lv-1,x-h[lv-1]-2);
}

signed main(){
    init();
    cout << eat(N,X) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main(){
	int v=0,w=0;
	std::vector<int> a(0),b(0);
	while(true){
		v++;
		a.resize(v);
		b.resize(v);
		std::cin>>a[v-1];
		std::cin>>b[v-1];
		if((a[v-1]==0)&&(b[v-1]==0)){
			break;
		}
	}
	for(int i=0;i<v-1;i++){
		if(a[i]>b[i]){
			w=a[i];
			a[i]=b[i];
			b[i]=w;
		}
	}
	for(int i=0;i<v-1;i++){
		std::cout<<a[i]<<" "<<b[i]<<std::endl;
	}
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e9
#define precise cout << std::setprecision(10) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        cout<<s[0]<<s[1]<<s[2]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3600
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
 
//const long long INF = 1LL << 55;
 
#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define MAX_N 300030

int n,m,q;
int grid[600][600];
int grid_cumrative[600][600];
void precalc(){
   for(int i = 1;i < 550;i++){
      for(int j = 1;j < 550;j++){
         grid_cumrative[i][j]
            = grid_cumrative[i][j-1] + grid_cumrative[i-1][j] - grid_cumrative[i-1][j-1] + grid[i-1][j-1];
      }
   }
   // rep(i,10){
      // rep(j,10)cout << grid[i][j] << " ";
      // cout << endl;
   // }
}
void query(int p,int q){
   int ans = 0;
   ans += grid_cumrative[q+1][q+1];
   ans -= (grid_cumrative[p][q+1] + grid_cumrative[q+1][p]);
   ans += grid_cumrative[p][p];
   cout << ans << endl;
}
int main(void){
   // ioboost;
   cin >> n >> m >> q;
   rep(i,m){
      int l,r;cin >> l >> r;
      grid[--l][--r]++;
   }
   precalc();
   rep(i,q){
      int p,q;cin >> p >> q;
      query(--p,--q);
   }
}

Measured memory_bytes: 3328
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int a1,a2,a3,count1=0,count2=0,c,c2;
  char b1,b2;
  while(cin>>a1>>b1>>a2>>b2>>a3){
    c=2*(sqrt((a1*a1-a3*a3/4)));
    c=2*(sqrt(a3*a3+c*c));
    c2=(a1+a2)*2;
    if(a1*a1+a2*a2==a3*a3)
      count1++;
    else if(c2==c)
      count2++;
  }
  cout<<count1<<endl<<count2<<endl;
  return 0;
}

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

def main():

    b = input()

    if b == 'A':
        ans = 'T'

    elif b == 'T':
        ans = 'A'

    elif b == 'C':
        ans = 'G'

    elif b == 'G':
        ans = 'C'


    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 8748
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll n, k; cin >> n >> k;
    ll d, a;
    bool has_no_sweets[n];
    rep(i, n){
        has_no_sweets[i] = true;
    }
    rep(i, k){
        cin >> d;
        rep(j, d){
            cin >> a;
            a--;
            has_no_sweets[a] = false;
        }
    }

    cout << accumulate(has_no_sweets, has_no_sweets + n, 0LL) << endl;



    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

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

    if(n == 1) {
        cout << 0 << endl;
        return 0;
    }

    vector <int> compare(n-1,0);
    for(int i=0; i<n-1; i++){
        if(height[i] >= height[i+1]) compare[i]=1;
        else compare[i]=0;
    }
    int count =0;
    int ans=0;
    for(int i=0; i<n; i++){ 
        if(compare[i] == 1){
            count ++;
        }
        else{
            if(count > ans) ans = count;
            count =0;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4580
#include "bits/stdc++.h"
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define gcd(a,b) __gcd(a,b)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define pb(n) push_back(n)
#define pp pop_back()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define type(a) typeid(a).name();
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define console(arr) cout << "["<<endl; for(ll i=0;i<(ll)arr.size();++i){cout << " [";for(ll j=0;j<(ll)arr[i].size();++j){(j==(int)arr[i].size()-1)?cout << arr[i][j]:cout << arr[i][j] << ",";}cout << "]"<<endl;} cout << "]"<<endl
#define starting() auto start = high_resolution_clock::now()
#define ending() auto stop = high_resolution_clock::now();auto duration = duration_cast<microseconds>(stop - start);cout << endl << endl << "Execution Time : "<<duration.count()/1000 << " ms" << endl
 
template <typename T1,typename T2>
void mapped(map<T1,T2>m){for(auto ite=m.begin();ite!=m.end();++ite){cout << "'" << ite->first << "'"<<" : "<<ite->second <<endl;}}
 
template <typename T1 , typename T2>
void mappedArr(map<T1,vector<T2>>m){for(auto ity=m.begin();ity!=m.end();++ity){cout << "'"<< ity->first <<"'"<<" : "<<"[";
for(int i=0;i<(int)ity->second.size();++i){(i==(int)ity->second.size()-1)?cout << ity->second[i]:cout << ity->second[i] << ",";}cout << "]"<<endl;}}
 
string int_to_string(int x){ stringstream ss; ss << x; string ni = ss.str(); return ni;}
int char_to_int(char c){ int n = (int)c - 48; return n; }
int string_to_int(string x){ int n; stringstream s(x); s >> n; return n; }
 
template <typename T1,typename T2>
void ArrPair(vector<pair<T1,T2>>vp){for(int i=0;i<(int)vp.size();++i){
cout << "(" << vp[i].first << "," << vp[i].second << ")"<<endl ;}}
 
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;
 
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  double summed = 0;
  for (int i = 0; i < n; ++i) {
	  cin >> v[i];
	  summed += v[i]; 
  }
  int x = ceil(summed/n);
  int y = floor(summed/n);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
	  ans += abs(x-v[i])*abs(x-v[i]);
  }
  int ans1 = 0;
  for (int i = 0; i < n; ++i) {
	  ans1 += abs(y-v[i])*abs(y-v[i]);
  }
  cout << min(ans1,ans);
}















Measured memory_bytes: 256