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

typedef pair<int, int> P;
typedef pair<P, P> PP;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> field(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> field[i][j];
        }
    }

    vector<PP> res;
    for (int i = 0; i < H; i++) {
        if (i % 2 == 0) {
            for (int j = 0; j < W; j++) {
                if (j == W - 1) {
                    if (field[i][j] % 2 && i != H - 1) {
                        field[i][j]--;
                        field[i + 1][j]++;
                        res.push_back(PP(P(i, j), P(i + 1, j)));
                    }
                } else {
                    if (field[i][j] % 2) {
                        field[i][j]--;
                        field[i][j + 1]++;
                        res.push_back(PP(P(i, j), P(i, j + 1)));
                    }
                }
            }
        } else {
            for (int j = W - 1; j >= 0; j--) {
                if (j == 0) {
                    if (field[i][j] % 2 && i != H - 1){
                        field[i][j]--;
                        field[i + 1][j]++;
                        res.push_back(PP(P(i, j), P(i + 1, j)));
                    }
                } else {
                    if (field[i][j] % 2) {
                        field[i][j]--;
                        field[i][j - 1]++;
                        res.push_back(PP(P(i, j), P(i, j - 1)));
                    }
                }
            }
        }
    }

    cout << res.size() << endl;
    for (int i = 0; i < res.size(); i++) {
        P p1 = res[i].first;
        P p2 = res[i].second;
        cout << p1.first + 1 << " " << p1.second + 1 << " " << p2.first + 1 << " " << p2.second + 1 << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

ll n, k;

int main() {
    cin >> n >> k;

    Vi v(n);
    REP(i, n) {
        cin >> v[i];
        v[i]--;
    }

    V<bool> vb(n, false);
    ll now = 0, cnt = 0;
    vb[0] = true;
    REP(i, n) {
        now = v[now];
        cnt++;
        if (cnt == k) {
            cout << now+1 << '\n';
            return 0;
        }
        if (vb[now]) break;
    }

    ll s = now;
    ll looplen = 0;
    REP(i, n) {
        now = v[now];
        looplen++;
        if (now == s) break;
    }

    k = k-cnt;
    k -= k/looplen*looplen;

    REP(i, k) {
        now = v[now];
    }

    cout << now+1 << '\n';

    return 0;
}


Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
	int N;
	cin >> N;
	vector<int> A(3*N);
	
	for (int i = 0; i < 3*N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	int res=0;

	for (int i = 0; i < N; i++) {
		res+=A[(3*N-2)-i*2];
	}
	
	cout << res << endl;
	return 0;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int32 n,m;
vector<vector<int32>> adj;
vector<int32> ans,ans2;
vector<bool> visited;

void dfs(int32 v){
  ans.pb(v);
  visited[v] = true;
  for(auto u : adj[v]){
    if(visited[u])continue;
    dfs(u);
    break;
  }
}
void dfs2(int32 v){
  if(v != 0)
    ans2.pb(v);
  visited[v] = true;
  for(auto u : adj[v]){
    if(visited[u])continue;
    dfs2(u);
    break;
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  adj.resize(n);
  REP(i,m){
    int32 a,b;
    cin >> a >> b;
    --a;--b;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  visited.resize(n,false);
  dfs(0);
  dfs2(0);
  ANS(ans.size() + ans2.size());
  reverse(all(ans2));
  for(auto a : ans2)cout << a+1 << " ";
  for(auto a : ans)cout << a+1 << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 12496
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 2e5+5;
int n;

ii foo[maxn];

int cnt[maxn];

int tot = 0;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i<= n; i++)
	{
		scanf("%d %d", &foo[i].X, &foo[i].Y);
		if(foo[i].X> foo[i].Y) swap(foo[i].X, foo[i].Y);
	}
	sort(foo+1, foo+n+1);
	vector< ii > mon;
	for(int i = 1; i<= n; i++)
	{
		if(mon.empty() || foo[i].Y> mon.back().Y) mon.pb(foo[i]);
	}
	ll res = 4e18;
	int minx = 1e9, maxx = -1e9;
	int miny = 1e9, maxy = -1e9;
	for(int i = 1; i<= n; i++)
	{
		minx = min(foo[i].X, minx);
		maxx = max(foo[i].X, maxx);
		miny = min(foo[i].Y, miny);
		maxy = max(foo[i].Y, maxy);
	}
	res = 1LL*(maxx-minx)*(maxy-miny);
	if((int) mon.size() == 1)
	{
		printf("%lld\n", res);
		return 0;
	}
	vector< ii > vec;
	for(int i = 1; i<= n; i++)
	{
		vec.pb(ii(foo[i].X, i));
		vec.pb(ii(foo[i].Y, i));
	}
	sort(vec.begin(), vec.end());
	int width = 1e9+5;
	int pt = 0;
	for(int i = 0; i< (int) vec.size(); i++)
	{
		if(i) 
		{
			cnt[vec[i-1].Y]--;
			if(cnt[vec[i-1].Y] == 0) tot--;
		}
		while(pt< (int) vec.size() && tot< n)
		{
			cnt[vec[pt].Y]++;
			if(cnt[vec[pt].Y] == 1) tot++;
			pt++;
		}
		if(tot == n)
		{
			width = min(width, vec[pt-1].X-vec[i].X);
		}
	}
	res = min(res, 1LL*width*(mon.back().Y-mon[0].X));
	printf("%lld\n", res);
}


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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            
            int X = n[0];
            int Y = n[1];
            int Z = n[2];
            
            Console.WriteLine((X-Z)/(Y+Z));
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> C(M);
  for (int i=0; i<M; i++) cin >> C.at(i);
  
  vector<int> dp(N+1, 50000);
  dp.at(0) = 0;
  
  for ( int i=1; i<=N; i++ ) {
    for ( int j=0; j<M; j++ ) {
      if ( i - C.at(j) >= 0 ) dp.at(i) = min(dp.at(i), dp.at( i - C.at(j) ) + 1);
    }
  }
  
  cout << dp.at(N) << endl;
  
  return 0;
}


Measured memory_bytes: 3168
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e9+7;

vector<vi> edges;
vector<int> dp;

int dfs(int a) {
    
    if(dp[a] != -1) return dp[a];
    
    int ans = 0;
    
    for(int b : edges[a]) {
        ans = max(ans, 1 + dfs(b));
    }
    
    dp[a] = ans;
    return ans;
}

int main() {
    
    int n, m;
    scanf("%d%d",&n,&m);
    
    dp.assign(n+1, -1);
    edges.resize(n+1);
    
    for(int i = 1; i <= m; ++i) {
        int a, b;
        scanf("%d%d",&a,&b);
        edges[a].push_back(b);
    }
    

    for(int i = 1; i <= n; ++i) {
        edges[0].push_back(i);
    }
    
    int ans = dfs(0);
    
    cout << ans-1 << endl;
    
    return 0;
}




Measured memory_bytes: 8696
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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! {
        n: usize,
        s: chars
    }

    let left = s[..n].iter().cloned() .collect::<Vec<_>>();
    let mut right = s[n..].iter().cloned() .collect::<Vec<_>>();
    right.reverse();
    
    let mut left_set = std::collections::HashMap::new();
    for (red, blue) in enum_all_subsets(&left) {
        *left_set.entry((red, blue)).or_insert(0u64) += 1;
    }
    let mut right_set = std::collections::HashMap::new();
    for (red, blue) in enum_all_subsets(&right) {
        *right_set.entry((red, blue)).or_insert(0u64) += 1;
    }

    let mut ret = 0u64;
    for (k, &v) in left_set.iter() {
        if let Some(v2) = right_set.get(k) {
            ret += v * v2;
        }
    }
    println!("{}", ret);
}

#[allow(dead_code)]
pub fn bit_filter<T: Clone>(b: usize, v: &[T]) -> Vec<T> {
    let mut ret = vec![];
    for i in 0..v.len() {
        if (b >> i) & 1 == 1 {
            ret.push(v[i].clone());
        }
    }
    ret
}
#[allow(dead_code)]
pub fn enum_all_subsets<'a, T: Clone + 'a>(v: &'a [T]) -> Box<Iterator<Item = (Vec<T>, Vec<T>)> + 'a> {
    Box::new((0..(1 << v.len())).map(move |s| (bit_filter(s, v), bit_filter(!s, v))))
}

Measured memory_bytes: 135332
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
cnt=0
for i in range(n):
  cnt+=b[a[i]-1]
for i in range(n-1):
  if a[i]+1==a[i+1]:
    cnt+=c[a[i]-1]
print(cnt)

Measured memory_bytes: 3188
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

T = T[::-1]
flags = [True for _ in range(N)]
for i in range(0, N - K):
    if flags[i] and T[i] == T[i + K]:
        flags[i + K] = False

res = 0
for i in range(0, N):
    if flags[i]:
        if T[i] == 'r':
            res += P
        elif T[i] == 's':
            res += R
        else:
            res += S
print(res)


Measured memory_bytes: 45296
#include <stdio.h>

int main(void) {
	int x,y,i;
	while(1){
	scanf("%d%d",&x,&y);
	if(x==0&&y==0)break;
	if(y<x){
		i=y;
		y=x;
		x=i;
	}
	printf("%d %d\n",x,y);
	}
	return 0;
}


Measured memory_bytes: 2020
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807int
#define I64_MAX2 1223372036854775807int
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define Aint(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//FUNCTION  
 
//solve

void solve(void)
{
  int H,W;
  cin>>H>>W;
  vector<vector<char> > DATA(H,vector<char>(W));
  vector<vector<int> > SUM_H(H,vector<int>(W,0));
  vector<vector<int> > SUM_W(H,vector<int>(W,0));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin>>DATA[i][j];
    }  
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if(DATA[i][j] == '.')SUM_W[i][j]++;
    }
    for (int j = 0; j < W-1; j++)
    {
      SUM_W[i][j+1] += SUM_W[i][j];
      if(DATA[i][j+1] =='#')SUM_W[i][j+1]=0;
    }

    for (int j = W - 1; j >= 1; j--)
    {
      SUM_W[i][j-1] = max(SUM_W[i][j],SUM_W[i][j-1]);
            if(DATA[i][j-1] =='#')SUM_W[i][j-1]=0;
    } 
  }


  for (int i = 0; i < W; i++)
  {
    for (int j = 0; j < H; j++)
    {
      if(DATA[j][i] == '.')SUM_H[j][i]++;
    }
    for (int j = 0; j < H-1; j++)
    {
      SUM_H[j+1][i] += SUM_H[j][i];
      if(DATA[j+1][i] =='#')SUM_H[j+1][i]=0;
    }

    for (int j = H - 1; j >= 1; j--)
    {
      SUM_H[j-1][i] = max(SUM_H[j][i],SUM_H[j-1][i]);
            if(DATA[j-1][i] =='#')SUM_H[j-1][i]=0;
    } 
  }
  int ANS = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      chmax(ANS,SUM_H[i][j] + SUM_W[i][j]-1); 
    }
  }
  cout<<ANS<<endl;
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

