akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
static const int MOD = 10000007;
static const int MAX = 100005;
int N, dp[MAX];


int main() {
  cin >> N;
  int H[N];
  rep(i,N) {
    cin >> H[i];
  }

  int maxv = 1;
  dp[0] = 1;
  REP(i, 1, N) {
    if ( H[i] <= H[i-1] ) {
      dp[i] = dp[i-1] + 1;
      maxv = max(maxv, dp[i]);
    } else {
      dp[i] = 1;
    }
  }
  cout << maxv - 1 << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pp pair<int, int>
#define ppp pair<pp, int>
#define pp4 pair<pp, pp>
#define pp3 pair<ll, pair<int, int> > 
#define fi first
#define se second
#define N  222
#define mod 1000000007
#define inf 2000000001
#define esp 1e-9
#define BLOCK 333
#define BITNUM 555
#define BASE 311097
typedef long long ll;
// const ll oo = (ll)1e18 + 1;
using namespace std;
int n, m;
string s[N];
int dp[N][N];

int main() {
    ios::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);  

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
    	cin >> s[i];
    }

    dp[1][1] = 0;

    for (int i = 2; i <= m; i++){
    	dp[1][i] = dp[1][i - 1] + (s[0][i - 1] != s[0][i - 2]);
    }

    for (int i = 2; i <= n; i++)
    	dp[i][1] = dp[i - 1][1] + (s[i - 1][0] != s[i - 2][0]);

    for (int i = 2; i <= n; i++)
    	for (int j = 2; j <= m; j++) {
    		dp[i][j] = min(
    			dp[i - 1][j] + (s[i - 1][j - 1] != s[i - 2][j - 1]), 
    			dp[i][j - 1] + (s[i - 1][j - 1] != s[i - 1][j - 2])
    		);
    	}

    int need = 0;

    if (dp[n][m] % 2 == 0) {
    	need = dp[n][m] / 2 + (s[0][0] == '#');
    } else {
    	need = (dp[n][m] + 1) / 2;
	}

	cout << need;
    return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <inttypes.h>

uint64_t itibansita(uint64_t x) {
	return x & -x;
}

int itibansita_bit(uint64_t x) {
	uint64_t is = itibansita(x);
	int kienai = 0, kieru = 63;
	if (x == 0) return -1;
	if (is == UINT64_C(0x8000000000000000)) return 63;
	while (kienai + 1 < kieru) {
		int m = kienai + (kieru - kienai) / 2;
		if ((is >> m) == 0) kieru = m; else kienai = m;
	}
	return kienai;
}

int N;
uint64_t A[256];
char S[256];

uint64_t henkan[64];

int main(void) {
	int T;
	int yosinagasayuri;
	if (scanf("%d", &T) != 1) return 1;
	for (yosinagasayuri = 0;yosinagasayuri < T; yosinagasayuri++) {
		int i;
		int ok = 0;
		if (scanf("%d", &N) != 1) return 1;
		for (i = 0; i < N; i++) {
			if (scanf("%" SCNu64, &A[i]) != 1) return 1;
		}
		if (scanf("%255s", S) != 1) return 1;
		memset(henkan, 0, sizeof(henkan));
		for (i = N - 1; i >= 0; i--) {
			uint64_t cur = A[i];
			int bit = itibansita_bit(cur);
			while (cur != 0) {
				if (henkan[bit] == 0) break;
				cur ^= henkan[bit];
				bit = itibansita_bit(cur);
			}
			if (S[i] == '1') {
				/* 0エリアのやつで表せないA[i]があれば、人1が目標を達成できる */
				if (cur != 0) ok = 1;
			} else {
				if (cur != 0) henkan[bit] = cur;
			}
		}
		printf("%d\n", ok);
	}
	return 0;
}

