akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

#define MAX 200002
long long MOD = 1000000007;
long long MODPOW2[MAX] = {0};

void initModPow2(){
	MODPOW2[0] = 1;
	for(int i=1; i<MAX; i++){
		MODPOW2[i] = (MODPOW2[i-1]*2)%MOD;
	}
}

long long GCD(long long x, long long y){
        long long r=0;

        if( x<y ) swap(x, y);
        r = x % y;
        while(r!=0){
                x = y;
                y = r;
                r = x % y;
        }
        return y;
}

// U(u個)とV(v個)が直交しているとき、どの2つも内積が0にならない選び方の数
// 余事象で考えて、2**(u+v)から内積が0になりうる選び方の数を引く
long long countUV(long long u, long long v){
	long long a=0, b=0, c=0, ret=0;
	a = MODPOW2[u+v] % MOD;
	b = (MODPOW2[u] - 1) % MOD;
	b = (b*(MODPOW2[v] - 1)) % MOD;
	ret = (a - b) % MOD;
	if(ret<0) ret += MOD;
	return ret;
}

class Tilt{
public:
	long long x;
	long long y;
	Tilt(){x = 0, y = 0;}
	Tilt(long long x, long long y){
		if(x == 0){
			this->x = 0; this->y = 1;
		}
		else if(y == 0){
			this->x = 1; this->y = 0;
		}
		else{
			long p, a, b;
			p = GCD(x, y);
			a = x / p; b = y / p;
			if(a > 0){
				this->x = a; this->y = b;
			}
			else{
				this->x = 0 - a; this->y = 0 - b;
			}
		}
	}
	inline bool operator==(const Tilt &t) const{
		if(x == t.x && y == t.y){
			return true;
		}
		else{
			return false;
		}
	}
	inline bool operator!=(const Tilt &t) const{
		return !(this->operator==(t)) ;
	}
};

class MyHash {
public:
	std::size_t operator() (const Tilt& t) const {
		return (std::size_t) abs(t.x);
	}
};

unordered_map<Tilt, long long, MyHash> m1, m2;

