akhauriyash/Code-Regression huggingface dataset:
//Compiler optimization
#pragma GCC optimize("Ofast")

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

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)
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 (a>b) { a=b; return 1; } return 0; }
ll pow(ll a,ll n, ll m){
    ll ret=1;
    for(;n>0;n>>=1,a=a*a%m){
        if(n%2==1){
        ret=ret*a%m;
        }
    }
    return ret;
}

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;

struct UnionFind {
    vi par; // par[i]:iの親の番号 
    vi sizes; //根ノードiの木に含まれるデータの数

    UnionFind(int N) : par(N), sizes(N, 1){ //最初は全てが根であるとして初期化
        fr(i,N) par[i] = i;
    }

    int find(int x){//データxが属する木の根を再帰関数で獲得　:root(x) = {xの木の根}
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y){ //xの木とyの木を併合
        int rx = find(x);
        int ry = find(y);
        if(rx == ry) return;
        if(sizes[x] < sizes[y]) swap(x,y);
        par[ry] = rx;
        sizes[rx] += sizes[ry];
        sizes[ry] = 0;
    }

    bool same(int x, int y){ // 同じ木に属するかどうか
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }

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



int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    ll n,m;
    cin >> n >> m;
    auto uf = UnionFind(n);
    ll a,b;
    fr(i,m){
        cin >> a >> b;
        uf.unite(a-1, b-1);
    }
    int res = 0;
    fr(i,n)chmax(res, uf.size(i));
    cout << res << endl;
}

Measured memory_bytes: 4948
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();

		if(b<=a) {
			System.out.println("delicious");
		}else if(b-a<=x) {
			System.out.println("safe");
		}else {
			System.out.println("dangerous");
		}

	}
}




Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
set<string> a;//自动去重
int n;
string s; 
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		a.insert(s);
	}
	cout<<a.size();
return 0;
}


Measured memory_bytes: 19100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;
const ll inf = 1001001001;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = n;
    int counts=0, countt=0;

    if(s[0]=='S')counts++;
    else countt++;

    rep(i, 1, n){
        if(s[i]=='S'){
            if(s[i-1]=='T'){
                ans -= 2*min(counts, countt);
                if(counts > countt){
                    counts = counts-countt+1; 
                    countt = 0;
                }
                else{
                    counts = 1;
                    countt = 0;
                }
            }
            else counts++;
        }
        if(s[i]=='T'){
            countt++;
        }
    }
    if(countt >0) ans -= 2*min(counts, countt);

    cout << ans << endl;

}

Measured memory_bytes: 640
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        k: usize,
        mut ll: [usize; n]
    };
    ll.sort();
    ll.reverse();
    println!("{}", ll[0..k].iter().sum::<usize>());
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S;
    cin >> S;
    cout << 700 + count( begin( S ), end( S ), 'o' ) * 100 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>

using ll = long long;

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

    std::vector<int>A(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> A[i];
    }

    ll sum = 0;
    int min = 1'000'000'000;
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if (A[i] < 0)cnt++;
        int abs = std::abs(A[i]);
        sum += abs;
        min = std::min(abs, min);
    }

    if (cnt % 2 == 1)
    {
        sum -= (min * 2);
    }
    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long n,k,a,b,counter;
vector<int> arr,brr,crr;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for (int i=0;i<n;i++){
        crr.push_back(i+1);
        cin>>k;
        arr.push_back(k);
    }
    for (int i=0;i<n;i++){
        cin>>k;
        brr.push_back(k);
    }
    do {
        counter++;
        if (arr==crr) a=counter;
        if (brr==crr) b=counter;
    } while (next_permutation(crr.begin(),crr.end()));
    cout<<abs(a-b);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;


