akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif

int seg[2010];

int get(int i) {
    ++i;
    int ans = 0;
    for (; i; i -= i & -i) {
        ans = ans + seg[i];
    }
    return ans;
}

void add(int i, int x) {
    ++i;
    for (; i < 2010; i += i & -i) {
        seg[i] = seg[i] + x;
    }
}

int get(int l, int r) {
    return get(r) - get(l - 1);
}


long long subSolve(ll lb, vector<ll> A, int Q, int K) {
    memset(seg, 0, sizeof(seg));

    long long ans = 0;

    vector<pair<ll, int> > items;
    set<int> guard;
    for (int i = 0; i < A.size(); i++)
        if (A[i] >= lb) items.push_back({A[i], i});
        else guard.insert(i);
    sort(items.begin(), items.end());
    guard.insert(-1);
    guard.insert(A.size());
    int cnt = 0;
    for (auto &&p : items) {
        int l = *--guard.lower_bound(p.second) + 1;
        int r = *guard.lower_bound(p.second) - 1;
        cnt += r - l + 1 - get(l, r) >= K;
        ans = p.first;
        if (cnt >= Q) break;
        add(p.second, 1);
    }
    if (cnt < Q) return 1e18;
    return ans - lb;
}

void solve(ll N, ll K, ll Q, vector<ll> A) {
    long long ans = 1e18;
    for (int i = 0; i < A.size(); i++) {
        ans = min(ans, subSolve(A[i], A, Q, K));
        //cout << A[i] << " " << subSolve(A[i], A, Q, K) << endl;
    }
    cout << ans << endl;
}


