akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

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

    int N, Y; cin >> N >> Y;
    Y /= 1000;

    rep(a, N + 1) {
        rep(b, N + 1) {
            if(a + b <= N && a + 5 * b + 10 * (N - a - b) == Y) {
                cout << N - a - b << " " << b << " " << a << "\n";
                return 0;
            } 
        }
    }

    cout << "-1 -1 -1\n" ; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[100000];
    for(int i=0;i<n;i++) cin>>a[i];
    if((n-1)%(k-1)==0){
    cout<<(n-1)/(k-1)<<endl;
    }
    else cout<<(n-1)/(k-1)+1<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;

typedef pair<string, int> psi;

int main(){
	while(true){
		int n, m;
		scanf("%d", &n);
		if(n == 0){ break; }
		map<string, int> items;
		for(int i = 0; i < n; i++){
			string name;
			int cost;
			cin >> name >> cost;
			items.insert(psi(name, cost));
		}
		map< string, set<string> > materials;
		queue<string> q;
		scanf("%d", &m);
		for(int i = 0; i < m; i++){
			string item;
			int k, cost = 0;
			set<string> material;
			cin >> item >> k;
			for(int j = 0; j < k; j++){
				string name;
				cin >> name;
				material.insert(name);
				cost += items[name];
			}
			materials.insert(pair< string, set<string> >(item, material));
			if(cost < items[item]){
				items[item] = cost;
				q.push(item);
			}
		}
		while(!q.empty()){
			string item = q.front();
			q.pop();
			map< string, set<string> >::iterator it = materials.begin();
			while(it != materials.end()){
				if((*it).second.find(item) != (*it).second.end()){
					int cost = 0;
					set<string>::iterator jt = (*it).second.begin();
					while(jt != (*it).second.end()){
						cost += items[*jt];
						jt++;
					}
					if(cost < items[(*it).first]){
						items[(*it).first] = cost;
						q.push((*it).first);
					}
				}
				it++;
			}
		}
		string query;
		cin >> query;
		printf("%d\n", items[query]);
	}
	return 0;
}

Measured memory_bytes: 0
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:i64 k:i64));
    if n % k == 0 { 0 } else { 1 }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}
tests! {
    test1: "7 3" => "1",
    test2: "100 10" => "0",
    test3: "1 1" => "0",
}


Measured memory_bytes: 4352
def q11(W):
    s = W.pop(0)
    deplicate.append(s)
    for w in W:
        if not w.startswith(s[-1]):
            return 'No'
    
        if w in deplicate:
            return 'No'
    
        deplicate.append(w)
        s = w
    return 'Yes'

N = int(input())
W = []

deplicate = []
for _ in range(N):
    W.append(input())

print(q11(W))


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

int main(void){

    int n;
    int i,j;
    for(;;){
    scanf("%d",&n);
    if(n==0)break;
    int a[11][11]={{0}};
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&a[i][j]);
            }
        }
    for(i=0;i<n;i++){
        a[n][i]=a[0][i]+a[1][i]+a[2][i]+a[3][i]+a[4][i]+a[5][i]+a[6][i]+a[7][i]+a[8][i]+a[9][i];
    }
    for(j=0;j<n+1;j++){
        a[j][n]=a[j][0]+a[j][1]+a[j][2]+a[j][3]+a[j][4]+a[j][5]+a[j][6]+a[j][7]+a[j][8]+a[j][9];
    }
    for(i=0;i<=n;i++){
        for(j=0;j<=n;j++){
            printf("%5d",a[i][j]);
            }
            printf("\n");
        }
    }
return 0;
}

Measured memory_bytes: 1044
def fibonacci(n):
    num1 = 1
    num2 = 1
    tmp = 1

    for i in range(1, n):
        tmp = num1 + num2
        num1 = num2
        num2 = tmp

    return tmp


if __name__ == '__main__':
    n = int(input())
    result = fibonacci(n)
    print(result)

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