/*

A_iが0のことはないはず

最後の人が1 → xが任意の値でx≠0にできる
最後の人が0 → x=A_Nまたはx=0のときのみx=0にできる

∴最後が1 → 絶対xは0にならない

…00の場合

i=N-1  A_N or 0を渡せばOK → A_N or (A_N ^ A_{N-1}) or 0 が来ればOK
i=N    A_N or 0が来ればOK

…000の場合

i=N-2   A_N or (A_N ^ A_{N-1}) or 0 を渡せばOK
        → A_N or (A_N ^ A_{N-1}) or (A_N ^ A_{N-2}) or (A_N ^ A_{N-1} ^ A_{N-2}) or 0 が来ればOK
i=N-1  A_N or 0 を渡せばOK → A_N or (A_N ^ A_{N-1}) or 0 が来ればOK
i=N    A_N or 0 が来ればOK

よって、0の連続の場合、最後にわたすべき値に任意のパターンでxorした値が来ればOK

…10の場合

i=N-1  A_N or 0を渡すとNG → A_N = A_{N-1} かつ A_{N-1} or 0 が来る とNG
i=N    A_N or 0が来ればOK

…1…10…0の場合

1の連続する部分において、A_iがすべて0エリアのA_iの任意個のxorで表せる &&
0エリアのA_iの任意個(0個でも)のxorの数値が来る → NG

…0…01…10…0の場合

人0にとって、1エリアへの入力がNGのやつになればいい
すなわち、1エリアを無視しておｋ (1エリアが勝つ条件を満たさなければ)

最初の入力はx=0なので、「0エリアのA_iの任意個(0個でも)のxorの数値」という条件を満たす

よって、それぞれの1エリアの各A_iについて、その先の0エリアをマージしたものxorで表せるかを判定すればおｋ
→どうやって？

A. XORに関する知見 http://nagoyacoder.web.fc2.com/topcoder/consideration/xor.html

愚直にやると？
T 100:
	for i in range(64):
		最初が1の数を探す 200: ← ソートすることで消せる
			ほかの数を変換する 200:

セットに加える → 変換不可の所かつ使えそうなところに加える

1 010
1 011
1 100
0 101
0 011
0 111

*/


Measured memory_bytes: 1676
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main() {
    int N = readln.chomp.to!int;
    foreach(i; 0..N) {
        bfs(readln.split.to!(int[])).writeln;
    }
}

int bfs(int[] ary) {
    auto list = DList!(Tuple!(int, int[]))(tuple(0, ary));
    while(!list.empty) {
        auto t = list.front;
        int depth = t[0];
        int[] vec = t[1];
        list.removeFront;
        if (check(vec)) return depth;
        {
            int[] v = vec.dup;
            swap(v[0], v[27]);
            swap(v[1], v[28]);
            swap(v[2], v[29]);
            swap(v[14], v[15]);
            swap(v[18], v[20]);
            list.insertBack(tuple(depth+1, v));
        } {
            int[] v = vec.dup;
            swap(v[2], v[21]);
            swap(v[5], v[24]);
            swap(v[8], v[27]);
            swap(v[11], v[18]);
            swap(v[12], v[14]);
            list.insertBack(tuple(depth+1, v));
        } {
            int[] v = vec.dup;
            swap(v[0], v[23]);
            swap(v[3], v[26]);
            swap(v[6], v[29]);
            swap(v[9], v[20]);
            swap(v[15], v[17]);
            list.insertBack(tuple(depth+1, v));
        } {
            int[] v = vec.dup;
            swap(v[6], v[21]);
            swap(v[7], v[22]);
            swap(v[8], v[23]);
            swap(v[12], v[17]);
            swap(v[9], v[11]);
            list.insertBack(tuple(depth+1, v));
        }
    }
    return 8;
}

bool check(int[] ary) {
    return ary.group.map!(a => a[1]).array == [9, 3, 3, 3, 3, 9];
}

Measured memory_bytes: 22268
a,b,c,d = map(int, input().split())
if a%d ==0:
  ao = a/d
else:
  ao = int(a/d +1)
if c%b ==0:
  taka = c/b
else:
  taka = int(c/b +1)

if taka> ao:
  print('No')
else:
  print('Yes')

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

#define ll long long int

ll topDown(int idx,vector<vector<int>> v,vector<bool> mark)
{
    if(idx==v.size()) return 0;
    vector<bool> cur_mark(3,true);

    ll cur = 0;
    for(int i = 0;i<3;i++)
    {
        if(mark[i]){
            cur_mark[i] = false;
            cur = max(cur, v[idx][i] + topDown(idx+1,v,cur_mark));
            cur_mark[i] = true;
        }
    }

    return cur;
}

ll bottomUp(vector<vector<int>> v)
{
    int n = v.size();
    vector<vector<ll>> dp(n+1,vector<ll>(3,0)); // 1 extra row

    for(int i = n-1;i>=0;i--)
    {
        dp[i][0] = v[i][0] + max(dp[i+1][1],dp[i+1][2]);
        dp[i][1] = v[i][1] + max(dp[i+1][0],dp[i+1][2]);
        dp[i][2] = v[i][2] + max(dp[i+1][1],dp[i+1][0]);
    }

    return max(dp[0][0],max(dp[0][1],dp[0][2]));
}

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

    vector<vector<int>> v(n,vector<int>(3));
    for(int i = 0;i<n;i++)
    {
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }

    // vector<bool> mark(3,true);
    // cout<<topDown(0,v,mark);

    cout<<bottomUp(v);


}