int main(void){
    string s,t;
    cin>>s>>t;
    int ans=0;
    if(s[0]==t[0])ans++;
    if(s[1]==t[1])ans++;
    if(s[2]==t[2])ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = map(int, input().split())

A = sorted(enumerate(A), key=lambda x: x[1], reverse=True)
dp = [[0]*(N+1) for _ in range(N+1)]

for n, (from_i, a) in enumerate(A):
    for j in range(n + 1):
        dp[n+1][j+1] = max(dp[n+1][j+1], dp[n][j] + a*(from_i - j))
        dp[n+1][j] = max(dp[n+1][j], dp[n][j] + a*(N - (n - j) - 1 - from_i))

print(max(dp[N]))


Measured memory_bytes: 93708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
  ll n; cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  ll res = 0;
  rep(i, n) {
    if (i == 0) continue;
    if (v.at(i-1) > v.at(i)) {
      res += v.at(i-1) - v.at(i);
      v.at(i) = v.at(i-1);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 4848
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    f = list(map(int, input().rstrip('\n').split()))
    f.sort(reverse=True)
    cor_v = 10 ** 13
    inc_v = -1
    while cor_v - inc_v > 1:
        bin_v = (cor_v + inc_v) // 2
        cost = 0
        #条件を満たすcostを全検索
        for i in range(n):
            t = a[i] * f[i]
            if t > bin_v:
                cost += (t - bin_v + f[i] - 1) // f[i]
        #costが制約を満たすか
        if cost <= k:
            cor_v = bin_v
        else:
            inc_v = bin_v
    print(cor_v)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 113364
s=str(input())
if len(s)==1:
	if s[0]=='L':
		print('No')
	else:
		print('Yes')
else:		
	ans='Yes'
	i=0
	while 2*i+1<len(s):
		if s[2*i]=='L':
			ans='No'
		if s[2*i+1]=='R':
			ans='No'
		i+=1
	print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define sz(x) (x).size()
#define lowbit(x) (x)&(-x)
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
#define int long long
namespace FastIO {
#define BUF_SIZE 100000
#define OUT_SIZE 100000
	bool IOerror=0;
	inline char nc() {
		static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
		if(p1==pend) {
			p1=buf;
			pend=buf+fread(buf,1,BUF_SIZE,stdin);
			if(pend==p1) {
				IOerror=1;
				return -1;
			}
		}
		return *p1++;
	}
	inline bool blank(char ch) {
		return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';
	}
	template<class T> inline bool read(T &x) {
		bool sign=0;
		char ch=nc();
		x=0;
		for(; blank(ch); ch=nc());
		if(IOerror)return false;
		if(ch=='-')sign=1,ch=nc();
		for(; ch>='0'&&ch<='9'; ch=nc())x=x*10+ch-'0';
		if(sign)x=-x;
		return true;
	}
	template<class T,class... U>bool read(T& h,U&... t) {
		return read(h)&&read(t...);
	}
#undef OUT_SIZE
#undef BUF_SIZE
};
using namespace std;
using namespace FastIO;

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

const int INF = 0x3f3f3f3f;
const int N = 2e6+10;

struct node {
	int l,r,mid,ma;
} tree[N];

int a[N],ans[N];
vector<int>e[N];
int n;

void pp(int x) {
	tree[x].ma=max(tree[ls].ma,tree[rs].ma);
}

void build(int x,int l,int r) {
	tree[x]= {l,r,(l+r)/2,0};
	if(l==r) {
		return ;
	}
	int mid=tree[x].mid;
	build(ls,l,mid);
	build(rs,mid+1,r);
}

void modify(int x,int pos,int k) {
	if(tree[x].l==pos && tree[x].r==pos) {
		tree[x].ma=k;
		return ;
	}
	int mid=tree[x].mid;
	if(pos<=mid) modify(ls,pos,k);
	if(pos>mid) modify(rs,pos,k);
	pp(x);
}

int query(int x,int l,int r) {
	if(l<=tree[x].l&&tree[x].r<=r) {
		return tree[x].ma;
	}
	int mid=tree[x].mid;
	int res=0;
	if(l<=mid) res=max(res,query(ls,l,r));
	if(r>mid) res=max(res,query(rs,l,r));
	return res;
}

void dfs(int u,int fa) {
	int now=a[u];
	int sum=query(1,1,now-1)+1;
	int pre=query(1,now,now);
	modify(1,now,max(sum,pre));
	ans[u]=query(1,1,n+5);
	for(auto v:e[u]) {
		if(v==fa) continue;
		dfs(v,u);
	}
	modify(1,now,pre);
}


signed main() {

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

	
	read(n);
	vector<int>b;
	for(int i=1; i<=n; i++) {
		read(a[i]);
		b.pb(a[i]);
	}
	sort(all(b));
	b.erase(unique(all(b)),b.end());
	for(int i=1; i<=n; i++) a[i]=lower_bound(all(b),a[i])-b.begin()+2;
	for(int i=1; i<n; i++) {
		int u,v;
		read(u,v);
		e[u].pb(v);
		e[v].pb(u);
	}
	build(1,1,n+5);
	dfs(1,1);
	for(int i=1; i<=n; i++)	cout<<ans[i]<<"\n";





	return 0;
}



Measured memory_bytes: 88904
#include <stdio.h>
 
int main(){
 int n;
 scanf("%d",&n);
 while(n){
  int a=0,b=0,aa,bb;
  for(int i=n;i>0;i--){
   scanf("%d %d",&aa,&bb);
   if(aa>bb){
    a+=aa+bb;
   }else if(aa<bb){
    b+=aa+bb;
   }else{
    a+=aa;
    b+=bb;
   }
  }
  printf("%d %d\n",a,b);
  scanf("%d",&n);
 }
}

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


int main(){
	long long  h,ans,c;
	ans=1;
	c=1;
	cin>>h;
	while(h>1)
	{
		h=h/2;
		ans=ans*2;
		c=c+ans;		
	}
	cout<<c;
return 0 ;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,m,k,wa;
  cin>>n>>m;
  k=0;
  wa=0;
  for(long i=0; i<m; i++){
    cin>>k;
    wa=wa+k;
  }
  if(wa>n){
    k=-1;
    cout<<k;
  }
  else{
    cout<<n-wa;
  }
}

Measured memory_bytes: 3624
def s():
 def b(M,x,y,n=1):
  M[x][y]=0;a=n
  if M[x-1][y]:a=max(a,b(M,x-1,y,n+1))
  if M[x][y-1]:a=max(a,b(M,x,y-1,n+1))
  if M[x+1][y]:a=max(a,b(M,x+1,y,n+1))
  if M[x][y+1]:a=max(a,b(M,x,y+1,n+1))
  M[x][y]=1
  return a
 for e in iter(input,'0'):
  n,m=int(e),int(input())
  P=[[0]*(n+2)for _ in[0]*(m+2)]
  for i in range(m):P[i+1][1:-1]=map(int,input().split())
  print(max(b(P,i,j)for i in range(1,m+1)for j in range(1,n+1)if P[i][j]))
if'__main__'==__name__:s()


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

int main() {
  string str;
  int cntZero = 0;
  int cntOne = 0;
  
  cin >> str;
  
  for(int i = 0; i < str.size(); i++){
    if(str.at(i) == '0') cntZero++;
    else cntOne++;
  }
  
  cout << min(cntZero, cntOne) * 2;
}


Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h: usize = read();
    let w: usize = read();
    let d: usize = read();
    let mut map: Vec<(i64, i64)> = vec![(0, 0); h * w + 1];

    for i in 0..h {
        for j in 0..w {
            let a: usize = read();
            map[a] = (i as i64, j as i64);
        }
    }

    let mut a: Vec<(usize, usize)> = vec![];
    let q: usize = read();
    for _ in 0..q {
        let l: usize = read();
        let r: usize = read();
        a.push((l, r));
    }
    let mut dist: Vec<Vec<i64>> = vec![vec![0; (h * w / d + 1) as usize]; d];

    for i in 1..h * w + 1 {
        if i <= d {
            continue;
        }
        if i > d {
            let a = map[i];
            let b = map[i - d];
            dist[i % d][i / d] = dist[i % d][i / d - 1] + (a.0 - b.0).abs() + (a.1 - b.1).abs();
        }
    }

    for i in 0..a.len() {
        let ai = a[i];
        println!("{}", dist[ai.1 % d][ai.1 / d] - dist[ai.0 % d][ai.0 / d]);
    }
}


Measured memory_bytes: 12668
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	A, B, M := getInt(), getInt(), getInt()
	a := make([]int, A)
	b := make([]int, B)

	minA := 1001001001
	minB := 1001001001
	for i := 0; i < A; i++ {
		a[i] = getInt()
		if a[i] < minA {
			minA = a[i]
		}
	}
	for i := 0; i < B; i++ {
		b[i] = getInt()
		if b[i] < minB {
			minB = b[i]
		}
	}
	minAB := 1001001001
	for i := 0; i < M; i++ {
		x, y, c := getInt()-1, getInt()-1, getInt()
		sum := a[x] + b[y] - c
		if minAB > sum {
			minAB = sum
		}
	}
	ans := minA + minB
	if ans > minAB {
		ans = minAB
	}
	out(ans)
}


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

int main() {
    vector<vector<int>> vec(100, vector<int>(100, 0));
    cin >> vec.at(99).at(99);
    int num = vec.at(99).at(99);
    cout << num * num * num << endl;
}


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

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

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

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

  cout << a[n-1] - a[0] << endl;

  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[15];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	bool ok=true;
	if(in[0]!='A')ok=false;
	int cnt=0;
	for(int i=2;i<n-1;i++){
		if(in[i]=='C'){
			cnt++;
			in[i]='c';
		}
	}
	if(cnt!=1)ok=false;
	for(int i=1;i<n;i++){
		if(in[i]<'a'||in[i]>'z')ok=false;
	}
	if(ok)printf("AC\n");else printf("WA\n");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long int
#define PB push_back
using namespace std;
const int INF = 3643648101919114514;
const int MOD = (int)1e9 + 7;

int n, a[200010], b[200010];
int dp1[4010][4010], dp2[4010][4010];
int ans = 0;

signed main()
{
  cin >> n;
  for(int i = 1; i <= n; i++){
    cin >> a[i] >> b[i];
    dp1[2005 - a[i]][2005 - b[i]]++;
  }

  for(int i = 1; i <= 4008; i++){
    for(int j = 1; j <= 4008; j++){
      dp1[i][j] += dp1[i - 1][j] + dp1[i][j - 1];
      dp1[i][j] %= MOD;
    }
  }

  dp2[0][0] = 1;
  for(int i = 0; i <= 4008; i++){
    for(int j = 0; j <= 4008; j++){
      if(i > 0)
	dp2[i][j] += dp2[i - 1][j];
      if(j > 0)
	dp2[i][j] += dp2[i][j - 1];
      dp2[i][j] %= MOD;
    }
  }

  for(int i = 1; i <= n; i++){
    ans += dp1[2005 + a[i]][2005 + b[i]];
    ans %= MOD;
  }
  for(int i = 1; i <= n; i++){
    ans -= dp2[a[i] * 2][b[i] * 2];
    ans += MOD;
    ans %= MOD;
  }

  cout << ans * 500000004 % MOD<< endl;
  return 0;
}


Measured memory_bytes: 254592
#include<bits/stdc++.h>
using namespace std;
 
#define NL '\n'
#define xx first
#define yy second
#define ll long long
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define async() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 
#define FayeValentine 
void dz(){cerr<<NL;}template<typename H,typename... T> void dz(H h,T... t){cerr<<' '<<h;dz(t... );}
#ifdef  FayeValentine
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",dz(__VA_ARGS__)
#else
#define debug(...) 
#endif

//bitwise sieve && segmented sieve
const int M = 50000, R = 100000; //limit of seive and max range of segment 
int marked[(M>>6)+9], segment[(R>>6)+9]; //prime flags
vector<int>primes; vector<ll>segment_primes; //primes are stored here
#define ifc(z, n) (z[n>>6]&(1<<((n>>1)&31))) //checks if composite
#define isc(z, n) (z[n>>6]|=(1<<((n>>1)&31))) //marks as composite
void sieve(int n){ //memset "marked" to zero
  for(int i = 3; i*i <= n; i+=2) if(!ifc(marked, i)) 
    for(int j = i * i; j <= n; j += (i + i)) isc(marked, j); 
  primes.pb(2);
  for(int i = 3; i <= n; i+=2) if(!ifc(marked, i)) primes.push_back(i); 
}


void absinthe() {
	sieve(M);
	int n, i = 0; cin >> n;
	for(int i = 0; i < M; i++) {
		if(primes[i]%5==1) {
			n--;	
			cout << primes[i] << " ";
		}
		
		if(n == 0) return;
	}
}

 
int main(){
  async();
  int __t = 1, __c; //cin >> __t;
  for(__c = 1; __c <=__t; __c++) {
    //cout << "Case " << __c << ": "; 
    absinthe();
  }
}  


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

int main(void){
    string S, T;
    cin >> S;
    cin >> T;
    int i;
    T = T.erase(T.size()-1);
    i=(S==T);

    if(i) cout << "Yes"  << endl;
    else cout << "No"  << endl;
    
    return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

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

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int x[n];
    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }
    vector<int> dis(100);
    for(int i = 0; i < 100; i++) {
        for(int j = 0; j < n; j++) {
            dis[i] += pow((x[j] - i - 1), 2);
        }
     }
     cout << *min_element(dis.begin(), dis.end()) << endl;
    return 0;
}

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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int[] rgb = new int[] { input[0], input[1], input[2] };
        Array.Sort(rgb);
        rgb.Reverse();
        int N = input[3];
        long cnt = 0;
        for (int i = N / rgb[0]; i >= 0; i--)
        {
            for (int j = (N - i * rgb[0]) / rgb[1]; j >= 0; j--)
            {
                if ((N - i * rgb[0] - j * rgb[1]) % rgb[2] == 0) cnt++;
            }
        }

        return cnt.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11220