if (B-A)%2==0:
    print((B-A)//2)
else:
    if (B-1)<(N-A):
        print(A-1+(B-A+1)//2)
    else:
        print(N-B+(B-A+1)//2)


Measured memory_bytes: 38400
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll f(ll x,ll c,ll d){
    ll res =x;
    res -=x/c;
    res -=x/d;
    res+= x/lcm(c,d);
    return res;
}

vector<int> to[100005];
const ll inf =100000000;

vector<ll>a,b,c,d;
ll n,m,q;
ll ans=0;
void bfs(vector<ll> v){
   if(v.size()==n+1) {
       ll sum=0;
       rep(i,q){
           if(v[b[i]]-v[a[i]]==c[i])sum+=d[i];
       }
       ans=max(ans,sum);
       return;
   }
   v.push_back(v.back());
   bfs(v);
   while(v.back()<m){
       v.back()++;
       bfs(v);
   }
}

int main(){
 int k;
 cin>>k;
 vector<ll> a;
 for(int i=1;i<=9;++i)a.push_back(i);
 while(1){
     if(k<=a.size()){
         cout<<a[k-1]<<endl;
         return 0;
     }
     k-=a.size();
     vector<ll> old;
     swap(old,a);
     for(ll x:old){
         for(int i=-1;i<=1;i++){
             int d=x%10+i;
             if(d<0||9<d)continue;
             ll nx= x*10+d;
             a.push_back(nx);
         }
     }
 }
}


Measured memory_bytes: 6960
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize, b: usize, k: usize
    }

    let mut k = k;
    for i in (1..std::cmp::min(a, b) + 1).rev() {
        if a % i == 0 && b % i == 0 {
            k -= 1;
        }
        if k == 0 {
            println!("{}", i);
            return;
        }
    }
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

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

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 100500;

int n, mn = N, mx, cnt;

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n;

	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		if (x == mn) cnt++;
		if (x < mn) mn = x, cnt = 1;
		if (x > mx) mx = x;
	}

	if (mx - mn > 1)
		cout << "No";
	else if (mn == mx)
		cout << (mx == n - 1 || mx <= n / 2 ? "Yes" : "No");
	else
		cout << (n - cnt > 1 && cnt + 1 <= mx && mx <= cnt + (n - cnt) / 2 ? "Yes" : "No");
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 256
loop do
  gem_num = STDIN.gets.to_i
  exit if gem_num == 0
  places = []
  gem_num.times do
    places << STDIN.gets.split(' ').map(&:to_i)
  end

  position = [10, 10]
  locus = []
  operation_num = STDIN.gets.to_i
  operation_num.times do
    direction, distance = STDIN.gets.split(' ')
    case direction
    when 'N'
      (1..distance.to_i).each do |i|
        position[1] += 1
        locus << position.dup
      end
    when 'S'
      (1..distance.to_i).each do |i|
        position[1] -= 1
        locus << position.dup
      end
    when 'E'
      (1..distance.to_i).each do |i|
        position[0] += 1
        locus << position.dup
      end
    when 'W'
      (1..distance.to_i).each do |i|
        position[0] -= 1
        locus << position.dup
      end
    end
  end

  puts (places - locus).empty? ? 'Yes' : 'No'
end



Measured memory_bytes: 6900
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,K;
int A[MAXN],cnt[MAXN],val[MAXN],tot;
bool cmp(int a,int b) {
    return a > b;
}
void Init() {
    read(N);read(K);
    for(int i = 1 ; i <= N ; ++i) {
	read(A[i]);
	cnt[A[i]]++;
    }
}
void Solve() {
    for(int i = 1 ; i <= N ; ++i) {
	if(cnt[i]) val[++tot] = cnt[i];
    }
    sort(val + 1,val + tot + 1,cmp);
    int ans = 0;
    for(int i = K + 1 ; i <= tot ; ++i) ans += val[i];
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Init();
    Solve();
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

double midx(vec A)
{
    ll N = SZ(A)-1;
    if(N % 2 == 1) return A[(N+1)/2];
    else return A[N/2]+A[N/2+1];
}


int main()
{
    ll N;
    cin >> N;
    vec A(N+1, 0), B(N+1, 0);
    for(ll i=1; i<N+1; ++i) {
        cin >> A[i] >> B[i];
    }
    sort(ALL(A));
    sort(ALL(B));

    ll midA = midx(A);
    ll midB = midx(B);
    _PR(midB-midA+1);

    return 0;
}

/*



*/

Measured memory_bytes: 7936
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main () {
    int R[MAX], n;
    
    cin >> n;
    for( int i = 0; i < n; i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for ( int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
        
    }
    cout << maxv << endl;
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


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

  rep(i, k) {
    vector<int> r(n, 0), l(n, 0);

    rep(j, n) {
      ++r[j];
      if(j+a[j]+1 < n) --r[j+a[j]+1];
    }
    rep(j, n-1) r[j+1] += r[j];

    reverse(ALL(a));
    rep(j, n) {
      ++l[j];
      if(j+a[j]+1 < n) --l[j+a[j]+1];  
    }
    rep(j, n-1) l[j+1] += l[j];
    reverse(ALL(a));
    reverse(ALL(l));

    rep(j, n) a[j] = r[j]+l[j]-1;

    if(*min_element(ALL(a)) == n) break;
  }
  line_out(a);
}

Measured memory_bytes: 5636
MOD = int(1e9+7)
N, K = map(int, input().split())

count = [0] * (K+1)
ans = 0
for now in range(K, 0, -1):
    count[now] = pow(K // now, N, MOD)
    for j in range(2*now ,K+1, now):
        count[now] -= count[j]
        if count[now] < 0:
            count[now] += MOD
    ans += now * count[now]
print(ans % MOD)

Measured memory_bytes: 72328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXSIZE=30000020;
int bufpos;
char buf[MAXSIZE];
#define NEG 0
void init(){
	#ifdef LOCAL
		freopen("C.txt","r",stdin);
	#endif
	buf[fread(buf,1,MAXSIZE,stdin)]='\0';
	bufpos=0;
}
#if NEG
int readint(){
	bool isneg;
	int val=0;
	for(;!isdigit(buf[bufpos]) && buf[bufpos]!='-';bufpos++);
	bufpos+=(isneg=buf[bufpos]=='-');
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return isneg?-val:val;
}
#else
int readint(){
	int val=0;
	for(;!isdigit(buf[bufpos]);bufpos++);
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return val;
}
#endif
char readchar(){
	for(;isspace(buf[bufpos]);bufpos++);
	return buf[bufpos++];
}
int readstr(char* s){
	int cur=0;
	for(;isspace(buf[bufpos]);bufpos++);
	for(;!isspace(buf[bufpos]);bufpos++)
		s[cur++]=buf[bufpos];
	s[cur]='\0';
	return cur;
}
int a[100002];
int main(){
	init();
	int n=readint(),cnt=0,cnt1=0,cnt2=0;
	while(n--){
		int x=readint();
		if (x%4==0)
			cnt2++;
		else if (x%2==0)
			cnt1++;
		else cnt++;
	}
	int to=cnt2;
	if (!cnt1)
		to++;
	if (cnt>to)
		puts("No");
	else puts("Yes");
}

Measured memory_bytes: 1280
#include"bits/stdc++.h"
// #include "prettyprint.hpp"

using namespace std;

#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, n) for(ll i=n; i>=0; i--)
#define reps(i, s, e) for(ll i=s; i<e; i++)
#define all(x) x.begin(),x.end()

typedef long long ll;

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

	if(N % 2 == 0){
		cout << N/2 - 1 << endl;
	}

	else{
		cout << ceil(N/2) << endl;
	}

	return 0;
}	

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	/**
	 * 表計算プログラム
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();	//行数
		int c = scan.nextInt();	//列数
		int[][] array = new int[r + 1][c + 1];
		//入力された数字を格納する
		for(int i = 0; i < r; i++){
			for(int l = 0; l < c; l++){
					array[i][l] = scan.nextInt();
			}//for
			//1行を格納した後、行の合計を計算をする
			array[i][c] = sum(array[i]);
		}//for
		for(int i = 0; i < c + 1; i++){
			//全ての数字を格納し終わってから列の合計を計算する
			array[r][i] = sum(array, i);
		}//for
		//出力
		for(int i = 0; i < r + 1; i++){
			for(int l = 0; l < c + 1; l++){
				if(l != 0) System.out.print(" ");
				System.out.print(array[i][l]);
			}//for
			System.out.println();
		}//for
	}//main
	/**
	 * 行の合計
	 * @param array
	 * @return n
	 */
	public static int sum (int[] array){
		int n = 0;
		for(int i = 0; i < array.length - 1; i++){
			n += array[i];
		}//for
		return n;
	}//sum
	/**
	 * 列の合計
	 * @param array
	 * @param col
	 * @return 
	 */
	public static int sum (int[][] array, int col){
		int n = 0;
		for(int i = 0; i < array.length - 1; i++){
			n += array[i][col];
		}//for
		return n;
	}//sum
}

Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
long long dp[107][100007]={};
int main(){
  int N,W;
  cin >> N >> W;
  int w[N],v[N];
  for(int i=0;i<N;i++) cin >> w[i] >> v[i];
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(w[i]<=j) dp[i+1][j] =max(dp[i+1][j],dp[i][j-w[i]] + v[i]);
      dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
    }
  }
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int a = s / 1000;
        int b = s / 100 - 10 * a;
        int c = s / 10 - s / 100 * 10;
        int d = s - s / 10 * 10 ;
        if(a == b || b == c || c == d){
            System.out.println("Bad");
        }else{
            System.out.println("Good");
        }
        sc.close();
    }
}

