akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;


int main()
{
    int n, x, count;

    while (true)
    {
        cin >> n >> x;
        if (n==0 && x==0)   break;
        
        count = 0;
        for (int i=1; i<=n; ++i)
        {
            for (int j=i+1; j<=n; ++j)
            {
                for (int k=j+1; k<=n; ++k)
                {
                    if (i+j+k == x) ++count;
                }
            }
        }
        cout << count << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
typedef long long ll;
 
int main() {
  ll a,b;
  cin >> a >> b;
  ll c = min(a,(ll)(b/2LL));
  a -= c;
  b -= c * 2LL;
  c += (ll)(b/4LL);
  cout << c << endl;
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(3 * n);
	for (auto &e : a) {
		cin >> e;
	}
	sort(begin(a), end(a));
	long long m = 0;
	for (int i = 0; i < n; i++) {
		m += a[n + 2 * i];
	}
	cout << m << endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;
  vll a(n + 1);
  rep(i, n + 1) {
    cin >> a[i];
  }

  /*
  if (n == 0) {
    if (a[0] == 1) {
      cout << 1 << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }
  */

  // 子を持つノードの数
  vll e(n + 1);

  for (int i = n - 1; i >= 0; i--) {
    ll child = e[i + 1] + a[i + 1];
    e[i] = (child + 1) / 2;
  }

  if (a[0] + e[0] != 1) {
    cout << -1 << endl;
    return 0;
  }

  vll sum_leaf(n + 2);
  for (int i = n; i >= 0; i--) {
    sum_leaf[i] = sum_leaf[i + 1] + a[i];
  }

  vll num_node(n + 1);
  num_node[0] = 1;
  REP(i, n) {
    num_node[i] = min(sum_leaf[i], (num_node[i - 1] - a[i - 1]) * 2);
  }
  num_node[n] = a[n];

  cout << accumulate(all(num_node), 0ll) << endl;

  return 0;
}


Measured memory_bytes: 6368
N = int(input())
zoro_try = []
zoro_cnt = 0
isOk = False
for i in range(N):
    d1, d2 = map(int, input().split())
    zoro_try.append([d1, d2])
    if i == 0 or i == 1: continue
    if zoro_try[i-1][0] == zoro_try[i-1][1] and zoro_try[i-2][0] == zoro_try[i-2][1] and zoro_try[i][0] == zoro_try[i][1]:
        isOk = True

if isOk:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9184
A = [list(map(int, input().split())) for i in range(3)]
Ab = [[0 for i in range(3)] for j in range(3)]

N = int(input())
b = [0 for i in range (N)]
for i in range(N):
  b[i] = int(input())
for i in range(3):
  for j in range(3):
    if A[i][j] in b:
      Ab[i][j] = 1
isbingo = False
for i in range(3):
  if (Ab[0][i] == Ab[1][i] == Ab[2][i] == 1\
      or Ab[i][0] == Ab[i][1] == Ab[i][2] == 1):
    isbingo = True
if (Ab[0][0] == Ab[1][1] == Ab[2][2] == 1\
   or Ab[0][2] == Ab[1][1] == Ab[2][0] == 1):
  isbingo = True
if isbingo:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define dump(x) cerr << #x << " = " << (x) << endl

using namespace std;

string S;

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

    cin >> S;

    bool c[26];
    REP(i, 26)
    {
        c[i] = false;
    }

    REP(i, S.size())
    {
        c[S[i] - 'a'] = true;
    }

    REP(i, 26)
    {
        if(!c[i]){
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
// static const ll max_n = 200010;



int main(){
    // int u, v;
    // bool updated = false;
    set<string> items;
    ll N, A;
    string S;
    scanf("%lld", &N);
    for(ll i=0;i<N;i++){
        cin >> S;
        items.insert(S);
    }

    cout << items.size() <<endl;

    return 0;

}

Measured memory_bytes: 15584
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

typedef long long int Int;

int main(void) {
    int n,k;
    Int sum = 0;

    cin>>n>>k;
    for(int i = 1;i <= n;i++) {
        int x;
        cin>>x;
        sum += 2*min(abs(x-k),x);
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    return buf;
}

fn main() {
    let n: i32 = read().trim().parse().unwrap();
    let v: Vec<i32> = read()
        .trim()
        .split(' ')
        .map(|x| x.parse().unwrap())
        .collect();
    let c: Vec<i32> = read()
        .trim()
        .split(' ')
        .map(|x| x.parse().unwrap())
        .collect();

    let mut ans = 0;
    for i in 0..n as usize {
        ans += std::cmp::max(v[i] - c[i], 0);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
vector<int> abc(3, 0);
int main() {
    for(int i = 0; i < 3; ++i) {
        cin >> abc.at(i);
    }
    sort(abc.begin(), abc.end());
    if(abc.at(0) != abc.at(1)) {
        cout << abc.at(0) << endl;
    }else if(abc.at(1) != abc.at(2)) {
        cout << abc.at(2) << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        public static void myout(Object text){System.out.println(text);}
        public static String getStr(){return sc.next();}
        public static int getInt(){return sc.nextInt();}
        public static Long getLong(){return sc.nextLong();}
        public static boolean isNext(){return sc.hasNext();}
        public static void main(String[] args){
                //String tmp = getStr();
                //int tmp = getInt();
                //Long tmp = getLong();
          Long N = getLong();
          LinkedList<Long> list = getDivisorList(N);
          //myout(list);
          int tmpSize = list.size();
          Long A,B;
          if(tmpSize % 2 == 1){
            tmpSize++;
            A = list.get((tmpSize / 2) - 1) - 1;
            B = list.get((tmpSize / 2) - 1) - 1;
          }else{
            A = list.get(tmpSize / 2) - 1;
            B = list.get((tmpSize / 2) - 1) - 1;
          }
          //myout("A:" + A);
          //myout("B:" + B);
          myout(A + B);
          
          
          
        }
        //便利メソッド追加枠ここから
		public static LinkedList<Long> getDivisorList(Long val){
        LinkedList<Long> list = new LinkedList<Long>();
        for(Long i = new Long(1); i * i <= val; i++){
                if(val % i == 0){
                        list.add(i);
                        if(i * i != val){
                                list.add(val / i);
                        }
                }
        }
        Collections.sort(list, Comparator.naturalOrder());
        return list;
}
        //便利メソッド追加枠ここまで
}


Measured memory_bytes: 40404
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let (n,y) = {
        let line = get_input();
        let mut split = line.split_whitespace();
        let n:i64 = split.next().unwrap().parse().unwrap();
        let y:i64 = split.next().unwrap().parse().unwrap();
        (n,y)
    };

    let mut ans = (-1,-1,-1);

    'outer: for a in 0..n+1 {
        for b in 0..n-a+1 {
            let c = n - a - b;
            if a + b + c == n && a * 10000 + b * 5000 + c * 1000 == y {
                ans = (a, b, c);
                break 'outer;
            }
        }
    }

    println!("{} {} {}", ans.0, ans.1, ans.2);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10, mod = 1e9 +  7;
inline int read() {
	int x = 0, f = 1; char c = getchar();
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * f;
}
int N, a[MAXN], b[MAXN], f[5001][5001], fac[10001], ifac[10001];
int add(int x, int y) {
	return (x + y) > mod ? (x + y - mod) : (x + y + mod) % mod;
}
int mul(int x, int y) {
	return 1ll * x * y % mod;
}
int fastpow(int a, int p) {
	int base = 1;
	while(p) {
		if(p & 1) base = mul(base, a);
		a = mul(a, a); p >>= 1;
	}
	return base;
}
void init() {
	fac[0] = 1;
	for(int i = 1; i <= 8000; i++) fac[i] = mul(i, fac[i - 1]);
	ifac[8000] = fastpow(fac[8000], mod - 2);
	for(int i = 8000; i; i--) ifac[i - 1] = mul(i, ifac[i]);
}
int id(int x) {
	return 2001 + x;
}
int C(int N, int M) {
	return 1ll * fac[N] * ifac[N - M] % mod * ifac[M] % mod;
}
main() {
//	freopen("a.in", "r", stdin);
	init();
	N = read();
	for(int i = 1; i <= N; i++) a[i] = read(), b[i] = read(), f[id(-a[i])][id(-b[i])]++;
    for(int i = 1; i <= 4221; i++)
    	for(int j = 1; j <= 4221; j++)
    			f[i][j] = add(f[i][j], add(f[i - 1][j], f[i][j - 1]));
    		//	printf("%d %d %d\n", i, j, f[i][j]);
    int sum = 0;
    for(int i = 1; i <= N; i++) 
		sum = add(sum, add(f[id(a[i])][id(b[i])], -C(a[i] + b[i] + a[i] + b[i], a[i] + a[i])));
		//这里会到8000.。。 
    sum = 1ll * sum * 500000004ll % mod;
    cout << sum % mod;
    return 0;
}
/*
8
2000 2000
1999 1998
1 1
1 1
2 1
1 3
2 1
3 3
*/

Measured memory_bytes: 87296
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
    a=input()
    if a=='AC':
        ac+=1
    elif a=='WA':
        wa+=1
    elif a=='TLE':
        tle+=1
    else:
        re+=1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

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

typedef long long ll;
const int MOD = 1000000007;

ll gcd(ll a, ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  if(a % b == 0) return a;
  return a / gcd(a, b) * b;
}

int main(){
  int N; 
  cin >> N;
  vector<ll> T(N);
  for(int i = 0; i < N; i++){
    cin >> T[i];
  }
  ll res = T[0];
  for(int i = 1; i < N; i++){
    res = lcm(max(res, T[i]), min(res, T[i]));
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
using Graph = vector<vector<int>>;

#define INF (1 << 21);


int main(){
  int a, ans = 0,b = 0;
  for(int i = 0;i < 5;++i){
    cin >> a;
    if(a % 10 != 0){
      ans += a + (10 - a%10);
      b = max(b, (10 - a%10));
    }
    else{
      ans += a;
    }
  }

  cout << ans - b;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int i, j;
  int h, w;

  while(scanf("%d %d", &h, &w) != EOF && (h != 0 && w != 0)) {
    for(i = 0; i < h; i++) {
      for(j = 0; j < w; j++) {
        printf("%c", (i != 0 && i != (h - 1) && j != 0 && j != (w - 1)) ? '.' : '#');
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

vi prime;

void sieve(){
    bool is_prime[55556];
    for(int i=0;i<55556;i++)is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<55556;i++){
        if(is_prime[i]){
	  prime.pb(i);
	  for(int j=2*i;j<55556;j+=i)is_prime[j]=false;
        }
    }
}

int main(){
  int n;
  vi ans;
  cin>>n;
  sieve();
  int i=0;
  while(n){
    if(prime[i]%5==1){
      if(prime[i]==11)cout<<prime[i];
      else cout<<" "<<prime[i];
      n--;
    }
    i++;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define int long long
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1e5+5;


int32_t main() {
	int N, K;
	cin >> N >> K;
	vector<int> used(105, 0);
	while(K--) {
		int t;
		cin >> t;
		for(int i = 0; i < t; i++) {
			int u;
			cin >> u;
			used[u]++;
		}
	}
	int ans = 0;
	for(int i = 1; i <= N; i++)
		if(!used[i]) ans++;
	cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

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

  int h;
  int ans{};
  for (int i = 0; i < N; i++) {
    cin >> h;
    if (h >= K) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint X;
    cin >> X;
    vector<lint> res;
    for (long long i = 1; i * i <= X; ++i) {
        if (X % i == 0) {
            res.push_back(i);
            if (X/i != i) res.push_back(X/i);
        }
    }
    for(lint r : res) {
        lint A = r / 2;
        lint target = X / r;
        while(true) {
            lint B = A - r;
            lint tmp = A*A*A*A+A*A*A*B+A*A*B*B+A*B*B*B+B*B*B*B;
            if(tmp == target) {
                cout << A << " " << B << endl;
                return 0;
            } else if(abs(tmp) > target) break;
            A++;
        }
        A = r / 2;
        while(true) {
            lint B = A - r;
            lint tmp = A*A*A*A+A*A*A*B+A*A*B*B+A*B*B*B+B*B*B*B;
            if(tmp == target) {
                cout << A << " " << B << endl;
                return 0;
            } else if(abs(tmp) > target) break;
            A--;
        }
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

long long dp[3000];
int main()
{
    int n,i,sum;
    scanf("%d",&n);

    dp[0]=1;
    for(i=1; i<=n; i++){
        for(int j=3; j<=i; j++){
            dp[i]=(dp[i]+dp[i-j])%mod;
        }
    }

    printf("%lld\n",dp[n]);
}

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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  vector<int> ans(N,0);
  int st = 0;
  int evn = 0, odd = 0;
  for (int i=0; i<N; i++){
    if (S[i] == 'L'){
      if (evn>0||odd>0){
        if ((i-st)%2==0){
          ans[i] += evn;
          ans[i-1] += odd;
        } else {
          ans[i-1] += evn;
          ans[i] += odd;
        }
        evn = 0;
        odd = 0;
      }
    } else {
      if (evn==0&&odd==0) st = i;
      if ((i-st)%2==0) evn++;
      else odd++;
    }
  }
  for (int i=N-1; i>-1; i--){
    if (S[i] == 'R'){
      if (evn>0||odd>0){
        if ((st-i)%2==0){
          ans[i] += evn;
          ans[i+1] += odd;
        } else {
          ans[i+1] += evn;
          ans[i] += odd;
        }
        evn = 0;
        odd = 0;
      }
    } else {
      if (evn==0&&odd==0) st = i;
      if ((st-i)%2==0) evn++;
      else odd++;
    }
  }
  for (int i=0; i<N; i++){
    if (i>0) cout << ' ';
    cout << ans[i];
  }
  cout << endl;
}


Measured memory_bytes: 1024
//  atcodder.xcode
//  main.cpp
//  Created by conan1024hao on 2019/11/09.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリ
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,a,b;
    cin>>n>>a>>b;
    int maxm=mmin(a,b);
    int minm=max(0,(a+b-n));
    cout<<maxm<<" "<<minm<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, q; std::string s;
    std::cin >> n >> q >> s;
    s = 'a' + s + 'a';
    std::vector<std::pair<char, int>> v;
    int ll = 1, rr = n;
    for (int i = 0; i < q; i++) {
        char c, d;
        std::cin >> c >> d;
        v.emplace_back(c, d == 'L');
        if (c == s[ll]) {
            if (d == 'L') ll--;
            else ll++;
        }
        if (c == s[rr]) {
            if (d == 'L') rr--;
            else rr++;
        }
    }

    int lpos = -1, rpos = -1;
    if (ll == 0) {
        int l = 1, r = n + 1;
        while (r - l > 1) {
            int m = (l + r) / 2;
            int pos = m;
            for (int i = 0; i < q; i++) {
                if (v[i].first == s[pos]) {
                    if (v[i].second) pos--;
                    else pos++;
                }
            }
            if (pos == 0) l = m;
            else r = m;
        }
        lpos = l;
    }

    if (rr == n + 1) {
        int l = 0, r = n;
        while (r - l > 1) {
            int m = (l + r) / 2;
            int pos = m;
            for (int i = 0; i < q; i++) {
                if (v[i].first == s[pos]) {
                    if (v[i].second) pos--;
                    else pos++;
                }
            }
            if (pos == n + 1) r = m;
            else l = m;
        }
        rpos = r;
    }

    // std::cout << lpos << " " << rpos << std::endl;

    int ret = n;
    if (lpos >= 0) ret -= lpos;
    if (rpos >= 0) ret -= n + 1 - rpos;
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 2776
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int> ruiseki(n+1,0);
    
    for(int i=1;i<=n;i++){
        ruiseki[i]=ruiseki[i-1];
        if(i>1){
            if(s.at(i-2)=='A' && s.at(i-1)=='C') ruiseki[i]++;
        }
    }
    
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        int yes=0;
        if(s[l-2]=='A' && s[l-1]=='C') yes=-1;
        cout<<yes+(ruiseki[r]-ruiseki[l-1])<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,m,t,p=0,a[102];
    scanf("%d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }

    for(i=0; i<n-1; i++)
    {
        m=i;
        for(j=n-1; j>=i+1; j--)
        {
            if(a[j]<a[j-1])
            {
                swap(a[j],a[j-1]);
            p++;
            }
        }

    }

    for(i=0; i<n-1; i++)
    {
        printf("%d ",a[i]);
    }
    printf("%d\n",a[n-1]);
    printf("%d\n",p);
    return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n;cin>>n;
	ll sum = 0;
	for(ll i = 1; i <= n; i++) {
		if (i % 3 != 0  && i % 5 != 0){
			sum += i;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
/* A - αlphabet */

#include <stdio.h>

int main(void){
  char alph;
  scanf("%c", &alph);
  if(alph >= 'A' && alph < 'A' + 26){
    printf("A\n");
  }else if(alph >= 'a' && alph < 'a' + 26){
    printf("a\n");
  }else{
    fprintf(stderr, "error!\n");
  }
  return 0;
}


Measured memory_bytes: 1572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            var ny = Array.ConvertAll(Console.ReadLine().Split(), int.Parse).ToList();
            int a1 = -1;
            int a2 = -1;
            int a3 = -1;
            int check = 0;
            for (int i = ny[0]; i >= 0; i--)
            {
                if (i * 10000 > ny[1]) continue;
                if (check == 1) break;
                for (int j = ny[0] - i; j >= 0; j--)
                {
                    if (10000 * i + 5000 * j + 1000 * (ny[0] - i - j) == ny[1])
                    {
                        a1 = i; a2 = j; a3 = ny[0] - i - j;
                        check = 1;
                    }
                }
            }
            Console.WriteLine(a1 + " " + a2 + " " + a3);
        }
    }
}


Measured memory_bytes: 13268
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {

        new Main().go();
    }

    PrintWriter out;
    Reader in;
    BufferedReader br;

    Main() throws IOException {

        try {

            //br = new BufferedReader( new FileReader("input.txt") );
            in = new Reader("input.txt");
            out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        }
        catch (Exception e) {

            //br = new BufferedReader( new InputStreamReader( System.in ) );
            in = new Reader();
            out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
        }
    }

    void go() throws IOException {

        int t = 1;
        while (t > 0) {
            solve();
            //out.println();
            t--;
        }

        out.flush();
        out.close();
    }

    int inf = 2000000000;
    int mod = 1000000007;
    double eps = 0.00000001;

    int n;
    int m;

    //ArrayList<Pair>[] g = new ArrayList[2000000];

    void solve() throws IOException {

        char[] s = in.next().toCharArray();
        int n = s.length;

        int[] cnt = new int[250];

        long ans = 0;

        for (int i = 0; i < n; i++) {
            ans += i - cnt[s[i]];
            cnt[s[i]]++;
        }

        out.println(ans+1);
    }

    class Pair implements Comparable<Pair>{

        int a;
        int b;

        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {

            if (a > p.a) return 1;
            if (a < p.a) return -1;
            if (b > p.b) return 1;
            if (b < p.b) return -1;
            return 0;
        }
    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }


        String nextLine() throws IOException {
            return br.readLine();
        }

    }

}

Measured memory_bytes: 27216
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 2000 + 47;

string s, t;
int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n >> s >> t;
	int cnt = 0;
	FOR(k, 1, n + 1)
	{
		if (s.substr(n - k, k) == t.substr(0, k)) cnt = max(k, cnt);
	}

	cout << 2 * n - cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl //小数をn桁で出力

int main() {
    IN(int, h);
    IN(int, w);
    int white = 0;
    vector<vector<char>> a(h,vector<char>(w));
    vector<vector<int>> dist(h,vector<int>(w,-1));
    REP(i, h){
        REP(j, w){
            cin >> a[i][j];
            if (a[i][j] == '.') {
                white++;
            }
        }
    }
    queue<pair<int, int>> que;
    que.push(MP(0, 0));
    dist[0][0] = 0;
    while (!que.empty()) {
        pair<int, int> now = que.front();
        que.pop();
        if (now.first > 0){
            if ((dist[now.first-1][now.second]==-1)&&(a[now.first-1][now.second]=='.')) {
                dist[now.first-1][now.second] = dist[now.first][now.second]+1;
                que.push(MP(now.first-1, now.second));
            }
        }
        if (now.second > 0){
            if ((dist[now.first][now.second-1]==-1)&&(a[now.first][now.second-1]=='.')) {
                dist[now.first][now.second-1] = dist[now.first][now.second]+1;
                que.push(MP(now.first, now.second-1));
            }
        }
        if (now.first < h-1){
            if ((dist[now.first+1][now.second]==-1)&&(a[now.first+1][now.second]=='.')) {
                dist[now.first+1][now.second] = dist[now.first][now.second]+1;
                que.push(MP(now.first+1, now.second));
            }
        }
        if (now.second < w-1){
            if ((dist[now.first][now.second+1]==-1)&&(a[now.first][now.second+1]=='.')) {
                dist[now.first][now.second+1] = dist[now.first][now.second]+1;
                que.push(MP(now.first, now.second+1));
            }
        }
    }
    if (dist[h-1][w-1]==-1) {
        COUT(-1);
    }else{
        COUT(white-dist[h-1][w-1]-1);
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input()) 
vlist = list(map(int, input().split()))
clist = list(map(int, input().split()))

ans = 0
for i, v in enumerate(vlist):
  netV = vlist[i] - clist[i]
  if netV >= 0:
    ans += netV

print("{}".format(ans))


Measured memory_bytes: 2940
N = int(input())
H = list(map(int, input().split()))
H.append(10000000000)
l = []
cnt = 0
x = 0
while x <= N-1:
  if H[x] >= H[x+1]:
    cnt += 1
    x += 1
  else:
    l.append(cnt)
    cnt = 0
    x += 1
print(max(l))

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) {
  	cout << "YES" << "\n";
  }else {
  	cout << "NO" << "\n";
  }
}

Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	int a, b, c;
	cin >> a >> b >> c;

	rep(i, 0, b) {
		if ((b*i+c) % a == 0) {
			YES;
			return 0;
		}
	}
	
	NO;
	


	return 0;
}


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

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

int main() {
  int N, W;
  std::cin >> N >> W;
  std::vector<int> w(N), v(N);
  for (int i = 0; i < N; ++i)
    std::cin >> w[i] >> v[i];

  long long inf = 1LL << 60;
  std::vector<std::vector<long long>> dp(N + 7,
                                         std::vector<long long>(2 * W, -inf));

  dp[0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= W; ++j) {
      chmax(dp[i + 1][j], dp[i][j]);
      chmax(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
    }
  }

  long long res = -inf;
  for (int j = 0; j <= W; ++j)
    chmax(res, dp[N][j]);
  std::cout << res << std::endl;
}


Measured memory_bytes: 169216
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;

int n;
string s;
char a[2]={'S','W'};

string ok(int f,int t){
    string ans = "";
    ans += a[f];
    ans += a[t];
    char key;
    if((s[0]=='o'&&a[f]=='S')||(s[0]=='x'&&a[f]=='W')){
        key = a[t];
    }
    else{
        key = a[!t];//少し心配
    }
    for(int i=1;i<n;i++){
        if((s[i]=='o'&&ans[i]=='S')||(s[i]=='x'&&ans[i]=='W')){
            ans += ans[i-1];
        }
        else{
            rep(j,2){
                //１つ前と違うものをたす
                if(a[j]==ans[i-1])continue;
                ans += a[j];
            }
        }
    }
    if(ans[n]!=ans[0])return "NO";
    if(ans[n-1]==key){
        ans.pop_back();
        return ans;
    }
    else{
        return "NO";
    }
}
int main(){
    cin >> n;
    cin >> s;
    rep(i,2)rep(j,2){
        if(ok(i,j)!="NO"){
            cout << ok(i,j) << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define maxn 1000010
#define ll long long
using namespace std;
int n,m,x,y,a[maxn],b[maxn],c[maxn],f[maxn],vis[maxn];
ll ans[maxn],sum[maxn];
vector<int>vec[maxn];
bool cmp(int x,int y){return a[x]-b[x]<a[y]-b[y];}
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
int main(){
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		c[i]=f[i]=i;
		ans[i]=max(0,a[i]-b[i]);
		sum[i]=b[i];
	}
	for(register int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
	sort(c+1,c+n+1,cmp);
	for(register int i=1;i<=n;i++){
		int u=c[i];
		vis[u]=1;
		for(auto v:vec[u]){
			if(!vis[v])continue;
			int x=find(u),y=find(v);
			if(x!=y){
				f[y]=x;
				sum[x]+=sum[y];
				ans[x]=min(ans[x],ans[y]+max(0ll,a[x]-b[x]-ans[y]-sum[y]));
			}
		}
	}
	printf("%lld",ans[find(1)]+sum[find(1)]);
	return 0;
}

Measured memory_bytes: 44540
#include"bits/stdc++.h"

using namespace std;

#define MAX 2000

int n;
int m;

vector<int> v[MAX];

queue<tuple<int, int, int> > q;

set<pair<int, int> > s;

bitset<MAX> con[MAX];

bitset<MAX>  child[MAX];
bitset<MAX> par[MAX];

bitset<MAX> stk;

inline void dfs(int b, int pr = -1) {
	auto &c = child[b];
	c.set(b, 1);
	for (int go : v[b]) {
		if (go == pr)continue;
		dfs(go, b);
		c |= child[go];
	}
}

int pat[MAX][MAX];
int lca[MAX][MAX];

int dep[MAX];


inline void dfs2(int b, int pr = -1, int star = 0) {
	pat[star][b] = pr;
	lca[star][b] = b;
	if (pr != -1) {
		if (lca[star][pr] != -1) {
			if (dep[lca[star][pr]] < dep[b]) {
				lca[star][b] = lca[star][pr];
			}
		}
	}
	for (int go : v[b]) {
		if (go == pr)continue;
		dfs2(go, b, star);
	}
}
inline void dfs3(int b, int pr = -1, int d = 0) {
	stk.set(b, 1);
	par[b] = stk;
	dep[b] = d;
	for (int go : v[b]) {
		if (go == pr)continue;
		dfs3(go, b, d + 1);
	}
	stk.set(b, 0);
}
bitset<MAX> ff;
int main() {
	cin >> n >> m;
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs3(0);
	dfs(0);
	for (int i = 0; i < n; i++) {
		dfs2(i, -1, i);
	}
	int edd = 0;
	for (int i = 0; i < m; i++) {
		int c, d;
		scanf("%d%d", &c, &d);
		c--;
		d--;
		con[c].set(d, 1);
		con[d].set(c, 1);
		q.push(make_tuple(0, c, d));
		edd++;
	}
	bitset<MAX> full;
	for (int i = 0; i < n; i++) {
		full.set(i);
	}
	while (!q.empty()) {
		int centre, lef, rig;
		tie(centre, lef, rig) = q.front();
		q.pop();
		int A = lef;
		int B = rig;
		ff.reset();
		if (lca[A][B] == B) {
			swap(A, B);
		}
		if (lca[A][B] == A) {
			ff = child[B] ^ full^child[pat[B][A]] ^ par[B] ^ par[A];
		}
		else {
			ff = child[B] ^ child[A] ^ par[A] ^ par[B];
			ff.set(lca[A][B]);
		}
		ff &= con[A] ^ con[B];
		//the node unconnected to node B
		//connected to A
		//the node is available at the pair(A,B)
		for (int i = (int)ff._Find_first(); i < n; i = (int)ff._Find_next(i)) {
			if (i == A || i == B)continue;
			if (con[B].test(i)) {
				swap(A, B);
			}
			q.push(make_tuple(A, i, B));
			con[i].set(B);
			con[B].set(i);
			edd++;
		}
	}
	cout << edd << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){
  
  ll a,b,aa,bb;
  cin >> a >> b;
  if(a != 0){
    if(((a-1) & 1)){
      ll many = a / 2;
      if(many & 1)aa = 1;
      else aa = 0;
    }else{
      ll many = a / 2;
      if(many & 1)aa = ((a -1) xor 1);
      else aa = a - 1;
    }
  }else{
    aa = 0;
  }
  if((b & 1)){
    ll many = (b + 1)/ 2;
    if(many & 1)bb = 1;
    else bb = 0;
  }else{
    ll many = (b + 1)/ 2;
    if(many & 1)bb = (b xor 1);
    else bb = b;
  }
  cout << (aa xor bb) << endl;




  return 0;
}


Measured memory_bytes: 256
require 'prime'
F = gets.to_i.prime_division
F.sort_by {|f,i| -i}
e=t = 0
until F.empty?
  e += 1
  t += i = F.size.times {|i| break i  if 0 > F[i][1] -= e }
  F.pop F.size-i
end
p t

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n, m;
  cin >> n >> m;

  ll ans = 0;
  if(abs(n-m) == 1){
    ll stand = n>m ? m : n;
    ll factorial = 1;
    REP1(i, stand+1){
      factorial *= i;
      factorial %= mod;
    }

    ans = (factorial * factorial % mod) * (stand + 1) % mod;
  }
  else if(abs(n-m) == 0){
    ll factorial = 1;
    REP1(i, n+1){
      factorial *= i;
      factorial %= mod;
    }

    ans = (factorial * factorial % mod) * 2 % mod;
  }
  else
    ans = 0;

  //cout << Decimal;
  cout << ans << endl;

  
  
}


Measured memory_bytes: 384
import java.util.Scanner;


public class Main {

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

		int s = sc.nextInt();
		
		int h = s / 3600;
		s = s % 3600;
		int m = s / 60;
		s = s % 60;
		
		System.out.println(h + ":" + m + ":" + s);

		sc.close();
	}

}

Measured memory_bytes: 17164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll 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;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

int main(){
	ll n = read();
	ll x,y,z;
	bool flag=0;
	for(x=1; x<=3500; x++){
		for(y=1; y<=3500; y++){
			ll up = n*x*y;
			ll down = 4*x*y-n*x-n*y;
			// if(x==1 && y==2) cout<<up<<" "<<down<<endl;
			if(down == 0) continue;
			if(up%down) continue;
			z = up/down;
			if(z<1 || z>3500) continue;
			flag = 1;
			break;
		}
		if(flag) break;
	}
	cout << x << " " << y << " " << z << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 5e5 + 5;
int n, a[M];

int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	cin >> n;
	int x = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		x ^= a[i];
	}
	for(int i = 0; i < n; i++)
		cout << (a[i] ^ x) << " ";
    	return 0;
}

Measured memory_bytes: 5196
import java.util.*;
public class Main
{
	public static void main(String[] args)
    {
      	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
      	double prob = 0;
      	if(n % 2 == 0) prob = 0.5;
      	else{
        	prob = ((n + 1) / 2.0) / (double)n;
        }
      	System.out.println(prob);
    }
}

Measured memory_bytes: 21844
#!/usr/bin/env python3
#EDPC G

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def dfs(s):
    if dp[s] != -1:
        return dp[s]
    elif len(edge[s]) == 0:
        return 0
    else:
        res = 0
        for v in edge[s]: 
            res = max(res,dfs(v)+1)
        dp[s] = res
        return res
n,m = LI()
dp = [-1]*n
edge = [[] for _ in range(n)]
for _ in range(m):
    x,y = LI()
    x -= 1
    y -= 1
    edge[x].append(y)

for i in range(n):
    dfs(i)
print(max(dp))

Measured memory_bytes: 166492
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <cstring>

using namespace std;
typedef pair<int, int> pii;
static const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
static const int dy[] = { 0, -1, -1, -1, 0, 1, 1, 1 };
static const int INF = 1000000000;

static int mat[400][400];
static bool has_bomb[400];
static bool dp[6][41];

inline bool between(int a, int b, int c){
	return a <= b && b < c;
}

int main(){
	ios_base::sync_with_stdio(false);
	int w, h, n;
	cin >> w >> h >> n;
	for(int i = 0; i < h * w; ++i){
		for(int j = 0; j < h * w; ++j){ mat[i][j] = INF; }
		mat[i][i] = 0;
		has_bomb[i] = false;
	}
	int sx, sy;
	cin >> sx >> sy;
	--sx; --sy;
	vector<vector<pii>> paths(n);
	for(int i = 0; i < n; ++i){
		int l;
		cin >> l;
		for(int j = 0; j < l; ++j){
			int x, y;
			cin >> x >> y;
			--x; --y;
			paths[i].emplace_back(x, y);
		}
		const auto p = paths[i].back();
		has_bomb[p.second * w + p.first] = true;
	}
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(has_bomb[i * w + j]){ continue; }
			for(int d = 0; d < 8; ++d){
				const int y = i + dy[d], x = j + dx[d];
				if(!between(0, y, h) || !between(0, x, w)){ continue; }
				if(has_bomb[y * w + x]){ continue; }
				mat[i * w + j][y * w + x] = 1;
			}
		}
	}
	for(int k = 0; k < w * h; ++k){
		for(int i = 0; i < w * h; ++i){
			for(int j = 0; j < w * h; ++j){
				mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
			}
		}
	}
	sort(paths.begin(), paths.end());
	int answer = INF;
	do {
		memset(dp, 0, sizeof(dp));
		for(int i = 0; i + 1 < paths[0].size(); ++i){
			const auto &p = paths[0][i];
			const int d = mat[sy * w + sx][p.second * w + p.first];
			if(d <= i){ dp[1][i] = true; }
		}
		for(int i = 1; i < n; ++i){
			for(int j = 0; j + 1 < paths[i - 1].size(); ++j){
				if(!dp[i][j]){ continue; }
				const auto &s = paths[i - 1][j];
				for(int k = j; k + 1 < paths[i].size(); ++k){
					const auto &t = paths[i][k];
					const int d =
						mat[s.second * w + s.first][t.second * w + t.first];
					if(d <= k - j){ dp[i + 1][k] = true; }
				}
			}
		}
		for(int i = 0; i <= w + h; ++i){
			if(dp[n][i]){ answer = min(answer, i); }
		}
	} while(next_permutation(paths.begin(), paths.end()));
	if(answer >= INF){ answer = -1; }
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 1828
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

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

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
    int a,p;
    cin>>a>>p;
    cout<<(a*3+p)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ar[111];
int main(void)
{
	int n;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; ++i) scanf("%d", ar + i);
	sort(ar, ar + n);
	printf("%d", ar[n - 1] - ar[0]);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, i;
	double f;
	int count = 0;

	scanf("%d", &n);

	//1からNまでの数で奇数をカウントする
	for (i = 1; i <= n; i++) {
		if (i % 2 != 0) {
			count++;
		}
	}

	f = (double)count / n;

	printf("%f", f);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  string s1,s2,s3; cin>>s1>>s2>>s3;
  cout<<"A"<<s2[0]<<"C"<<endl;

  return 0;
}


Measured memory_bytes: 256
// http://abc065.contest.atcoder.jp/tasks/arc076_a

#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <unordered_map>

int main () {

	uint64_t n, m;
	scanf("%llu%llu", &n ,&m);

	std::unordered_map<uint64_t, uint64_t> map;
	map[0] = 1;
	map[1] = 1;
	uint64_t currentMaxA = 1;

	const uint64_t c = 1000000007;

	auto fac = [&map, &currentMaxA] (uint64_t a) -> uint64_t {
		if (a > currentMaxA) {
			for (uint64_t i = currentMaxA + 1; i <= a; ++i) {
				map[i] = (map[i - 1] * (i % c)) % c;
			}
			currentMaxA = a;
		}
		return map[a];
	};

	if (n > m) std::swap(n, m);

	if (m - n > 1) {
		printf("0");
	} else {
		uint64_t d = (m == n) ? 2 : 1;
		printf("%llu", (((fac(m) * fac(n)) % c) * d) % c);
	}

	return 0;

}


Measured memory_bytes: 4388