/**
 * ??????????????¨????????????

n??m ????????? A ??¨???m ?? 1 ?????????????????? b ??????????????????A ??¨ b ?????????????????????????????°????????????????????????????????????

?¬????????????? m ????????°??????????????????????????? m ?? 1????????????????????¨???????????????

b={b1, b2, bm}
?¬????????????? n ????????°??????????????????????????? m ????¨?????????????????????? n ?? m ???????????¨???????????????

??????????????????????????????????????????????????°????????¨???????´???¨?????????m ?? 1 ?????????????????? b ???????????? i ?????????????´???? bi(i=1,2,...,m)???n ?? m ????????? A ?????? n ?? m ??????????´????????????????i ??? j ?????????????´???? aij(i=1,2,...,n,j=1,2,...,m) ??§??????????????????

n ?? m ????????? A ??¨ m ?? 1 ?????????????????? b ????????????n ?? 1 ?????????????????? c ??¨?????????c ??? i ?????????????´? ci ????¬?????????§??????????????????

ci=???j=1maijbj=ai1b1+ai2b2+...+aimbm

Input
???????????? n ??¨ m ????????????????????§??????????????????????¶???? n ???????????? A ???????´? aij ????????????????????§??????????????????????¶???? m ?????????????????? b ???????´? bi ?????????????????????????????????????????????

Output
????????? n ???????????????????????????????????? c ???????´? ci ???????????????????????????????????????????????????

Constraints
1???n,m???100
0???bi,aij???1000

Sample Input
3 4
1 2 0 1
0 3 0 1
4 1 1 0
1
2
3
0

Sample Output
5
6
9
 */