Measured memory_bytes: 35636
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
#define PI 3.14159265359
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        string a, b;
        cin >> a >> b;
        int c = 0;
        loop(0, a.length()) {
            if (a[i] != b[i])
                c++;
        }
        cout << c << endl;
    }
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int a=s.size(), z=0;
    bool f = false;
    rep(i, s.size()){
        if(!f && s[i]=='A'){
            a = i;
            f = true;
        }
        if(s[i]=='Z'){
            z = max(z, i);
        }
    }
    printf("%d\n", z-a+1);
    return 0;
}

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

int main() {
	long long N, W;
	cin >> N >> W;
	vector<long long>value(N), weight(N);
	for (long long i = 0; i < N; i++) {
		cin >> value.at(i) >> weight.at(i);
	}
	vector<vector<long long>>DP(110, vector<long long>(20000));
	for (long long i = 0; i < N; i++) {
		DP.at(i).at(0) = 0;
	}
	for (long long j = 0; j < W; j++) {
		DP.at(0).at(j) = 0;
	}
	for (long long i = 0; i < N; i++) {
		for (long long j = 0; j <= W; j++) {
			if (j < weight.at(i)) DP.at(i + 1).at(j) = DP.at(i).at(j);
			else DP.at(i + 1).at(j) = max(DP.at(i).at(j), DP.at(i).at(j - weight.at(i)) + value.at(i));
		}
	}
	cout << DP.at(N).at(W) << endl;
}