Measured memory_bytes: 16640
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;

int main() {
	int a;
	cin >> a;
	if (a % 2 == 0) {
		cout << a;
	}
	else
		cout << a * 2;
}



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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  vector<vector<int>> a(n,vector<int>(n,-1));
  rep(i,n) {
    int m;
    cin >> m;
    int x, y;
    rep(j,m) {
      cin >> x >> y;
      x--;
      a[i][x] = y;
    }
  }
  rep(i,1<<n) {
    bool can = true;
    rep(j,n) {
      if(i & (1<<j)) {
        rep(k,n) {
          if(a[j][k] == 0 && (i & (1<<k))) can = false;
          if(a[j][k] == 1 && !(i & (1<<k))) can = false;
        }
      } 
    }
    if(can) {
      int l = 0;
      rep(j,n) {
        if(i & (1<<j)) l++;
      }
      ans = max(ans,l);
    }
  }
  cout << ans << endl;
  return 0;
}

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

namespace ConsoleApp1
{
    static class ATorT
    {
        static void Main(string[] args)
        {
            var nab = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToList();
            int n = nab[0];
            int a = nab[1];
            int b = nab[2];

            Console.WriteLine(Math.Min(n * a, b));
            Console.ReadLine();
        }
    }
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int a = A + B;
  int b = B + C;
  int c = A + C;

  int ans;
  ans = min(a,b);
  ans = min(ans,c);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

bool check(string s) {
	if(s.size() % 2 == 1) return false;
	ll len = s.size()/2;
	rep(i,0,len) if(s[i] != s[i+len]) return false;
	return true;
}

int main() {
    cin.sync_with_stdio(false);
	string s;
	cin >> s;
	s.pop_back();
	while(true) {
		if(check(s)) {
			cout << s.size() << endl;
			return 0;
		}
		s.pop_back();
	
	}

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <typename T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N, K, S;
    cin >> N >> K >> S;

    vector<int> ans(N);
    REP(i, K) {
        ans[i] = S;
    }
    REP(i, N - K) {
        ans[i + K] = (S + 2) % 1'000'000'000 + 1;
    }

    REP(i, N - 1) {
        cout << ans[i] << " ";
    }
    cout << ans[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a >= k)
        cout << k << endl;
    else if(a + b >= k)
        cout << a << endl;
    else
        cout << a - (k - b - a) << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;
import java.util.TreeMap;
import java.util.Map;

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

        int N = sc.nextInt();
        int[] a = new int[N];
        int min = 1000001;
        int max = 0;
        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
            max = Math.max(max, a[i]);
            min = Math.min(min, a[i]);
        }
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();

        for(int i=min-1; i<=max+1; i++){
            map.put(i, 0);
        }
        for(int i=0; i<N; i++){
            map.put(a[i], map.get(a[i]) + 1);
        }
        int ans = 0;
        for(int i=min; i<=max; i++){
            ans = Math.max(ans, map.get(i - 1) + map.get(i) + map.get(i + 1));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 52016
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, k;
	cin >> n >> k;
	if(n%k==0) cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   int n = Integer.parseInt(br.readLine());
   int TarouP = 0;
   int HanakoP = 0;

   for(int i = 0; i < n;i++){

	   String[] token = br.readLine().split(" ");

	   if(  token[0].compareTo( token[1] ) > 0 ){//??????:0?????±???:1

	       TarouP += 3;

	   }else if(token[0].compareTo( token[1] ) < 0 ){

		   HanakoP += 3;

	   }else{
		   TarouP++;
		   HanakoP++;
	   }


   }

   System.out.println(TarouP+" "+HanakoP);

  }
}

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

