akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>

using  namespace std;

int main(){
	while(1){
		int N; cin >> N;
		if(!N) break;
		pair<int, int> a[200];
		a[0].first = 0;
		a[0].second = 0;		
		for(int i=1; i<N; i++){
			int n, d; cin >> n >> d;
			if(d==0){
				a[i].first = a[n].first-1;
				a[i].second = a[n].second;
			} else if(d==1){
				a[i].first = a[n].first;
				a[i].second = a[n].second-1;
			} else if(d==2){
				a[i].first = a[n].first+1;
				a[i].second = a[n].second;
			} else{
				a[i].first = a[n].first;
				a[i].second = a[n].second+1;
			}
		}

		if(N!=1){
			int fmax =-999, fmin = 999;
			int smax =-999, smin = 999;
			for(int i=0; i<N; i++){
				fmax = max(fmax, a[i].first);
				fmin = min(fmin, a[i].first);
				smax = max(smax, a[i].second);
				smin = min(smin, a[i].second);
			}
			cout << fmax-fmin+1 << " " << smax-smin+1 << endl;
		} else{
			cout << 0 << " " << 0 << endl;
		}
	}
}



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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

ll XOR(ll A) {
    ll cnt = (A + 1) / 2;
    ll ans = cnt % 2;
    if (A % 2 == 0) ans ^= A;
    return ans;
}