Measured memory_bytes: 20624
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	string s;
	cin >> s;
	int ans = 0;
	REP(i, s.size()){
		if(s[i] == 'g') ans++;
		else ans--;
	}
	cout << ans/2 << endl;
	return 0;
}


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

int main(void) {
  double x1, y1, x2, y2;
  scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
  printf("%f\n", sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
  return 0;
}


Measured memory_bytes: 2100
#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<unordered_map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<bitset>
#include<fstream>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
#include<fstream>
const ll INF=9223372036854775807;
const ll mod=998244353
;
int  MOD(int  a, int  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b, ll  c)
{
    return max(c,max(a,b));
}
ll min3(ll  a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y,ll mod1)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod1;
        y = y>>1;
        x = (x*x)%mod1;
    }
    return res;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x,ll p)
{
    return power(x,p-2,p);
}
int main()
{
    fastio;
    int n,m;
    cin>>n>>m;
    vector<pair<ll,ll>> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i].f>>v[i].s;
    }
    sort(all(v));
    int x=m;
    int j=0;
    multiset<int> g;
    ll ans=0;
    while(x>=0)
    {
        while(j<v.size()&&v[j].f+x<=m)
        {
            g.insert(v[j].s);
            j++;
        }
        if(!g.empty())
        {
            ans+=*(g.rbegin());auto it=g.end();it--;
            g.erase(it);
        }
        x--;
    }
    cout<<ans;
}