int main(){
	int n ;
  	cin>> n;
  	vector <int> a(n) , dp(n , 0);
  	for(auto &i : a) 
      	cin>>i;
 	
  	
  	for(int i = 1; i < n ; i++)
    {
      dp[i] = min(i-1 >= 0 ? abs(a[i-1]-a[i]) + dp[i-1] : INT_MAX , i-2 >= 0 ? abs(a[i-2]-a[i]) + dp[i-2] : INT_MAX) ; 
      dp[i] == INT_MAX ? dp[i] = 0 : dp[i] = dp[i];
    }
  
  	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
function main(N, A) {
  const res = [];
  for (let i = 0; i < N; i++) {
    res.push(0);
  }

  for (let i = 0; i < N; ++i) {
    const boss = parseInt(A[i]) - 1;
    res[boss]++;
  }

  console.log(res.join('\n'));
}
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const N = parseInt(input[0]);
const A = input[1].replace('\n').split(' ');
main(N, A);


Measured memory_bytes: 55260
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;


struct Point
{
    double x;
    double y;
    Point(){}
    Point(double a,double b):x(a),y(b){}
};

struct Segment
{
    Point p1;
    Point p2;
    Segment(){}
    Segment(Point a,Point b):p1(a),p2(b){}
};

double longueur(Segment s)
{
    return sqrt((s.p1.x-s.p2.x)*(s.p1.x-s.p2.x) + (s.p1.y-s.p2.y)*(s.p1.y-s.p2.y));
}

double calculateArea(Segment s1,Segment s2,Segment s3)
{
    double a = longueur(s1), b = longueur(s2), c = longueur(s3);
    double s = (a+b+c)/2.;
    return sqrt(s*(s-a)*(s-b)*(s-c));
}

double ProductVect(Point p1,Point p2,Point p3)
{
    return (p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y);
}

int main()
{
    ios_base::sync_with_stdio(false);

    int nb_points;
    int cas = 1;
    while(cin>>nb_points)
    {
        if(nb_points == 0) break;
        cout<<cas<<" ";
        cas++;
        vector<Point> points(nb_points);
        for(int c=0;c<nb_points;c++)
        {
            cin>>points[c].x>>points[c].y;
        }
        double res = 0;
        int deb = 0;
        for(int c=0;c<nb_points;c++)
        {
            res+=(points[c].x+points[(c+1)%nb_points].x)*(points[(c)].y-points[(c+1)%nb_points].y);
        }
        cout<<fixed<<setprecision(1)<<max(res,-res)/2.<<endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n-1);
  rep(i,n-1)
    cin >> a.at(i);

  vector<int> b(n);
  rep(i,n-1){
    b.at(a.at(i)-1) ++;
  }
  rep(i,n)
    cout << b.at(i) << endl;
  return 0;
}


Measured memory_bytes: 4840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;



int main()
{
	int n, m,ans = 0;
	cin >> n>>m;
	vector <int> x(m);
	vector<int> max(m - 1);

	for (int i = 0;i < m;i++)
	{
		cin >> x[i];
		if(i < m-1)max[i] = 0;
	}

	sort(x.begin(), x.end());

	for (int i = 0;i < m - 1;i++)
	{
		max[i] = x[i + 1] - x[i];
		ans += max[i];
	}

	if (n == 1)
	{
		cout << ans << endl;
	}
	else if (m <= n)
	{
		cout << "0" << endl;
	}
	else
	{
		sort(max.begin(),max.end());
		for (int i = m - 2;i >= m - n;i--)
		{
			ans -= max[i];
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define Sim template<class n
Sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
Sim> auto operator << (ostream &p, n y) -> 
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
Sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
Sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
Sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define int LL
#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "
const int M = 1024 * 1024;

int n;
LL k;
int T[M], dp[M], last[M], first[M], vis[M], in[M];
VI R;

void add(int x)
{
	if (!in[x])
	{
		R.PB(x);
		in[x] = 1;
	}
	else
	{
		while (in[x])
		{
			in[R.back()] = 0;
			R.pb();
		}
	}
}

main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(NULL);
	scanf("%lld%lld", &n, &k);
	FOR(i, 1, n)
	{
		scanf("%lld", T + i);
		if (first[T[i]] == 0)
		{
			first[T[i]] = i;
		}
	}
	dp[n + 1] = 1;
	FORD(i, n, 1)
	{
		if (last[T[i]] == 0)
		{
			dp[i] = first[T[i]] + 1;
		}
		else
		{
			if (last[T[i]] == n)
			{
				dp[i] = 1;
			}
			else
			{
				dp[i] = dp[last[T[i]] + 1];
			}
		}
		last[T[i]] = i;
	}
	FOR(i, 1, n + 1)
	{
		debug(i, dp[i]);
	}
	k--;
	int tmp = 1;
	VI V;
	while (k > 0 && !vis[tmp])
	{
		V.PB(tmp);
		vis[tmp] = 1;
		tmp = dp[tmp];
		k--;
	}
	debug(k, tmp, V);
	if (k > 0)
	{
		int ind = 0, l = 0;
		while (V[ind] != tmp)
		{
			ind++;
		}
		VI X;
		FOR(i, ind, SIZ(V) - 1)
		{
			X.PB(V[i]);
		}
		l = SIZ(X);
		k %= l;
		ind = 0;
		while (k > 0)
		{
			ind = (ind + 1) % SIZ(X);
			k--;
		}
		
		tmp = X[ind];
	}
	
	FOR(i, tmp, n)
	{
		add(T[i]);
	}
	for (auto x : R)
	{
		printf("%lld ", x);
	}
	printf("\n");
	return 0;
}





Measured memory_bytes: 17748
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll r,d,x2;
    std::cin >> r>>d>>x2;
    for (int i = 0; i < 10; i++) {
        x2 = r*x2-d;
        std::cout << x2 << std::endl;
    }
}


Measured memory_bytes: 256
/*ex6_2
 kt125*/

#include<stdio.h>
#include<string.h>
#define SIZE 102

int main(void){
    int length;
    char text[SIZE];

    fgets(text, SIZE, stdin);

    length = strlen(text); //文字列の長さ

    putchar(text[0]); //先頭文字を出力
    printf("%d", length-3); //間の文字数を出力
    putchar(text[length-2]); //末尾文字を出力
    printf("\n"); //改行

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int n,m,k=0,i,j,l=0,s;
	scanf("%d %d",&n,&m);
	if(n<=1)
	k=0;
	else
	for(i=1;i<n;i++)
	{
		k=k+i;
	}
	if(m<=1)
	l=0;
	else
	for(j=1;j<m;j++) 
	{
		l=l+j;
	}
	s=l+k;
	printf("%d",s);
 } 

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

using namespace std;

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

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

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

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

const int MAX = 2 * 1000 * 100 + 47;
int A[MAX];
int L[MAX];
LL k;
int n;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;
    FOR(i, 0, n) {
        cin >> A[i];
        A[i]--;
    }

    FILL(L, -1);
    int cur = 0;
    int cnt = 0;

    while (L[cur] == -1) {
        L[cur] = cnt++;
        cur = A[cur];
        if (cnt == k) {
            cout << cur + 1 << endl;
            return 0;
        }
    }

    k -= L[cur];
    int len = cnt - L[cur];
    //cerr << len << endl;
    k %= len;
    FOR(i, 0, k) {
        cur = A[cur];
    }

    cout << cur + 1 << endl;
}

Measured memory_bytes: 5140
#include <bits/stdc++.h>
using namespace std;
int main() {
	//input
	int64_t N, K;
	cin >> N >> K;

	//calculation
	int64_t div = N / K;
	int64_t rem = N % K;

	//output
	if (rem == 0) {
		cout << 0 << endl;
	} else {
		int64_t output = min(rem, max(rem, K) - min(rem, K));
		cout << output << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)

int main()
{
  int n, m;
  cin >> n >> m;

  priority_queue<int> pq;
  rep(i,0,n)
  {
    int x;
    cin >> x;
    pq.push(x);
  }
  
  rep(i,0,m)
  {
    int t = pq.top();
    pq.pop();
    pq.push(t / 2);
  }

  long long sum = 0;
  // while (not pq.empty())
  rep(i,0,n)
  {
    sum += pq.top();
    pq.pop();
  }

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


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a >= b) {

			String answer = String.valueOf(b);

			for(int i = 1;i < a;i++) {

				answer = answer + String.valueOf(b);

			}
			System.out.println(answer);
		}else {

			String answer = String.valueOf(a);

			for(int i = 1;i < b;i++) {

				answer = answer + String.valueOf(a);

			}
			System.out.println(answer);
		}

	}

}


