akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
const ll inf = 1LL << 62;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

const int MAX_N = 20010;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll H;
    int N;
    cin >> H >> N;
    vector<pair<ll, ll>> A(N);
    rep(i, N) cin >> A[i].first >> A[i].second;
    vector<ll> dp(MAX_N, inf);
    dp[0] = 0;
    rep(i, MAX_N) {
        rep(j, N) {
            if(i - A[j].first >= 0) dp[i] = min(dp[i], dp[i - A[j].first] + A[j].second);
        }
//        voutput(dp);
    }
    ll ans = dp[H];
    rep(i, H, MAX_N) {
        ans = min(ans, dp[i]);
    }
    output(ans);
    
    
    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(M: "List[int]", D: "List[int]"):
    print(0 if M[0]==M[1] else 1)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    M = [int()] * (2)  # type: "List[int]"
    D = [int()] * (2)  # type: "List[int]"
    for i in range(2):
        M[i] = int(next(tokens))
        D[i] = int(next(tokens))
    solve(M, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
    a: usize,
    b: usize
    }
    let ans = a * b / gcd(&a, &b);
    println!("{}", ans);
}
// O(log(N))
fn gcd(a: &usize, b: &usize) -> usize {
    let (mut x, mut y) = if a < b { (*b, *a) } else { (*a, *b) };
    let mut r = x % y;
    while r != 0 {
        x = y;
        y = r;
        r = x % y;
    }
    y
}


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

#define mp make_pair
#define pb push_back

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef long long ll;
typedef double db;

typedef multiset<int> mset;

mset mts;

int n, a;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++) {
		scanf("%d", &a);
		if(mts.empty()) mts.insert(a);
		else {
		    mset :: iterator it = mts.lower_bound(a);
			if(it == mts.begin()) mts.insert(a);
			else {
				it --;
				mts.erase(mts.find(* it));
				mts.insert(a);
			} 
	    }
	}
	printf("%d\n", (int) mts.size());
	return 0;
}


Measured memory_bytes: 4992
X = int(input())
Alist = []
Blist = [0]
flag = 0
for i in range(1,10**4):
  Alist.append(i)
for j in range(1,10**4):
  Blist.append(j)
  Blist.append(-j)
for i in range(len(Alist)):
  for j in range(len(Blist)):
    if(Alist[i]**5 - Blist[j]**5 == X):
      print(Alist[i],Blist[j])
      flag = 1
      break
  if(flag==1):
    break

Measured memory_bytes: 9996
#include<iostream>

using namespace std;

int main() {
	long x;
	cin >> x;
	if (x % 2 == 1) {
		long y = x / 2;
		cout << y * (y + 1);
	}
	else {
		long y = x / 2;
		cout << y * y;
	}
	return 0;
}

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

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

    public static string Solve()
    {
        int N = ReadInt();
        string[] S = new string[N];
        for (int i = 0; i < N; i++)
        {
            S[i] = Read();
        }
        Array.Sort(S);
        int cnt = 0;
        string tmp = S[0];
        cnt++;
        for (int i = 1; i < N; i++)
        {
            if (tmp != S[i])
            {
                cnt++;
                tmp = S[i];
            }
        }
        return cnt.ToString();
    }

    public static int Gcd(int a, int b)
    {
        if (a < b)
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }

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


Measured memory_bytes: 38684
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    double D;
    cin >> N >> D;
    int ans = 0;
    REP(i, N) {
        long double x, y;
        cin >> x >> y;
        if (sqrt(x*x+y*y) <= D) ans++;
        //debug(sqrt(x*x+y*y))
    }

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


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

 int binarysearch(int arr[],int l,int r,int x){
   while(l<=r)
   {
      int m=(l+r)/2;
       if(arr[m]==x)
        return m;
       else if(arr[m]>x)
        r=m-1;
       else if(arr[m]<x)
        l=m+1;

   }

   return -1;



 }
 int main()
 {
     int n;
     scanf("%d",&n);
     int a[n];
     for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
     int q,p,result;
     scanf("%d",&q);
     for(int i=0;i<q;i++)
     {
         scanf("%d",&p);
         result=binarysearch(a,0,n-1,p);
         if(result!= -1)
            printf("1\n");
         else
            printf("0\n");

     }


     return 0;



 }