Measured memory_bytes: 6528
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long int
using namespace std;

void desperate_optimization(bool submitting=true,int precision=10)
{
  if(!submitting) return;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
int segtree[800005];
int left(int p) {return (p<<1);}
int right(int p) {return ((p<<1)+1);}
int rangemax(int p,int l,int r,int i,int j)
{
  if(i<=l && r<=j) return segtree[p];
  if(i>r || j<l) return 0;
  return max(rangemax(left(p),l,(l+r)/2,i,j),rangemax(right(p),(l+r)/2+1,r,i,j));
}
void update(int p,int l,int r,int index,int val)
{
  if(index>r||index<l) return;
  if(l==r && l==index) {segtree[p]=val;return;}
  update(left(p),l,(l+r)/2,index,val);
  update(right(p),(l+r)/2+1,r,index,val);
  segtree[p]=max(segtree[left(p)],segtree[right(p)]);
}
int32_t main()
{
  desperate_optimization(true);
  //freopen("input.txt","r",stdin);
  int n;
  cin>>n;
  vector<int> heights(n);
  vector<int> values(n);
  vector<int> dp(n+1);
  for(int i=0;i<n;i++) cin>>heights[i];
  for(int i=0;i<n;i++) cin>>values[i];
  for(int i=0;i<n;i++)
  {
    dp[heights[i]]=max(dp[heights[i]],rangemax(1,0,n,1,heights[i]-1)+values[i]);
    update(1,0,n,heights[i],dp[heights[i]]);
  }
  int answer=0;
  for(int i=0;i<=n;i++) answer=max(answer,dp[i]);
  cout<<answer;


  return 0;
}


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

using namespace std;

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

    int x, y;
    cin >> x >> y;

    for(int i = 0; i <= x; i++){
        int j = x - i;
        if(i * 2 + 4 * j == y){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3648
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

#define NMAX 500010

struct QUARR{
    int l;
    int r;
    int index;
    int type;
    int ans;
    bool operator<(QUARR q) const{
        if(type==1){
            if(q.r==r) return q.l>l;
            return q.r>r;
        }
        else{
            return q.index>index;
        }
    }
};

int ft_bit[NMAX];
void ft_add(int a,int w,int N){
    for(int x=a;x<=N;x+=x&-x){
        ft_bit[x]+=w;
    }
}

int ft_sum(int a){
    int ret=0;
    for(int x=a;x>0;x-=x&-x){
        ret+=ft_bit[x];
    }
    return ret;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    QUARR qu[NMAX];
    int last[NMAX];
    int c[NMAX];
    int N,Q;

    cin>>N>>Q;
    for(int i=1;i<=N;i++){
        cin>>c[i];
        last[i]=-1;
    }

    for(int i=1;i<=Q;i++){
        int l,r;
        cin>>l>>r;
        qu[i].l=l;
        qu[i].r=r;
        qu[i].index=i;
        qu[i].type=1;
        qu[i].ans=0;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=qu[1].r;i++){
        if(last[c[i]]==-1){
            ft_add(i,1,N);
            last[c[i]]=i;
        }
        else{
            ft_add(last[c[i]],-1,N);
            ft_add(i,1,N);
            last[c[i]]=i;
        }
    }

    qu[1].ans=ft_sum(qu[1].r)-ft_sum(qu[1].l-1);
    qu[1].type=2;
    for(int i=2;i<=Q;i++){
        for(int j=qu[i-1].r+1;j<=qu[i].r;j++){
            if(last[c[j]]==-1){
                ft_add(j,1,N);
                last[c[j]]=j;
            }
            else{
                ft_add(last[c[j]],-1,N);
                ft_add(j,1,N);
                last[c[j]]=j;
            }
        }
        qu[i].ans=ft_sum(qu[i].r)-ft_sum(qu[i].l-1);
        qu[i].type=2;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=Q;i++){
        cout<<qu[i].ans<<"\n";
    }
}


Measured memory_bytes: 35076
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int a[10234];
int ans[100][100];

int main(){
	int h, w, n;
	
	cin >> h >> w >> n;
	
	REP(i,n) cin >> a[i];
	
	int c_h = 0;
	int c_w = 0;
	
	REP(i,n){
		REP(j,a[i]){
			if (c_h%2 == 0)	ans[c_h][c_w] = i+1;
			else ans[c_h][w-c_w-1] = i+1;
			c_w++;
			if (c_w >= w){
				c_w = 0;
				c_h++;
			}
		}
	}
	
	REP(i,h){
		REP(j,w){
			if (j) cout << " ";
			cout << ans[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int N, u, v, a[111111], b[111111];

std::vector<std::vector<int>> G;

bool visit[111111] = {0};


void bfs(int* a, int i)
{
  memset(a, -1, sizeof(int) * 111111);

  a[i] = 0;

  std::queue<int> queue;

  queue.push(i);

  while (! queue.empty()) {
    int x = queue.front(); queue.pop();

    for (const auto& k : G[x])
      if (a[k] == -1) {
        a[k] = a[x] + 1;

        queue.push(k);
      }
  }
}

void dfs(int i)
{
  for (const auto k : G[i]) {
    if (visit[k])
      continue;

    if (a[k] > b[k])
      continue;

    visit[k] = true;

    dfs(k);
  }
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N >> u >> v;

  G.resize(N);

  u --;
  v --;

  for (int i = 0; i < N - 1; i ++) {
    int s, t;

    std::cin >> s >> t;

    s --;
    t --;

    G[s].push_back(t);
    G[t].push_back(s);
  }

  bfs(a, u);
  bfs(b, v);

  visit[u] = true;

  dfs(u);

  int cp = 0;

  for (int i = 0; i < N; i ++) {
    if (! visit[i])
      continue;
    
    int c = b[i] - 1;

    for (const auto& k : G[i])
      if (visit[k])
        if (b[k] < b[i] - 1)
          c = b[i];

    cp = std::max(c, cp);
  }

  std::cout << cp << std::endl;

  return 0;
}


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


int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	int good;
	auto s = to_string(N);
	for (char x : s) {
		good = 0;
		for (char y : s) {
			if (x == y)
				good++;
			else if (good && x != y)
				break;
			if (good == 3) {
				cout << "Yes" << "\n";
				return (0);
			}
		}
	}
	cout << "No" << "\n";
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int x;
	cin >> x;

	int a = x / 500;
	int b = x % 500;
	int c = b / 5;

	out(a * 1000 + c * 5);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int GCD(int X, int Y){
int re=-1;
do{
    re=X%Y;
    if(re==0) break;
    X=Y;
    Y=re;
}while(re!=0);
return Y;
}
int main(void){
    int x,y,tmp,answer,a;
    scanf("%d %d",&x,&y);
    if(x<y){
        tmp=x;
        x=y;
        y=tmp;
    }
    answer=GCD(x,y);
    printf("%d\n",answer);
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>

int main() {
    int x;
    std::cin >> x;
    for (int k = 0; k <= x; ++k) {
        int l = k * 100, r = k * 105;
        if (l <= x && x <= r) {
            std::cout << 1 << std::endl;
            return 0;
        }
    }

    std::cout << 0 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <stdbool.h>
#include <stdio.h>

bool IsPrime(int Number)
{
    double Quotient = DBL_MAX;
    for (double Denominator = 2.;
         Denominator < Number; Denominator += 1.)
    {
        if (Quotient <= Denominator)
        {
            return true;
        }
        Quotient = Number / Denominator;
        int Truncated = Quotient;
        if (Quotient == Truncated)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int InputCount = 0;
    scanf("%d", &InputCount);
    size_t Count = 0;
    for (int i = 0; i < InputCount; ++i)
    {
        int Input = 0;
        scanf("%d", &Input);
        if (IsPrime(Input))
        {
            ++Count;
        }
    }
    printf("%d\n", Count);
    return 0;
}



Measured memory_bytes: 2040
m, k = map(int,input().split())
if m == 0:
  if k == 0:
    print("0 0")
  else:
    print(-1)
  quit()
  
if m == 1:
    if k == 0:
        print("0 0 1 1")
    else:
        print(-1)
    quit()

n = 2**m
if k >= n:
    print(-1)
    quit()
    
a = list(range(0,k)) + [k] + list(range(0,k))[::-1] + list(range(k+1,n))[::-1]  + [k] + list(range(k+1,n))
b = [str(t) for t in a]
print(" ".join(b))
    
  
  


Measured memory_bytes: 36852
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

char c;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> c;
  if (c == 'A') cout << 'T';
  else if (c == 'T') cout << 'A';
  else if (c == 'G') cout << 'C';
  else cout << 'G';
  cout << endl;
  return 0;
}



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

int main(){
    long long n, a, b;
    scanf("%lld%lld%lld",&n,&a,&b);
    if(a+b-1 > n){
        printf("-1\n");
        return 0;
    }
    if(a * b < n){
        printf("-1\n");
        return 0;
    }
    for(long long i=n-a+1;i<=n;i++){
        printf("%lld ", i);
    }
    long long nn = n-a;
    n = n-a;
    for(long long i=b-2;i>=0;i--){
        long long gae;
        if(i < (nn % (b-1))){
            gae = nn / (b-1) + 1;
        }else{
            gae = nn / (b-1);
        }
        for(long long j=n-gae+1;j<=n;j++){
            printf("%lld ", j);
        }
        n -= gae;
    }
    printf("\n");
}


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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

#define MAX_H 6
#define MAX_W 6

int main(void) {
  
	ios::sync_with_stdio(false);	cin.tie(0);
    int H, W, K;  cin >> H >> W >> K;
    char field[MAX_H][MAX_W];
    int ans = 0;
    
    for(int i = 0 ; i < H ; i++)
      for(int j = 0 ; j < W ; j++)  cin >> field[i][j];

    for(int bit1 = 0 ; bit1 < (1<<H); bit1++){
      for(int bit2 = 0 ; bit2 < (1<<W) ; bit2++){

        int black = 0;
        for(int i = 0 ; i < H ; i++){
          for(int j = 0 ; j < W ; j++){
            if((bit1 & (1<<i)) || (bit2) & (1<<j))  continue;
            else if(field[i][j] == '#') black++;
          }
        }

        if(black == K)  ans += 1;
      }
    }

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


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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD=1e9+7;

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

  int n,m;
  while(true){
      cin>>n>>m;
      if(n==0) break;
      int dis[n][n];
      for(int i=0;i<n;i++)for(int j=0;j<n;j++){
          dis[i][j]=INF;
          if(i==j) dis[i][j]=0;
      }
      for(int i=0;i<m;i++){
          int a,b;cin>>a>>b;
          a--;b--;
          dis[a][b]=1;
          dis[b][a]=1;
      }
      for(int k=0;k<n;k++){
          for(int i=0;i<n;i++){
              for(int j=0;j<n;j++){
                  dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
              }
          }
      }
      int res=0;
      for(int i=0;i<n;i++) if(dis[0][i]<3) res++;
      cout<<res-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3988
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long yokin = 100;
        long n = 0;

        while (yokin < x) {
            yokin = (long) ((double) yokin * 1.01);
            n++;
        }

        System.out.print(n);
    }
}

Measured memory_bytes: 35728
#include<cstdio>

using namespace std;

int y,m,d;

void pre(){
	printf("pre-meiji\n");
}

void meiji(){
	printf("meiji %d %d %d\n", y-1867, m, d);
}

void taisho(){
	printf("taisho %d %d %d\n", y-1911, m, d);
}

void showa(){
	printf("showa %d %d %d\n", y-1925, m, d);
}

void heisei(){
	printf("heisei %d %d %d\n", y-1988, m, d);
}

int main(void){

	
	while(scanf("%d%d%d", &y, &m, &d) != EOF){
		if(y < 1868){
			pre();
		}else if(y == 1868){
			if(m < 9){
				pre();
			}else if(m == 9){
				if(d < 8){
					pre();
				}else {
					meiji();
				}
			}else{
				meiji();
			}
		}else if(y > 1868 && y < 1912){
			meiji();
		}else if(y == 1912){
			if(m < 7){
				meiji();
			}else if(m == 7){
				if(d < 30){
					meiji();
				}else {
					taisho();
				}
			}else{
				taisho();
			}
		}else if(y > 1912 && y < 1926){
			taisho();
		}else if(y == 1926){
			if(m < 12){
				taisho();
			}else if(m == 12){
				if(d < 25){
					taisho();
				}else {
					showa();
				}
			}else {
				showa();
			}
		}else if( y > 1926 && y < 1989){
			showa();
		}else if( y == 1989){
			if(m < 1){
				showa();
			}else if(m == 1){
				if(d < 8){
					showa();
				}else {
					heisei();
				}
			}else {
				heisei();
			}
		}else{
			heisei();
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

	int n;
	string s,t;
	cin >> n >> s >> t;

	bool found=true;
	for(int i=0;i<n;i++){
		found=true;
		for(int j=0;i+j<n;j++){
			if(s[i+j]!=t[j]){
				found=false;
				break;
			}
		}
		if(found){
			cout << i+n << "\n";
			return 0;
		}
	}
	cout << 2*n << "\n";

	return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from collections import deque
n,m=map(int,input().split())
Edges=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1; b-=1
    Edges[a].append(b)
    Edges[b].append(a)
if m%2:
    print(-1)
    exit()
Ans=[]
AnsSet=set()
Par=[-1]*n
V=[]
Visited=[False]*n
Cnt=[0]*n
q=deque([0])
Visited[0]=True
while q:
    fr=q.popleft()
    for to in Edges[fr]:
        if to==Par[fr] or (to,fr) in AnsSet:
            continue
        if Visited[to]:
            AnsSet.add((fr,to))
            Ans.append((fr,to))
            Cnt[fr]+=1
        else:
            Par[to]=fr
            Visited[to]=True
            q.append(to)
            V.append(to)
for v in V[::-1]:
    if Cnt[v]%2:
        Ans.append((v,Par[v]))
    else:
        Ans.append((Par[v],v))
        Cnt[Par[v]]+=1
for c,d in Ans:
    print(c+1,d+1)

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

int main() {
  int n;
  cin >> n;
  if (n % 1000 == 0) {
    cout << 0 << endl;
  } else {
    int ans = 1000 - n % 1000;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#define MAX 20
#define INF 100000
#define ll long long
#define forall(i,a,b) for(int i = a; i < b; ++i)
#define sd(s) scanf("%d", &s);
#define ss(s) scanf("%s", )
using namespace std;

int N, M;
int D[1 << MAX];
int Cnt[1 << MAX];
int W[MAX][MAX];
int P;
int answer = INF;

string INIT;
int main() {
	int l1, l2, r1, r2;
	sd(l1);
	sd(r1);
	sd(l2);
	sd(r2);

	if (l1 >= r2 || l2 >= r1) cout << 0;
	else {
		if (l1 >= l2) {
			cout << min(r1,r2) - l1;
		}
		else {
			cout << min(r1,r2) - l2;
		}
	}
}

Measured memory_bytes: 256