Measured memory_bytes: 21716
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b,c=MI()
    t=max(a,b,c)
    temp=3*t-(a+b+c)
    if temp%2==1:
        temp+=3
    print(temp//2)

main()


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

signed main()
{
  int L, R;
  cin >> L >> R;
  
  if( R-L > 2019 ) R = L+2019;
  
  int ans = 1000000000000000;
  for( int i = L; i <= R; i++ ){
    for( int j = i+1; j <= R; j++ ){
      if( i*j%2019 < ans ) ans = i*j%2019;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#import <stdio.h>
#import <stdlib.h>
#define MIN(a,b) ((a)<(b)?(a):(b))

long calc(long *A, long N, int positive) {
    long s = 0;
    long count = 0;
    
    for (long i=0;i<N;i++){
        s += A[i];
        if(i%2==(positive ? 0 : 1)) {
            if (s<=0) {
                count += 1-s;
                s=1;
            }
        } else {
            if (s>=0) {
                count += s+1;
                s=-1;
            }
        }
    }
    
    return count;
}

int main() {
    long N;
    scanf("%ld", &N);
    long *A = (long*)malloc(N * sizeof(long));
    
    long n;
    long i = 0;
    while (scanf("%ld", &n) != EOF) {
        A[i] = n;
        i++;
    }
    
    printf("%ld", MIN(calc(A,N,1),calc(A,N,0)));
    
    free(A);
    return 0;
}



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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX


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

	int n,i,ans=0;
	double d;
	cin>>n>>d;
	for(i=0;i<n;i++)
	{
		double x,y;
		cin>>x>>y;
		double dis = sqrt(x*x+y*y);
		if(dis<=d)
			ans++;
	}
	cout<<ans;
	return 0;
}


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

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

ll f(ll x,int c,int d){
    ll res = x;
    res -= x/c;
    res -= x/d;
    res += x/lcm(c,d);
    return res;
}

int main()
{
    ll a,b;
    int c,d;
    cin >> a >> b >> c >> d;
    ll ans = f(b,c,d) - f(a-1,c,d);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
	"sort"
)

func main() {
	sc := NewScanner()

	a := make([]int, 3)
	for i := 0; i < 3; i++ {
		a[i] = sc.NextInt()
	}
	sort.Ints(a)
	ans := (a[1] - a[0]) + (a[2] - a[1])
	fmt.Printf("%v\n", ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
N, A, B = map(int, input().split())

def digit_sum(num):
    num = str(num)
    out = 0
    for i in num:
        out += int(i)
    return out

final = 0
for i in range(1, N+1):
    if A <= digit_sum(i) <= B:
        final += i
print(final)

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

int main(){
  string S;
  cin >> S;
  int Q;
  cin >> Q;
  string pref, suf;
  bool reversed = false;
  while(Q--){
    int t;
    cin >> t;
    if(t == 1){
      reversed ^= 1;
      swap(pref,suf);
    }else{
      int f;
      char c;
      cin >> f >> c;
      
      if(f == 1) pref += c;
      else suf += c;
    }
  }
  reverse(pref.begin(), pref.end());
  if(reversed) reverse(S.begin(), S.end());
  cout << pref << S << suf << endl;
}


Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int N; cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);
  rep(i,N) cin >> a[i];
  rep(i,N) cin >> b[i];
  rep(i,N) cin >> c[i];
  sort(all(a));
  sort(all(c));
  ll ans=0;
  rep(i,N){
    ll x=lower_bound(a.begin(),a.end(),b[i])-a.begin();
    ll y=upper_bound(c.begin(),c.end(),b[i])-c.begin();
    ans+=x*(N-y);
  }
  cout << ans << endl;
}

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

using namespace std;
#define int long long
bool kind(int j, int i) {
    return (1 << j) & i;
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> p(N, vector<pair<int, int>>());
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++) {
            int x, y;
            cin >> x >> y;
            x--;
            p[i].push_back({x, y});
        }
    }
    int max = 0;
    for (int i = 0; i < (1 << N); i++) { // 正直ものかどうかの組み合わせのループ
        int count = 0;
        bool ok = true;
        for (int j = 0; j < N; j++) { // それぞれの人についてのループ
            if (!kind(j,i)) {
                continue;
            }
            count ++;
            for (auto& q : p[j]) { // それぞれの証言についてのループ
                if (kind(q.first, i) != q.second) {
                    // conflict!!
                    ok = false;
                    break;
                }
            }
            if (!ok) { // 矛盾があったらbreak
                break;
            }
        }
        // 矛盾がないので最大値を交信
        if (ok) {
            max = std::max(max, count);
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, m: usize,
        ab: [(Usize1, Usize1); m]
    }

    let mut graph = vec![Vec::new(); n];
    for (a, b) in ab {
        graph[a].push(b);
        graph[b].push(a);
    }
    let visited = vec![false; n];
    let ans = dfs(0, &graph, visited);
    println!("{}", ans);
}

fn dfs(node: usize, graph: &[Vec<usize>], mut visited: Vec<bool>) -> usize {
    visited[node] = true;
    let mut terminated = true;
    let mut res = 0;
    for &next in &graph[node] {
        if !visited[next] {
            terminated = false;
            res += dfs(next, graph, visited.clone());
        }
    }
    if terminated {
        res = if visited.iter().all(|b| *b) {
            1
        } else {
            0
        };
    }
    res
}

Measured memory_bytes: 2148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main
{
    public static void main(String[] args)throws IOException {
        BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));
        String[]s=bufferedReader.readLine().split( " ");
        long k=Long.parseLong(s[0]),a=Long.parseLong(s[1]),b=Long.parseLong(s[2]);
        List<Long>list=new ArrayList<>();
        list.add(k+1);
        k-=((a-1)+2);
        long ans = 0;
        if(k==0)
            ans=b;
        if(k>0 && b>a) {
            ans = b;
            while (k > 1) {
                ans -= a;
                ans += b;
                k-=2;
            }
        }
        if(k==1)
            ans++;
        list.add(ans);
        System.out.println(Collections.max(list));
    }
}