ll A, B, C, D;


ll cnt(ll n){
    ll in;
    if(A%n==0){
        in = A;
    }else{
        in = (n-A%n) + A;
    }

    return (B-in)/n+1;
}

int main(){
    cin >> A >> B >> C >> D;
    // printf("%lld %lld %lld\n", cnt(C), cnt(D), cnt(C*D/__gcd(C,D)));
    // printf("%lld\n", B-A+1-cnt(C)-cnt(D)+cnt(C*D/__gcd(C,D)));
    printf("%lld\n", B-A+1-B/C+(A-1)/C-B/D+(A-1)/D+B/(C*D/__gcd(C,D)) - (A-1)/(C*D/__gcd(C,D)));
    return 0;
}

Measured memory_bytes: 256
dict = {"I":1, "V":5, "X":10, "L":50, "C":100, "D":500, "M":1000}

while True:
    try:
        roman = raw_input()
        sum = 0
        value = 1000
        for i in range(len(roman)):
            if value >= dict[roman[i]]:
                value = dict[roman[i]]
                sum += value
            else:
                sum -= 2*value
                value = dict[roman[i]]
                sum += value
        print sum
    except:
        break

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



int main() {
  int N;
  cin>>N;
  vector<int> h(N);
  rep(i,N){
      cin>>h.at(i);
  }
  vector<int> dp(N);
  dp.at(1)=abs(h.at(1)-h.at(0));
  for(int i=2;i<N;i++){
      int x,y;
      x=dp.at(i-2)+abs(h.at(i-2)-h.at(i));
      y=dp.at(i-1)+abs(h.at(i-1)-h.at(i));
      dp.at(i)=min(x,y);
  }
  cout<<dp.at(N-1)<<endl;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;
    int mxdur=0;

    int k,n;
    cin>>k>>n;
    vector<int> a(n);

    rep(i,n)cin>>a[i];

    rep(i,n-1){
        int dur = a[i+1] - a[i];
        chmax(mxdur,dur);
    }

    chmax(mxdur,a[0] + (k-a[n-1]));


    cout<<k - mxdur<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

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

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	//偶数距離は自由にswapできる
	//奇数距離はコスト1かかる
	int n;
	cin >> n;
	int ans = 0;
	map<int, int> mp;
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		mp[b[i]] = 0;
	}
	int cnt = 0;
	for (auto &i : mp) {
		i.second = ++cnt;
	}

	rep(i, n) {
		if (mp[b[i]] % 2 == i % 2) {
			ans++;
		}
	}
	cout << ans / 2 << endl;


	return 0;
}

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

