akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
ll x[3][1005];
ll sum[1005];

int main(){
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> x[0][i] >> x[1][i] >> x[2][i];
    ll MAX = 0;
    for(int i = 0; i <= 1; i++){
        for(int j = 0; j <= 1; j++){
            for(int k = 0; k <= 1; k++){
                for(int n = 0; n < N; n++){
                    if(i == 0) sum[n] += x[0][n];
                    else sum[n] -= x[0][n];
                    if(j == 0) sum[n] += x[1][n];
                    else sum[n] -= x[1][n];
                    if(k == 0) sum[n] += x[2][n];
                    else sum[n] -= x[2][n];
                }
                sort(sum, sum+N, greater<>());
                ll s = 0;
                for(int n = 0; n < M; n++) s += sum[n];
                MAX = max(MAX, s); 
                for(int n = 0; n < N; n++){
                    sum[n] = 0;
                }
            }
        }
    }
    cout << MAX << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int A[110],a,b,c,d,i,sum=0;
	for(i=0;i<100;i++) A[i]=0;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	for(i=a;i<b;i++) A[i]++;
	for(i=c;i<d;i++) A[i]++;
	for(i=0;i<100;i++){
		if(A[i]==2) sum++;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
import numpy as np
N, A, B = map(int, input().split())

total = 0
for i in range(1, N+1):
  a = i
  lis =[]
  while i >0:
    lis.append(i%10)
    i //=10
  lis.reverse()
  lis = np.array(lis)
  SUM = np.sum(lis)

  if SUM >=A and SUM <=B:
    total += a
    
print(total)

Measured memory_bytes: 12472
import java.util.*;

public class Main{

    public static void main(String args[]){

        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
		int r = sc.nextInt();
        int D = sc.nextInt();
        int x = sc.nextInt();

        for(int i = 1; i <= 10; i++){
            x = r * x - D;
            System.out.println(x);
        }

    }

}

Measured memory_bytes: 21972
N = int(input())
A = list(map(int, input().split()))

if sum(x < 0 for x in A) % 2 == 0:
  result = sum(map(abs, A))
else:
  minimum_abs, idx = abs(A[0]), 0
  for i in range(1, N):
    if minimum_abs > abs(A[i]):
      minimum_abs, idx = abs(A[i]), i
  result = sum(map(abs, (v for i, v in enumerate(A) if i != idx))) - abs(minimum_abs)

print(result)


Measured memory_bytes: 14332
#include <iostream>

using namespace std;

int main()
{
    string S, T;

    cin >> S >> T;

    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3908
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main(void) {

  string exp; cin >> exp;
  int ans; cin >> ans;

  stack<int> nums;
  for (unsigned int i = 0; i < exp.size(); i++) {
    if (exp[i] == '*') {
      int v1 = nums.top(); nums.pop();
      int v2 = exp[++i] - '0';
      nums.push(v1*v2);
    } else if (exp[i] == '+') {
      continue;
    } else {
      nums.push(exp[i] - '0');
    }
  }
  int a1 = 0;
  while (!nums.empty()) {
    a1 += nums.top(); nums.pop();
  }

  int a2 = exp[0] - '0';
  for (unsigned int i = 1; i < exp.size(); i++) {
    if (exp[i] == '+') {
      a2 += exp[i+1] - '0';
    } else if (exp[i] == '*') {
      a2 *= exp[i+1] - '0';
    }
  }

  if (a1 == ans) {
    if (a2 == ans) {
      cout << "U" << endl;
    } else {
      cout << "M" << endl;
    }
  } else if (a2 == ans) {
    cout << "L" << endl;
  } else {
    cout << "I" << endl;
  }

  return 0;
}

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

const int maxn = 1e6 + 10;
char s[maxn];

int deg[maxn], dis[maxn];

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1) + 1;
	for (int i = 1; i <= n; i++) {
		if (s[i - 1] == '<') deg[i]++;
		if (s[i] == '>') deg[i]++;
	}
	queue<int>que;
	for (int i = 1; i <= n; i++) if (deg[i] == 0) que.push(i);
	while (que.size()) {
		int u = que.front(); que.pop();
		if (s[u - 1] == '>') 
			if (!--deg[u - 1]) dis[u - 1] = dis[u] + 1, que.push(u - 1);
		if (s[u] == '<')
			if (!--deg[u + 1]) dis[u + 1] = dis[u] + 1, que.push(u + 1);
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += dis[i];
		//cout << dis[i] << endl;
	}
	printf("%lld\n", ans);
}

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

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n , m;
    cin>>n>>m;
    char x[n][n+1];
    for (int i = 0; i < n; ++i) {
        cin>>x[i];
    }
    char xx[m][m+1];
    for (int j = 0; j < m; ++j) {
        cin>>xx[j];
    }
    bool is = false;
    for(int i = 0 ; i <= n - m ; i++){
        for (int j = 0; j <= n - m; ++j) {
            is = true;
            for(int ii = 0 ; ii < m ; ii++){
                for(int jj = 0 ; jj < m ; jj++){
                    if(x[ii + i][jj + j] != xx[ii][jj]){
                        is = false;
                        goto suck;
                    }
                }
            }
            suck:;
            if(is)
                goto fuck;
        }
    }
    fuck:;
    if(is){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

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

const int MAXN = 200;
const int MAXK = 100;

int main() {
	string s;
	int k;
	cin >> s >> k;
	vector<vector<vector<int>>> dp(s.size() + 1, vector<vector<int>>(k + 1, vector<int>(2, 0)));
	// empty string without non-zero digit equal is 1
	dp[0][0][1] = 1;

	for (int i = 1; i <= s.size(); ++i) {
		// current digit
		int cur = s[i - 1] - '0';

		for (int j = 0; j <= k; ++j) {
			// fill 0 to smaller
			dp[i][j][0] = dp[i - 1][j][0];

			// fill 1-9 to smaller
			if (j) {
				dp[i][j][0] += dp[i - 1][j - 1][0] * 9;
			}

			// fill 0 to equal
			if (cur) {
				dp[i][j][0] += dp[i - 1][j][1];
			}

			// fill 1 to (cur-1) to equal
			if (cur > 1 && j) {
				dp[i][j][0] += dp[i - 1][j - 1][1] * (cur - 1);
			}

			// fill cur to equal
			dp[i][j][1] += cur ? (j ? dp[i - 1][j - 1][1] : 0) : dp[i - 1][j][1];
		}
	}
	cout << dp[s.size()][k][0] + dp[s.size()][k][1] << endl;
	return 0;
}

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

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep2(i,a,b) for(ll i=a; i<=b; i++)
#define drep2(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back


int main ()
{
  int a, b;
  cin >> a >> b;
  if (max(a,b) > 8) 
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
}

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

int main() {
    ll n,k;
    cin >> n >> k;
    ll tmp;
    vector<ll> d(k);
    vector<bool> A(k,false);
    for(int i=0;i<k;i++){
        cin >> d[i];
        for(int j=0;j<d[i];j++){
            cin >> tmp;
            A[--tmp]=true;
        }
    }
    ll ans=0;
    for(int i=0; i<n ; i++ ){
        if(!(A[i])) ans++;
    }
    cout << ans << endl;
    return 0 ;
}


Measured memory_bytes: 3640
n, m = gets.split.map(&:to_i)
s = []
ans = 0

board = []
m.times do |i|
  k, *s = gets.split.map(&:to_i)
  board << s
end

power = gets.split.map(&:to_i)
power.length.times do |i|
  board[i] << power[i]
end
#p board

# ture false走査
(2**n).times do |i|
  x = i.to_s(2).rjust(n, '0')
  count = 1
  set = []
  x.split('').each do |c|
    set << count if c == "1"
    count += 1
  end
  #p "set:#{set}"
  flag = 1
  board.each do |a|
    check = a[-1]
    if check != a[0..(a.length-2)].count{|i| set.include?(i)}%2
      flag = 0
      break
    end
  end
  ans += 1 if flag == 1 

end 

#p board
p ans

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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var w = int.Parse(Console.ReadLine());
			var n = int.Parse(Console.ReadLine());
			var r = new int[w];
			for (int i = 0; i < w; i++)
				r[i] = i + 1;
			for (int i = 0; i < n; i++)
			{
				var ab = Console.ReadLine().Split(',').Select(j=>int.Parse(j)).ToArray();
				var tmp = r[ab[0]-1];
				r[ab[0]-1] = r[ab[1]-1];
				r[ab[1]-1] = tmp;
			}
			for(int i=0;i<w;i++)
			{
				Console.WriteLine(r[i]);
			}
		}
	}
}