#include <iostream>
#include <sstream>
#include <vector>

int main(int argc, char const *argv[]) {
  unsigned short m, n;
std::string Param;
std::istringstream iss;
  while (true) {


  getline(std::cin, Param);
  iss.str(Param);
  iss >> n >> m;
iss.clear();
  if (n > 100 || m > 100) {
    std::cout << "Error: 0 < m, n < 100" << std::endl;
  } else {
    break;
  }
}

std::vector<std::vector<unsigned short>> Matrix(n, std::vector<unsigned short>(m, 0));

for (size_t i = 0; i < n; i++) {
  getline(std::cin, Param);
  iss.str(Param);
  for (size_t j = 0; j < m; j++) {
    iss >> Matrix[i][j];
  }
  iss.clear();
}

std::vector<unsigned short> Vector(m, 0);
for (size_t i = 0; i < m; i++) {
  getline(std::cin, Param);
  iss.str(Param);
  iss >> Vector[i];
  iss.clear();
}
unsigned int p = 0;
for (size_t i = 0; i < n; i++) {
  p = 0;
  for (size_t j = 0; j < m; j++) {
    p += Matrix[i][j] * Vector[j];
  }
  std::cout << p << std::endl;
}
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S.at(0) == 'R' && S.at(1) == 'R' && S.at(2) == 'R' ) {
  cout << "3" << endl;
}
else if (S.at(0) == 'R' && S.at(1) == 'R' && S.at(2) == 'S') {
  cout << "2" << endl;
}
else if (S.at(0) == 'S' && S.at(1) == 'R' && S.at(2) == 'R') {
  cout << "2" << endl;
}
else if (S.at(0) == 'R' && S.at(1) == 'S' && S.at(2) == 'R') {
  cout << "1" << endl;
}
  else if (S.at(0) == 'R' && S.at(1) == 'S' && S.at(2) == 'S') {
  cout << "1" << endl;
}
  else if (S.at(0) == 'S' && S.at(1) == 'R' && S.at(2) == 'S') {
  cout << "1" << endl;
}
  else if (S.at(0) == 'S' && S.at(1) == 'S' && S.at(2) == 'R') {
  cout << "1" << endl;
}
  else if (S.at(0) == 'S' && S.at(1) == 'S' && S.at(2) == 'S') {
  cout << "0" << endl;
}
return 0;
}


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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){

    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i,n)cin >> h[i];

    ll dp[110000];
    REP(i,110000)dp[i] = LINF;
    dp[0] = 0;

    REP(i,n){
        REPS(j,k){
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 4504
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    vector<ll> d(N);
    for (int i = 0; i < N; i++) cin >> d[i];
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
    return 0;
}


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

using namespace std;
ll computeXOR(ll n)
{
    // Modulus operator are expensive on most of the
    // computers. n & 3 will be equivalent to n % 4.

    switch(n & 3) // n % 4
    {
    case 0:
        return n;     // if n is multiple of 4
    case 1:
        return 1;     // If n % 4 gives remainder 1
    case 2:
        return n + 1; // If n % 4 gives remainder 2
    case 3:
        return 0;     // If n % 4 gives remainder 3
    }
}

int main()
{
    ll A,B;  cin >> A >> B;
    ll z = computeXOR(B) ^ computeXOR(A - 1);
    cout << z;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n,m,Q1[maxn],Q2[maxn];
vector<int>A[maxn];

int serch(int x,int y)
{
    int l = 0,r = A[x].size();
    int res;
    while(l <= r)
    {
        int m = (l + r) / 2;
        if(A[x][m] < y)
        {
            l = m + 1;
        }
        else if(A[x][m] == y)
        {
            res = m;
            break;
        }
        else if(A[x][m] > y)
        {
            r = m - 1;
        }
    }
    return res + 1;
}

int main()
{
    scanf("%d %d",&n,&m);
    for(int i = 1;i <= m;i++)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        A[x].push_back(y);
        Q1[i] = x,Q2[i] = y;
    }
    for(int i = 1;i <= n;i++)
    {
        if(A[i].size() == 0) continue;
        sort(A[i].begin(),A[i].end());
    }
    for(int i = 1;i <= m;i++)
    {
        int turn = serch(Q1[i],Q2[i]);
        printf("%06d%06d\n",Q1[i],turn);
    }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int a,b;
  a = (s[0] - '0') * 10 + (s[1] - '0');
  b = (s[2] - '0') * 10 + (s[3] - '0');
  if (a >= 1 && a <= 12) {
    if (b >= 1 && b <= 12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }else {
    if (b >= 1 && b <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 256
def check(human):
    sum = 0
    for i in human:
        if(i == 0):
            sum += 1
    return sum

def resolve():
    data = [int(i) for i in input().split()]
    
    human = [0 for i in range(data[0])]
    sweet = data[1]
    
    for i in range(sweet):
        mem = int(input())
        have = [int(j) for j in input().split()]
        
        for k in have:
            human[k-1] += 1
    
    print(check(human))
resolve()

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

#define all(x) (x).begin(), (x).end()
#define szof(x) int32_t((x).size())
#define str(x) to_string(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const ll MOD998 = 998244353;
const int INF = 1e9;
const ll LLINF = 1e18;

mt19937_64 rng((uint) chrono::steady_clock::now().time_since_epoch().count());

template <class T>
T rnd(T l, T r) {
	return uniform_int_distribution<T>(l, r)(rng);
}

void run() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int &x : a) {
		cin >> x;
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		for (int prev = max(0, i - 2); prev < i; prev++) {
			dp[i] = min(dp[i], dp[prev] + abs(a[prev] - a[i]));
		}
	}
	cout << dp.back() << "\n";
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cout.precision(10); cout << fixed;
	int tests = 1;
	// cin >> tests;
	while (tests--) {
		run();
	}
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
	return 0;
}


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

int main(void)
{
    ll N, M;
    cin >> N >> M;
    priority_queue<ll> A;
    ll a;
    for(ll i=0;i<N;i++){
        cin >> a;
        A.push(a * -1);
    }
    ll b, c;
    priority_queue<pair<ll, ll> > bc; 
    for(ll i=0;i<M;i++){
        cin >> b >> c;
        bc.push(make_pair(c, b));
    }
    ll max_number = 0;
    while(A.size() > 0){
        a = A.top() * -1;
        A.pop();
        if(bc.size()==0){
            max_number += a;
            continue;
        }
        pair<ll, ll> bc_top = bc.top(); 
        bc.pop();
        c = bc_top.first;
        b = bc_top.second;
        max_number += max(a, c);
        if(b>1){
            bc.push(make_pair(c, b-1));
        }
    }
    cout << max_number;
    return 0;
}

Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    long long N, K;
    vector<long long> A;

    cin >> N >> K;
    for (long long i = 0; i < N; i++)
    {
        long long t;
        cin >> t;
        A.push_back(t);
    }

    long long m = A[0];
    long long g = A[0];
    for (long long i = 1; i < N; i++)
    {
        m = max(m, A[i]);
        g = __gcd(g, A[i]);
    }

    if (m < K || K % g != 0)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 1400
L = list(input())
L_ = []
a = L.pop(0)
cnt = 0

while True:
    if len(L) == 0:
        break
    else:
        b = L.pop(0)
    if a is not b:
        cnt += 1
        if len(L_) != 0:
            a = L_.pop()
        elif len(L) == 0:
            break  
        else:
            a = L.pop(0)
    elif a is b:
        L_.append(a)
        a = b
    # print(L_, a,  L)

print(cnt * 2)



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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ull N,sum=0;		cin>>N;
	if(N==0)	cout<<"0"<<endl;
	else if(N%2) cout<<"0"<<endl;
	else{
		sum+=N/10;
		sum+=N/50;
		sum+=N/250;
		sum+=N/1250;
		sum+=N/6250;
		sum+=N/31250;
		sum+=N/156250;
		sum+=N/781250;
		sum+=N/3906250;
		sum+=N/19531250;
		sum+=N/97656250;
		sum+=N/488281250;
		sum+=N/2441406250;
		sum+=N/12207031250;
		sum+=N/61035156250;
		sum+=N/305175781250;
		sum+=N/1525878906250;
		sum+=N/7629394531250;
		sum+=N/38146972656250;
		sum+=N/190734863281250;
		sum+=N/953674316406250;
		sum+=N/4768371582031250;
		sum+=N/23841857910156250;
		sum+=N/119209289550781250;
		sum+=N/596046447753906250;
		sum+=N/2980232238769531250;
		cout<<sum<<endl;
	}
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, m, d := floatScanner(), floatScanner(), floatScanner()
	if d == 0 {
		fmt.Println((n - d) / n / n * (m - 1))
	} else {
		fmt.Println(2 * (n - d) / n / n * (m - 1))
	}
}


Measured memory_bytes: 640
N,Y = map(int,input().split())
L = []
for x in range(N+1):
  for y in range(N+1):
    if(9*x+4*y+N == Y//1000 and x+y <= N):
      L.append(x)
      L.append(y)
      L.append(N-x-y)
      break
if (L != []):      
  print(L[0],L[1],L[2])
else:
  print(-1,-1,-1)

Measured memory_bytes: 3188
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	static int MOD=1000000007;
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] s=br.readLine().split(" ");
		int N=Integer.parseInt(s[0]);
		int k=Integer.parseInt(s[1]);
		s=br.readLine().split(" ");
		int[] A=new int[N];
		for(int i=0;i<N;i++){
			A[i]=Integer.parseInt(s[i]);
		}
		HashMap<Integer,Integer> hm=new HashMap<>();
		for(int i=0;i<N;i++){
			int count=0;
			for(int j=0;j<N;j++){
				if(A[j]<A[i])
					count++;
			}
			hm.put(i,count);
		}
		long total=0;
		long factor=((long)k*((long)k-1));
		factor>>=1;
		factor%=MOD;
		for(int i=0;i<N;i++){
			total=(total+((long)hm.get(i)*factor));
			total%=MOD;
		}
		long sum=0;
		int[] small=new int[N];
		for(int i=0;i+1<N;i++){
			for(int j=i+1;j<N;j++){
				if(A[i]>A[j]){
					small[i]++;
				}
			}
		}
		//System.out.println();
		for(int i=0;i<N;i++){
			sum=sum+small[i];
			sum%=MOD;
		}
		total=(total+sum*k);
		total%=MOD;
		System.out.println(total);
	}
}