int main() {
  int N, m, cnt;
  cin >> N;
  
  cnt = 0;
  for(int j=1; j<=N; j++) {
    m = 0;
    if(j%2==0){
      continue;
    }
    for(int i=1; pow(i,2)<=j; i++) {
      if(pow(i,2)==j) {
        m++;
      } else if(j%i==0) {
        m += 2;
      }
    }
    if(m==8) {
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n; cin >>n;
  string s,t,ans; cin >> s >> t;
  for (ll i = 0; i < n; ++i) {
      ans += s[i];
      ans += t[i];
  }
  cout << ans << endl;
  return 0;
}

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

void chmin(int &a,int b){
  a=min(a,b);
}

signed main(){
  int N,M;cin>>N>>M;
  int T=1<<N;

  std::vector<int> a(M),key(M,0);

  for(int i=0;i<M;i++){
    int b;cin>>a[i]>>b;
    while(b--){
      int k;cin>>k;k--;
      key[i]|=(1<<k);
    }
  }

  std::vector<int> dp(10000,INF);
  dp[0]=0;

  for(int i=0;i<M;i++)
    for(int j=0;j<T;j++)
      chmin(dp[j|key[i]],dp[j]+a[i]);

  if(dp[T-1]>=INF)dp[T-1]=-1;
  cout<<dp[T-1]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>

const int m=998244353;
using namespace std;
using namespace __gnu_pbds;

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

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}



int32_t main(){
	
	//FIO();
	
		int n=1e6;
    vector<int> is_prime(n+1, 1);
    is_prime[0] = is_prime[1] = 1;
   for (int i = 2; i * i <= n; i++) {
    if (is_prime[i]==1) {
         for (int j = i * i; j <= n; j += i){
         	if(is_prime[j]==1)
         	 is_prime[j] = i;
		 }
       }
    }
    
    int m;
    cin>>m;
    
    int a[m];
    map<int,int> ma;
    bool f= false;
    for(int i=0;i<m;i++){
    	cin>>a[i];
    	vector<int> p;
    	int x=a[i];
    	while(is_prime[x]!=1){
    	    p.push_back(is_prime[x]);
    	    x=x/is_prime[x];
		}
		if(x!=1){
			p.push_back(x);
		}
	    p.resize(unique(p.begin(),p.end())-p.begin());
		for(int j=0;j<p.size();j++){
			if(ma[p[j]]){
				f=true;
			}
			++ma[p[j]];
		}
	}
	
	if(!f){
		cout<<"pairwise coprime\n";
		return 0;
	}
	
	int gc = a[0];
	for(int i=1;i<m;i++){
		gc=__gcd(gc, a[i]);
	}
	if(gc==1){
		cout<<"setwise coprime\n";
	}else{
		cout<<"not coprime\n";
	}

		
	
	

	return 0;
	
		
}




Measured memory_bytes: 23764
n = int(input())
s = input()

tmp = 0
for i in range(n-1):
	for j in range(i+tmp+1, n):
		if not s[i:j] in s[j:]:
			break
	tmp = max(tmp, j-i-1)

"""
二重ループ型だが実際はO(ans N)でうごく.
"""

print(tmp)

Measured memory_bytes: 40716
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string r;
  cin>>r;
  if(r==s)cout<<a-1<<" "<<b<<endl;
  else cout<<a<<" "<<b-1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str1, str2;
  cin >> str1 >> str2;
  int count = 0;
  bool ans = false;
  for(int i = 0; i < str1.size(); i++){
    if(str1.at(i) == str2.at(i)){
      count++;
    }
    else{
        break;
    }    
  }
  if(count == str1.size()){
    if(str2.size() == str1.size() + 1)
      ans = true;
  }
  if (ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;

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

const int B = 310;
int color[100010],  par[100010], depth[100010];
int top[100010];
int goUp[100010];
bool vis[100010];
int n;
vector<vector<int>> g;

void decomp(int root){
    rep(i,n) vis[i] = false, par[i] = -1;
    queue<int> q;
    q.push(root);
    vector<int> tord;
    while(q.size()){
        int v = q.front(); q.pop();
        vis[v] = true;
        tord.push_back(v);
        for(int c : g[v]){
            if(!vis[c]){
                q.push(c);
                par[c] = v;
                depth[c] = depth[v] + 1;
            }
        }
    }
    rep(i,n) vis[i] = false;
    int c = 0;
    for(int u : tord){
        if(vis[u]) continue;
        q.push(u);
        int k = 0;
        while(q.size() && k < B){
            int v = q.front(); q.pop();
            vis[v] = true;
            color[v] = c;
            goUp[v] = par[u];
            top[v] = u;
            k++;
            for(int c : g[v]){
                if(!vis[c]) q.push(c);
            }
        }
        while(q.size()) q.pop();
        c++;
    }
    // rep(i,n) printf("v:%d col:%d dep:%d\n", i, color[i], depth[i]);
}

int solve(int u, int v){
    while(color[u] != color[v]){
        // cout << u << " " << v << endl;
        assert(u != -1 && v != -1);
        if(depth[top[u]] > depth[top[v]]) u = goUp[u];
        else v = goUp[v];
    }
    while(u != v){
        assert(u != -1 && v != -1);
        if(depth[u] > depth[v]) u = par[u];
        else v = par[v];
    }
    return u;
}

int main(){
    cin >> n;
    g.assign(n,{});
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int c;
            cin >> c;
            g[i].push_back(c);
            par[c] = i;
        }
    }
    decomp(0);
    int q;
    cin >> q;
    rep(i,q){
        int u,v;
        cin >> u >> v;
        cout << solve(u,v) << endl;
    }
}

Measured memory_bytes: 9088
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const LL MOD = 1e9+7;
const int N = 2e6;
const int ALPHA = 26;
LL mod_pow(LL base, LL exp)
{
    if(exp==0) return 1;
    if(exp&1) return (base*mod_pow(base,exp-1))%MOD;
    else return mod_pow((base*base)%MOD, exp>>1);
}
LL fac[N+1];
LL fac_inv[N+1];
LL C(int n, int k)
{
    if(!(0 <= k && k <= n)) return 0;
    LL num = fac[n];
    LL den = (fac_inv[k]*fac_inv[n-k])%MOD;
    return (num*den)%MOD;
}
int main()
{
    fac[0] = 1;
    for(LL n = 1; n <= N; n++)
        fac[n] = (n*fac[n-1])%MOD;
    fac_inv[N] = mod_pow(fac[N],MOD-2);
    for(LL n = N-1; n >= 0; n--)
        fac_inv[n] = (fac_inv[n+1]*(n+1))%MOD;

    int k; cin >> k;
    string s; cin >> s;
    int n = k+s.length();

    LL f = 0;
    for(int i = 0; i <= min(n,(int)s.length()-1); i++)
        f = (f+C(n,i)*mod_pow(25,n-i))%MOD;
    cout<<(mod_pow(26,n)-f+MOD)%MOD<<endl;
    return 0;
}

Measured memory_bytes: 36516
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
const int MOD=1000000007;

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  for(int i=1;i<=100;i++){
    if(A*i%B==C){cout<<"YES"<<endl;return 0;}
  }
  cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll z=1000000007;
ll dp[100005];

int main()
{
  IOS;
  ll t=1;
//  cin>>t;
  for(ll i=0;i<100005;i++)
  {
    dp[i]=z;
  }
  dp[0]=0;
  while(t--)
  {
    ll i,l,p,j,ans=0,n;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
      cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
      for(j=i+1;j<=i+2;j++)
      {
        if(j<n)
        dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
      }
    }

    cout<<dp[n-1]<<"\n";

  }

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

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

   if ((B - A) < 2 || A-1 > K) {
      cout << K + 1 << endl;
      return 0;
   }

   int sum = A;
   DUMP(sum)
   sum += (B - A) * ((K - (A-1))/2);
   DUMP(sum)
   sum += (K - (A-1)) % 2;
   DUMP(sum)
   cout << sum << endl;

   return 0;
}