Measured memory_bytes: 5916
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=2e12;
ll cnt=0;
#define nil -1
int p[200];
int c[200][200];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>p[i-1]>>p[i];
    for(int i=0;i<=n;i++)c[i][i]=0;
    for(int l=2;l<=n;l++){
      for(int i=1;i<=n-l+1;i++){
        int j=i+l-1;
        c[i][j]=(1<<21);
        for(int k=i;k<=j-1;k++){
          c[i][j]=min(c[i][j],c[i][k]+c[k+1][j]+p[i-1]*p[k]*p[j]);
        }
      }
    }
    cout<<c[1][n]<<endl;
   return 0;
}



Measured memory_bytes: 3196
package main

import (
	"bufio"
	"fmt"
	"strings"

	"os"
	"strconv"
)

//scanで一行づつ読み込む
var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)

//sort
// array := []int{5, 1, 4, 2, 3}
// sort.Sort(sort.IntSlice(array))

func main() {
	// a := make([]int, n)
	n0 := nextLine()
	n, _ := strconv.Atoi(n0)
	n2 := strings.Split(nextLine(), " ")
	arr := []int{}
	for _, i := range n2 {
		j, _ := strconv.Atoi(i)
		arr = append(arr, j)
	}
	slice := arr[:]
	// sort.Sort(sort.IntSlice(arr))
	// a, b := arr[0], arr[1]
	var ans int = 0
	count := make([]int, n)
	count[0] = 0
	t := true

	for t {
		sel := true
		t = false
		for i, v := range slice {

			if v == 0 {
				sel = true
				continue

			}
			if sel && v > 0 {
				ans++
				sel = false
				slice[i]--
				t = true

			} else if !sel && v > 0 {
				slice[i]--
			}
		}

	}

	fmt.Fprintln(wtr, ans)
	_ = wtr.Flush()
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
# Linear Approximation
from statistics import median
n = int(input())
a = list(map(int, input().split()))
b = []
_sum = 0
for i in range(n):
    b.append(a[i] - i - 1)
med = median(b)
for i in range(n):
    _sum += abs(b[i] - med)
print(int(_sum))


Measured memory_bytes: 27252
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

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

int absA(long long num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int absB(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}



const long long INF = 100100100100;

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> retu(110000);
    for (int i = 0; i < N; i++) cin >> retu.at(i);
    vector<long long> dp(110000);
    for (long long i = 0; i < 110000; i++) {
        dp.at(i) = INF;
    }
    dp.at(0) = 0;
    
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + absA(retu.at(i) - retu.at(i+j)));
        }
    }
    cout << dp[N - 1] << endl;

}