Measured memory_bytes: 22484
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;

using Graph = vector<vector<int>>;

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

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b;






}

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

int main(){

  int N;

  cin>>N;

  long long a[100001];

  long long ans=0;

  long long cnt=0;

  cin>>a[0];

  
  if(a[0]<0){
	cnt++;
  }

  
  long long minn=labs(a[0]);
  
  ans+=labs(a[0]);
  
  for(int i=1;i<N;i++){
	cin>>a[i];

	if(a[i]<0){
	  cnt++;
	}

	if(minn>labs(a[i])){
	  minn=labs(a[i]);
	}

	ans+=(labs(a[i]));
	
  }
  
  
  if(cnt%2==0){
  }else{
	ans-=(2*labs(minn));

  }
  

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


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    string S;
    cin >> S;

    int v1 = 10 * (S[0] - '0') + (S[1] - '0');
    int v2 = 10 * (S[2] - '0') + (S[3] - '0');

    auto MM = [](int v) { return 1 <= v && v <= 12; };

    if (MM(v1) && MM(v2)) {
        cout << "AMBIGUOUS\n";
    } else if (MM(v1)) {
        cout << "MMYY\n";
    } else if (MM(v2)) {
        cout << "YYMM\n";
    } else {
        cout << "NA\n";
    }

    return 0;
}



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