Measured memory_bytes: 256
program cv
  implicit none
  integer :: n
  read(*,*) n
  select case(n)
    case(:104)
      write(*,'(i0)') 0
    case(105:134)
      write(*,'(i0)') 1
    case(135:164)
      write(*,'(i0)') 2
    case(165:188)
      write(*,'(i0)') 3
    case(189:194)
      write(*,'(i0)') 4
    case(195:200)
      write(*,'(i0)') 5
    case default
      write(*,'(i0)') 0
  end select
  stop
end program cv

Measured memory_bytes: 256
// AOJ ITP 1_6_B
#include<cstdio>
#include<string>
#define rep(i,a) for( int i = 0; i != (a); ++i )

const std::string suit = "SHCD";
bool used[52];

int main()
{
	int n;
	scanf( "%d", &n );
	rep( i, n )
	{
		char ch[2];
		int r;
		scanf( "%s%d", ch, &r );
		used[suit.find( *ch )*13+r-1] = true;
	}

	rep( i, 52 )
		if( !used[i] )
			printf( "%c %d\n", suit[i/13], i%13+1 );

	return 0;
}

Measured memory_bytes: 1060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#include <ctime>
#define Maxn 100005
#define Maxm 1000005
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define eps 1e-8
#define random(x) (rand()%x)+1
#define LL long long
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
const int mod=1e9+7;
int main()
{
	//input;output;
	int m,n,k,p;
	int arr[Maxn];
	int ans[105][105];
	while(~scanf("%d%d",&m,&n))
	{
		p=1;
		scanf("%d",&k);
		for(int i=1;i<=k;i++)
			scanf("%d",arr+i);
		for(int i=0;i<m;i++)
		{
			if(i%2==0)
			{
				for(int j=0;j<n;j++)
				{
					if(arr[p])
					{
						ans[i][j]=p;
						arr[p]--;
					}
					else
					{
						p++;
						ans[i][j]=p;
						arr[p]--;
					}
				}
			}
			else
			{
				for(int j=n-1;j>=0;j--)
				{
					if(arr[p])
					{
						ans[i][j]=p;
						arr[p]--;
					}
					else
					{
						p++;
						ans[i][j]=p;
						arr[p]--;
					}
				}
			}
		}
		for(int i=0;i<m;i++)
			for(int j=0;j<n;j++)
				printf("%d%c",ans[i][j],j==n-1?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 384
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

p = 10**9 + 7

all = 0
aft = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            all += 1
            if i < j:
                aft += 1

print((all * K * (K-1)//2 + K * aft) % p)


Measured memory_bytes: 3188
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

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

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

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> a(n);
    int ate = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ate += (d - 1) / a[i] + 1;
    }
    cout << ate + x;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

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

        int a = scan.nextInt();
        int b = scan.nextInt();
        int n = scan.nextInt();
        int s[] = new int[n];
        int f[] = new int[n];
        int g = 0;
        int i;
        for (i = 0; i < n; i++) {
            s[i] = scan.nextInt();
            f[i] = scan.nextInt();

            if (s[i] < a && b < f[i] || s[i] < b && a < f[i]) {
                g += 0;
            } else {
                g += 1;
            }

        }
        if (g == n) {
            System.out.println(0);
        } else {
            System.out.println(1);
        }
    }

}



Measured memory_bytes: 26588
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = stdin.nextInt();
        int m = stdin.nextInt();
        int[] p = new int[n];
        int[] x = new int[m];
        int[] y = new int[m];
        for (int i = 0; i < n; i++) {
            p[i] = stdin.nextInt() - 1;
        }
        for (int i = 0; i < m; i++) {
            x[i] = stdin.nextInt() - 1;
            y[i] = stdin.nextInt() - 1;
        }

        UnionFind uf = new UnionFind(n);
        for (int i = 0; i < m; i++) {
            uf.union(x[i], y[i]);
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (uf.same(i, p[i])) {
                ans++;
            }
        }

        System.out.println(ans);
    }

    private static final class UnionFind {
        private int[] parent;

        public UnionFind(int size) {
            this.parent = IntStream.range(0, size).toArray();
        }

        public int find(int x) {
            if (parent[x] == x) {
                return x;
            } else {
                parent[x] = find(parent[x]);
                return parent[x];
            }
        }

        public void union(int x, int y) {
            x = find(x);
            y = find(y);
            if (x != y) {
                parent[x] = y;
            }
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }
    }
}