void main_(istream &cin) {
    ll Q;
    ll N;
    ll K;
    cin >> N;
    vector<ll> A(N - 1 + 1);
    cin >> K;
    cin >> Q;
    for (int i = 0; i <= N - 1; i++) {
        cin >> A[i];
    }
    solve(N, K, Q, A);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





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

int main() {
  
  vector<long> able(5);
  vector<long> num(6);
  
  long N , abmin = -1, ans;
  cin >> N;
  num.at(0) = N;
  
  for (long i = 0 ; i < 5 ; i++){
    cin >> able.at(i);
    
    if (abmin < 0){
      abmin = i;
    }
    else if (able.at(i) < able.at(abmin)){
      abmin = i;
    }
  
  }
  
  
  long st = abmin;
  long kai;
  
  if (N % able.at(abmin) == 0)
    kai = N / able.at(abmin) ;
  else
    kai = ( N / able.at(abmin) ) + 1;
  
  long leave;
  leave = st + kai - 1;
  
  ans = leave + (6 - abmin) - 1;
  
  cout << ans << endl;
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair



int main(){
    typedef vector<string> vs;
    int h, w;
    while (cin >> h >> w, h | w){
        vs G(h);
        for (auto & a : G) cin >> a;

        vector<vector<bool>> vis(h, vector<bool>(w, false));
        int cx = 0, cy = 0;
        const int dx[] = { 1, 0, -1, 0 };
        const int dy[] = { 0, -1, 0, 1 };

        map<char, int> m;
        m['>'] = 0, m['^'] = 1, m['<'] = 2, m['v'] = 3;

        while (1){
            if (vis[cy][cx]){
                cout << "LOOP" << endl;
                goto end;
            }
            vis[cy][cx] = true;
            char c = G[cy][cx];
            if (c == '.'){
                cout << cx << " " << cy << endl;
                goto end;
            }
            cx += dx[m[c]], cy += dy[m[c]];
        }
    end:;
    }
}

Measured memory_bytes: 1256
N = int(input())
X = list(map(int,input().split()))
X = sorted(X)
minx = X[0]
maxx = X[-1]

ans = 10 ** 9 + 7
for i in range(minx, maxx + 1):
    temp = 0
    for j in range(N):
        temp += (i - X[j]) ** 2
    ans = min(ans, temp)
print(ans)

Measured memory_bytes: 38512
#include<stdio.h>
int main(void) {
	int i, N, K, j, s, g = 0,q=0;
	int d[100];
	int a[100][100];
	scanf("%d",&N);
	scanf("%d", &K);
	s = 0;
	for (i = 0; i < K; i++) {
		scanf("%d", &d[i]);
		for (j = 0; j < d[i]; j++) {
			scanf("%d", &a[i][j]);
		}

	}
	for (s = 1; s <= N; s++) {
		for (i = 0; i < N; i++) {
			if (q == 1) {
				q = 0;
				break;
			}
			for (j = 0; j < d[i]; j++) {
				if (q == 1) {
					break;
				}
				if (a[i][j] == s) {
					g++;
					q++;
					break;



				}

			}


		}
	}
	printf("%d", N - g);
return 0;
}

Measured memory_bytes: 2180
//#pragma GCC optimize(2)
#include<cstdio>
#define L 1<<23
#define C (c=*A++)
#define ENS //__attribute__((optimize("-O2")))
#define NES //__attribute__((optimize("-O2"))) __inline__ __attribute__((always_inline))
#define N 131073

struct node{long long s,t;NES bool operator<(const node&b){return (s==b.s&&t<b.t)||s<b.s;}}v[N<<5],t1[N],t2[N];
int n,l[N],r[N],a[N],lf[N],rf[N],cnt,wt,ss[19];char fl[L],*A=fl;long long mid;
NES void read(int&x){char c;for(x=0;'0'>C||c>'9';);while('0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,C;}NES void print(long long x){if(!x)putchar(48);else{for(wt=0;x;ss[++wt]=x%10,x/=10);for(;wt;putchar(ss[wt--]+48));}}
NES bool dfs(int x)
{
	if(!l[x])return v[lf[x]=rf[x]=++cnt]=(node){a[x],a[x]},true;int le=l[x],ri=r[x];
	if(!dfs(le)||!dfs(ri))return false;int s1=0,s2=0,i,j;
	for(lf[x]=cnt+1,j=rf[ri],i=rf[le];i>=lf[le];i--)
	{
		for(;j>=lf[ri]&&v[i].t+v[j].s>mid;j--);
		if(j+1==lf[ri])break;t1[++s1]=(node){v[i].s,v[j].t};
	}
	for(j=rf[le],i=rf[ri];i>=lf[ri];i--)
	{
		for(;j>=lf[le]&&v[i].t+v[j].s>mid;j--);
		if(j+1==lf[le])break;t2[++s2]=(node){v[i].s,v[j].t};
	}int p1=s1,p2=s2;
	if(p1||p2)
		if(!p2||(p1&&t1[p1]<t2[p2]))v[++cnt]=(node){t1[p1].s+a[x],t1[p1].t+a[x]},p1--;
		else v[++cnt]=(node){t2[p2].s+a[x],t2[p2].t+a[x]},p2--;
	while(p1||p2)
		if(!p2||(p1&&t1[p1]<t2[p2])){if(v[cnt].t>t1[p1].t+a[x])v[++cnt]=(node){t1[p1].s+a[x],t1[p1].t+a[x]};p1--;}
		else{if(v[cnt].t>t2[p2].t+a[x])v[++cnt]=(node){t2[p2].s+a[x],t2[p2].t+a[x]};p2--;}
	return(rf[x]=cnt)>=lf[x];
}
ENS int main()
{int i,fa;long long le,ri;
	for(fl[fread(fl,1,L,stdin)]=EOF,read(n),i=2;i<=n;read(a[i]),ri+=a[i],i++)if(read(fa),l[fa])r[fa]=i;else l[fa]=i;
	for(;ri&&(cnt=0,mid=ri>>1,dfs(1));ri>>=1);for(le=mid;le<ri;mid=(le+ri)>>1,cnt=0,dfs(1)?ri=mid:le=mid+1);print(ri);
}

Measured memory_bytes: 27008
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, k = sc.nextLong()
    val Mod = math.pow(10, 9).toLong + 7
    var ans = 0L
    for (i <- k to n + 1) {
      val min = (0L + i - 1L) * i / 2L
      val max = (n + n - i + 1L) * i / 2L
      ans = (ans + (max - min + 1)) % Mod
    }

    println(ans % Mod)
  }

}


Measured memory_bytes: 57416
#![allow(unused)]

use std::{cell, cmp, collections, convert, fmt, io, iter, ops, str};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! debugln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! debugln {
    ($($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let n = parse_line::<usize>();

    let nums = parse_vec::<u64>();
    let ans = nums.iter().sum::<u64>() - n as u64;

    println!("{}", ans);
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if !buf.is_empty() {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn next_prime(x: i32) -> i32 {
    for i in (x + 1).. {
        if is_prime(i) {
            return i;
        }
    }

    panic!("attempt to add with overflow");
}

fn is_prime(x: i32) -> bool {
    let ceil = f64::from(x).sqrt().ceil() as i32;
    x == 2 || (2..(ceil + 1)).all(|i| x % i != 0)
}

fn bit_high(bits: u64, pos: u64) -> bool {
    bits & (1 << pos) != 0
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;

class Program {
  static void Main(string[] args) {
    int kase = 1;
    while(true) {
      int x = int.Parse(Console.ReadLine());
      if (x == 0) break;
      Console.WriteLine("Case {0}: {1}", kase, x);
      kase++;
    }
  }
}

Measured memory_bytes: 5780
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
struct item{
    ll weight;
    ll value;
};

int main(){
    int N,W;
    cin>>N>>W;
    ll dp[N+1][W+1];
    item arr[N+1];

    for(int i=1;i<=N;i++){
        cin>>arr[i].weight;
        cin>>arr[i].value;
    }

    for(int i=0;i<=N;i++){
        dp[i][0]=0;
    }
    for(int i=0;i<=W;i++){
        dp[0][i]=0;
    }
    ll maximum=0;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=W;j++){
            dp[i][j]=dp[i-1][j];
            if(arr[i].weight>j){
                continue;
            }
            dp[i][j]=max(dp[i][j],arr[i].value + dp[i-1][j - arr[i].weight]);  //Important recurence
        }
        maximum=max(maximum,(*max_element(dp[i],dp[i]+W+1)));
    }
    cout<<maximum;
}

Measured memory_bytes: 79104
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  string st;
  int ans=0,n;
  cin>>st>>n;
  REP(i,n){
    string ring;
    cin>>ring;
    ring = ring + ring;
    if(ring.find(st)!=string::npos) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a*b>c*d)printf("%d",a*b);
    else printf("%d",c*d);
    return 0;
    
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		int tap = 0;
		int sasi = 1;
		while (sasi < B){

			sasi += (A - 1);
			tap++;
		}
		System.out.println(tap);
	}

}

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

using namespace std;
const int maxn=2e3+45;
const int INF=1e9+7;
#define charmax(x,y) x=max(x,y)
#define charmin(x,y) x=min(x,y)
int pos[2][maxn];int dp[maxn][maxn];int num[2*maxn];
int w;
void add(int x,int p){for(int i=x;i<=w;i+=i&-i) num[i]+=p;}
int sum(int x){int ans=0;for(int i=x;i>=1;i-=i&-i) ans+=num[i];return ans;}
int main()
{
    int n;
    scanf("%d",&n);
    w=n*2;
    memset(dp,0,sizeof dp);
    //memset(dp,INF,sizeof dp);
    for(int i=1;i<=w;i++){
        char s;int x;
        cin>>s>>x;
        pos[s=='W'][x]=i;
        add(i,1);
    }
    pos[0][0]=pos[1][0]=w+1;
    for(int i=0;i<=n;i++){
        add(pos[0][i],-1);
        for(int j=0;j<=n;j++){
            add(pos[1][j],-1);
            if(i||j){
                dp[i][j]=INF;
                if(i){
                    charmin(dp[i][j],dp[i-1][j]+sum(pos[0][i]-1));
                }
                if(j){
                    charmin(dp[i][j],dp[i][j-1]+sum(pos[1][j]-1));
                }
            }
        }
        for(int j=0;j<=n;j++){
            add(pos[1][j],1);
        }
    }
    printf("%d\n",dp[n][n]);
    return 0;
}


Measured memory_bytes: 16640
#! /usr/bin/python3
N = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

m = min(a, b, c, d, e)
#print("min", m)

t = 5
k = max(0, N - m) // m
t += k
#print("rem", N-m)
#print("k=", k)

k = 1 if max(0, N - m) % m > 0 else 0
t += k
#print("k=", k)

print(t)





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

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

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

using namespace std;

int main(){

  int n;
  scanf("%d", &n);

  vector<int> v;

  REP(i,3 * n){
    int t;
    scanf("%d", &t);
    v.pb(t);
  }

  sort(ALL(v), greater<int>());
  llong res = 0;
  REP(i,n){
    res += v[2 * i + 1];
  }

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



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

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

    int n;
    double m; cin>>n>>m;
    double arr[n];
    for(double &i:arr) cin>>i;
    double sum=0;
    for(double i:arr) sum+=i;

    double temp= (sum/(m*4.0000));

    sort(arr, arr+n);
    if(arr[n-(int)m]>=temp) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
typedef pair<int,int> P;
int w,h;
int grid[21][21];
P start,goal;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int ans = 11;
bool isvalid(int x,int y){
  return (x>=0&&x<w&&y>=0&&y<h);
}
void dfs(P p, int t){
  if(p == goal){
    ans = t;
    return;
  }
  if(t >= ans) return;
  int x = p.first;
  int y = p.second;
  REP(r,4){
    int nx = x + dx[r];
    int ny = y + dy[r];
    if(isvalid(nx,ny) && grid[ny][nx] != 1){
      while(isvalid(nx,ny)){
        if(grid[ny][nx] == 3 ||
            (isvalid(nx+dx[r],ny+dy[r]) && grid[ny+dy[r]][nx+dx[r]] == 1)){
          if(grid[ny][nx] != 3) grid[ny+dy[r]][nx+dx[r]] = 0;
          dfs(P(nx,ny),t+1);
          if(grid[ny][nx] != 3) grid[ny+dy[r]][nx+dx[r]] = 1;
          break;
        }
        nx += dx[r];
        ny += dy[r];
      }
    }
  }
}
int main(){
  while(cin>>w>>h,w){
    REP(y,h)REP(x,w){
      cin>>grid[y][x];
      if(grid[y][x]==2){
        start = P(x,y);
      }
      if(grid[y][x]==3){
        goal = P(x,y);
      }
    }
    ans = 11;
    dfs(start,0);
    if(ans > 10) ans = -1;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include<math.h>
#include<bitset>
#include<string>
#include<iostream>
#include<vector>
#include<string.h>
using namespace std;


int main()
{
    int n,k,q;
    cin>>n>>k>>q;
    int a[q],human[n];
    for(int i=0;i<q;i++) cin>>a[i];
    for(int i=0;i<n;i++) human[i]=k-q;
    
    for(int i=0;i<q;i++){
        human[a[i]-1]++;
    }
    
    for(int i=0;i<n;i++){
        if(human[i]<=0)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int input_side_a  = 0;
		int input_side_b  = 0;
		int input_angel_c  = 0;

		double side_c =0;
		double area_s = 0.0;
		double circum_l = 0.0;
		double height_h = 0.0;
		double radians_c = 0.0;

		Scanner sc= new Scanner( System.in );

		input_side_a = sc.nextInt();
		input_side_b = sc.nextInt();
		input_angel_c = sc.nextInt();

		radians_c = Math.toRadians( input_angel_c );

		area_s = ( 1.0 / 2.0 ) * input_side_a * input_side_b * Math.sin( radians_c );
		side_c = Math.sqrt( Math.pow( input_side_a, 2 ) + Math.pow( input_side_b, 2 ) - 2 * input_side_a * input_side_b * Math.cos( radians_c ) );
		circum_l = input_side_a + input_side_b + side_c;
		height_h = input_side_b * Math.sin( radians_c );

		System.out.println( area_s );
		System.out.println( circum_l );
		System.out.println( height_h );

		sc.close();
	}
}


Measured memory_bytes: 26176
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const [N, M, Q] = lines[0].split(' ').map(Number)
const q = Array(Q)
for (let i = 0; i < Q; i++) {
    q[i] = lines[i + 1].split(' ').map(Number)
}

const f = (A) => {
    let sum = 0
    for (let i = 0; i < Q; i++) {
        const a = A[q[i][0] - 1]
        const b = A[q[i][1] - 1]
        if (b - a === q[i][2]) {
            sum += q[i][3]
        }
    }
    return sum
}

const ss = []
const s = []
let v = 0
while (v !== undefined) {
    if (s.length === N) {
        ss.push([...s])
        s.pop()
        v++
    } else if (v >= M) {
        v = s.pop()
    } else {
        s.push(v + 1)
    }
}

let A = null
let ans = 0
while (A = ss.pop()) {
   ans = Math.max(ans, f(A)) 
}

console.log(ans)


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long n, string s){
    int ans=0;
    REP(h,0,1000){
        string i=to_string(h);
        while(i.size()<3) i = '0'+i;

        int now=0;
        REP(j,0,n){
            if(s[j]==i[now]) now++;
            if(now==3){
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    string S;
    cin>>S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 384
N=input()

if(int(N[-1])==2 or int(N[-1])==4 or int(N[-1])==5 or int(N[-1])==7 or int(N[-1])==9):
  print('hon')
elif(int(N[-1])==0 or int(N[-1])==1 or int(N[-1])==6 or int(N[-1])==8):
  print('pon')
else:
  print('bon')

Measured memory_bytes: 9172
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vvi g;

P dfs(int v,int b,vi& used){
	used[v]=b;
	P p;
	if(b) p.first++;
	else p.second++;
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		if(used[u]==-1){
			P q=dfs(u,!b,used);
			p.first+=q.first;
			p.second+=q.second;
		}
		if(used[u]==b) return {-inf,0};
	}
	return p;
}

int main(){
	cin>>n>>m;
	g=vvi(n);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vi used(n,-1);
	int tmp=0;
	map<int,int> M;
	for(int i=0;i<n;i++) if(used[i]==-1){
		P p=dfs(i,1,used);
		int A=p.first,B=p.second;
		if(A<0){
			cout<<-1<<endl;
			return 0;
		}
		tmp+=min(A,B);
		M[abs(A-B)]++;
	}
	vi dp(n+1);
	dp[tmp]=1;
	for(auto i=M.begin();i!=M.end();i++){
		int v=i->first,N=i->second;
		vi DP(n+1,-1);
		for(int j=0;j<=n;j++){
			if(dp[j]) DP[j]=0;
			else if(j>=v&&DP[j-v]!=-1&&DP[j-v]<N){
				DP[j]=DP[j-v]+1;
				dp[j]|=1;
			}
		}
	}
	ll res=0;
	for(int i=0;i<=n;i++) res=max(res,(ll)dp[i]*i*(n-i));
	cout<<res-m<<endl;
}

Measured memory_bytes: 9988
#include <iostream>
#include <iomanip>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
 
int main(){
  int A, B;
  cin >> A >> B;
  if(A + B >= 10) {
    cout << "error" << endl;
  } else {
    cout << A + B << endl;
  }
}

Measured memory_bytes: 256
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int N;
	cin>>N;
	int x,y;
	x=800*N;
	y=(N/15)*200;

	cout<<x-y<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A1 = [[-a-i,i] for i, a in enumerate(A)]
A2 = [[a-i,i] for i, a in enumerate(A)]
A1.sort()
A2.sort()
i = j = 0
cnt = 0
while i < N and j < N:
    if A1[i][0] == A2[j][0]:
        buf1 = 1
        for k in range(i+1, N):
            if A1[k][0] != A1[i][0]:
                break
            buf1 += 1
        buf2 = 1
        for k in range(j+1, N):
            if A2[k][0] != A2[j][0]:
                break
            buf2 += 1
        cnt += buf1 * buf2
        i += buf1
        j += buf2
    elif A1[i][0] < A2[j][0]:
        i += 1
    else:
        j += 1
print(cnt)


Measured memory_bytes: 78492
#include<iostream>
using namespace std;
int main()
{
    string a;
    cin>>a;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='C') 
        {
            for(int j=i+1;j<a.size();j++) 
            if(a[j]=='F') 
            {
                cout<<"Yes"<<'\n';
                goto hre;
            }
        }
        
    }
    cout<<"No"<<'\n';
    hre:;
    return 0;
}

Measured memory_bytes: 256
fun main() {
    readLine() // skip
    val list = readLine()!!.split(" ").map { it.toLong() }.toLongArray()

    val group = list
        .asSequence()
        .groupBy { it }
        .mapValues { it.value.count().toLong() }
        .toMutableMap()

    val resultList = mutableListOf<Long>()
    var result = list.sum()

    val q = readLine()!!.toInt()
    (0 until q).map {
        val (b, c) = readLine()!!.split(" ").map { it.toLong() }
        result += (c - b) * (group[b] ?: 0L)
        resultList.add(result)

        group[c] = (group[c] ?: 0L) + (group[b] ?: 0L)
        group[b] = 0
    }

    resultList.forEach { println(it) }
}

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

int main(void){
	int N,a,b;
	ll K;
	cin>>N>>K;
	map<int,ll> mp;
	rep(i,N){
		cin>>a>>b;
		mp[a]+=b;
	}
	for(auto x:mp){
		K-=x.second;
		if(K<=0){
			cout<<x.first<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>
#define mod 1000000007
typedef long long ll;

ll mpow(ll a, ll b) {
  ll ans = 1, now = b;
  while(now) {
    if(now & 1) ans *= a, ans %= mod;
    a *= a, a %= mod, now >>= 1;
  }
  return ans;
}

ll rev(ll a) {
  return mpow(a, mod - 2);
}

int main(void) {
  ll i, j, k, n, ans = 0, now, m = 1e6, cnt[m], num, lcm = 1;
  bool p[m];
  for(i = 0; i < m; ++i) p[i] = true, cnt[i] = 0;
  p[0] = p[1] = false;
  for(i = 2; i < 1e3; ++i) if(p[i]) for(j = 2; i * j < m; ++j) p[i * j] = false;
  scanf("%lld", &n);
  ll a[n];
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
    now = a[i];
    for(j = 2; j * j <= a[i]; ++j) if(p[j]) {
      num = 0;
      while(!(now % j)) num++, now /= j;
      if(cnt[j] < num) cnt[j] = num;
    }
    if(!cnt[now]) cnt[now] = 1;
  }
  for(i = 2; i < m; ++i) lcm *= mpow(i, cnt[i]), lcm %= mod;
  for(i = 0; i < n; ++i) ans += lcm * rev(a[i]), ans %= mod;
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 9088
function Main(inp) {
    var input = inp.split("\n").map(function(n) { return Number(n);});
    var n = input[0];
    var a = input[1];
    if (Math.floor(n % 500) <= a) {
        console.log('Yes');
        return;        
    }
    console.log('No');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
N,Q = map(int,input().split())
S = str(input())
t = [0]*(N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
for i in range(Q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])


Measured memory_bytes: 9412
N = int(input())
a = []
b = []
c = []
for i in range(N):
    a += [list(map(int, input().split()))]
    
row = [1]*9
col = [1]*9
dops = [1]*16
dneg = [1]*16

def sett(x, y):
    row[y] = 0
    col[x] = 0
    dops[x+y] = 0
    dneg[y-x+7] = 0

def dsett(x, y):
    row[y] = 1
    col[x] = 1
    dops[x+y] = 1
    dneg[y-x+7] = 1
    
def paint(ans):
    pain = [["."]*8for _ in range(8)]
    for i, j in ans.items():
        pain[i][j] = "Q"
        print("".join(pain[i]))
    
cnt = 1
def serch(h):
    global cnt
    if h == 8:
        aa = 0
        for i, j in a:
            if ans[i] == j:
                aa += 1
        if aa == len(a):
            cnt = 0
            paint(ans)
            return
    for i in range(8):
        if row[h] and col[i] and dops[h+i] and dneg[h-i+7] and cnt:
            sett(i, h)
            ans[h] = i
            
            serch(h+1)
            
            dsett(i, h)
            del ans[h]

ans = {}          
serch(0) 

    
    


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

main(){
    int n,W,i,s1=0,s2,ans,max=99999999;
    cin >> n;
    vector<int> w(n);
    for(i=0;i<n;i++) cin >> w[i];

    W=accumulate(w.begin(), w.end(), 0);
    for(i=0;i<n;i++){
        s1+=w[i];
        if(abs(s1-(W-s1))<max){
            max=abs(s1-(W-s1));
        }
    }
    cout << max << endl; 
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()

x1 = a / 0.08
y1 = b /0.1
x2 = (a+1) / 0.08
y2 = (b+1) /0.1


# exit()
if ceil(y1) <= ceil(x1) < y2:
    ans = ceil(x1)
    print(ans)
elif ceil(x1) <= ceil(y1) < x2:
    ans = ceil(y1)
    print(ans)
else:
    print(-1)



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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void){
    ll x;
    cin>>x;
    rep(a,0,10000+1){
        rep(b,-10000,a){
            ll num = a*a*a*a*a - b*b*b*b*b;
            if(num==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }

    return 0;

}

Measured memory_bytes: 3632
import sys

def read():
    return sys.stdin.readline().rstrip()

def main():
    h, w = map(int, read().split())
    s = [list(read()) for _ in range(h)]
    row = [[0 for _ in range(w)] for _ in range(h)]
    col = [[0 for _ in range(w)] for _ in range(h)]
    for i in range(h):
        c = 0
        for j in range(w):
            if s[i][j] == "#":
                for k in range(j - c, j):
                    row[i][k] = c
                c = 0
            else:
                c += 1
        for k in range(w - c, w):
            row[i][k] = c
    for i in range(w):
        c = 0
        for j in range(h):
            if s[j][i] == "#":
                for k in range(j - c, j):
                    col[k][i] = c
                c = 0
            else:
                c += 1
        for k in range(h - c, h):
            col[k][i] = c
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(row[i][j] + col[i][j], ans)
    print(ans - 1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 250760
N=int(input())
P=[0]+list(map(float,input().split()))

DP=[[0]*(N+1) for _ in range(N+1)]
DP[0][0]=1

for i in range(N):
    for j in range(i+1):
        DP[i+1][j+1]+=DP[i][j]*P[i+1]
        DP[i+1][j]+=DP[i][j]*(1-P[i+1])

#for row in range(N+1):
    #string=''
    #for column in range(N+1):
        #string+=str(DP[row][column])+' '
    #print(string)

ans=0
half=(N+1)//2
for k in range(half,N+1):
    ans+=DP[N][k]

print(ans)

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(auto& i : a) cin >> i;
    for(auto& i : b) cin >> i;

    vector<pair<ll,ll>> ha(n), hb(n);
    
    REP(i, n){
        if(i == 0){
            ha[i].first = ha[i].second = a[i];
        }else{
            if(a[i] > a[i-1]){
                ha[i].first = ha[i].second = a[i];
            }else{
                ha[i].first = 1;
                ha[i].second = a[i];
            }
        }
    }

    RREP(i, n){
        if(i == n-1){
            hb[i].first = hb[i].second = b[i];
        }else{
            if(b[i] > b[i+1]){
                hb[i].first = hb[i].second = b[i];
            }else{
                hb[i].first = 1;
                hb[i].second = b[i];
            }
        }
    }

    ll ans = 1;
    REP(i, n){
        ll d = min(ha[i].second, hb[i].second) - max(ha[i].first, hb[i].first) + 1;
        if(d < 0) ans = 0;
        ans *= d;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>

using namespace std;

int main(){
	int n,m,k,l;
	char a[105][105];
	while(1){
		scanf("%d %d",&n,&m);
		if( n==0 && m==0 ) break;
		k=0; l=0;
		for(int i=0 ; i<n ; i++ ){
			scanf("%s",&a[i]);	
		}
		int b[105][105]={0};
		while(1){
			if(a[k][l]=='.'){
				printf("%d %d\n",l,k);
				break;
			}
			if(b[k][l]==1){
				printf("LOOP\n");
				break;
			}
			if(a[k][l]=='>'){
				b[k][l]=1;
				l++;
				continue;
			}
			if(a[k][l]=='v'){
				b[k][l]=1;
				k++;
				continue;
			}
			if(a[k][l]=='<' ){
				b[k][l]=1;
				l--;
				continue;
			}
			if(a[k][l]=='^' ){
				b[k][l]=1;
				k--;
				continue;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2692
import math
(N, P) = map(int, input().split())

p = P
primes = {}
d = 2
maxd = int(math.sqrt(P))

while d <= maxd and p > 1:
    while p%d == 0:
        if d not in primes:
            primes[d] = 1
        else:
            primes[d] += 1
        p = p//d
    d += 1
if p > 1:
    primes[p] = 1
#print(primes)

ans = 1
for k in primes:
    n = primes[k]//N
    if n > 0:
        ans *= k**n

print(ans)



Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
char s[15];

int main()
{
	cin>>s;
	rep(i,4)
	{cout<<s[i];}
	cout<<" ";
	rep2(i,4,12)
	{
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T=1;
    //cin >> T;
    while(T--){
      ll n,m,k;
      cin>>n>>m>>k;
      ll a[n], b[m];
      rep(i,n) cin>>a[i];
      rep(i,m) cin>>b[i];
      ll l=0;
      ll sum=0;
      rep(i,n){
        if(sum+a[i]>k) break;
        else{
            sum+=a[i];
            l++;
        }
      }
      ll ans=l;
      rep(i,m){
        if(sum+b[i]<=k){
            sum+=b[i];
            ans=max(ans, i+1+l);
        }
        else{
            if(l==0) break;
            else{
                l--;
                sum-=a[l];
                i--;
            }
        }
      }
      cout<<ans<<el;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 6936
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,d;
  cin>>n>>d;
  vector<int> a(d);
  for(int i=0;i<d;i++){
    cin>>a.at(i);
  }
  if(d==1)
    cout<<n-1;
  else{
    sort(a.begin(),a.end());
    if(a.back()-(n-a.back())>1){
      cout<<a.back()-(n-a.back())-1;
    }else
      cout<<0;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 500001

static int H;
static int A[MAX];

static void maxHeapify(int i)
{
    int left = 2 * i;
    int right = 2 * i + 1;
    int largest;

    if (left <= H && A[left] > A[i]) {
        largest = left;
    } else {
        largest = i;
    }

    if (right <= H && A[right] > A[largest]) {
        largest = right;
    }

    if (largest != i) {
        int tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(largest);
    }
}

int main()
{
    scanf("%d", &H);
    for (int i = 1; i <= H; i++) {
        scanf("%d", &A[i]);
    }

    for (int i = H / 2; i >= 1; i--) {
        maxHeapify(i);
    }

    for (int i = 1; i <= H; i++) {
        printf(" %d", A[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1]; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1]; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define pb(x) push_back(x)
#define vi vector <int>
#define pi pair <int, int>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	READ(r);
	cout << 3*r*r;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  char b;
  scanf("%s",&b);
  if(b=='A'){
    printf("T");
  }else if(b=='T'){
    printf("A");
  }else if(b=='G'){
    printf("C");
  }else if(b=='C'){
    printf("G");
  }
  return 0;
}

Measured memory_bytes: 128
f=lambda:map(int,input().split())
n,m=f()
c=[[] for _ in range(n+1)]
for _ in range(m):
    a,b=f()
    c[a]+=[b]
    c[b]+=[a]
print("IMPOSSIBLE" if all(n not in c[i] for i in c[1]) else "POSSIBLE")

Measured memory_bytes: 41784
n=int(input())
ls=[0]*n
x=1
y=1
z=1
p=6
m=int(n**0.5)
for x in range(1,m+3):
  for y in range(1,x+1):
    for z in range(1,y+1):
      k=6
      if x==y or y==z:
        k=3
        if x==z:
          k=1
      j=x*x+y*y+z*z+x*y+y*z+x*z
      if j<=n:
        ls[j-1]+=k
      else:
        break
for i in ls:
  print(i)


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

int main()
{
  int N;
  cin >> N;
  cout << pow(N, 3) << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
  int N;
  int i, j;
  scanf("%d", &N);

  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) {
      if (i*j == N) {
        printf("Yes\n");
        return 0;
      }
    }
  }

  printf("No");


}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    vector<vector<int>> sw(m, vector<int>(0));
    vector<int> p(m, 0);
    for (auto i = 0; i < m; i++) {
        int k; cin >> k;
        for (auto j = 0; j < k; j++) {
            int s; cin >> s;
            sw[i].push_back(s - 1);
        }
    }
    for (auto i = 0; i < m; i++) cin >> p[i];

    int ans = 0;
    for (auto i = 0; i < (1 << n); i++) {
        int cnt = 0;
        for (auto j = 0; j < m; j++) {
            int sw_cnt = 0;
            for (auto k = 0; k < (int)sw[j].size(); k++) {
                if(i & (1 << sw[j][k])) sw_cnt++;
            }
            if (sw_cnt % 2 == p[j]) cnt++;
        }
        if(cnt == m) ans++;
    }

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

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MOD 1000000007L
#define INF 100000000000

signed main() {
	string s;
	cin >> s;
	if (s.substr(0, 4) == "YAKI") {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <string>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

typedef pair<int,int> P;
const int HMAX = 1005, WMAX = 1005;
int W, H;
P par[HMAX][WMAX];
int lank[HMAX][WMAX];
char field[HMAX][WMAX];
const int DX[4] = {0, 1, 0, -1}, DY[4] = {1, 0, -1, 0};

void init() {
  REP(y, H) REP(x, W) {
    par[y][x] = make_pair(y, x);
    lank[y][x] = 0;
  }
}

P find(P p) {
  if (par[p.first][p.second] == p) {
    return p;
  } else {
    return par[p.first][p.second] = find(par[p.first][p.second]);
  }
}

void unite(P i, P j) {
  i = find(i);
  j = find(j);
  if (i == j) return;
  int li = lank[i.first][i.second], lj = lank[j.first][j.second];
  if (li < lj) {
    par[i.first][i.second] = j;
    return;
  } else {
    par[j.first][j.second] = i;
    if (li == lj)
      lank[i.first][i.second]++;
    return;
  }
}

bool same(P i, P j) {
  return find(i) == find(j);
}

bool islegal(P p) {
  int y = p.first, x = p.second;
  return 0 <= x and x <= W and 0 <= y and y < H;
}

bool is_floor(int y, int x, char c) {
  return islegal(P(y, x)) && field[y][x] == c;
}

int main() {
  cin >> W >> H;
  P start = P(0, 0), tr;
  REP(y, H) {
    string row;
    cin >> row;
    REP(x, W) {
      field[y][x] = row[x];
    }
  }
  init();
  REP(y, H) REP(x, W) {
    P p(y, x);
    if (field[y][x] == '#') continue;
    if (field[y][x] == 't') {
      tr = p;
      field[y][x] = '.';
    }
    REP(i, 4) {
      P n(y + DY[i], x + DX[i]);
      if (is_floor(n.first, n.second, '.')) unite(p, n);
    }
  }
  int t;
  cin >> t;
    if (same(tr, start)) {
      cout << 0 << endl;
      return 0;
    }
  for (int i = 1; i <= t; i++) {
    int x, y;
    cin >> x >> y;
    field[y][x] = '.';
    REP(dir, 4) {
      int ny = y + DY[dir], nx = x + DX[dir];
      if (is_floor(ny, nx, '.')) unite(P(ny,nx),P(y,x));
    }
    if (same(tr, start)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    rep(i, b) cout << a;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
stair = list(map(int,input().split()))
dp = [0 for i in range(n)]
for i in range(1,n):
    if(i == 1):
        dp[i] = dp[i-1]+abs(stair[i]-stair[i-1])
    else:
        dp[i] = min(dp[i-1]+abs(stair[i]-stair[i-1]),dp[i-2]+abs(stair[i]-stair[i-2]))
    # print(dp[i])
print(dp[-1])

Measured memory_bytes: 20592
# coding: utf-8
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i * 500 + j * 100 + k * 50 == X:
                cnt = cnt + 1
                
print(cnt)


Measured memory_bytes: 2940
// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;
int N;
const int M=1e5+10;
vector<int> g[M];
int dist[2][M],id;
void dfs(int now,int past=-1) {
	if(past!=-1) dist[id][now]=dist[id][past]+1;
	for(int i=0;i!=g[now].size();i++) if(g[now][i]!=past) dfs(g[now][i],now);
}
int main() {
	cin>>N;
	for(int i=0;i<N-1;i++) {
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	id=0;
	dfs(0);
	id=1;
	dfs(N-1);
	int ret=0;
	for(int i=0;i<N;i++) {
		if(dist[0][i]<=dist[1][i]) ret++;
	}
	if(ret>=(N+2)/2) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
	return 0;
}

Measured memory_bytes: 11136
import heapq, copy
n, k = map(int, input().split())
v = list(map(int, input().split()))
ans = -10 ** 10
for a in range(min(n, k) + 1):
    for b in range(min(n, k) - a + 1):
        have = []
        for i in range(a):
            have.append(v[i])
        for i in range(b):
            have.append(v[-i-1])

        tmp = sum(have)
        # heapq.heapify(have)
        have.sort()
        ans = max(ans, tmp)

        for c in range(k - a - b):
            if c >= len(have):
                break
            item = have[c]
            if item >= 0:
                break

            tmp -= item
            ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 74820
#include<cstdio>
bool first = true;
void write(int n){
  if(first){
    first=false;
    printf("%d",n);
  }else{
    printf(" %d",n);
  }
}
int main(){
  int n;
  while(scanf("%d",&n)>0){
    first = true;
    if(n&0x1)write(0x1);
    if(n&0x2)write(0x2);
    if(n&0x4)write(0x4);
    if(n&0x8)write(0x8);
    if(n&0x10)write(0x10);
    if(n&0x20)write(0x20);
    if(n&0x40)write(0x40);
    if(n&0x80)write(0x80);
    if(n&0x100)write(0x100);
    if(n&0x200)write(0x200);
    printf("\n");
  }
}

Measured memory_bytes: 1012
import java.util.Arrays;
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    final int inf = (int) 1e9 + 5;
    int n = sc.nextInt(), k = sc.nextInt();
    int[] h = new int[n];
    for (int i = 0; i < n; i++) h[i] = sc.nextInt();
    int[] dp = new int[n];
    Arrays.fill(dp, 1, n, inf);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
      int[] a = new int[k + 1];
      for (int g = 1; g <= k; g++)
        a[g] = i + g;
      for (int j : a)
        if (j < n) {
          dp[j] = Math.min(dp[j], dp[i] + Math.abs(h[i] - h[j]));
        }
    }
    System.out.println(dp[n - 1]);
  }
}


Measured memory_bytes: 63040