Measured memory_bytes: 1920
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007

// for using in pairs
#define F first
#define S second

// Macros
#define all(x) begin(x), end(x)

// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

#define int long long

///////////////////////////////////////////////////////////////////////

void solve(int tc)
{
	string s;
	cin >> s;

	int ans = 0;
	for (int i = 0; i < s.size(); i++)
	{
		ans += (int)(s[i] - '0');
	}

	if (ans % 9 == 0)
	{
		cout << "Yes\n";
	}else
	{
		cout << "No\n";
	}

}

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

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

	int t = 1;
	// cin >> t;
	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


Measured memory_bytes: 3784
///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)
/////////////////////////// ..... ///////////////////////////
#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }
/////////////////////////// ..... ///////////////////////////
#define int ll
#define pb(x) push_back(x)
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////
const int N = 1e5+2;
vector<int> g[N];
int n,m;
int dp[N+1];
int visited[N+1];

int dfs(int u){
	if(visited[u])return dp[u];
	visited[u]=1;
	int mx = 0;
	for(int child : g[u]){
		mx = max(mx, dfs(child)+1);
	}
	return dp[u]=mx;
}
/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	cin >> n >> m;
	For(i,m){
		int u,v; cin >> u >> v;
		g[u].pb(v);
	}
	dp[1] = 0;
	int ans = 0;
	For(i,n){
		ans = max(ans,dfs(i+1));
	}
	cout << ans <<"\n";

}

int32_t main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		freopen("TC", "r", stdin);
		//freopen("output.txt","w",stdout);
	#endif 
    ios_base:: sync_with_stdio(false); 
   	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
	#ifndef ONLINE_JUDGE
    	cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
    #endif
}

Measured memory_bytes: 12544
#include <iostream>
#include <string>
#include <set>
#include <unordered_map>
#include <vector>
#include <utility>
#include <cassert>
#include <algorithm>
#include <cstring>

using namespace std;

vector<int> dp;

int StepCases(int step) {
  if(dp[step] != -1) return dp[step];
  dp[step] = (StepCases(step - 1) + StepCases(step - 2)) % 1'000'000'007;
  return dp[step];
}