Measured memory_bytes: 92244
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
	ll A,B;
	cin >> A >> B;
	string ans = (max(A, B) > 8) ? ":(" : "Yay!";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,n,b,num=0;
  scanf("%d",&n);
  if(n<1||n>100)return 0;
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int flag=1;
  while(flag){
    flag=0;
    for(j=n-1;j>0;j--){
      if(a[j]<a[j-1]){
	b=a[j];
	a[j]=a[j-1];
	a[j-1]=b;
	flag=1;
	num++;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",a[i]);
    else printf("%d ",a[i]);
  }
  printf("%d\n",num);
  return 0;
}



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

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

int main(){
  int a,b;
  cin >> a >> b;
  cout << (b%a==0 ? a+b:b-a) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MOD 1000000007
#define MAX_N 100001
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

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

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll n, n2, a[MAX_N];
bool used[MAX_N];
ll double_num = -1;
vector<ll> double_index;
ll comb[2][MAX_N];

void init() {
    comb[0][0] = 1;
    for (ll i = 1; i <= n + 1; ++i) {
        comb[0][i] = mod(mod(comb[0][i - 1] * (n + 1 - i + 1)) * mod_pow(i, MOD - 2, MOD));
    }
    comb[1][0] = 1;
    for (ll i = 1; i <= n2; ++i) {
        comb[1][i] = mod(mod(comb[1][i - 1] * (n2 - i + 1)) * mod_pow(i, MOD - 2, MOD));
    }
}

int main() {
    cin >> n;
    fill(used, used + n, false);
    for (ll i = 0; i <= n; ++i) {
        cin >> a[i];
        if (used[a[i]]) {
            double_num = a[i];
        }
        used[a[i]] = true;
    }
    for (ll i = 0; i <= n; ++i) {
        if (a[i] == double_num) {
            double_index.push_back(i);
        }
    }
    n2 = (double_index[0]) + (n - double_index[1]);
    
    init();
    
    for (ll k = 1; k <= n + 1; ++k) {
        ll ans = mod(comb[0][k] - comb[1][k - 1]);
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3712
import sys

# sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    c = read_str()
    if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':
        print('vowel')
    else:
        print('consonant')


main()


Measured memory_bytes: 2940
/*
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

typedef stack<int> si;

/* global variables */

/* subroutines */

/* main */

int main() {
  si st;

  for (;;) {
    string s;
    cin >> s;
    if (cin.eof()) break;

    if (s[0] == '+') {
      int b = st.top(); st.pop();
      int a = st.top(); st.pop();
      st.push(a + b);
    }
    else if (s[0] == '-') {
      int b = st.top(); st.pop();
      int a = st.top(); st.pop();
      st.push(a - b);
    }
    else if (s[0] == '*') {
      int b = st.top(); st.pop();
      int a = st.top(); st.pop();
      st.push(a * b);
    }
    else
      st.push(atoi(s.c_str()));
  }

  printf("%d\n", st.top());
  return 0;
}

Measured memory_bytes: 1196
A=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
b=[int(input()) for _ in range(N)]

s=[]
t=[]
cross_1=0
cross_2=0

ans="No"

for i in b:
    for j in range(3):
        if i in A[j]:
            s.append(j)
            t.append(A[j].index(i))
            if j==A[j].index(i):
                cross_1+=1
                if j==1:
                    cross_2+=1
            elif j==2-A[j].index(i):
                cross_2+=1
                
for k in range(3):
    if s.count(k)==3:
        ans="Yes"
for l in range(3):
    if t.count(l)==3:
        ans="Yes"
if cross_1==3:
    ans="Yes"
elif cross_2==3:
    ans="Yes"

print(ans)
    
    


Measured memory_bytes: 3064
n=int(input())
a=[]
for s in range(0,n+1):
    a.append(1)
for l in range(0,7):
    if l == 0:
        a[1]=2
    else:
        if 6**l<=n:
            a[6**l]=2
        else:
            pass
        if 9**l<=n:
            a[9**l]=2
        else:
            pass
for i in range(0,n+1):
    if a[i]>=2:
        for j in range(0,7):
            if i+6**j<=n:
                if a[i+6**j]>=2:
                    a[i+6**j]=min(a[i+6**j],a[i]+1)
                else:
                    a[i+6**j]=a[i]+1
            else:
                break
        for k in range(0,6):
            if i + 9**k<=n:
                if a[i+9**k]>=2:
                    a[i+9**k]=min(a[i+9**k],a[i]+1)
                else:
                    a[i+9**k]=a[i]+1
            else:
                break
    else:
        pass
print(a[n]-1)


Measured memory_bytes: 3992
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

i64 K;

int main() {
    cin >> K;

    i64 N = 50;
    i64 a[50];

    if (K < N) {
        for (int j = 0; j < N; ++j) {
            a[j] = (j < K) ? N : 0;
        }
    } else {
        i64 b = K / N, w = K % N;
        for (int j = 0; j < N; ++j) {
            a[j] = (N-1) + b - w;
            if (j < w) {
                a[j] += (w+1);
            }
        }
    }

    cout << N << endl;
    for (int j = 0; j < N; ++j) {
        if (j > 0) cout << " ";
        cout << a[j];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Diagnostics.Contracts;

class Program
{
    static void Main()
    {
        var input = MyUtil.ReadlongArray();
        var unit = input[1] + input[2];

        var count = input[0] / unit * input[1];
        var amari = input[0] % unit;

        if (amari > input[1])
        {
            count += input[1];
        }
        else
        {
            count += amari;
        }
        WriteLine(count);
        ReadKey();
    }
}

static class MyUtil
{
    /// <summary>
    /// 指定の桁のビットを取得します。
    /// </summary>
    /// <param name="num"></param>
    /// <param name="count">取得する桁。</param>
    /// <returns></returns>
    public static int GetBit(this int num, int count)
    {
        int mask = (int)Math.Pow(2, count - 1);
        return (num & mask) == 0 ? 0 : 1;
    }

    /// <summary>
    /// <c>int</c>を2進数ビット配列に変換します。
    /// </summary>
    /// <param name="num"></param>
    /// <returns></returns>
    public static int[] ToBitArray(this int num)
    {
        const int size = sizeof(int) * 8;
        var array = new int[size];
        for (int i = 0; i < size; i++)
        {
            array[i] = num.GetBit(size - i);
        }
        return array;
    }

    public static long[] ReadlongArray()
    {
        return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
    }

    public static int[] ReadintArray()
    {
        return ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    /// <summary>
    /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="ts"></param>
    public static void WriteToConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        Console.WriteLine(stringBuilder.ToString());
    }

    public static void WriteToDebugConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        System.Diagnostics.Debug.WriteLine(stringBuilder.ToString());
    }
}


Measured memory_bytes: 13396