Measured memory_bytes: 3536
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<string>

#define MOD 1000000007

using namespace std;

typedef long long ll;

ll dp[201][10001];

int main(void){

  int n,m;
  cin >> n >> m;

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

  sort(a.begin(),a.end(),greater<int>());

  fill(dp[0],dp[201],0);
  dp[0][0]=1;

  for(int i=0;i<n;i++){
    memcpy(dp[i + 1], dp[i], sizeof(dp[i]));
    for(int j=m-a[i];j>=0;j--){
      dp[i+1][j+a[i]]+=dp[i][j];
    }
  }

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

  ll ans=0,sum=0;
  for(int i=0;i<n;i++){
    for(int j=max(0LL,m-sum-a[i]+1);j<=m-sum-(i?a[i-1]:0);j++){
      ans+=dp[n-i][j];
      ans%=MOD;
    }
    sum+=a[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 16920
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
cin>>n;
int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int c=1;int m=a[0];int ans;
  for(int i=1;i<n;i++)
  {
       m=min(m,a[i]);
       if(a[i]==m)
         {c++;
        }
  }
cout<<(c);
return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main() {
	bool ans=false;
	int N;
	cin>>N;
	if(N>=28)cout<<"Yes";
	else
	{
		if(N%4==0||N%7==0)ans=true;
		switch(N)
		{
			case 11:
			case 18:
			case 22:
			case 15:
			case 19:
			case 26:
			case 25:ans=true;
			break;
			default:
			break;
		}
		if(ans)cout<<"Yes";
		else cout<<"No";
	}
}

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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAX_N = 1e5;

template<typename T, typename IT>
std::vector< std::pair<T, int> > rle(IT first, IT last) {
  T last_value = *first;

  std::vector< std::pair<T, int> > ret;
  int cnt = 0;
  for(auto it = first; it != last; ++it) {
    T e = *(it);
    if(last_value == e) ++cnt;
    else {
      ret.push_back(std::make_pair(last_value, cnt));
      last_value = e;
      cnt = 1;
    }
  }
  ret.push_back(std::make_pair(last_value, cnt));
  return ret;
}

int main() {
  std::string S;
  std::cin >> S;

  auto counts = rle<char>(S.begin(), S.end());

  int ans[MAX_N] = {};
  int i = 0;
  for(auto p : counts) {
    char c = p.first;
    int n = p.second;
    if(c == 'R') {
      i += n - 1;
      ans[i] += (n + 1) / 2;
      ans[i + 1] += n / 2;
      i += 1;
    } else {
      ans[i] += (n + 1) / 2;
      ans[i - 1] += n / 2;
      i += n;
    }

  }

  rep(t, S.length()) {
    std::cout << ans[t] << ' ';
  }
}

Measured memory_bytes: 1908
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

int main(){
    ll n, t;
    std::cin >> n >> t;
    ll last = 0; // お湯が切れたタイミング
    ll sum = 0;
    for(int i = 0; i < n; i++){
        ll tmp;
        std::cin >> tmp;
        if(last <= tmp){
            sum += t;
            last = tmp + t;
        }else{
            if(tmp + t > last){
                sum += tmp + t - last;
                last = tmp + t;
            }
        }
    }

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


Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()
ans=0
for i in range(n-1):
    if s[i]==s[i+1]:
        ans+=1
tmp=0
m=0
omake=0
for i in range(n-1):
    if s[i]!=s[i+1]:
        tmp+=1
        if tmp%2==0:
            m+=1
        elif i==n-2:
            omake+=1
    elif tmp>0 and i==n-2 and tmp%2==1:
        omake+=1

if m<k:
    print(ans+2*min(m,k)+omake)
else:
    print(ans+2*min(m,k))

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

typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	
	int ans=0;
	for(int i=1;i<=a[n-1];i++)
	{
		int ind = lower_bound(a,a+n,i) - a;
		if(ind==n/2)
			ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>

int main()
{
  std::string s, t;
  std::cin >> s >> t;
  std::sort(s.begin(), s.end());
  std::sort(t.begin(), t.end(), std::greater<int>());
  if ( s < t ) std::cout << "Yes\n";
  else std::cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#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 (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    if(N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < N / 2; i++) {
        if(S[i] != S[i + N / 2]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, K, A[200000]; cin >> N >> K;
  if(K > N) {
    cout << 0 << endl;
    return 0;
  }
  REP(i, N) cin >> A[i];
  sort(A, A+N);
  int ans = 0;
  REP(i, N-K) ans += A[i];
  cout << ans << endl;
}

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

using namespace std;

typedef long long int64;

int N, subtree[100000], NextPath[100000], idx[100000];
char S[100001];
vector< int > g[100000];
deque< int64 > dp[100000][2];
int64 ret;

void BuildSubTreeSize()
{
  memset(subtree, -1, sizeof(subtree));
  stack< pair< int, int > > s;
  s.emplace(0, -1);
  while(!s.empty()) {
    auto p = s.top();
    s.pop();
    if(~subtree[p.first]) {
      NextPath[p.first] = -1;
      for(auto& to : g[p.first]) {
        if(p.second == to) continue;
        subtree[p.first] += subtree[to];
        if(NextPath[p.first] == -1 || subtree[NextPath[p.first]] < subtree[to]) {
          NextPath[p.first] = to;
        }
      }
    } else {
      s.push(p);
      subtree[p.first] = 1;
      for(auto& to : g[p.first]) {
        if(p.second != to) s.push({to, p.first});
      }
    }
  }
}

void update(int idx)
{
  bool button = S[idx] == '(';
  if(~NextPath[idx]) swap(dp[NextPath[idx]], dp[idx]);
  if(dp[idx][button ^ 1].size() > 1) {
    ret += dp[idx][button ^ 1][1];
    dp[idx][button ^ 1].pop_front();
  } else {
    dp[idx][button ^ 1][0] = 0;
  }
  dp[idx][button].push_front(0);
  ++dp[idx][button][1];
  for(auto& to : g[idx]) {
    if(to == NextPath[idx]) continue;
    auto& dp1 = dp[idx], & dp2 = dp[to];
    for(int j = 0; j < dp2[0].size(); j++) {
      if(j < dp1[1].size()) ret += dp1[1][j] * dp2[0][j];
    }
    for(int j = 0; j < dp2[1].size(); j++) {
      if(j < dp1[0].size()) ret += dp1[0][j] * dp2[1][j];
    }
    for(int j = 0; j < dp2[0].size(); j++) {
      int nextIdx = j + (button ? -1 : 1);
      if(nextIdx < 0) continue;
      while(dp1[0].size() <= nextIdx) dp1[0].push_back(0);
      dp1[0][nextIdx] += dp2[0][j];
    }
    for(int j = 0; j < dp2[1].size(); j++) { // '('
      int nextIdx = j + (button ? 1 : -1);
      if(nextIdx < 0) continue;
      while(dp1[1].size() <= nextIdx) dp1[1].push_back(0);
      dp1[1][nextIdx] += dp2[1][j];
    }
    dp2[0].clear();
    dp2[1].clear();
  }
}

int main()
{
  scanf("%d", &N);
  scanf("%s", S);
  for(int i = 0; i < N - 1; i++) {
    int A, B;
    scanf("%d %d", &A, &B);
    --A, --B;
    g[A].push_back(B);
    g[B].push_back(A);
  }
  for(int i = 0; i < N; i++) {
    dp[i][0].push_back(0);
    dp[i][1].push_back(0);
  }
  BuildSubTreeSize();
  iota(idx, idx + N, 0);
  sort(idx, idx + N, [&](const int& a, const int& b)
  {
    return (subtree[a] < subtree[b]);
  });
  for(int i = 0; i < N; i++) update(idx[i]);
  printf("%lld\n", ret);
}

Measured memory_bytes: 195988
N = int(input())
A = [int(i) for i in input().split()]

def solve() :
    s = sum(A)
    if s % (N * (N + 1) // 2) != 0 :
        return 'NO'
        
    a = s // (N * (N + 1) // 2)
    ret = 0
    for i in range(N) :
        d = A[i] - A[i-1]
        if (a - d) % N != 0 or (a - d) < 0 :
            return 'NO'
        ret += (a - d) // N
        
    if ret == a :
        return 'YES'
    else :
        return 'NO'
        
print(solve())

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

struct node {
  struct node *right;
  struct node *left;
  int val;
};

typedef struct node Node;

Node *root;

void insert(Node *cur, int curVal) {
  if (cur->val == -1) {
    cur->val = curVal;
  }
  else if (curVal < cur->val) {
    if(cur->left == NULL) {
      Node *new = malloc(sizeof(Node));
      new->val = -1;
      new->left = NULL;
      new->right = NULL;
      //      printf("allocated a node\n");
      cur->left = new;
    }
    insert(cur->left, curVal);
  } else {
    if(cur->right == NULL) {
      Node *new = malloc(sizeof(Node));
      new->val = -1;
      new->left = NULL;
      new->right = NULL;
      //printf("allocated a node\n");
      cur->right = new;
    }
    insert(cur->right, curVal);
  }
}

void inorder(Node *cur){
  if (cur == NULL)
    return;

  inorder(cur->left);
  printf(" %d", cur->val);
  inorder(cur->right);
}

void preorder(Node *cur){
  if (cur == NULL)
    return;

  printf(" %d", cur->val);
  preorder(cur->left);
  preorder(cur->right);
}

void find(Node *cur, int search) {
  //  printf("searching for %d\n", search);

  if (cur->val == search) {
    printf("yes\n");
    return;
  }

  if (cur == NULL) {
    printf("no\n");
    return;
  }

  if (cur->val < search) {
    if (cur->right == NULL) {
      printf("no\n");
      return;
    }
    find(cur->right, search);
  } else {
    if (cur->left == NULL) {
      printf("no\n");
      return;
    }
    find(cur->left, search);
  }
}

int main() {
  int commands, i, num;
  char com[20];
  root = malloc(sizeof(Node));
  root->val = -1;
  root->left = NULL;
  root->right = NULL;

  scanf("%d", &commands);

  for (i = 0; i < commands; i++) {
    scanf("%s", &com);
    if (!strcmp(com, "insert")) {
      scanf("%d", &num);
      insert(root, num);
      //printf("inserted!\n");
    } else if (!strcmp(com, "print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if (!strcmp(com, "find")) {
      int num;
      scanf("%d", &num);
      find(root, num);
    }
  }
}



Measured memory_bytes: 14188
import java.lang.System;
import java.lang.Exception;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in).useDelimiter("\\D");

        int w = sc.nextInt();
        int[] ans = new int[w];
        for (int i = 0; i < w; i++) {
            ans[i] = i + 1;
        }

        // 並び替え
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int tmp = ans[a - 1];
            ans[a - 1] = ans[b - 1];
            ans[b - 1] = tmp;
        }

        // 並び替え結果の出力
        for (int answer: ans) {
            System.out.println(answer);
        }
    }
}

Measured memory_bytes: 15372
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int l, r, d;
	cin >> l >> r >> d;
	print(r / d - (l - 1) / d);
}

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

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

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  cout << N * (N + 1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
n, a = map(int, input().split())
xlst = list(map(int, input().split()))
dp = [[0 for _ in range(5001)] for _ in range(n + 1)]
center = 2500
dp[0][center] = 1
for i, x in enumerate(xlst, 1):
    num = x - a
    for j in range(5001):
        dp[i][j] = dp[i - 1][j]
        if 0 <= j - num <= 5000:
            dp[i][j] += dp[i - 1][j - num]
print(dp[-1][center] - 1)

Measured memory_bytes: 11524
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue>
#define ll long long
using namespace std;
int a[100005],b[100005],c[100005];
/*bool cmp(int x,int y)
{
   return x>y;
}*/
int main()
{
    int n;
    ll ans=0;
    //int flag=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	 } 
	 sort(a,a+n); 
	  for(int i=0;i<n;i++)
	{
		scanf("%d",&b[i]);
	 } 
	  sort(b,b+n);
	  for(int i=0;i<n;i++)
	{
		scanf("%d",&c[i]);
	 }
	  sort(c,c+n);
	  ll x,y;
	for(int i=0;i<n;i++)
	{
		x=lower_bound(a,a+n,b[i])-a;
		//printf("%d\n",x);
		y=upper_bound(c,c+n,b[i])-c;
		//printf("%d\n",y);
		ans+=x*(n-y);
	}
	  printf("%lld\n",ans);
	return 0;
	
}

Measured memory_bytes: 1408
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int k = sc.nextInt();
    String s = sc.next();
    
    if(s.length()>k){
      System.out.println(s.substring(0, k)+"...");
    }
    else{
      System.out.println(s);
    }
  }
}


Measured memory_bytes: 38668
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef pair<P,P> Edge;
typedef long long ll;

const double PI=4*atan(1.0);

//#define RED_FILE

#ifdef RED_FILE
ifstream ifs("input.txt");
ofstream ofs("output.txt");
#define cin ifs
#define cout ofs
#endif

int dp[2][321];

int main(){

    int t;
    cin>>t;
    while(t--){
        memset(dp,0,sizeof(dp));
        int n;
        cin>>n;
        int a[101];
        for(int i = 0; i < n; i++)
            cin>>a[i];
        if(n==1){
            cout<<a[0]<<endl;
            continue;
        }
        dp[0][a[0]]=a[1];
        for(int i = 1; i < n-1; i++){
            memset(dp[i%2],0,sizeof(dp[i%2]));
            for(int j = 0; j < 321; j++){
                // ツ遷ツ暗堋つウツつケツづゥ
                if(dp[(i-1)%2][j]-1>=0)
                    dp[i%2][dp[(i-1)%2][j]-1]=max(dp[i%2][dp[(i-1)%2][j]-1],j+a[i+1]);
                // ツ遷ツ暗堋つウツつケツづ按つ「
                dp[i%2][dp[(i-1)%2][j]]=max(dp[i%2][dp[(i-1)%2][j]],a[i+1]);
            }
        }
        int maxNum=0;
        for(int i = 0; i < 321; i++)
            maxNum=max(dp[(n-2)%2][i],maxNum);
        cout<<maxNum<<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std ; 

typedef long long ll ; 
int a[111111] ; 
int main()
{
    int N, L  ; 
    scanf("%d%d", &N, &L) ;
    for(int i = 1 ; i <= N ; i++){
        scanf("%d", a+i) ; 
    }
    bool ans = false ; 
    int loc ; 
    for(int i = 1 ; i <= N-1 ; i++){
        if(a[i] + a[i+1] >= L){
            ans = true ; 
            loc = i ; 
        }
    }
    if(!ans)
        puts("Impossible") ; 
    else{
        puts("Possible") ; 
        for(int i = 1 ; i < loc ; i++) 
            printf("%d\n", i) ;
        for(int i = N-1 ; i > loc ; i--)
            printf("%d\n", i) ;
        printf("%d\n", loc) ; 
    }
    return 0 ;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>

int main()
{
  char s[11],t[11],u[11];
  int a,b;

  scanf("%s %s",s,t );
  scanf("%d %d",&a,&b );
  scanf("%s", u);

  if(strcmp(s,u))
    printf("%d %d",a,b-1);
  else
    printf("%d %d",a-1,b );

    return 0;
}


Measured memory_bytes: 1704
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <deque>
#include <functional>

inline void
rep(int n, std::function<void(int)> f) {
    for (int i = 0; i < n; i++) {
        f(i);
    }
};

typedef std::pair<int, int> P;

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	
	std::deque<uint64_t> v;
	
	uint64_t n;
	uint64_t tmp;
	std::cin >> n;
	std::cin.ignore();
	rep(5, [&](int i) {
			std::cin >> tmp;
			v.push_back(tmp);
			});
	std::sort(v.begin(), v.end());

	uint64_t sa = n % v.front();
	uint64_t c;
	if (sa != 0) {
		c = n / v.front() + static_cast<uint64_t>(1);
	}
	else {
		c = n / v.front();
	}

	std::cout << c + static_cast<uint64_t>(4)<< '\n';

	return 0;
}



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

max_streak = 0
streak = 0
checker = [False] * N
prev = None
for check in range(0, N-1):
    checker[check] = H[check] >= H[check+1]

    if checker[check] is True:
        streak += 1
    else:
        streak = 0
    
    max_streak = max(max_streak, streak)

print(max_streak)


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

typedef long long ll;

int n;
int a[200000];
ll s[200001];

int main(){
    cin >> n;
    rep(i, n){
        cin >> a[i];
    }

    rep(i, n){
        s[i + 1] = s[i] + a[i];
    }
    ll ans = 1e15;
    for(int i = 1; i < n; ++i){
        ll a = s[i];
        ll b = s[n] - s[i];
        ans = min(abs(a - b), ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX / 2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psi = pair<string, int>;

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

  int A,B; cin >> A>>B;
  
  int ans = max(0, A - B * 2);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i<n; i++)

using namespace std;

int main(void) {
    string s;
    int k;
    cin >> s >> k;

    vector<string> subs;
    rep(i, 5) subs.push_back({'z'+1});

    rep(start, s.size()) {
        rep(li, k) {
            string si = s.substr(start, li+1);
            if(si > subs[k-1]) break;
            auto it = lower_bound(subs.begin(), subs.end(), si);
            if (*it == si) continue;

            subs.insert(it, si);
            subs.resize(k+1);
        }
    }
    cout << subs[k-1] << endl; 
}


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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int x;
    cin >> x;
    if(400 <= x && x<= 599)
        cout << 8;
    if(600 <= x && x <=799)
        cout << 7;
        if(800 <= x && x <=999)
        cout << 6;
            if(1000 <= x && x <=1199)
        cout << 5;
            if(1200 <= x && x <=1399)
        cout << 4;
            if(1400 <= x && x <=1599)
        cout << 3;
            if(1600 <= x && x <=1799)
        cout << 2;
            if(1800 <= x && x <=1999)
        cout << 1;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

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

typedef tuple<ll, ll, ll> T;
int main(int argc, char const *argv[]) {
    int n,q; cin>>n>>q;
    vector<T> a;
    rep(i,n) {
        ll s,t,x; cin>>s>>t>>x;
        a.emplace_back(s-x, 0, x);
        a.emplace_back(t-x, 1, x);
    }
    a.emplace_back(-LINF,0,LINF);
    a.emplace_back(LINF,1,LINF);
    sort(a.begin(), a.end());
    vector<ll> d(q);
    rep(i,q) cin>>d[i];

    int idx = 0;
    multiset<ll> st;
    for (const auto [t, fl, x]: a) {
        while (t > d[idx] && idx < q) {
            if (st.empty() || *st.begin() == LINF) {
                cout << -1 << '\n';
            }
            else {
                cout << *st.begin() << '\n';
            }
            ++idx;
        }
        if (fl == 0) {
            st.insert(x);
        }
        else {
            auto itr = st.lower_bound(x);
            st.erase(itr);
        }
    }

    return 0;
}

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

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

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  char x,y;
  cin >> x >> y;
  if(x<y){
    cout << '<' << endl;
  }else if(x==y){
    cout << '=' << endl;
  }else{
    cout << '>' << endl;
  }
}



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

int main() {
  string S;
  cin >> S;
  
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  
  else cout << "No" << endl;
}

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

//flagを用いたバブルソート
int bubbleSort(int A[],int N){
    int sw = 0;
    bool flag = 1;
    for(int i = 0; flag;i++){
        flag = 0;
        for(int j=N-1;j >= i+1;j--){
            if(A[j] < A[j-1]){
                //隣接要素を交換する
                swap(A[j],A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(){
    int A[100],N,sw;
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    sw = bubbleSort(A,N);

    for(int i=0;i<N;i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#define rep(i,n) for(int i = 0; i < (long int)n; i++)
typedef long long ll;
using namespace std;

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << (b - b/c - b/d + b/(c*d/__gcd(c,d)))
  - ((a-1) - (a-1)/c - (a-1)/d + (a-1)/(c*d/__gcd(c,d)));
  return 0;
}


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

points = Array.new(3,0)
grades = Array.new
while true do
    points = gets.split.map(&:to_i)
    break if points[0] == -1 and points[1] == -1 and points[2] == -1
    if points[0] == -1 or points[1] == -1 then
        grades << "F"
    else
        case points[0] + points[1]
        when 80..100 then
            grades << "A"
        when 65..79 then
            grades << "B"
        when 50..64 then
            grades << "C"
        when 30..49 then
            if points[2] >= 50 then
                grades << "C"
            else
                grades << "D"
            end
        when 0..29 then
            grades << "F"
        end
    end
end

puts grades


Measured memory_bytes: 6888
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#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 reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    cout << n / 3 << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <climits>
#include <cmath>
#include <stdio.h>

using namespace std;

bool isPossible(vector<int> &v, int ans, int k)
{
    int sum = 0;
    for (size_t i = 0; i < v.size(); i++)
    {
        int cuts = ceil((long double)v[i] / ans) - 1;
        sum += cuts;
    }
    return sum <= k;
}

int binary_search(vector<int> &v, int k)
{
    int max_v = *max_element(v.begin(), v.end());
    int l = 1, r = max_v;
    while (r - l > 1)
    {
        bool ispossible = isPossible(v, (l + r)/2, k);
        if (!ispossible)
        {
            l = (l + r) / 2;
        }
        else
        {
            r = (l + r) / 2;
        }
    }
    if (isPossible(v, l, k))
        return l;
    else return r;
}

int main()
{
    int N, k;
    cin >> N >> k;
    vector<int> v(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> v[i];
    }
    cout << binary_search(v, k) << endl;
    return 0;
}

Measured memory_bytes: 4052
require 'set'
loop do
    n, m = gets.split.map(&:to_i)
    break if n == 0
    g = {}
    (1..n).each {|i| g[i] = {}}
    m.times do
        a, b, f = gets.split.map(&:to_i)
        g[a][b] = f
        g[b][a] = f
    end
    start_node = [1, 1]
    nodes = Set[start_node]
    cost = Hash.new(Float::INFINITY)
    cost[start_node] = 0
    reached = Set.new
    loop do
        u = nodes.min_by {|v| cost[v]}
        nodes.delete(u)
        reached << u
        i, ticket = u
        if i == n
            puts cost[u]
            break
        end
        if ticket == 1
            g[i].each do |j, _|
                g[j].each do |k, _|
                    v = [k, 0]
                    if !reached.include?(v)
                        cost[v] = cost[u] if cost[v] > cost[u]
                        nodes << v
                    end
                end
            end
        end
        g[i].each do |j, f|
            v = [j, ticket]
            if !reached.include?(v)
                cost[v] = cost[u] + f if cost[v] > cost[u] + f
                nodes << v
            end
        end
    end
end



Measured memory_bytes: 7036
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int n;
pair<int,int> work[201000];
int main(){
	scanf("%d", &n);
	for( int i = 1; i <= n; ++i )
		scanf("%d%d", &work[i].second, &work[i].first);
	sort(work+1, work+1+n);
	for( int i = 1; i <= n; ++i ){
		if( i != 1 )
			work[i].second += work[i-1].second;
		if( work[i].second > work[i].first ){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int res=0;
        for(int i=1; i<6; i++){
            if(sc.nextInt()==0){
                res = i;
                break;
            }
        }
        
        System.out.println(res);
        }
    }

Measured memory_bytes: 35760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

ll sub[120];

map<ll,ll> prime_factor(ll n) {
  map<ll,ll> ret;
  for(ll i = 2LL; i*i<=n; i++) {
    while(n%i==0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n!=1) ret[n] = 1;
  return ret;
}

int main() {
  ll n;
  cin >> n;
  map<ll,ll> mp = prime_factor(n);
  ll ans = 0;
  ll cnt = 1;
  for(ll i = 1; i<=15; i++) {
    rep(j,i) sub[cnt+j-1] = i-1;
    cnt += i;
  }
  for(auto p : mp) ans += sub[p.second];
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) 
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}



Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var n=Arr.shift()-0;
   if(n===0)break;
   var ans=[];
   for(var i=0;i<n;i++){
      var arr=(Arr.shift()).split(" ");
      var name=arr.shift();
      arr=arr.map(Number);
      arr.unshift(name);
      (function(L, P, A, B, C, D, E, F, S, M){
         var time=A+B+C+((D+E)*M);
         var money=(F*S*M)-P;
         ans.push([L,money/time]);
      }).apply(null,arr);
   }
   ans.sort(function(a,b){
      if(a[1]==b[1])return (a[0].toString()>b[0].toString())?1:-1;
      else return b[1]-a[1];
   });
   ans.forEach(function(v){console.log(v[0]);});
   console.log("#");
}

Measured memory_bytes: 18236
a=input().split()
b=int(a[0])
c=int(a[1])
d=int(a[2])
x=0
y=0
if d-c<=2:
    x+=b+1
else:
    if b<=min(c,d) :
        x+=b+1
    else:
        x+=c+abs(d-c)*((b-min(c,d)+1)//2)+(b-(min(c,d)-1))%2
print(x)

Measured memory_bytes: 39876
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}




int main() {
  int r,g,b,n;
  cin >> r >> g >> b >> n;

  ll res = 0;
  for (int i = 0;i <= n/r;i++){
    for (int j = 0;j <= n/g;j++){
      if (i*r + j*g > n) continue;
      ll rem = n - i*r - j*g;
      if (rem % b != 0) continue;
      res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3684
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> days(n), earns(n);
    for (int i = 0; i < n; i++){
        cin >> days[i] >> earns[i];
    }
    vector<vector<int>> dead2earns(m);
    for (int i = 0; i < n; i++){
        int dead = m - days[i];
        if (dead >= 0){
            dead2earns[dead].push_back(earns[i]);
        }
    }
    multiset<int> mul_st;
    int ans = 0;
    for (int day = m - 1; day >= 0; day--){
        for (int earn : dead2earns[day]){
            mul_st.insert(earn);
        }
        if (!mul_st.empty()){
            auto itr = mul_st.end();
            itr--;
            ans += *itr;
            mul_st.erase(itr);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8576
//Traveling Plan

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define nxvarep(n,x,a) ll n,x;cin>>n>>x;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    nvarep(n,a);
    a.insert(a.begin(),0LL);
    a.pb(0LL);
    ll goke = 0;
    rep(i,1,n+2){
        goke+=abs(a[i]-a[i-1]);
    }
    rep(i,1,n+1){
        ll ans = goke-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]);
        cout<<ans<<nnn;
    }
    return 0;
}

Measured memory_bytes: 2032
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	long long int v[51];
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	pair<long long int, long long int> res[51];
	res[0] = make_pair(0, 1);
	res[1] = make_pair(v[0], 1);
	for(int i = 2; i <= n; i++){
		res[i] = make_pair(-1, -1);
	}
	for(int i = 1; i < n; i++){
		for(int j = i + 1; j > 0; j--){
			if(res[j - 1].first < 0) continue;
			if(res[j - 1].first + v[i] > res[j].first){
				res[j] = make_pair(res[j - 1].first + v[i], res[j - 1].second);
			} else if(res[j - 1].first + v[i] == res[j].first){
				res[j] = make_pair(res[j].first, res[j - 1].second + res[j].second);
			}
		}
	}
	long long int anssum = 0, ansnum = 1;
	long long int combnum = 0;
	for(int i = a; i <= b; i++){
		if(anssum * i < res[i].first * ansnum){
			anssum = res[i].first;
			ansnum = i;
			combnum = res[i].second;
		} else if(anssum * i == res[i].first * ansnum){
			combnum += res[i].second;
		}
	}
	printf("%.10f\n%lld\n", (double)anssum / ansnum, combnum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;

    string s;
    cin>>s;

    int answer=0;

    for (int i=1;i<n;i++) {
        int count=0;
        for (char x='a';x<='z';x++) {
            bool left=false;
            bool right=false;

            for(int j=0;j<i;j++){
                if(s[j]==x){
                    left=true;
                }
            }
            for(int j=i;j<n;j++){
                if(s[j]==x){
                    right=true;
                }
            }
            if(left&&right){
                count++;
            }
        }
        if(count>answer){
            answer=count;
        }
    }

    cout<<answer<<endl;


}


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

int main(){
    int i,x;
    i = 0;
    while (1) {
        cin >> x;
        
        if(x == 0 ) break;
        
        cout << "Case" << " " << ++i << ":" << " "  << x << endl;
    }
    return 0;
}

Measured memory_bytes: 1160