int main()
{
    ll A, B;
    cin >> A >> B;

    ll ans = XOR(B) ^ XOR(A - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int BIT[200010];
int n, k;
vector<P> vec;
int ans;

int sum(int i) {
	int res = 0;
	while (0 < i) {
		res += BIT[i];
		i -= i & -i;
	}
	return res;
}

void add(int i) {
	while (i <= n + 1) {
		BIT[i]++;
		i += i & -i;
	}
}

signed main() {
	cin >> n >> k;
	vec.push_back({ 0,1 });
	int cnt = 0;
	for (int i = 2; i <= n + 1; i++) {
		int a; cin >> a;
		cnt += a - k;
		vec.push_back({ cnt,i });
	}
	sort(all(vec));
	for (int i = 0; i < (int)vec.size(); i++) {
		ans += sum(vec[i].second);
		add(vec[i].second);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
typedef long long ll;
int gcd(ll a, ll b){
  if (a%b == 0) return(b);
  else return(gcd(b, a%b));
}
int main() {
  ll k; cin>>k;
  ll s=0;
  rep(i, k) {
    rep(j, k) {
      rep(m, k) {
        s+=gcd(i, gcd(j, m));
      }
    }
  }
  cout<<s;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD  998244353
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
#define F first
#define S second
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
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() {
  cout << fixed << setprecision(10);
  int n,k;
  cin >> n >> k;
  vector<int> l(k),r(k);
  rep(i,k){
    cin >> l[i] >> r[i];
  }
  vector<int> dp(n,0);
  dp[0]=1;
  rep(i,n){
    rep(j,k){
      int d = l[j];
      int e = r[j];
      //cout << "d" << d << endl;
      if(i+d<n){
        dp[i+d]+=dp[i];
        dp[i+d]=dp[i+d]%MOD;
      }
      if(i+e+1<n){
        dp[i+e+1]=dp[i+e+1]-dp[i]+MOD;
        dp[i+e+1]=dp[i+e+1]%MOD;
      }
    }
    if(i>=1){
      dp[i+1]=dp[i]+dp[i+1];
      dp[i+1]=dp[i+1]%MOD;
    }
    /*
    cout << "n" << i  << endl;
    rep(k,n){
      cout << dp[k] << endl;
    }
    */
  }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 4048
import sys
input = sys.stdin.readline
N = list(map(int, list(input())[: -1]))
K = int(input())
dp = [[0] * (K + 1) for _ in range(len(N) + 1)]
dplim = [[0] * (K + 1) for _ in range(len(N) + 1)]
dplim[0][0] = 1
for i in range(len(N)):
  for j in range(K + 1):
    if N[i] > 0 and (j < K): dplim[i + 1][j + 1] += dplim[i][j]
    else: dplim[i + 1][j] += dplim[i][j]
    for k in range(10):
      if k < N[i] and (j < K):
        dp[i + 1][j + (k > 0)] += dplim[i][j]
      if k > 0 and (j < K): dp[i + 1][j + 1] += dp[i][j]
      elif j < K: dp[i + 1][j] += dp[i][j]
res = 0
#print(dp, dplim)
for i in range(len(N) + 1):
  res += dp[i][-1]
print(res + dplim[-1][-1])

Measured memory_bytes: 40176
#include<atcoder/all>
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int) (n); i++)
#define MAX 300001
using namespace atcoder;
using namespace std;

int op(int a, int b){
  return max(a, b);
}

int e(){
  return 0;
}
  
int main(){
  int N, K, A;
  cin >> N >> K;
  segtree<int, op, e> seg(MAX);
  rep(i, N){
    cin >> A;
    if(!i) seg.set(A, 1);
    else{
      int m = seg.prod(max(0, A - K), min(MAX, A + K + 1));
      seg.set(A, m + 1);
    }
  }
  cout << seg.all_prod() << endl;
  return 0;
}

Measured memory_bytes: 8572
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]

c = [[0]*3 for _ in range(3)]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                c[i][j] = 1

for i in range(3):
    if c[i][0] and c[i][1] and c[i][2]:
        print('Yes')
        exit()
    if c[0][i] and c[1][i] and c[2][i]:
        print('Yes')
        exit()
if c[0][0] and c[1][1] and c[2][2]:
    print('Yes')
    exit()
if c[0][2] and c[1][1] and c[2][0]:
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 3064
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

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

	if a % 3 == 0 {
		println!("Possible");
		return;
	}
	if b % 3 == 0 {
		println!("Possible");
		return;
	}
	if (a+b) % 3 == 0 {
		println!("Possible");
		return;
	}
	println!("Impossible");
}


Measured memory_bytes: 2108
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()
	ans := 0

	for t := min(a, c); t <= max(b, d); t++ {
		if a < t && t <= b && c < t && t <= d {
			ans++
		}
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A(N, 0);
  REP(i, N) cin >> A[i];
  ll all = 0;
  REP(i, N) { all += A[i]; }
  all /= 2;
  REP(i, N) {
    if (i % 2 == 1)
      all -= A[i];
  }
  cout << (all * 2);
  REP(i, N - 1) {
    cout << " " << (2 * (A[i] - all));
    all = A[i] - all;
  }

  return 0;
}


Measured memory_bytes: 2176
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

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

  int n, k;
  cin >> n >> k;
  vi ans(n, 0);
  REP(i, k) {
    int d;
    cin >> d;
    REP(j, d) {
      int a;
      cin >> a;
      a--;
      ans[a]++;
    }
  }
  int po = 0;
  REP(i, n) {
    if (ans[i] == 0)
      po++;
  }
  cout << po << endl;
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <fstream>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;


// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  os << "--------" << std::endl;
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}


void solve()
{
  ll A;
  ld B;
  std::cin >> A >> B;

  ll ans = (A * std::round(B * 100)) / 100;
  print(ans);

  return;
}

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



Measured memory_bytes: 3792
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1e2 + 2, K = 1e5 + 5;
int numbers[N], n, dp[K][2];

int winner(int k, int turn) {
  if (K == 0)
    return !turn;

  if (dp[k][turn] != -1)
    return dp[k][turn];

  int currWinner = !turn;
  for (int i = 0; i < n && currWinner != turn && numbers[i] <= k; i++)
    currWinner = winner(k - numbers[i], !turn);

  return dp[k][turn] = currWinner;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(); cout.tie();
  int k;
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> numbers[i];
  sort(numbers, numbers+n);
  for (int i = 0; i < K; i++)
    dp[i][0] = dp[i][1] = -1;
  
  if (winner(k, 0) == 0)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  
  return 0;
}


Measured memory_bytes: 8472
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from itertools import permutations

def dist(p1, p2):
    return ((p2[0]-p1[0])**2 + (p2[1]-p1[1])**2)**0.5

def main():
    n = int(readline())
    p = []
    for _ in range(n):
        x, y = map(int, readline().split())
        p.append((x, y))

    pp = [int(i) for i in range(n)]
    sig = 0
    k = 0
    for i in permutations(pp):
        k += 1
        for j in range(len(i)-1):
            sig += dist(p[i[j]], p[i[j+1]])
    print(sig/k)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
// AOJ 0330: Halting Problem
// 2017.10.27 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define ADDV	1
#define ADDC	2
#define SUBV	3
#define SUBC	4
#define SETV	5
#define SETC	6
#define IFV		7
#define HALT	8

typedef struct { int lin, cmd, v1, v2, v3, con, to; } T;
T pgm[52]; int n;

int tr['z'+1];
char var[26]; int sz;
int lin[1002];
char tmp[110][26];
char mk[51][16][16][16][16][16];

void doprint()
{
	int i;
	for (i = 'a'; i <= 'z'; i++) if (tr[i] >= 0) printf("%c=%d\n", i, var[tr[i]]);
}

void calc(int id, int v)
{
	if (v < 0 || v >= 16) { doprint(); exit(0); }
	var[id] = v;
}

int varid(char x)
{
	int r;
	if (tr[x] < 0) r = sz++, tr[x] = r;
	else r = tr[x];
	return r;
}

int main()
{
	int i, pc, cnt;
	char cmd, b1[10], b2[10], b3[10];
	T *tp;

	memset(tr, -1, sizeof(tr)), memset(lin, -1, sizeof(lin)), sz = 0;
	scanf("%d", &n);
	for (tp = pgm, i = 0; i < n; i++, tp++) {
		scanf("%d%s", &tp->lin, b1); lin[tp->lin] = i, cmd = *(b1+1);
		if (cmd == 'A') tp->cmd = HALT;
		else if (cmd == 'D' || cmd == 'U') {
			scanf("%s%s%s", b1, b2, b3);
			tp->v1 = varid(*b1), tp->v2 = varid(*b2);
			if (*b3 >= 'a') {
				tp->cmd = (cmd == 'D') ? ADDV : SUBV;
				tp->v3 = varid(*b3);
			} else {
				tp->cmd = (cmd == 'D') ? ADDC : SUBC;
				tp->con = atoi(b3);
			}
		} else if (cmd == 'E') {
			scanf("%s%s", b1, b2);
			tp->v1 = varid(*b1);
			if (*b2 >= 'a') {
				tp->cmd = SETV;
				tp->v2 = varid(*b2);
			} else {
				tp->cmd = SETC;
				tp->con = atoi(b2);
			}
		} else {		// IF
			scanf("%s%d", b1, &tp->to);
			tp->cmd = IFV, tp->v1 = varid(*b1);
		}
	}
	pc = 0, cnt = 0;
	while (1) {
		tp = pgm+pc;
		if      (tp->cmd == ADDV) calc(tp->v1, var[tp->v2] + var[tp->v3]);
		else if (tp->cmd == ADDC) calc(tp->v1, var[tp->v2] + tp->con);
		else if (tp->cmd == SUBV) calc(tp->v1, var[tp->v2] - var[tp->v3]);
		else if (tp->cmd == SUBC) calc(tp->v1, var[tp->v2] - tp->con);
		else if (tp->cmd == SETV) calc(tp->v1, var[tp->v2]);
		else if (tp->cmd == SETC) calc(tp->v1, tp->con);
		else if (tp->cmd == HALT) break;

		if (tp->cmd == IFV && var[tp->v1] != 0) {
			if (lin[tp->to] < 0) break;
			if (mk[pc][var[0]][var[1]][var[2]][var[3]][var[4]]) { puts("inf"); return 0; }
			mk[pc][var[0]][var[1]][var[2]][var[3]][var[4]] = 1;
			pc = lin[tp->to];
		} else {
			pc++;
			if (pc == n) break;
		}
	}
	doprint();
	return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename Ostream,typename Container>
Ostream& operator<<(Ostream& os,const Container& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

struct UnionFind{
	vi data;
	UnionFind(int n):data(n,-1){}
	int Find(int i){
		return data[i]<0?i:(data[i]=Find(data[i]));
	}
	bool Unite(int a,int b){
		a=Find(a),b=Find(b);
		if(a==b) return false;
		if(-data[a]<-data[b]) swap(a,b);
		data[a]+=data[b];
		data[b]=a;
		return true;
	}
	int Size(int i){
		return -data[Find(i)];
	}
};

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int s,int d,int w):src(s),dst(d),weight(w){}
};
typedef vector<vector<Edge>> Graph;
bool operator<(const Edge& a,const Edge& b){return a.weight<b.weight;}
bool operator>(const Edge& a,const Edge& b){return a.weight>b.weight;}

int Kruskal(const Graph& g,vector<Edge>& forest)
{
	int n=g.size();
	vector<Edge> es;
	rep(i,n) es.insert(end(es),all(g[i]));
	sort(all(es));
	
	UnionFind uf(n);
	int res=0;
	for(auto e:es)
		if(uf.Unite(e.src,e.dst)){
			res+=e.weight;
			forest.push_back(e);
		}
	return res;
}

int main()
{
	for(int n,m;cin>>n>>m && n|m;){
		Graph g(n);
		rep(i,m){
			int u,v,w; cin>>u>>v>>w; u--,v--;
			g[u].emplace_back(u,v,w);
		}
		vector<Edge> tree;
		Kruskal(g,tree);
		cout<<tree[n/2-1].weight<<endl;
	}
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    long long N, C;
    cin >> N >> C;
    vector<long long> x(N + 2), v(N + 2);
    for(long long i = 1; i <= N; i++) {
        cin >> x[i] >> v[i];
    }
    x[0] = 0;
    x[N + 1] = C;
    long long cal = 0;
    vector<vector<long long>> dp(2, vector<long long>(N + 2, 0));
    for(long long i = 1; i <= N; i++) {
        cal += v[i] - x[i] + x[i - 1];
        dp[0][i] = max(dp[0][i - 1], cal);
    }
    cal = 0;
    //左回り
    for(long long i = N; i >= 1; i--) {
        cal += v[i] - x[i + 1] + x[i];
        dp[1][i] = max(dp[1][i + 1], cal);
    }

    long long res = 0;
    for(long long i = 0; i <= N; i++) {
        cal = dp[0][i] + dp[1][i + 1] - x[i];
        res = max(cal, res);
        cal = dp[0][i] + dp[1][i + 1] + x[i + 1] - C;
        res = max(cal, res);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
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;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    map<ll,ll> m;
    ll ans = 0;
    rep(i,n) {
        m[a[i]]++;
        ans += m[a[i]]-1;
    }
    rep(i,n) {
        ll nans = ans;
        ll ns = m[a[i]];
        if(ns >= 2) nans -= ns-1;
        cout << max(0LL,nans) << endl;
    }
}

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

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int left = 0, right = 0;
    scanf("%d%d", &left, &right);
    ans += (right - left + 1);
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;

vector<ll> a,b;

int main(){
  ll n;
  cin >> n;
  a.resize(n);
  b.resize(n);
  for(ll i=0;i<n;++i){
    cin >> a[i];   
  }
  for(ll i=0;i<n;++i){
    cin >> b[i];   
  }

  ll llp = 0;
  ll llm = 0;
  for(ll i=0;i<n;++i){
    if(b[i] > a[i]){
      llp += (b[i] - a[i])/2;
    }else{
      llm += a[i] - b[i];
    }
  }
  cerr << llp<<","<<llm<<endl;
  if(llp >= llm){
    cout <<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}


fun main() {
    val N = nextInt()
    val A = nextLongList().sorted()
    val B = nextLongList().sorted()
    val C = nextLongList().sorted()
    var ans = 0L
    for (b in B) {
        val an = A.lower_bound(b).toLong()
        val cn = N - C.upper_bound(b).toLong()
        ans += an * cn
    }
    println(ans)
}

fun <E : Comparable<E>> List<E>.lower_bound(v: E): Int {
    val res = binarySearch(v, Comparator { o1, o2 -> if (o1 >= o2) 1 else -1 })
    return if (res >= 0) res else res.inv()
}

fun <E : Comparable<E>> List<E>.upper_bound(v: E): Int {
    val res = binarySearch(v, Comparator { o1, o2 -> if (o1 > o2) 1 else -1 })
    return if (res >= 0) res else res.inv()
}

Measured memory_bytes: 69928
//Author- VMAX


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*
/*
ll prf(ll n)
{
    ll c=0,i;
    while(n%2==0)
    {
        n=n/2;
        c++;
    }
    for(i=3;i*i<=n;i++)
    {
        while(n%i==0)
    }
    
    
    
}
*/

int main()
{
     fast
     
     ll n;cin>>n;
     ll a[n],i,s=0;
     map<ll,ll>m;
     f(i,n)
     {
         cin>>a[i];
         m[a[i]]++;
         s+=a[i];
     }
       ll q,x,y;
       cin>>q;
       while(q-->0)
       {
           cin>>x>>y;
           s-=x*m[x];
           s+=y*m[x];
           m[y]+=m[x];
           m[x]=0;
           o(s)
       }
     
   //   o(s)
       
     
   
    re
}

Measured memory_bytes: 10284
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	double xa,ya,xb,yb,xc,yc,xd,yd;
	int a;
	while(cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd){
		if(xa==xb){
			if(yc==yd) a=1;
			else a=2;
		}else if(xc==xd){
			if(ya==yb) a=1;
			else a=2;
		}else{
			double l=(yb-ya)/(xb-xa);
			double m=(yd-yc)/(xd-xc);
			if(fabs(l*m+1)<0.000001) a=1;
			else a=2;
		}
		switch(a){
		case 1:
			cout<<"YES"<<endl;
			break;
		case 2:
			cout<<"NO"<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1216
use std::collections::HashMap;
use std::io::{self, Read};

fn main() {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer).unwrap();
    let mut dist = HashMap::new();
    for c in buffer.trim().chars() {
        let count = dist.entry(c).or_insert(0);
        *count += 1;
    }
    if dist.len() == 2 && dist.values().all(|x| *x == 2) {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            int n = ReadAndParseInt();
            var a = ReadAndParseLongArr();
            for(int i=1;i<n;++i)
            {
                a[i] = a[i] + a[i - 1];
            }

            long min = long.MaxValue;
            for(int i=1;i<n;++i)
            {
                long x = a[i - 1];
                long y = a[n - 1] - x;
                min = Math.Min(min, Math.Abs(x - y));
            }
            Console.WriteLine(min);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 34012
a, b, c, x, y = list(map(int, input().split()))
result = [a*x+b*y]

if x > y:
  result.append((y*2*c) + ((x-y)*a))
  result.append(y*b+(x*(c*2)))
else:
  result.append((x*2*c) + ((y-x)*b))
  result.append(x*a+(y*(c*2)))

result.append(c*2*max(x,y))
print(min(result))


Measured memory_bytes: 3064
#include<iostream>
#include<vector>

using namespace std;


#define PI			3.14159265
#define OO			1e18
#define SS       	second
#define FF       	first
#define Trace(n)  	cout<< #n <<" = "<< n << endl; 
#define ll			long long
#define endl		"\n"
#define EPS		    1e-9
//#define MOD         1e9 + 7	    
//int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
//int dy[] = { -1, 1, 0, 0, 1, -1, 1, -1 };

void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int F(int n)
{
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		if (i*i > n)
			break;
		for (int j = 1; j <= n; j++)
		{
			if ((i*i) + (j*j) > n)
				break;
			for (int k = 1; k <= n; k++)
			{
				if ((i*i) + (j*j) + (k*k) + (i*j) + (j*k) + (i*k) > n)
					break;
				if ((i*i) + (j*j) + (k*k) + (i*j) + (j*k) + (i*k) == n)
					ans++;
			}
		}
	}

	return ans;
}
int main()
{
	fast();
	int n;
	cin >> n;

	for (int i = 1; i <= n; i++)
		cout << F(i) << endl;


#ifndef ONLINE_JUDGE
	//system("pause");
#endif

}

Measured memory_bytes: 3152
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        if (!isKaibun(s)) {
            System.out.println("No");
            return;
        }
        if (!isKaibun(s.substring(0,(s.length()-1)/2))) {
            System.out.println("No");
            return;
        }
        if (!isKaibun(s.substring((s.length()+3)/2-1))) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }

    public static boolean isKaibun(String s) {
        int n = s.length();
        for (int i = 0; i < n / 2; i++) {
            if (s.charAt(i) != s.charAt(n - i - 1)) {
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

signed main(){

    int H, W, N; cin >> H >> W >> N;
    int a, b;
    map<Pii, int> m;
    REP(n, N){
        cin >> a >> b;
        FOR(x, -2, 1) FOR(y, -2, 1){
            int i = a - 1 + x, j = b - 1 + y;
            if(i >= 0 && j >= 0 && i < H - 2 && j < W - 2) m[Pii(i, j)] += 1;
        }
    }

    vec ans(10, 0);
    for(auto p: m) ans[p.second]++;
    
    ans[0] = (H - 2) * (W - 2);
    FOR(i, 1, 10) ans[0] -= ans[i];
    REP(i, 10) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 56448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define INF 1e9;
int main(){
  ll N; cin >> N;
  string S; cin >> S;
  vector<ll> left_west(N);//今見ている場所より左に何人西を向いている人が居るか.
  vector<ll> right_east(N);//今見ている場所より右に何人東を向いている人が居るか.

  ll left_sum = 0;
  for(ll i = 0;i < N;i++){
    left_west[i] = left_sum;
    if(S[i] == 'W')left_sum++;
  }

  ll right_sum = 0;
  for(ll i = N-1;i >= 0;i--){
    right_east[i] = right_sum;
    if(S[i] == 'E')right_sum++;
  }

  ll ans = INF;
  for(ll i = 0;i < N;i++){
    ans = min(ans,left_west[i]+right_east[i]);
  }

  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

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


const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(8);
    int l;
    cin >> l;
    // if (l % 3 == 0) {
    //     cout << (l / 3) * (l / 3) * (l / 3) << endl;
    //     return 0;
    // }
    // int res = 0;
    // rep (i, l + 1) {
    //     rep (j, l + 1) {
    //         int k = l - (i + j);
    //         if (k < 0) continue;
    //         int tmp = i * j * k;
    //         res = max(res, tmp);
    //     }
    // }
    double a = (double)l / 3;
    double b = (l - a) / 2;
    double c = l - a - b;
    cout << a * b * c << endl;
    // cout << res << endl;
    
    return 0;
}



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

int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    int s;
    cin >> s;
    int ans = 0;
    vector<int> a;
    a.push_back(s);
    while(1){
        int n = a.back();
        if(n % 2 == 0){
            a.push_back(n/2);
        }else{
            a.push_back(3 * n + 1);
        }
        for(int i = 0; i < a.size()-1; i++){
            if(a.back() == a[i]){
                cout << a.size() << endl;;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7

using namespace std;

ll ola,n,ar[N],ans[N];
set < pi > dp[N];

bool ison(ll mask,ll ind)
{
    return (mask>>ind)&1;
}

void solve()
{
    dp[0].insert(mp(ar[0],0));

    rep(i,1,ola)
    {
        dp[i].insert(mp(ar[i],i));

        rep(b,0,n)
        {
            if(!ison(i,b))
                continue;

            ll j = i^(1 << b);

            for(set < pi >::iterator it = dp[j].begin();it!=dp[j].end();it++)
                dp[i].insert(*it);

            while(dp[i].size() > 2)
                dp[i].erase(dp[i].begin());
        }

        for(set < pi >::iterator it = dp[i].begin();it!=dp[i].end();it++)
            ans[i] += (*it).first;
    }

    return;
}

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

    cin >> n;
    ola = (1<<n);

    rep(i,0,ola)
        cin >> ar[i];

    solve();

    rep(k,1,ola)
    {
        ans[k] = max(ans[k],ans[k-1]);
        cout << ans[k] << "\n";
  //      cout << dp[k].first << " " <<dp[k].second << "\n";
    }

    return 0;
}


Measured memory_bytes: 54272
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
using namespace std;

class Point {
public:
    double x, y;

    Point(double x=0, double y=0): x(x), y(y) {}

    Point operator + (Point p) { return Point(x+p.x, y+p.y); }
    Point operator - (Point p) { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(x*a, y*a); }
    Point operator / (double a) { return Point(x/ a, y/ a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x*x, y*y; }
    bool operator < (const Point &p) const {
	return x != p.x ? x<p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const {
	return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

typedef Point Vector;

struct Segment {
    Point p0, p1;
};

typedef Segment Line;

double dot(Vector a, Vector b) {
    return a.x*b.x + a.y*b.y;
}

double norm(Vector a) {
    return a.x*a.x + a.y*a.y;
}

double abs(Vector a){
    return sqrt(norm(a));
}

/*
  ???????????§??????????????¨??????????????°??????
  |a*b|=|a||b|sin(theta)
 */
double cross(Vector a, Vector b){ 
    return a.x*b.y - a.y*b.x;
}
    
int main() {
    int n,i,d;
    
    Point p0, p1, p2;
    cin >> p0.x >> p0.y >> p1.x >> p1.y;
    cin >> n;
    for(i=0;i<n;i++){
	cin >>  p2.x >> p2.y;
	
	if (cross(p1-p0, p2-p0) > EPS) cout << "COUNTER_CLOCKWISE" << endl;
	else if (cross(p1-p0, p2-p0) < -EPS) cout << "CLOCKWISE" << endl;
	else if (dot(p1-p0, p2-p0)/ (abs(p1-p0)*abs(p2-p0)) + 1 < EPS) cout << "ONLINE_BACK" << endl;
	else if (abs(p2-p0) > abs(p1-p0)) cout << "ONLINE_FRONT" << endl;
	else cout << "ON_SEGMENT" << endl;

    }
    return 0;

}

Measured memory_bytes: 1224
# -*- coding: utf-8 -*-
"""
Created on Thu May 12 18:42:47 2016
"""

class Plane:
    def __init__(self, num_of_jewels):
        self.jewels = []
        for i in range(21):
            self.jewels.append([False] * 21)
        self.nj = num_of_jewels
        self.robot = [10, 10]
    def putJewels(self, x, y):
        self.jewels[x][y] = True
    def moveRobot(self, direction, str_distance):
        distance = int(str_distance)
        axe, dir = {'N':[1, 1], 'S':[1, -1], 'E':[0, 1], 'W':[0, -1]}[direction]
        for dis in range(1, distance+1):
            self.robot[axe] += dir
            if self.jewels[self.robot[0]][self.robot[1]] == True:
                self.nj -= 1
                self.jewels[self.robot[0]][self.robot[1]] = False
                
    def judge(self):
        if self.nj == 0:
            return True
        else:
            return False
            
if __name__ == '__main__':
    while True:
        n = int(input())
        if n == 0:
            break
        
        p = Plane(n)
        for i in range(n):
            x, y = map(int, input().split())
            p.putJewels(x, y)
        
        m = int(input())
        for i in range(m):
            d1, d2 = input().split()
            p.moveRobot(d1, d2)
            
        print({True:'Yes', False:'No'}[p.judge()])

Measured memory_bytes: 7740
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>

int main(int argc, char *argv[])
{
	int n;

	cin >> n;
	vector<double> v(n);
	for (int i=0;i<n;i++)
	{
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	double a=(v[0]+v[1])/2;

	for (int i=2; i<n; i++)
	{
		a=(a+v[i])/2;
	}
	cout << a;
	return 0;
}



Measured memory_bytes: 256
using Yorukatsu022.Questions;
using Yorukatsu022.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu022.Questions
{
    /// <summary>
    /// ABC060 B
    /// </summary>
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var abc = inputStream.ReadIntArray();
            var a = abc[0];
            var b = abc[1];
            var c = abc[2];

            for (int i = 1; i <= b; i++)
            {
                if ((a * i) % b == c)
                {
                    yield return "YES";
                    yield break;
                }
            }

            yield return "NO";
        }
    }
}


namespace Yorukatsu022
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu022.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu022.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++){
    cin>>a[i];
  }
  int res=1000;
  for(int i=0; i<n; i++){
    int res1=0;
    while (a[i]%2 ==0){
      a[i]/=2;
      ++res1;
    }
    if (res1==0) {
      res = 0;
      break;
    }
    if (res1<res){
      res=res1;
    }
  }
  cout<<res<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(2 * M), b(2 * M);
    rep(i, M) cin >> a.at(i) >> b[i];
    rep(i, M) a.at(i + M) = b.at(i);
    rep(i, M) b.at(i + M) = a.at(i);
    vector<int> order(N);
    rep(i, N) order[i] = i + 1;
    int ans = 0;
    do{//すべての周り方を調べて道がつながっているのか調べる。
        bool flag = true;
        rep(i, N - 1){
            auto itr = a.begin();
            while(1){
                itr = find(itr, a.end(), order[i]);
                if(itr == a.end()){
                    flag = false;
                    break;
                }
                int index = itr - a.begin();
                if(b[index] == order[i + 1]){
                    break;
                }
                itr++;
            }
        }
        if(flag == true && order[0] == 1){
            ans++;
        }
    }while(next_permutation(all(order)));
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import collections
N = int(input())
A = list(map(int, input().split()))

L = []
R = []
for i in range(N):
    L.append(i+A[i])
    R.append(i-A[i])

C_L = collections.Counter(L)
C_R = collections.Counter(R)
ans = 0
for l, t in C_L.items():
    if l in C_R:
        ans += t*C_R[l]
print(ans)


Measured memory_bytes: 144016
import sys
sys.setrecursionlimit(1000000)
N = int(input())
a = [0]*(N+1)
for i in range(1, N+1):
    a[i] = int(input())

def solve(i, n):
    if n == 2:
        print(i)
    elif i == N:
        print(-1)
    else:
        return solve(i+1, a[n])

solve(0, 1)

Measured memory_bytes: 92916
def solve(N, K, As):
    Bs = ["{0:041b}".format(a) for a in As]
    ans = ""
    for i in range(0, 41):
        ck = sum([int(b[i]) for b in Bs])
        if ck > N - ck:
            ans += "0"
        else:
            ans += "1"

    Kstr = "{0:041b}".format(K)
    d = 0
    for k in range(1, 42):
        x = Kstr[:k-1] + "0" + ans[k:]
        X = int(x, 2)
        if X <= K:
            d = max(d, sum(X ^ a for a in As))
    return d

if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, K, As))


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

typedef long long ll;

typedef pair<int, pair<int, int> > p;

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

    int A, B;
    cin >> A >> B;

    if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
   int H,W;cin >> H >> W;
   vector<vector<int>>c(10,vector<int>(10));
   rep(i,10)rep(j,10)cin >> c[i][j];
   for(int k=0;k<10;k++){
       for(int i=0;i<10;i++){
           for(int j=0;j<10;j++){
               c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
           }
       }
   }
   ll ans=0;
   rep(i,H)rep(j,W){
       int a;cin >> a;
       if(a==-1)continue;
       ans+=c[a][1];
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int A, B, K;
	cin >> K >> A >> B;

	auto ans = "NG";
	for (auto i = A; i <= B; ++i)
	{
		if (i % K == 0)
		{
			ans = "OK";
			break;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3600