Measured memory_bytes: 25300
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  int money[4]={6000,4000,3000,2000};
  int n,t;
  for(int i=0;i<4;i++){
    cin>>t>>n;
    t--;
    cout<<money[t]*n<<endl;
  }
}

Measured memory_bytes: 1160
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;

int N;
int A[MAXN];

void input()
{
    read(N);
    for (int i = 1; i <= N; ++i) {
        read(A[i]);
    }
}

void solve()
{
    static int cnt[MAXN];

    for (int i = 1; i <= N; ++i) {
        int x = A[i] + N - 1;
        if (x & 1) {
            puts("0");
            return;
        }
        x >>= 1;
        if (cnt[1 + x]) {
            if (cnt[N - x]) {
                puts("0");
                return;
            }
            cnt[N - x] = 1;
        } else
            cnt[1 + x] = 1;
    }
    int ans = 1;
    for (int i = 1; i * 2 <= N; ++i) {
        ans = ans * 2 % MOD;
    }

    printf("%d\n", ans);
}

int main()
{
#ifdef __DEBUG
    freopen("C.in", "r", stdin);
    freopen("C.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 还君明珠双泪垂，恨不相逢未嫁时。
//     -- 张籍《节妇吟·寄东平李司空师道》


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
int n ;
unsigned long int m = 0;
scanf("%d",&n);
for(int i = 1;i < n+1 ;i++){
	m += i;
	if(i % 15 == 0) m -= i;
	else if(i % 3 == 0) m -= i;
	else if(i % 5 == 0) m -= i;}
	printf("%lu",m);
	return 0;
}


Measured memory_bytes: 1732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        long[] a=cin.ArrayLong(N,0);
        Array.Sort(a);
        Console.WriteLine(a[N-1]-a[0]);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13396
#include<stdio.h>

int main(void){


 int length = 0;


 int height = 0;


 int area = 0;


 int cir = 0;





 scanf("%d %d",&length,&height);


 area = length * height;


 cir = length*2 + height*2;


 printf("%d %d\n",area,cir);


 return 0;


}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){

    string s,t;
    cin >> s;
    transform(s.begin(),s.end(),s.begin(),::tolower);
    int count_s=0;
    while(cin>>t){
        if(t=="END_OF_TEXT"){
            cout << count_s << endl;
            break;
        }else{
            transform(t.begin(),t.end(),t.begin(),::tolower);
            if(t==s){
                count_s += 1;            
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[15];
    for(int i=0;i<10;i++)
    {
        scanf("%d",&arr[i]);
    }
    sort(arr,arr+10);
    printf("%d\n%d\n%d\n",arr[9],arr[8],arr[7]);
    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {   
    long double sr = sqrt(x); 
    return ((sr - floor(sr)) == 0); 
} 
bool isPrime(int x){
    for(int i = 2; i * i <= x; ++i){
        if(x % i == 0) return 0;
    }
    return 1;
}
int fun(int n){
    if(n & 1) return 3 * n + 1;
    else return n/2;
}
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int arr[n];
    read(arr);
    sort(arr, arr + n);
    cout << fixed << setprecision(5) ;
    double ans = arr[0];
    for(int i = 1; i < n; ++i){
        ans = (ans + arr[i]) / 2;
    }
    cout << ans ;
}


Measured memory_bytes: 3792
using System;
using System.Linq;

namespace ConsoleApp3
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(" ").Select(decimal.Parse).ToArray();
            var x = input[0];
            var k = input[1];
            var d = input[2];

            var minX = x % d;
            var count = Math.Floor(Math.Abs(x) / d);

            var leftCount = k - count;

            if (leftCount < 0)
            {
                Console.WriteLine(Math.Abs(x) - k * d);
            }
            else if (leftCount % 2 == 0)
            {
                Console.WriteLine(Math.Abs(minX));
            }
            else if (minX > 0)
            {
                Console.WriteLine(Math.Abs(minX - d));
            }
            else
            {
                Console.WriteLine(Math.Abs(minX + d));
            }
        }
    }
}