using namespace std;

#define pb push_back

int main()
{
    vector<int>vec;
    int a,b;
    cin>>a>>b;

    int add = a+b;
    vec.pb(add);
    int mul = a*b;
    vec.pb(mul);
    int sub = a-b;
    vec.pb(sub);

    sort(vec.begin(),vec.end());

    cout<<vec[2]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for (int i = m; i < (int)(n); i++)

int main() {
  string s,t;
  int ans=0;
  cin>>s>>t;
  rep(i,3) if(s.at(i)==t.at(i)) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    char s1[100];
    cin>>s1;
    int i=0,c=0;
    while(s1[i]!='\0'){
        if(s1[i]=='1'){
            c++;
        }
        i++;
    }
    cout<<c<<endl;
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> AB(N);
  for (int i = 0; i < N; i++) {
    cin >> AB[i].first >> AB[i].second;
  }

  sort(AB.begin(), AB.end());

  int m = 0;
  long long v = 0;
  for (int i = 0; i < N; i++) {
    if (m + AB[i].second < M) {
      m += AB[i].second;
      v += (long long)AB[i].first * AB[i].second;
    } else {
      v += (long long)AB[i].first * (M - m);
      break;
    }
  }

  cout << v << endl;

  return 0;
}


Measured memory_bytes: 1152
# https://atcoder.jp/contests/agc021/tasks/agc021_a

n = input()
if int(n) >= int(n[0] + '9' * (len(n) - 1)):
    ans = int(n[0]) + 9 * (len(n) - 1)
else:
    ans = int(n[0]) - 1 + 9 * (len(n) - 1)
print(ans)

Measured memory_bytes: 38384
#include<cstdio>
#include<cmath>
#include<malloc.h>
#include<stdlib.h>
#include<algorithm>
int main()
{
	long int A,B,ans;
	char s;
	while(~scanf("%ld %c %ld",&A,&s,&B))
	{
		if(s=='+')
		ans=A+B;
		else if(s=='-')
		ans=A-B;
		else
		continue;
		printf("%ld\n",ans);
	}
	return 0;
}

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

const int MOD = 1000000007;
long long fac[2001];
long long finv[2001];
long long inv[2001];

void culc()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for (int i = 2; i <= 2000; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

    return;
}

long long culc2(int n, int k)
{
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    long long s;

    cin >> s;

    culc();

    int maxSize = s / 3;
    long long ans = 0;

    for (int i = 1; i < maxSize + 1; i++)
    {
        long long remind = s - ((long long)i * 3);
        long long n = i + remind - 1;
        long long r = remind;

        long long myCount = 0;
        if (n == r)
        {
            myCount = 1;
        }
        else
        {
            myCount = culc2(n, r);
        }

        ans += myCount;
        ans %= MOD;
    }

    cout << ans << endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P, ll>;
using PP = pair<P ,P>;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    vector<vector<int> > ans(h, vector<int>(w, 0));
    int col = 1;
    for(int i=0;i<h;i++){
        if(s[i].find("#") == s[i].npos) continue;
        int j = 0, x;
        while(j < w && s[i][j] != '#')j++;
        for(int x=0;x<j;x++) ans[i][x] = col;
        ans[i][j] = col;
        j++;
        for(;j<w;j++){
            if(s[i][j] == '#') col++;
            ans[i][j] = col;
        }
        col++;
    }
    for(int i=0;i<h;i++){
        if(ans[i][0] == 0){
            int d = 0;
            for(int x=1;i+x<h;x++){
                if(ans[i+x][0] != 0){
                    d = x;
                    break;
                }
            }
            if(d == 0){
                for(int x=-1;i-x>=0;x--){
                    if(ans[i+x][0] != 0){
                        d = x;
                        break;
                    }
                }
            }
            for(int j=0;j<w;j++){
                ans[i][j] = ans[i+d][j];
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << ans[i][j] << " \n"[j==w-1];
        }
    }
    return 0;
}

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

int main() {
	int a, b, c, d, sum = 0;
	cin >> a >> b >> c >> d;

	if (a < b)
		sum += a;
	else
		sum += b;

	if (c < d)
		sum += c;
	else
		sum += d;
	
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
n_vertex, n_edge = gets.split.map(&:to_i)
#puts "#{n_vertex} #{n_edge}"
edges = n_vertex.times.map { Array.new(n_vertex, -1) }
for i in 0...n_edge do
  u, v, d = gets.split.map(&:to_i)
#  puts "#{u} #{v} #{d}"
  edges[u - 1][v - 1] = d
  edges[v - 1][u - 1] = d
end
#for i in 0...n_vertex do
#  puts edges[i].join(" ")
#end

for i in 1...n_vertex do
  if edges[0][i] > 0
    targ_v = i
    targ_d = edges[0][i]
    break
  end
end
#puts "#{targ_v} #{targ_d}"

t_max = gets.to_i
#puts "#{t_max}"
count = 0
for t in 0...t_max do
  n_new = gets.to_i
#  puts "#{n_new}"
  for i in 0...n_new do
    new_id, dst = gets.split.map(&:to_i)
#    puts "#{new_id} #{dst}"
  end
  
  if t < t_max / 2
    command = -1
  else
    if count < targ_d
#      command = targ_v
      command = -1
      count += 1
    else
      command = -1
    end
  end
  puts command
end


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

int main() {
  int N;
  cin >> N;
  
  int a, b, c, d;
  a = N % 10;
  b = N / 10 % 10;
  c = N / 100 % 10;
  d = N / 1000 % 10;
  
  
  if (b == c) {
    if (a == b && d == b)
      cout << "Yes";
    if (a == b && d != b)
      cout << "Yes";
    if (a != b && d == b)
      cout << "Yes";
    if (a != b && d != b)
      cout << "No";
  }
  else
    cout << "No";
}

Measured memory_bytes: 256
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(S:chars,T:chars);
    let mut S:Vec<char> = S;
    let mut T:Vec<char> = T;
    S.sort();
    T.sort();
    let mut cntS = vec![0;26];
    let mut cntT = vec![0;26];
//    println!("{:?}",S);
//    println!("{:?}",T);
    for c in S{
        cntS[c as usize - 'a' as usize]+=1;
    }
    for c in T{
        cntT[c as usize - 'a' as usize]+=1;
    }
    cntS.sort();
    cntT.sort();
    for i in 0..26{
        if cntS[i] == 0{
            continue;
        }
        if cntT[i] == 0{
            continue;
        }
        if cntS[i] != cntT[i]{
            println!("No");
            return;
        }
    }
    println!("Yes");
}

Measured memory_bytes: 6396