int main(int argc, char* argv[]){
	int N, M;
	long long zero = 0;

	cin >> N;
	m1.reserve(N);
	m2.reserve(N);

	initModPow2();
	long long ans=1; 
	for(int i=1; i<=N; i++){
		long long a, b;
		cin >> a >> b;

		if(a == 0 && b == 0){
			zero++;
			continue; //(0, 0)は除外するが、数えておく
		}
		Tilt t =Tilt(a, b);
		if(m1.count(t)==0){
			m1[t] = 1;
			m2[t] = 1;
		}
		else{
			long long v = m1[t];
			m1[t] = v+1;
			m2[t] = v+1;
		}
	}
	for(auto itr = m1.begin(); itr != m1.end(); itr++){
		if(m2.empty()) break;
		long long x, y, u, v;
		Tilt t = itr->first;
		auto tmpitr1 = m2.find(t);
		if(tmpitr1 == m2.end()){
			continue;
		}
		u = itr->second;
		x = t.x;
		y = t.y;
		Tilt w = Tilt(0 - y, x); //法線ベクトル
		auto tmpitr2 = m2.find(w);
		if( tmpitr2 != m2.end()){
			v = m1[w];
		}
		else{
			v = 0;
		}
		long long uvcnt = countUV(u, v);
		ans = (ans * uvcnt) % MOD;
		m2.erase(t);
		m2.erase(w);
	}
	ans = ans + (zero % MOD) -1 ; //(0, 0)は他のどの要素とも直交するので足す。まったく選ばないを引く。
	ans = ans % MOD;
	if(ans < 0) ans += MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 26636
require 'prime'
#require 'pry'

N = gets.to_i

prime_orders = N.prime_division.map {|nums| nums[1] }

ans = 0
prime_orders.each do |order|
  temp_order = order
  d = 1
  loop do
    break if temp_order < 0
    temp_order -= d
    d += 1
  end
  ans += d - 2
end 

puts ans

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

int main(){
  int n; ll m; cin >> n >> m;
  vl a(n); rep(i,n) cin >> a[i];
  vl s(n+1); rep(i,n) s[i+1] = (s[i] + a[i])%m;

  // mapを使って累積和の剰余類ごとに集計
  map<ll,ll> C;
  ll ans = 0LL;
  rep(i,n+1) {
    ans += C[s[i]];
    C[s[i]]++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,k,x,y,ans=1,b;
int fir[100005],nxt[200005],to[200005],cnt=0;

void dfs(int x,int f,int dep){
	if(dep==1) b=k-1;
	if(dep>1) b=k-2;
	for(int i=fir[x];i;i=nxt[i]){
		if(to[i]==f) continue;
		ans=1LL*ans*(b--)%mod;
	}
	for(int i=fir[x];i;i=nxt[i]){
		if(to[i]==f) continue;
		dfs(to[i],x,dep+1);
	}
}

int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<n;i++){
		scanf("%d %d",&x,&y);
		to[++cnt]=y,nxt[cnt]=fir[x],fir[x]=cnt;
		to[++cnt]=x,nxt[cnt]=fir[y],fir[y]=cnt;
	}
	dfs(1,0,1);
	ans=1LL*ans*k%mod;
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];

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

  ll ans = A[N-1];
  ll now = N-2;
  bool h = 1;
  rep(i,N-2){
    if(h){
      ans += A[now];
      h = 0;
    }
    else{
      ans += A[now];
      h = 1;
      now--;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 4836
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	int a, b, c, x;
	cin >> a >> b >> c >> x;

	int count=0;
	for(int i=0;i<=a;i++) {
		for(int j=0;j<=b;j++) {
			for(int k=0;k<=c;k++) {
				if(500*i + 100*j + 50*k == x) count++;
			}
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    static int count=0;

    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int w = 0,h = 0,sx = 0,sy = 0;
	char[][] tiles;
	
	while(sc.hasNext()){
	    w = sc.nextInt();
	    h = sc.nextInt();
	    if(w==0 && h==0) break;

	    tiles = new char[h][];

	    for(int i = 0;i<h;i++){
		tiles[i] = sc.next().toCharArray();
	    }
	    
	    for(int i = 0;i<tiles.length;i++){
		for(int j = 0;j<tiles[i].length;j++){
		    if(tiles[i][j]=='@'){ sy=i; sx=j;}
		}
	    }
	    
	    goTiles(sy,sx,tiles);
	    System.out.println(count);
	    count=0;
	}
    }
    public static void goTiles(int y,int x,char[][] tiles){
	if(y>=tiles.length || y<0) return;
	if(x>=tiles[y].length || x<0) return;
	if(tiles[y][x]=='#' || tiles[y][x]=='N') return;
	
	count++;
	tiles[y][x] = 'N';
	//System.out.println("now: "+y+","+x+" count: "+count);
	
	goTiles(y-1,x,tiles);
	goTiles(y,x+1,tiles);
	goTiles(y+1,x,tiles);
	goTiles(y,x-1,tiles);
    }
}

Measured memory_bytes: 29728
#![allow(non_snake_case, unused_imports)]
 
// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }
 
// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};
 
// Functions
 
// Main
fn main(){
    input!{
        ABC: [usize; 3],
    }
    println!("{}", 
        if ABC.iter().filter(|&&x| x==5).count() == 2 &&
           ABC.iter().filter(|&&x| x==7).count() == 1 {"YES"}else{"NO"}
    );
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
typedef long long lint;

const int MAXN = 60;
const int MOD = 1e9+7;
lint dp[MAXN][4][4];

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<vector<int> > board(H, vector<int>(W));
  int cur = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < A[i]; j++) {
      int index = cur + j;
      board[index/W][index%W] = i+1;
    }
    cur += A[i];
  }
  for (int i = 1; i < H; i += 2) {
    reverse(board[i].begin(), board[i].end());
  }
  for (int i = 0; i < H; i++) {
    cout << board[i][0];
    for (int j = 1; j < W; j++) {
      cout << " " << board[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int w;
    cin >> w;
    cout << w*32 << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define int long long 

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

ll n, k;
vl a;

signed main()
{
  cin >> n >> k;
  rep(i, n){
    ll A;
    cin >> A;
    a.pb(A);
  }

  ll ans = 0;
  vi c(60, 0);
  rep(i, n){
    rep(j, 60){
      if(a[i]>>j & 1) c[j]++;
    }
  }

  ll x = 0;
  for(int i = 59; i >= 0; i--){
   if(c[i] < n-c[i]){
//      cout << i << ":" << (1LL<<i) << endl;
      if(x + (1LL<<i) <= k){
        x += 1LL<<i;
      }
    }
  }

  rep(i, n){
    ans += x^a[i];
  }

  cout << ans << endl;
  //cout << x << endl;

  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline void read(rel &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  x=f?x:-x;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  rec c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int r[99],n=read(),m=read();
int main(){
for (;m--;){
  r[read()]++,r[read()]++;
  }
for (int i=1;i<=n;++i){
  write(r[i]),pl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int w;
	while(1){
	scanf("%d",&w);
	if(w == -1)
		break;

	if(w <= 10){
		printf("%d\n",4280-1150);
	}
	else if(w > 10 && w <= 20){
		printf("%d\n",4280-(1150+125*(w-10)));
	}
	else if(w > 20 && w <= 30){
		printf("%d\n",4280-(1150+1250+140*(w-20)));
	}
	else if(w > 30){
		printf("%d\n",4280-(1150+1250+1400+160*(w-30)));
	}
	}
	return 0;
}

Measured memory_bytes: 600
#line 1 "/home/parallels/kyopro/cplib/template.cpp"
#include<bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i = 0;i < n;i++)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
using vpi = vector<Pi>;
using vpl = vector<Pl>;

void lyn(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

#line 1 "/home/parallels/kyopro/cplib/debug.cpp"
#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout << "[" << #a << "," << #b << "] = " << "[" << a << "," << b << "]" << '\n'
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
	cout << "{"; for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i]; cout << "}";
	return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
	cout << "{\n"; for (auto& vec : arr)cout << "  " << vec << ",\n"; cout << "}";
	return out;
}
template<class S,class T> ostream &operator << (ostream& out, const pair<S,T>& p){
  cout << "{" << p.first << "," << p.second << "}" << '\n';
  return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
	for (auto& i : arr)cin >> i; return in;
}
#line 2 "main.cpp"

int count(string s,string t){
  int cnt = 0;
  for(int i =0 ;i < s.size();i++){
    cnt += (s[i] != t[i]);
  }
  return cnt;
}
int main(int argc, char const* argv[])
{
  lyn();
  
  string s,t;cin >> s >> t;
  
  int m = t.size();
  int n = s.size();
  int ans = 10000000;
  for(int i = 0;i + m <= n;i++){
    chmin(ans,count(t,s.substr(i,m)));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string a, b, c; cin >> a >> b >> c;
    string res = "NO";
    if(a.back() == b[0] and b.back() == c[0]){
        res = "YES";
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if (a>b && a>c) {
      System.out.println(b*c/2);
    } else if (b>a && b>c){
      System.out.println(a*c/2);
    } else {
      System.out.println(a*b/2);
    }
  }
}

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

int main() {
    int L,R,d,cnt;
    cin >> L >> R >> d;
    cnt = 0;
    for(int i = L; i <= R; i++) {
        if(i % d == 0) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
using namespace std;

double solve(double a){
    double all=a;
    for(int i=2; i<11; i++){
        if(i%2){
            a /= 3;
            all += a;
        }else{
            a *= 2;
            all += a;
        }
    }
    return all;
}

int main()
{
    double a;
    while(cin>>a,!cin.eof()){
        cout<<fixed<<setprecision(8);
        cout<<solve(a)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1276
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=3e5+5;
const int mod=998244353;
int n,len,p[N],sum,a[N];
int fastpow(int x,int y){
	int res=1;
	while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}
	return res;
}
void fwt(int *p,int op){
	for(int i=1;i<len;i<<=1)
		for(int j=0;j<len;j+=i<<1)
			for(int k=0;k<i;++k){
				int x=p[j+k],y=p[j+k+i];
				p[j+k]=(x+y)%mod;
				p[j+k+i]=(x-y+mod)%mod;
			}
	if(!op){
		int inv_len=fastpow(len,mod-2);
		for(int i=0;i<1<<n;++i)p[i]=1ll*p[i]*inv_len%mod;
	}
}
int main(){
	scanf("%d",&n);len=1<<n;
	for(int i=0;i<len;++i)scanf("%d",&p[i]),sum+=p[i];
	sum=fastpow(sum,mod-2);
	for(int i=0;i<len;++i)p[i]=1ll*p[i]*sum%mod,a[i]=mod-1;
	p[0]=(p[0]+mod-1)%mod;a[0]=(1<<n)-1;
	fwt(p,1);fwt(a,1);
	for(int i=0;i<len;++i)a[i]=1ll*a[i]*fastpow(p[i],mod-2)%mod;
	fwt(a,0);
	for(int i=0;i<1<<n;++i)printf("%d\n",(a[i]-a[0]+mod)%mod);
	return 0;
}


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

  
int main(){
 int a;
  cin >> a;
  if(a < 1200)cout << "ABC" <<endl;
  else if(a<2800) cout << "ARC" << endl;
  else cout << "AGC" <<endl; 
 
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	string A;
	cin >> A;
	if (A[0]==A[1] && A[1]==A[2])
		cout << "No";
	else
		cout << "Yes";
}

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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
const int N = 5e5+5;

int n , k , c;
string s;

int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> k >> c;
    cin >> s;
    s = ' '+s;

    vector<int> pre , suf;
    for(int i=1; i<=n; i++)
    {
        if (s[i] == 'o')
        {
            pre.push_back(i);
            i += c;
        }
    }
    for(int i=n; i>0; i--)
    {
        if (s[i] == 'o')
        {
            suf.push_back(i);
            i -= c;
        }
    }

    reverse(suf.begin() , suf.end());

    vector<int> v;
    for(int i=1; i<=n; i++)
    {
        if (s[i] == 'x') continue;
        int l = upper_bound(pre.begin() , pre.end() , i-1)-pre.begin() , nxt , s=0;
        l--;
        s += (l+1);
        if (l >= 0) nxt = max(i,pre[l]+c);
        else nxt = i;

        int r = upper_bound(suf.begin() , suf.end() , nxt) - suf.begin();
        s += (suf.size() - r);
        if (s < k) v.push_back(i);
    }

    for(auto i : v)
        cout << i << '\n';

    return 0;
}

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

#define mp make_pair
#define pb push_back
#define ll long long int
#define sd(x) scanf("%lld",&x)
#define inf 1e18+9
#define pll pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define bits(x) __builtin_popcountll(x)
#define ld long double
#define test() ll test; cin>>test; while(test--)
#define fi first
#define se second


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


inline ll GCD(ll x, ll y) {
    if(x<y) swap(x,y);
    if(x==0) return y;
    if(y==0) return x;
    return GCD(x%y,y);
}

ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}

ll power(ll x, ll n, ll mod) {
    ll res = 1;
    x %= mod;
    while(n) {
        if(n&1) {
            res = ((res*x)%mod+mod)%mod;
        }
        x = ((x*x)%mod+mod)%mod;
        n>>=1;
    }

    return res;
}


int main() {
    fastio;

    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll ans = -inf;

    ans = max(ans,b*d);
    ans = max(a*c,ans);
    ans = max(ans,d*a);
    ans = max(ans,b*c);
    cout<<ans<<endl;
    
}






Measured memory_bytes: 3648
N = int(input())

AList = list(map(int, input().split()))
BList = list(map(int, input().split()))

ans = 0

for i in range(N):
    ans += min(AList[i], BList[i])
    BList[i] = BList[i] - min(AList[i], BList[i])

    ans += min(AList[i + 1], BList[i])
    AList[i + 1] = AList[i + 1] - min(AList[i + 1], BList[i])

print(ans)

Measured memory_bytes: 19116
#include<cstdio>
#include<cstring>
using namespace std;
#define rep(i,j) for(int i=0;i<(j);++i)
#define reps(i,j,k) for(int i=j;i<k;++i)
int n,m,s,d;
char stage[50][20];
int check(){
    int now = m;
    rep(i,d){
        reps(j,1,n-1){
            if(stage[i][j-1] == '1' && stage[i][j] == '1')return 1;
        }
    }
    rep(i,d){
        if(now < n-1 && stage[i][now] == '1')now++;
        else if(now >= 1&&stage[i][now-1] == '1')now--;
    }
    if(now == s)return 0;
}
int main(){
    while(scanf("%d",&n),n){
        scanf("%d%d%d",&m,&s,&d);
        m--,s--;
        rep(i,d)scanf("%s",stage[i]);
        if(check() == 0){
            puts("0");
            goto exit;
        }
            rep(i,d){
                rep(j,n-1){
                    if(stage[i][j] == '0'){
                        stage[i][j] = '1';
                        if(check() == 0){
                            printf("%d %d\n",i+1,j+1);
                            goto exit;
                        }
                        stage[i][j] = '0';
                    }
                }
            }
            puts("1");
        exit:;
        memset(stage,0,sizeof(stage));
    }
    return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  int W,H,N;
  cin >> W >> H >> N;
  vector<vector<int>> a(N,vector<int>(3));
  rep(i,N){
    cin >> a.at(i).at(0) >> a.at(i).at(1) >> a.at(i).at(2);
  }
  int max_1 = 0;
  int min_2 = W;
  int max_3 = 0;
  int min_4 = H;

  rep(i,N){
    if (a.at(i).at(2) ==1) {
      max_1 = max(max_1,a.at(i).at(0));
    }
    if (a.at(i).at(2) ==2) {
      min_2 = min(min_2,a.at(i).at(0));
    }
    if (a.at(i).at(2) ==3) {
      max_3 = max(max_3,a.at(i).at(1));
    }
    if (a.at(i).at(2) ==4) {
      min_4 = min(min_4,a.at(i).at(1));
    }
  }
  if(min_2 - max_1 > 0 && min_4 - max_3 > 0){
    ll ans = (min_2 - max_1) * (min_4 - max_3);
    cout << ans <<endl;
    return 0;
  }else{

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

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>mp;
int main()
{
    ll n,a;
    cin>>n;
    for(ll i=1; i<=n-1; i++)
    {
        cin>>a;
        mp[a]++;
    }
    for(ll i=1; i<=n; i++)
    {
        cout<<mp[i]<<endl;
    }
    mp.clear();
    return 0;
}



Measured memory_bytes: 16132
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
	while (true) {
		int n, x;
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		int counter = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				for (int k = 1; k <= n; k++) {
					if (i != j && j != k && i != k && i + j + k == x) counter++;
				}
			}
		}
		cout << counter / 6 << endl;
	}
}


Measured memory_bytes: 3116
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    string t="ACGT";
    int l=0,ans=0;
    bool flag=0;
    for(int i=0;i<s.size();i++){
        for(int j=0;j<4;j++){
            if(s[i]==t[j]){
                l++;
                ans=max(ans, l);
                flag=1;
            }
        }
        if(!flag) l=0;
        flag=0;
    }
    cout<<ans<<endl;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		int a_in;
		cin >> a_in;
		v.at(i) = a_in;
	}

	sort(v.begin(), v.end());
	double ans = v.at(0);
	for (int i = 1; i < n ; i++) {
		ans = (ans + v.at(i)) / 2;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    PriorityQueue<Double> pq = new PriorityQueue<>();
    for (int i = 0; i < N; i++) {
      double v = scanner.nextInt();
      pq.add(v);
    }

    while (pq.size() > 1) {
      double a = pq.poll();
      double b = pq.poll();
      pq.add((a + b) * 0.5d);
    }

    System.out.println(pq.poll());
  }
}


Measured memory_bytes: 23892
#include<stdio.h>
int main(void){
        int a[3];
        int i,tmp;;
        scanf("%d %d %d",&a[0],&a[1],&a[2]);
        for(i=0;i<=2;i++){
                if(a[0]>a[1]){
                        tmp = a[0];
                        a[0] = a[1];
                        a[1] = tmp;
                }else if(a[1]>a[2]){
                        tmp = a[1];
                        a[1] = a[2];
                        a[2] = tmp;
                }
        }
        printf("%d %d %d\n",a[0],a[1],a[2]);
        return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define MOD 1000000007
#define inf 1e18
#define deb(x) cout << #x << " -> " << x << "\n";

#ifdef LOCAL_DEFINE
	mt19937 rng(228);
#else 
	mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	cout.precision(10);
	cout << fixed;
	int l, r, d, ans = 0;
	cin >> l >> r >> d;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) ans++;
	}		
	cout << ans << "\n";
	return 0;
}


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

class ITP1
{
    static void Main()
    {
        int a;
        int[] x = new int[6];
        int[] y = new int[6];
        string str1 = Console.ReadLine();
        string str2 = Console.ReadLine();
        for (int i = 0; i < 6; i++)
        {
            x[i] = int.Parse(str1.Split()[i]);
            y[i] = int.Parse(str2.Split()[i]);
        }


        for (int i = 0; i < 15; i++)
        {
            if (x[0] == y[0] && x[5] == y[5])
            {
                if (x[1] == y[1] && x[4] == y[4])
                {
                    if (x[2] == y[2] && x[3] == y[3])
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
                else
                {
                    /*SpinCW*/
                    a = y[4]; y[4] = y[3]; y[3] = y[1]; y[1] = y[2]; y[2] = a;
                }
            }
            else
            {
                if (i % 2 == 0)
                {
                    /*RolS*/
                    a = y[0]; y[0] = y[4]; y[4] = y[5]; y[5] = y[1]; y[1] = a;
                }
                else
                {
                    /*RolE*/
                    a = y[0]; y[0] = y[3]; y[3] = y[5]; y[5] = y[2]; y[2] = a;
                }
            }
        }
        Console.WriteLine("No");
    }
}

Measured memory_bytes: 19640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

#define MAX_T 50
#define MAX_P 10

typedef struct {
	int id;
	int time;
	int problem_submit[MAX_P];
	bool problem_accepted[MAX_P];
} team_log;

team_log logs[MAX_T];
int M, T, P, R;

int count_of_accepted(team_log *t)
{
	int i;
	int cnt = 0;
	for (i = 0; i < P; i++)
		if (t->problem_accepted[i])
			cnt++;
	return cnt;
}

int calc_time(team_log *t)
{
	int i;
	int time = t->time;
	for (i = 0; i < P; i++) {
		if (t->problem_accepted[i]) {
			int count_of_rejected = t->problem_submit[i]-1;
			int penalty_time = 20*count_of_rejected;
			time += penalty_time;
		}
	}
	return time;
}

void calc_count_and_time(team_log *t, int *cnt, int *time)
{
	*cnt = count_of_accepted(t);
	*time = calc_time(t);
}

int equal(team_log *l, team_log *r)
{
	int cnt_l, cnt_r;
	int time_l, time_r;

	calc_count_and_time(l, &cnt_l, &time_l);
	calc_count_and_time(r, &cnt_r, &time_r);
	return cnt_l == cnt_r && time_l == time_r;
}

int compare(const void *x, const void *y)
{
	team_log *l, *r;
	int cnt_l, cnt_r;
	int time_l, time_r;

	l = (team_log *)x;
	r = (team_log *)y;
	calc_count_and_time(l, &cnt_l, &time_l);
	calc_count_and_time(r, &cnt_r, &time_r);

	return !(cnt_l > cnt_r
		|| (cnt_l == cnt_r && time_l < time_r)
		|| (cnt_l == cnt_r && time_l == time_r && l->id > r->id));
}

void initialize()
{
	int i;
	for (i = 0; i < T; i++) {
		logs[i].id = i+1;
		logs[i].time = 0;
		memset(logs[i].problem_submit, 0, sizeof(logs[i].problem_submit));
		memset(logs[i].problem_accepted, 0, sizeof(logs[i].problem_accepted));
	}
}

int main(void)
{
	for (;;) {
		int i;

		scanf("%d %d %d %d", &M, &T, &P, &R);
		if (M == 0 && T == 0 && P == 0 && R == 0)
			break;

		initialize();
		for (i = 0; i < R; i++) {
			int m, t, p, j;
			scanf("%d %d %d %d", &m, &t, &p, &j);
			t--;
			p--;

			logs[t].problem_submit[p]++;
			if (j == 0) {
				logs[t].time += m;
				logs[t].problem_accepted[p] = true;
			}
		}

		qsort(logs, T, sizeof(team_log), compare);
		
		for (i = 1; i < T; i++)
			printf("%d%c", logs[i-1].id, (equal(&logs[i-1], &logs[i])?'=':','));
		printf("%d\n", logs[T-1].id);
	}
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  bool c[N][N];
  bool v[N];
  int a[M];
  int b[M];
  queue<int> q;
  REP(i,N)REP(j,N)c[i][j]=0;
  REP(i,M){
    int x,y;
    cin>>x>>y;
    a[i]=x-1;
    b[i]=y-1;
    c[a[i]][b[i]]=1;
    c[b[i]][a[i]]=1;
  }
  int ans=0;
  REP(i,M){
    REP(i,N)v[i]=0;
    c[a[i]][b[i]]=0;
    c[b[i]][a[i]]=0;
    q.push(0);
    while(!q.empty()){
      int p=q.front();
      q.pop();
      v[p]=1;
      REP(j,N){
        if(c[p][j] and !v[j]){
          q.push(j);
        }
      }
    }
    bool flag=0;
    REP(j,N)if(!v[j])flag=1;
    if(flag)ans++;
    c[a[i]][b[i]]=1;
    c[b[i]][a[i]]=1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import bisect
import heapq
import itertools
import math
import numpy as np
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]



#いまいるところ,
#listとnが与えられたときn回テレポートしたところを出力する
def now_place(li,n):
    now = 1
    for i in range(n):
        now = li[now-1]
    return now

#p回のテレポートでたどってきた道筋のルートを返す

def root(li,p):
    ans = []
    now = 1
    for j in range(p):
        ans.append(now_place(li,j+1))
    return ans



n,k = MI()
a = LI()
#訪れたところのメモがtown
town = []
#訪れたかどうかを0と1で管理
visit=[0]*n
p = 1
while visit[p-1] == 0:
    town.append(p)
    visit[p-1] = 1
    p = a[p-1]
l = town.index(p)
if k <len(town):
    print(town[k])
else:
    print(town[l + (k-l)%(len(town[l:]))])


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

int main()
{
    int a, b;
    cin >> a >> b;

    if (a % 2 == 0 || b % 2 == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#define int long long
#define INF 1000000
using namespace std;
int dp[101][3][2],p[101];
int n,k,a,b;
void pst(int day,int tas){
    dp[day][tas][1]=dp[day-1][tas][0];
    for(int i=0;i<3;i++){
        if(i!=tas){
            dp[day][tas][0]+=dp[day-1][i][0];
            dp[day][tas][0]+=dp[day-1][i][1];
            dp[day][tas][0]%=10000;
        }
    }
}
signed main(){
    cin>>n>>k;
    fill(p,p+101,-1);
    for(int i=0;i<k;i++){
        cin>>a>>b;
        p[a]=b-1;
    }
    if(p[1]!=-1)dp[1][p[1]][0]=1;
    else{
        dp[1][0][0]=1;
        dp[1][1][0]=1;
        dp[1][2][0]=1;
    }
    for(int i=2;i<=n;i++){
        if(p[i]!=-1){
            pst(i,p[i]);
        }
        else{
            for(int j=0;j<3;j++){
                pst(i,j);
            }
        }
    }
    int ans=0;
    for(int i=0;i<3;i++){
        for(int j=0;j<2;j++){
            ans+=dp[n][i][j];
            ans%=10000;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#include <string>
using namespace std;

//宣言
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//数値
#define MOD 1000000007
#define INF (1<<20)
const double EPS = 1e-10;
const double PI = acos(-1.0);

//操作
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) FOR(i,0,n)
#define REPB(i,n) for(int i=n;i>=0;--i)
#define SORT(A) sort(A,A+sizeof(A)/sizeof(A[0]))
#define VSORT(A) sort(A.begin(),A.end())
#define EXIST(s,e) (s.find(e)!=s.end())
#define PB push_back
#define MP make_pair
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);

//DEBUG
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main() {
	int x,y;
	cin >> x >> y;
	if (x%y == 0) cout << -1 << endl;
	else {
		cout << x << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <string>
#include<iomanip>
#include<limits>
using namespace std;
int main(void){
   int N,K;
   cin>>N>>K;
   int P[N];
   int count=0;
   for(int i=0;i<N;i++){
       cin>>P[i];
       if(P[i]>=K){
           count++;
       }
   }
   cout<<count<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    ll ai = a[n-1];
    ll aj = a[0];
    ll r = (ai + 1) / 2;
    ll minDiff = LLINF;
    rep(i, n-1) {
        if (chmin(minDiff, abs(a[i] - r))) {
            aj = a[i];
        }
    }
    cout << ai << " " << aj << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
typedef struct graph{
  int k, *v, *c, d, p;
}T_graph;
int main(){
  int n;
  scanf("%d", &n);
  T_graph g[n];
  int id;
  int i, j;
  for(i = 0; i < n; i++){
    scanf("%d", &id);
    scanf("%d", &g[id].k);
    g[id].v = (int *)malloc(sizeof(int) * g[id].k);
    g[id].c = (int *)malloc(sizeof(int) * g[id].k);
    for(j = 0; j < g[id].k; j++)
      scanf("%d %d", &g[id].v[j], &g[id].c[j]);
    g[id].d = 2147483647;
    g[id].p = 0;
  }
  g[0].d = 0;
  g[0].p = 1;
  int q[n];
  int qn = 1;
  q[0] = 0;
  int p = 0;
  for(i = n; i > 0; i--){
    for(p = 0; p < qn; p++)
      for(j = 0; j < g[q[p]].k; j++){
	//printf(" %d", g[q[p]].v[j]);
	if(g[q[p]].d + g[q[p]].c[j] < g[g[q[p]].v[j]].d)
	  g[g[q[p]].v[j]].d = g[q[p]].d + g[q[p]].c[j];
	if(!g[g[q[p]].v[j]].p){
	  q[qn] = g[q[p]].v[j];
	  g[g[q[p]].v[j]].p = 1;
	  qn++;
	}
      }
  }
  for(i = 0; i < n; i++){
    printf("%d %d\n", i, g[i].d);
    free(g[i].v), free(g[i].c);
  }
  return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <set>
using namespace std;
int main(void){
    int N;
    cin >> N;
    set<string> history;
    char lastchar;
    int flg = 1;
    for(auto i = 0; i < N; ++i){
        string s;
        cin >> s;
        if(i != 0){
            if(s[0] != lastchar){
                flg = 0;
                break;
            }
            if(history.count(s) != 0){
                flg = 0;
                break;
            }
        }
        lastchar = *--s.end();
        history.insert(s);
    }
    if(flg){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,x[100],y[100];
map<pair<int,int>,int> mp;
int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
    n=read();int ans=maxd;
    rep(i,1,n) {x[i]=read();y[i]=read();mp[make_pair(x[i],y[i])]=1;}
    if (n==1) {puts("1");return 0;}
    rep(i,1,n)
    {
        rep(j,1,n)
        {
            if (i==j) continue;
            int p=x[i]-x[j],q=y[i]-y[j];
            int cost=0;
            rep(k,1,n)
            {
                int nx=x[k]+p,ny=y[k]+q;
                if (!mp.count(make_pair(nx,ny))) cost++;
            }
            ans=min(ans,cost);
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int w;
	while(w=in(),w!=-1){
		if(w<=10){
			cout<<4280-1150<<endl;
		}else if(w<=20){
			cout<<4280-1150-(w-10)*125<<endl;
		}else if(w<=30){
			cout<<4280-1150-1250-(w-20)*140<<endl;
		}else{
			cout<<4280-1150-1250-1400-(w-30)*160<<endl;
		}
	}
	return 0;
}

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

#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e6 + 41;
const int mod = 1e9 + 7;
const long long INF = 3e18 + 12;
const int inf = 1e9;

int main () {
	boost;
	string s;
	cin >> s;
	if (s == "SUN") cout << 7;
	if (s == "MON") cout << 6;
	if (s == "TUE") cout << 5;
	if (s == "WED") cout << 4;
	if (s == "THU") cout << 3;
	if (s == "FRI") cout << 2;
	if (s == "SAT") cout << 1;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=6;
static const int D=365;
static const int ntype=26;
static const double swap_rate=0.8;
static const double change_rate=1-swap_rate;
static int ans[D+1];
static int max_score=0;
static int t=1100000;

class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int Score(int type){
    int sum=0;
    contest[type].last=0;
    for(int day=1;day<=D;++day){
        if(ans[day]==type){
            sum+=contest[type].s[day];
            int n=day-contest[type].last;
            sum-=contest[type].c*(n*(n-1)/2);
            contest[type].last=day;
        }
    }
    if(ans[D]!=type){
        int n=D-contest[type].last;
        sum-=contest[type].c*(n*(n+1)/2);
    }
    return sum;   
}

void Output(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int d=1;d<=D;++d) cout<<ans[d]<<'\n';
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int before=ans[p];
    int after=rand()%ntype+1;
    int before_score=Score(before)+Score(after);
    ans[p]=after;
    int delta=Score(before)+Score(after)-before_score;
    if(delta>0){ 
        max_score+=delta;
    }
    else ans[p]=before;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp_score=Score(ans[p1])+Score(ans[p2]);
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int delta=Score(ans[p2])+Score(ans[p1])-temp_score;
    if(delta>0){
        max_score+=delta;
    }
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void Solve(int times){
    Greedy();
    for(int i=1;i<=ntype;++i) max_score+=Score(i);
    for(int i=0;i<times;++i){
        double p=(double)rand()/RAND_MAX;
        if(p<swap_rate) swap();
        else change();
    }
}

int main(){
    srand(seed);
    Input();
    Solve(t);
    Output();
}


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

int main(){
  string s;
  cin >>s;
  int a[26]={};
  for(int i=0;i<s.size();++i){
    a[s[i]-'a']++;
  }
  for(int i=0;i<26;++i){
    if(a[i]==0){cout<<(char)('a'+i)<<endl;return 0;}
  }
  cout<<"None"<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                     \
  ifstream in("abc130/abc130_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, X;
  cin >> N >> X;

  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  ll ans = 0;
  vector<int> sum(N + 1, -1);
  sum[0] = 0;
  repi(i, 1, N + 1) {
    ans++;
    sum[i] = sum[i - 1] + c[i - 1];
    if (sum[i] > X) {
      break;
    }
  }
   if (sum[N] != -1 && sum[N] <= X) ans++;

   cout << ans << endl;
}

Measured memory_bytes: 3576
while True:
    H,W = map(int,input().split())
    gyo = ''
    if H == 0:
        break
    for j in range(H):
        if (j+1) % 2 == 0:
            for i in range(W):
                if (i + 1) % 2 == 0:
                    gyo = str(gyo) + "#"
                else:
                    gyo = str(gyo) + '.'
        else:
            for k in range(W):
                if (k + 1) % 2 == 0:
                    gyo = str(gyo) + "."
                else:
                    gyo = str(gyo) + '#'
        print(gyo)
        gyo = ''
    print()


Measured memory_bytes: 5608