int main(int argc, char *argv[]) {
  vector<string> area_map;
  int H, W;
  cin >> H >> W;
  area_map.reserve(H);
  for(int i = 0; i < H; i++){
    string row;
    cin >> row;
    area_map.push_back(row);
  }
  vector<vector<pair<int, int>>> lit_map; // <v, h>
  for(int y = 0; y < H; y++){
    vector<pair<int, int>> lit_row;
    int count = 0;
    for(int x = 0; x < W; x++){
      if(area_map[y][x] == '.') {
        count++;
        continue;
      }
      if(count) {
        for(int i = 0; i < count; i++){
          lit_row.push_back({0, count});
        }
        count = 0;
      }
      lit_row.push_back({0, 0});
    }
    if(count) {
      for(int i = 0; i < count; i++){
        lit_row.push_back({0, count});
      }
      count = 0;
    }
    lit_map.push_back(lit_row);
  }
  for(int x = 0; x < W; x++){
    int count = 0;
    for(int y = 0; y < H; y++){
      if(area_map[y][x] == '.') {
        count++;
        continue;
      }
      if(count) {
        for(int i = 0; i < count; i++){
          lit_map[y - 1 - i][x].first = count;
        }
        count = 0;
      }
      lit_map[y][x].first = 0;
    }
    if(count) {
      for(int i = 0; i < count; i++){
        lit_map[lit_map.size() - 1 - i][x].first = count;
      }
      count = 0;
    }
  }
  int max_val = 0;
  for(int y = 0; y < H; y++){
    for(int x = 0; x < W; x++){
      //cerr << "(" << lit_map[y][x].first << "," << lit_map[y][x].second << ")\t";
      max_val = max(lit_map[y][x].first + lit_map[y][x].second - 1, max_val);
    }
    //cerr << endl;
  }
  cout << max_val << endl;
  return 0;
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    int x; cin >> x;
  	int ans;
    FOR(i,1,180){
      if(360*i%x == 0){
        ans=360*i/x;
        break;
      }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
const ll INF = 1000000007;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m+1);
	rep(i, m) cin >> a[i];
  a[m]=-1;
	vector<ll> dp(n + 1);
	dp[0] = 1;
	int k = 0;
	for (int i = 1; i <= n; i++) {
		if (i == a[k]) {
			dp[i] = 0;
			k++;
		}
		else {
			if (i == 1) dp[i] = 1;
			else dp[i] = (dp[i - 1] + dp[i - 2]) % INF;
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
#define N 20

int main(){

  int i;
  char str[N];

  scanf("%s", str);

  for(i=strlen(str);i>=1;i--){

    printf("%c", str[i-1]);

    if(i-1==0){

      printf("\n");

    }

  }

  return 0;

}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

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

	int ans = 0;
	for(int m = 1; m <= M; m++) {
		for(int d = 11; d <= D; d++) {
			if(!(d % 10 >= 2 and d / 10 >= 2)) continue;
			int D = d % 10 * (d / 10);
			ans += (D == m);
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

int main() {
  int n, w; cin >> n >> w;
  vector<int> res(n);
  for (int i = 0; i < n; i++) res[i] = i + 1;
  for (int i = 0; i < w; i++) {
    int a, b;
    scanf("%d,%d", &a, &b);
    swap(res[a-1], res[b-1]);
  }
  for (int i = 0; i < n; i++) cout << res[i] << endl;
}

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

using namespace std;

#define pb push_back
#define fio ios::sync_with_stdio(false);

typedef long long ll;
typedef pair <ll, ll> pi;

const ll maxn  = 1e5 + 5;

ll n, a, b, cur;
vector <pi> v;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
	    cin >> a >> b;
	    v.pb({b, a});
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < v.size(); i++) {
	    a = v[i].second, b = v[i].first;
	    cur += a;
	  //  cout << cur << " " << b << " " << a << endl;
	    if (cur > b) {
	        cout << "No\n";
	        return 0;
	    }
	}
	cout << "Yes\n";
	return 0;
}


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

int main() {
  int n, min, max;
  long long sum = 0;
  cin >> n;
  vector<int> v(n);
  for (auto& e : v) cin >> e;
  min = max = v[0];
  for (const auto& e : v) {
    if (min > e) min = e;
    if (max < e) max = e;
    sum += e;
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define fora(i,n) for(int i=0; i<n; i++)
int main() {
	std::ios::sync_with_stdio(false);
	int n,count=0;
	cin >> n;
	vector<int> a(n);
	fora(i,n){
		cin>>a[i];
		while(a[i]%2==0){
			a[i]/=2;
			count++;
		}
	}
	cout<<count<<"\n";
}


Measured memory_bytes: 256
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let (a,b) = get!(i32,i32);

    println!("{}", if a <=8&&b<=8 {"Yay!"} else {":("});
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<set>
#include<queue>
#include<cstdlib>
#include<algorithm>

using namespace std;
#define pb push_back
#define mp make_pair
#define SZ(x) (int)(x).size()

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<LL, LL> pll;

const double eps = 1e-10;
const double PI = acos(-1.0);
//const double PI = 3.14159265358979323846264338327950288419716939937510
int dcmp(const double &x) { if (fabs(x) < eps) return 0; return x < 0 ? -1 : 1; }
const int MOD = 1e9 + 7;
const int INF = 2e9;
const double INF_d = 1e64;

template<class T> 
T qmod(T a, T b){ T ret = 1; while (b){ if (b & 1) ret *= a; b >>= 1; a *= a; } return ret; }
template<class T>
T gcd(T a, T b){ return !b ? a : gcd(b, a % b); }
template<class T>
T ex_gcd(T a, T b, T &x, T &y){
    if (!b){ x = 1, y = 0; return a; }
    T t, ret;
    ret = ex_gcd(b, a % b, x, y);
    t = x, x = y, y = t - a / b * y;
    return ret;
}
template<class T>
T inv(T t, T p){ return t == 1 ? 1 : (p - p / t) * inv(p % t, p) % p; }
// head

const int N = 1e4 + 7;
int f[N], n, m;

void init(int n){
    for (int i = 0; i <= n; i++) f[i] = i;
}

int find_fa(int x){ return x == f[x] ? x : f[x] = find_fa(f[x]); }

void unite(int x, int y){
    int rx = find_fa(x), ry = find_fa(y);
    if (rx != ry) f[max(rx, ry)] = min(rx, ry);
}

int main(){
    scanf("%d%d", &n, &m);
    init(n);
    for (int i = 0; i < m; i++){
        int x, y, op;
        scanf("%d%d%d", &op, &x, &y);
        if (op) printf("%d\n", find_fa(x) == find_fa(y) ? 1 : 0);
        else{
            unite(x, y);
        }
    }
    return 0;
}


Measured memory_bytes: 3244
N, K = map(int, input().split())
H = sorted(map(int, input().split()), reverse=True)

if K >= N:
    print(0)
else:
    sum = [0]
    for i in range(0, N):
        #print(sum, H[i], sum[i-1], i)
        sum.append(sum[i]+H[i])

    #print(sum)
    print(sum[N]- sum[K])

Measured memory_bytes: 26020
#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];
    }
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j : {i + 1, i + 2})
        {
            if (j < n)
            {
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
            }
        }
    }
    cout << dp[n - 1];
}

Measured memory_bytes: 3960
N=int(input())
l= [list(map(int, input().split())) for i in range(3)]
a=0
for i in range(N-1):
    a+=l[1][l[0][i]-1]
    if l[0][i+1]==l[0][i]+1:
        a+=l[2][l[0][i]-1]
a+=l[1][l[0][N-1]-1]
print(a)

Measured memory_bytes: 3060
N = int(input())
hlist = list(map(int, input().split()))
dp = [10**9]*(N)
dp[0] = 0
dp[1] = abs(hlist[1] - hlist[0])
for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(hlist[i]-hlist[i-1]), dp[i-2]+abs(hlist[i]-hlist[i-2]))
print(dp[-1])


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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int a,b;
	cin >> a >> b;
	if(a <= b){
		for(int i = 0;i < b;i++){
			cout << a;
		}
	}else{
		for(int i = 0;i < a;i++){
			cout << b;
		}
	}
	cout  << "\n";
}