Measured memory_bytes: 28248
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  ll mi=1e9+7;
  ll ret=0;
  rep(i,n){
    ll a;cin>>a;
    if(a<mi)ret++;
    chmin(mi,a);
  }
  cout<<ret<<endl;
  

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*cout <<"Debug"
cout <<x-30<<' '<<y-30<<endl;*/
vector<string>v;
vector<int>ansl;
string s;
int ary[100005] = {0};
int mp[200][200];
int cnt = 0;
int d_x[] = {1, 1, 0, -1, -1, 0};
int d_y[] = {1, 0, -1, -1, 0, 1};
int t;
/*
void dfs(int x,int y,int lpcnt){
  mp[x][y] = 1;
  cout <<"Debug ";
  cout <<x-30<<' '<<y-30<<endl;
  cnt++;
  lpcnt++;
  int watasi = lpcnt;
  int used[6] = {0};
  for(int dx = 0;dx<6;dx++){
    int nx = x+d_x[dx],ny = y+d_y[dx];
    int dft = sqrt((nx-30)*(nx-30)+(ny-30)*(ny-30));
    if((dft<=30)&&(watasi < t)&&(mp[nx][ny] == 0)){
        dfs(nx,ny,watasi);
        used[dx] = 1;
    }
    for(int i = 0;i<6;i++){
      if(used[i]){
        if((nx == x + d_x[i])&&(ny == y + d_y[i])){
          dfs(nx,ny,watasi);
        }
      }
    }
    }
}
*/
int main(){
  long int N;

  cin >>N;
  while(N != 0){
    int cnt = 0;

    for(long int i = N+1;i<=2*N;i++){
      long int x = i,waru = sqrt(i),flg = 0;
      if(i == 2){
        cnt++;
        break;
      }
      if(i%2 == 0){
        continue;
      }
      while (waru > 1) {
        if(x%waru == 0){
          flg = 1;
          break;
        }
        waru--;
      }
      if(flg == 0)cnt++;
    }
    ansl.push_back(cnt);
    cin >>N;
  }

  for(int i = 0;i<(int)ansl.size();i++){
    cout <<ansl[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3128
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt(),m=sc.nextInt();
			int[] a=new int [n],b=new int[n],c=new int [m],d=new int[m];
			for(int i=0;i<n;i++){
				a[i]=sc.nextInt(); b[i]=sc.nextInt();
			}
			for(int i=0;i<m;i++){
				c[i]=sc.nextInt(); d[i]=sc.nextInt();
			}
			for(int i=0;i<n;i++){
				int ans=0;
				for(int j=1;j<m;j++) if(Math.abs(a[i]-c[ans])+Math.abs(b[i]-d[ans])>Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j])) ans=j;
				System.out.println(ans+1);
			}
		}
	}
}

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

int main() {
    int n;
    int before;
    int ans = 0;
    int ans_buf = 0;
    cin >> n >> before;
    for(int i = 1; i < n; i++){
        int buf;
        cin >> buf;
        if(buf <= before){
            ans_buf++;
        }else{
            ans_buf = 0;
        }
        before = buf;
        ans = max(ans,ans_buf);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256