Measured memory_bytes: 3612
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# print(N, A, B)

m = 0
for i in range(N):
    a = A[i]
    b = B[i]
    if a <= b:
        m += a
        r = b - a
        a = A[i + 1]
        if a <= r:
            m += a
            A[i + 1] = 0
        else:
            m += r
            A[i + 1] -= r
    else:
        m += b

print(m)


Measured memory_bytes: 82020
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

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

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::vector<ll> divisors( ll x )
{
  std::vector<ll> ret;

  for( ll i = 1; i*i <= x; ++i ) if( x%i == 0 )
  {
    ret.emplace_back( i );

    if( i != x/i )
      ret.emplace_back( x/i );
  }

  return ret;
}

ll X;

int main()
{
  std::cin >> X;

  auto ds = divisors( X );

  for( auto d : ds )
  {
    rep( A, 150 )
    {
      ll B = A-d;  
      ll r = A*A*A*A*A-X;
      bool neg = r<0?true:false;

      r = llabs(r);

      ll x = 0;

      while( x*x*x*x*x < r )
        ++x;

      if( x*x*x*x*x > r )
        --x;

      
      //printf( "A: %lld, B: %lld, d: %lld, r: %lld, x: %lld\n", A, B, d, r, x );

      if( x*x*x*x*x == r && (neg?-1:1)*B == x )
      {
        std::cout << A << ' ' << B << std::endl;

        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int D, N;
  cin>>D>>N;
  vector<int> T(D);
  REP(i, D) cin>>T[i];
  vector<int> A(N), B(N), C(N);
  REP(i, N) cin>>A[i]>>B[i]>>C[i];
  const int M = 101;
  int dp[200][101] = {};
  REP(i, D)REP(j, M) dp[i][j] = -INF;
  REP(j, N) {
    if(A[j] <= T[0]  && T[0] <= B[j]) dp[0][C[j]] = 0;
  }
  FOR(i, 1, D){
    REP(j, N) if(A[j] <= T[i] && T[i] <= B[j]){
      REP(k, M) {
        dp[i][C[j]] = max(dp[i][C[j]], dp[i - 1][k] + abs(C[j] - k));
      }
    }
  }
  int ans = 0;
  REP(k, M) ans = max(ans, dp[D - 1][k]);
  cout<<ans<<endl;
  return 0;
}

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

//N??\???????´???°?????????O(N log log N)
int N = 1010101;
set<int> primes;
vector<bool> is_prime(N + 1, true);
void init() {
        is_prime[0] = is_prime[1] = false;
        for (int i = 2; i <= N; i ++) {
                if (is_prime[i]) {
                        primes.insert(i);
                        for (int j = i + i; j <= N; j += i) is_prime[j] = false;
                }
        }
}

int main() {
        init();
        int a, d, n;
        while (scanf("%d%d%d", &a, &d, &n), n) {
                int cnt = 0;
                for (;;) {
                        if (primes.count(a)) cnt ++;
                        if (cnt == n) break;
                        a += d;
                }
                printf("%d\n", a);
        }
        return 0;
}

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

using namespace std;

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;

  int ans = 0;
  for (int i = 0; i < n - 2; ++i) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000//10^12
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007

using namespace std;

//void型なので返り値は無し　d[]に結果が格納されるので欲しいものをansに
int main(void)
{
	//変数の宣言
	ll int n;
	int dp[20];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	int ok,ng;



	//データの読み込み


	scanf("%lld",&n);
//	scanf_s("%lld",&n);


/*	for(i=0;i<n;i++){
//		scanf("%s",&s[i]);
		scanf_s("%s",&s[i]);
	}*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理
	i=0;
	while(n!=0){
		dp[i]=n%10;
		n=n/10;
		i++;
	}

	len=i;
	for(i=-1;i<len;i++){
		temp=0;
		for(j=0;j<len;j++){
			if(j<i){
				temp=temp+9;
			}else if(j==i){
				temp=temp+dp[j]-1;
			}else{
				temp=temp+dp[j];
			}
		}

		ans=max(ans,temp);
	}

	//	printf("計算部分終了\n");

	//出力
	
	printf("%d",ans);

	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
    template <class C>
    static char test(typename C::const_iterator*);
    template <class C>
    static int test(...);
    static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
    static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o,
                                                             const C& c) {
    o << '{';
    for (auto it = c.begin(); it != c.end();)
        o << *it << (++it != c.end() ? ", " : "}");
    return o;
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
    return o << '(' << p.fi << ", " << p.se << ')';
}

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

    int n;
    cin >> n;
    unordered_set<string> s;
    F0R (i, n) {
        string ss;
        cin >> ss;
        s.insert(ss);
    }
    cout << SZ(s) << endl;

    return 0;
}


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

int main() {

 int N,K;
  cin >> N>>K;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0;i<K;i++){
    ans=ans+p[i];
  }
  cout <<ans<<endl;
  
 return 0;
}


Measured memory_bytes: 3636
def main
  n, time_limit = gets.split.map(&:to_i)

  min_cost = 10000
  n.times do |i|
    cost, time = gets.split.map(&:to_i)
    next if time_limit < time

    min_cost = cost if cost < min_cost
  end

  if 1000 < min_cost
    puts 'TLE'
  else
    puts min_cost
  end
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 1788
def solve
  if N.odd?
    N.times do |i|
      return 0 if A[i] != (i+1)/2 * 2
    end
  else
    N.times do |i|
      return 0 if A[i] != i/2 * 2 + 1
    end
  end
  (2 ** (N/2)) % M
end

M=10**9+7
N=gets.to_i
A=gets.split.map(&:to_i).sort
p solve


Measured memory_bytes: 9712
#include <stdio.h>
#define MAX 500001

int heap[MAX];
int heap_size;

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
 
void maxHeapify(int i){
  int l, r, L, tmp;
  l=left(i);
  r=right(i);
  if(l <= heap_size && heap[l] > heap[i]){
   L=l;
  }
  else{
   L = i;
  }

  if(r <= heap_size && heap[r] > heap[L]){
   L=r;
  }
  if(L != i){
    tmp=heap[i];
    heap[i] = heap[L];
    heap[L] = tmp;
    maxHeapify(L);
  }
}
 
void builtMaxHeap(void){
  int i;
  for(i = heap_size/2; i > 0; i--){
    maxHeapify(i);
  }
}
 
 
int main(void){
  int i,n;
  scanf("%d",&n);
  heap_size = n;
  for(i = 1; i <= n; i++){
    scanf("%d",&heap[i]);
  }
 
  builtMaxHeap();
 
  for(i = 1; i <= n; i++){
    printf(" %d",heap[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;
//ll mod = 998244353;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	//t %= mod;
	if (n % 2 == 1)t *= a;
	return t /*% mod*/;
}

//const int INF = 1001001001;
const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

vector<pair<ll, ll>> prime_factorize(ll N) {
	vector<pair<ll, ll>> res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0;
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}


int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<int>row(h);
	vector<int>col(w);
	vector<vector<bool>>t(h, vector<bool>(w));
	int black = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c;
			cin >> c;
			if (c == '#') {
				col[j]++;
				row[i]++;
				black++;
				t[i][j] = true;
			}
			else {
				t[i][j] = false;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < (1 << (h + w)); i++) {
		int tmp = black;
		vector<int>col2 = col;
		for (int j = 0; j < (h + w); j++) {
			if ((i >> j) & 1){
				if (j < h) {
					tmp -= row[j];
					for (int k = 0; k < w; k++) {
						if (t[j][k])col2[k]--;
					}
				}
				if (j >= h) {
					tmp -= col2[j - h];
				}
			}
		}
		if (tmp == k)ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3628
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int[] p=new int[n];
		boolean[] b=new boolean[n];
		for(int i=0;i<n;i++){
			p[i]=scanner.nextInt()-1;
			if(i==p[i]){
				b[i]=false;
			}else{
				b[i]=true;
			}
		}
		int ans=0;
		int cnt=0;
		for(int i=0;i<n;i++){
			if(b[i]){
				cnt=0;
				continue;
			}else{
				if(cnt==1){
					cnt=0;
					continue;
				}
				cnt++;
				ans++;
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 23376
object Main extends App {
  import scala.io.StdIn._

  val n = readInt
  implicit val task = readLine.trim.split(' ').map(_.toInt).toList
  println(
    lowerBound(0, 100)(canMake) - 1
  )
  def canMake(norma: Int)(implicit task: List[Int]): Boolean = {
    def sub(restTask: List[Int], stocked: Int = 0): Boolean = {
      restTask match {
        case Nil ⇒ true
        case h::t if stocked + h >= norma ⇒ sub(t, stocked + h - norma)
        case _ ⇒ false
      }
    }
    sub(task)
  }
  def lowerBound(from: Int, until: Int)(func: Int => Boolean) : Int = {
    var left = from
    var right = until
    while(left < right){
      val mid = (left + right) / 2
      if (func(mid)){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 44192
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define MOD 1000000007;
using namespace std;

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

    int num {};
    cin >> num;

    int first {num/100};
    int sec {num%100};

    if (first >= 1 && first <= 12) {
    	if (sec >= 1 && sec <= 12) cout<<"AMBIGUOUS"<<endl;
    	else cout<<"MMYY"<<endl;
    }
    else {
    	if (sec >= 1 && sec <= 12) cout<<"YYMM"<<endl;
    	else cout<<"NA"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for n in range(b + 1):
        for k in range(c + 1):
            if i * 500 + n * 100 + k * 50 == x:
                ans += 1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 310, p = 998244353;
char w[maxn];
int n, k, c1, res;
vector<int> c;
int dp[maxn][maxn][maxn];

void add(auto &a, auto v) {
	a += v - p;
	a += (a>>31) & p;
}
void get_ans() {
	//for (int i = 0;i <= k;++i) dp[0][0][i] = 1;
	dp[0][0][0] = 1;
	int sum = 0;
	for (int i = 1;i <= c.size();++i) {
		int cp = c[i-1];
		sum += cp;
		for (int j = sum;j <= c1;++j) {
			for (int w = 0;w <= j;++w) {
				int cost = max(0, w - cp);
				for (int s = cost;s <= k;++s) 
					add(dp[i][j][s], dp[i-1][j-w][s-cost]);
			}
		}
	}
	for (int s = 0;s <= k;++s)
		add(res, dp[c.size()][c1][s]);
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> w+1 >> k;
	n = strlen(w+1);
	for (int i = 1, cnt = 0;i <= n+1;++i) {
		if (w[i] == '1') ++cnt;
		else c.pb(exchange(cnt, 0));
	}
	c1 = count(w+1, w+1+n, '1');
	k = min(k, c1);
	if (c.size() == 1) 
		return cout << 1 << '\n', 0;
	get_ans();
	cout << res << '\n';
}


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

#define MAXN 100

using namespace std;

int A[MAXN];

int main()
{
  int N;
  int sum1, sum2;

  cin >> N;

  for ( int i = 0; i < N; ++i ) scanf("%d", &A[i]);
  sort(A,A+N,greater<int>());

  sum1 = sum2 = 0;

  for ( int i = 0; i < N; ++i ) {
    if ( i%2 ) sum2 += A[i];
    else sum1 += A[i];
  }

  cout << sum1-sum2 << "\n";
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  double R;
  cin >> R ;
  cout << 2*R*3.14159265358979;
  return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 62;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    ll a, b, c, d;
    cin>> a >> b >> c >> d;
    ll ans = a * c;
    if(ans < a * d)  ans = a * d;
    if(ans < b * c)  ans = b * c;
    if(ans < b * d)  ans = b * d;
    cout << ans << endl;
}

Measured memory_bytes: 3632
const H,N=map(x->parse(Int,x),split(readline()))
function update(dp,a,b)
	for j=1:H
		nxt=min(j+a,H+1)
		dp[nxt]=min(dp[nxt],dp[j]+b)
	end
end
function main()
	dp=ones(Int,H+1)*1145141919
	dp[1]=0
	for i=1:N
		a,b=map(x->parse(Int,x),split(readline()))
		update(dp,a,b)
	end
	println(dp[H+1])
end
main()

Measured memory_bytes: 114344
//In The Name Of The God

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define F first
#define S second
#define X first.first
#define Y first .second
#define A second.first
#define B second.second
#define mp make_pair
#define pb push_back
#define pf push_front
#define P push
#define pob pop_back
#define pof pop_front
#define PO pop
#define rep(i,j,k) for(int i = j ; i <= k ; ++ i)
#define rrep(i,j,k) for(int i = j ; i>=k ; --i)
#define FR(i,j,k) for(int i = j ; i < k ; ++ i )
#define rFR(i,j,k) for(int i = j ; i > k ; -- i )
#define lb(x) x&-x
#define p2(x) (1LL<<x)
#define SZ size()
#define LB lower_bound
#define UB upper_bound
#define IT iterator
#define RIT reverse_iterator
#define E end()
#define BE begin()
#define RE rend()
#define RBE rbegin()
#define UN unsigned

typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll ;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<int,pll> pipl;
typedef pair<pll,int> ppli ;
typedef pair<pll,pll> plpl ;
typedef pair<ll,pii> lpip;
typedef pair<pii,ll> lppi;
typedef pair<pii,pii> lppp;
typedef pair<ll,pll> lpipl;
typedef pair<pll,ll> lppli ;
typedef pair<pll,pll> lplpl ;
typedef vector<int> vi ;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii > stpi;
typedef set<pll> stpl;
typedef vi::IT vit;
typedef vl::IT vlt;
typedef vpi::IT vpit;
typedef vpl::IT vplt;
typedef sti::IT stit;
typedef stl::IT stlt;
typedef stpi::IT stpit;
typedef stpl::IT stplt;
typedef vpi::RIT rvpit;
typedef vpl::RIT rvplt;
typedef sti::RIT rstit;
typedef stl::RIT rstlt;
typedef stpi::RIT rstpit;
typedef stpl::RIT rstplt;

const int MAXN = 500000;
const int SUPERN = 5000000;
const int MAXS = 325;
const int SUPERS = 1000;
const int MD = 1e9+7;
//......Structures.......

//......Variables........
ll n;
string s,v;
//......Funcs............
ll sum(ll a,ll b)
{
    return (a+b)%MD;
}
ll mu(ll a,ll b)
{
    return (a*b)%MD;
}
ll mn(ll a,ll b)
{
    return(a-b+MD)%MD;
}
//......Code.............
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>s;
    v=s;
    reverse(s.BE,s.E);
    if(s==v)
    {
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256