akhauriyash/Code-Regression huggingface dataset:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, k = MAP()
ans = 0
if k == 0:
    ans = n**2
else:
    for b in range(k+1, n+1):
        x = n//b
        y = n % b
        ans += (b-k)*x + (y-k+1 if y >= k else 0)
print(ans)

Measured memory_bytes: 10296
#include<iostream>
#include<map>
using namespace std;
int n;
int a[200001];
map<int,int>m;
bool can(int mid){
	m.clear();
	for(int i=1; i<=n ;i++){
		if(a[i]>a[i-1]) continue;
		auto it=m.end();
		while(!m.empty()){
			--it;
			if(it->first<=a[i]) break;
			m.erase(it);
			it=m.end();
		}
		m[a[i]]++;
		int cur=a[i];
		while(cur>0 && m[cur]==mid){
			m.erase(cur);
			m[--cur]++;
		}
		if(cur==0) return false;
	}
	return true;
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	bool flag=true;
	for(int i=1; i<=n ;i++){
		cin >> a[i];
		if(i>1 && a[i]<=a[i-1]) flag=false;
	}
	if(flag){
		cout << "1\n";
		return 0;
	}
	int l=2,r=3e5,mid;
	while(l!=r){
		mid=(l+r)/2;
		if(can(mid)) r=mid;
		else l=mid+1;
	}
	cout << l << endl;
}

Measured memory_bytes: 1024
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfInt().sorted()
    var p: Int
    var q: Int
    if (N % 2 != 0) {
        if (A[0] != 0) return println(0)
        p = 1
        q = 2
    } else {
        p = 0
        q = 1
    }
    var ans = 1L
    while (p < N) {
        if (A[p] != q || A[p + 1] != q) return println(0)
        ans = ans * 2 % 1000000007
        p += 2
        q += 2
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfLong() = listOfString().map(String::toLong)
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }


Measured memory_bytes: 53992
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(a) (a).begin(), (a).end()

using namespace std;
using ll = long long;

int main() {
  int n, m;
  ll k;
  cin >> n >> m >> k;
  vector<ll> a(n), b(m);

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

  vector<ll> aa(n + 1, 0ll), bb(m + 1, 0ll);

  rep(i, n) aa[i + 1] = aa[i] + a[i];
  rep(i, m) bb[i + 1] = bb[i] + b[i];

  int ans = 0;

  for (int i = 0; i <= n; ++i) {
    int res = 0;
    ll remain = k - aa[i];
    if (remain < 0) break;
    res = i;

    int j = upper_bound(all(bb), remain) - bb.begin();
    res += j - 1;
    ans = max(ans, res);
  }

  cout << ans << endl;
}


Measured memory_bytes: 9560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int t;
  cin>>t;    int ac=0,tle=0,wa=0,re=0;
  while(t--)
  {
    string s;
    cin>>s;
    if(s=="AC") ac++;
    if(s=="TLE") tle++;
    if(s=="WA") wa++;
    if(s=="RE") re++;
  }
  cout<<"AC x "<<ac<<endl;
  cout<<"WA x "<<wa<<endl;
  cout<<"TLE x "<<tle<<endl;
  cout<<"RE x "<<re<<endl;
  return 0;
}  


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

const int len = 1000010;
int a,b,c;
char s[len];

bool pd(int n) {
	int m = n/2;
	for (int i=0;i<m;i++) {
		if (s[i]!=s[i+m]) return false;
	}
	return true;
}

int main() {
	//freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	scanf("%s",s);
	a = strlen(s);
	for (int i=a-1;i>0;i--) {
		if (i%2 == 0 && pd(i)) {cout << i << endl;break;}
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

int main(){
	int n;
    cin >> n;
    cout << n*n*n << endl;
    
    return 0;
}


Measured memory_bytes: 256
// Tazoe

#include <iostream>
using namespace std;

int main()
{
	int A1, A2, A3, A4;
	cin >> A1 >> A2 >> A3 >> A4;

	int B1, B2, B3, B4;
	cin >> B1 >> B2 >> B3 >> B4;

	int S = A1+A2+A3+A4;
	int T = B1+B2+B3+B4;

	if(S>=T){
		cout << S << '\n';
	}
	else{
		cout << T << '\n';
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define SIZE(x) ((int)((x).size()))
#define PB push_back
#define ST first
#define ND second
#define mp(x,y) make_pair(x,y)
#define DEBUG 1
#define debug(x) {if (DEBUG)cerr <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; FOREACH(it, (x)) cerr <<*it <<", "; cout <<endl; }}
typedef short int sint;

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	set<string> zb;
	REP(i, n) {
		string temp;
		cin >> temp;
		zb.insert(temp);
	}
	cout << zb.size() << endl;
}

Measured memory_bytes: 19276
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll OO = 1e18+7;
const int MOD = 1e9+7;
const int N = 1e5+7;

ll dp[N];
int n,k;
ll h[N];

int main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    scanf("%d %d",&n,&k);
    REP(i,0,n-1) scanf("%lld",&h[i]);

    REP(i,1,n-1)
    {
        dp[i] = OO;
        REPI(j,i-1,i-k)
        {
            if (j < 0) break;
            dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }
    printf("%lld\n",dp[n-1]);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define fi first
#define se second
 
const ll MOD = 1000000007;
const string RGB = "RGB"; 

int main() {
   int N; scanf("%d", &N);
   vector<int> a(N + 1);
   for (int i = 1; i <= N; ++i)
      scanf("%d", &a[i]);
   vector<int> b(N + 1);
   int ans = 0;
   for (int i = N; i >= 1; --i) {
      b[i] = a[i];
      for (int j = 2 * i; j <= N; j += i)
         b[i] += b[j];
      b[i] %= 2;
      if (b[i] == 1)
         ++ans;
   }
   printf("%d\n", ans);
   for (int i = 1; i <= N; ++i) {
      if (b[i] == 1)
         printf("%d ", i);
   }
   return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());

    ll ans = 0;
    for (int x = 0; x < n; x++) {
        for (int y = x + 1; y < n; y++) {
            for (int z = y + 1; z < n; z++) {
                ll a = v[x];
                ll b = v[y];
                ll c = v[z];

                if (a + b > c && a != b && b != c) {
                    ans++;
                }

            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n;
double p[3030], dp[3030][3030], res;

signed main() {
	cin >> n;
	rep(i,n) cin >> p[i];
	dp[0][0] = 1;
	rep(i,n) rep(j,3000) {
		dp[i+1][j+1] += dp[i][j] * p[i];
		dp[i+1][j] += dp[i][j] * (1.-p[i]);
	}
	reps(i,(n+1)/2,n+1) res += dp[n][i];
	printf("%.14lf\n",res);
}

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

int main() {
  char c;
  cin >> c;

  switch(c) {
	case 'a':
		cout << "vowel" << endl;
		break;
	case 'i':
		cout << "vowel" << endl;
		break;
	case 'u':
		cout << "vowel" << endl;
		break;
	case 'e':
		cout << "vowel" << endl;
		break;
	case 'o':
		cout << "vowel" << endl;
		break;
	default:
		cout << "consonant" << endl;
		break;
  }
}

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

using namespace std;

const int MAX_N = 1e5 + 5;

vector<int> adj [MAX_N];
int vis [MAX_N];

int unvis_nb (int u) {
  for (int nxt : adj[u]) {
    if (!vis[nxt]) return nxt;
  }
  return -1;
}

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

  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  vis[1] = 1;
  vector<int> ans = {1};

  while (unvis_nb(ans.back()) != -1) {
    int nxt = unvis_nb(ans.back());
    ans.push_back(nxt);
    vis[nxt] = 1;
  }

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

  while (unvis_nb(ans.back()) != -1) {
    int nxt = unvis_nb(ans.back());
    ans.push_back(nxt);
    vis[nxt] = 1;
  }

  cout << (int) ans.size() << endl;
  for (int u : ans) {
    cout << u << " ";
  }
  cout << endl;
}


Measured memory_bytes: 7160
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
 
	int n, k; cin>>n>>k;
	if(n>=10)
	  cout<<k<<endl;
	 else	   
	  	cout<< (k+100*(10-n))<<endl;
	return 0;
}

Measured memory_bytes: 256
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y


def solve(K,H):
    # dp[i][k] = H[i]は消さずH[:i]まででk列消したと仮定した時の(H[:i+1]の)コスト
    H = [0]+H+[0]
    N = len(H)
    dp = [[float('inf')]*(i+1) for i in range(N)]
    dp[0] = [0]


    for r,hr in enumerate(H):
        for l,hl in enumerate(H[:r]):
            for k in range(l+1):
                dp[r][k+(r-l-1)] = min2(dp[r][k+(r-l-1)], dp[l][k]+max2(0,hr-hl))
    return dp[-1][K]

if __name__ == '__main__':
    N,K = map(int,input().split())
    H = list(map(int,input().split()))

    print(solve(K,H))

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

#define INF 1000000007
#define ll long long
#define F first
#define S second
#define pii pair<ll int,ll int>
#define pb push_back
#define ppb pop_back
#define vi vector<ll int>


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int n,m;
		cin >> n >> m;
		int s,c;
		int A[3];
		A[0] = -1;
		A[1] = -1;
		A[2] = -1;
		bool flag=true;
		for(int i=0;i<m;i++){
			cin >> s >> c;
			if(A[s-1] == -1 || A[s-1] == c) A[s-1] = c;
			else flag=false;
			//if(!flag) cout << i;
		}
		if(A[0] == 0 && n>1) flag=false;
		if(flag){
			//bool f=false;
			for(int i=0;i<n;i++){
				if(A[i] == -1) A[i] = 0;
			}
			if(n>1){
				if(A[0]==0) A[0]=1;
			}
			for(int i=0;i<n;i++) cout << A[i];
		}
		else cout <<"-1";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;

bool sortbysec(const pair<ll,ll> &a, 
              const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
} 

ll maxSubArraySum(ll a[], ll size) 
{ 
    ll max_so_far = INT_MIN, max_ending_here = 0; 
  
    for (ll i = 0; i < size; i++) 
    { 
        max_ending_here = max_ending_here + a[i]; 
        if (max_so_far < max_ending_here) 
            max_so_far = max_ending_here; 
  
        if (max_ending_here < 0) 
            max_ending_here = 0; 
    } 
    return max_so_far; 
} 

ll findSubarraySum(ll arr[], ll n, ll sum = 0) 
{
    unordered_map<ll, ll> prevSum;
    ll res = 0;
    ll currsum = 0;
    for (ll i = 0; i < n; i++)
    {
        currsum += arr[i];
        if (currsum == sum) res++;
        if (prevSum.find(currsum - sum) != prevSum.end()) res += (prevSum[currsum - sum]);
        prevSum[currsum]++;
    }
    return res; 
} 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll a,b,c,d;cin>>a>>b>>c>>d;
    while(1)
    {
        c-=b;
        if(c<=0)
        {
            cout<<"Yes\n";
            break;
        }
        a-=d;
        if(a<=0)
        {
            cout<<"No\n";
            break;
        }
    }
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<algorithm>
int main() {
	
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	char A;
	int n=0;

	for (int i = 0; i < 4; i++) {
		scanf("%c", &A);
		if (A == '+') {
			n++;
		}
		else {
			n--;
		}
	}
	printf("%d", n);
	
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n,t,a;
    cin >> n >> t >> a;
    ld h[n];
    F0R(i,n) cin >> h[i];
    ld mnDif = INF;
    ll mnIndex = -1;
    F0R(i,n){
      ld dif = abs(a - (t - h[i]*0.006));
      if(mnDif > dif){
        mnDif = dif;
        mnIndex = i;
      }
    }

    cout << mnIndex +1 << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

vector<int> a;

int main()
{
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n, a, b; cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i

ans = ""
i = 0
while(n != 0)
  if n & 1 == 1
    ans += '1'
    n -= (-1) ** i
  else
    ans += '0'
  end
  n >>= 1
  i += 1
end
puts ans == "" ? 0 : ans.reverse


Measured memory_bytes: 3836
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N = int(input())
    A = li_input()

    ans = 1
    Bkt = [0] * 100001

    for a in A:
        Bkt[a] += 1

    for i in range(1, len(A) - 1):
        ans = max(ans, Bkt[i - 1] + Bkt[i] + Bkt[i + 1])

    print(ans)


main()


Measured memory_bytes: 15656
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string.h>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	long long N, a[100000], i, j, ans=0;
	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> a[i];
	}

	for (i = 0; i < N; i++) {
		ans += a[i]-1;
	}

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

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(3 * 10 ** 5)
input = sys.stdin.buffer.readline


def main() -> None:
    def dfs(v, par, cnt):
        ans[v] = cnt + vs[v]
        for c in edges[v]:
            if c == par:
                continue
            dfs(c, v, ans[v])

    N, Q = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        edges[a].append(b)
        edges[b].append(a)
    vs = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        vs[p - 1] += x
    ans = [0] * N
    dfs(0, -1, 0)
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 274220
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    vector<int> cnt(4);
    rep(i, 3) {
        int a, b;
        cin >> a >> b;
        cnt[--a]++;
        cnt[--b]++;
    }
    sort(All(cnt));
    if(cnt[0] == 1 && cnt[1] == 1 && cnt[2] == 2 && cnt[3] == 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int cam(int x,int y,int z)
{
	if(x>=y&&x>=z)return x;
	else if(y>=z&&y>=z)return y;
	else return z;
 } 
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int k;
	cin>>k;
	int tem=cam(a,b,c);
	int tem1=tem;
	while(k--)
	{
		tem*=2;
	}
	cout<<a+b+c+tem-tem1;
 } 

Measured memory_bytes: 256
def main():
    K, S = map(int, input().split())
    ans = 0
    for i in range(K+1):
        for j in range(K+1):
            tmp = i + j
            if 0 <= S - tmp <= K:
                ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9084
#include <algorithm>
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
const int INF = (int)1e9 + 7;

template<typename Abel> struct BIT {
    const Abel UNITY_SUM = 0;
    vector<Abel> dat;
    BIT(int n) : dat(n, UNITY_SUM) { }  // [0, n)
    inline void add(int i, Abel x) {
        while (i < (int)dat.size()) { dat[i] += x; i |= i + 1; }
    }
    inline Abel sum(int i) {    // [0, i]
        Abel res = UNITY_SUM;
        while (i >= 0) { res += dat[i]; i = (i & (i + 1)) - 1; }
        return res;
    }
    inline Abel sum(int a, int b) { return sum(b - 1) - sum(a - 1); }   // [a, b)
    Abel operator[](int i) { return sum(i, i + 1); }
    friend ostream& operator<<(ostream& os, BIT<Abel> &bit) {
        for (int i = 0; i < (int)bit.dat.size(); i++) os << bit[i] << " ";
        return os;
    }
};

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    long long th = (1LL * n * (n + 1) / 2 + 1) / 2;
    auto check = [&](long long k) {
        vector<int> b(n);
        for (int i = 0; i < n; i++) b[i] = a[i] >= k ? 1 : -1;
        BIT<int> bit(n * 2 + 1);
        long long cnt = 0;
        int acc = n;
        bit.add(acc, 1);
        for (int i = 0; i < n; i++) {
            acc += b[i];
            cnt += bit.sum(acc);
            bit.add(acc, 1);
        }
        return th <= cnt;
    };
    auto binary_search = [&](long long ok, long long ng) {
        assert(check(ok) == true);
        assert(check(ng) == false);
        while (abs(ng - ok) > 1) {
            long long mid = (ng + ok) / 2;
            (check(mid) ? ok : ng) = mid;
        }
        return ok;
    };
    cout << binary_search(0, INF) << endl;
    return 0;
}


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

int main() {
	int N, M;
	ll K;
	cin >> N >> M >> K;
	vector<ll> A(N), B(M);
	rep(i, N) cin >> A[i];
	rep(i, M) cin >> B[i];

	vector<ll> Asum(N + 1, 0);
	vector<ll> Bsum(M + 1, 0);
	for(int i = 1; i <= N; i++)
		Asum[i] = Asum[i - 1] + A[i - 1];
	for(int i = 1; i <= M; i++)
		Bsum[i] = Bsum[i - 1] + B[i - 1];

	int ans = 0;
	int best0 = M;
	rep(i, N + 1) {
		int j;
		for(j = best0; j >= 0; --j) {
			if(Bsum[j] <= K - Asum[i] && j >= 0) {
				ans = max(ans, i + j);
				break;
			}
		}
		best0 = j;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9596
using System;
using System.Collections.Generic;
//using System.Linq;
class Program
{
  //static List<string> list;
  //static List<int> primes = new List<int>{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,
  //                              59,61,67,71,73,79,83,89,97};
	static void Main(string[] args)
	{
		// 入力フェーズ
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);

        // 処理


    // 出力
    int ret = 0;
      if(B%A==0)
      {
        ret = A+B;
        Console.WriteLine(ret + "");
      }else
      {
        ret = B - A;
        Console.WriteLine(ret + "");
      }
        //Console.WriteLine(strct + 1);
    }
		class myClass{ //自作クラス
			public long total {set; get;} // 全部の層数
			public long paty {set; get;}  // パティの数
      public long banz {set; get;}  // バンズの数
		}

    static void myMethod(int arg)
    {

    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
const long long inv2=500000004;
const int N=105,mu=1000000007;
int h[N],b[N],dp[N],dp2[N],f[N],n;
bool cmp(int x,int y){
	return h[x]==h[y]?x<y:h[x]>h[y];
}
int find(int x){
	if (f[x]==x) return f[x];
	f[x]=find(f[x]);
	return f[x];
}
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=1ll*x*x%mu)
		if (y&1) ans=ans*1ll*x%mu;
	return ans;
}
void merge(int x,int y){
	int fx=find(x),fy=find(y);
	if (fx==fy) return;
	int t2=ksm(2,h[fy]-h[fx])*1ll*dp2[fy]%mu;
	dp[fx]=(1ll*dp[fx]*(t2+dp[fy])%mu+1ll*dp2[fx]*dp[fy]%mu)%mu; 
	dp2[fx]=inv2*t2%mu*dp2[fx]%mu;
	dp[fx]=(dp[fx]+dp2[fx])%mu;
	f[fy]=fx;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&h[i]);
	for (int i=1;i<=n;i++) b[i]=i;
	std::sort(b+1,b+n+1,cmp);
	for (int i=1;i<=n;i++) dp2[i]=2,dp[i]=0,f[i]=i;
	for (int j=1;j<=n;j++){
		int i=b[j];
		if (h[i-1]>=h[i]) merge(i,i-1);
		if (h[i+1]>=h[i]) merge(i,i+1); 
	}
	int ff=find(1);
	printf("%d",(dp[ff]+1ll*dp2[ff]*ksm(2,h[ff]-1))%mu);
}

Measured memory_bytes: 256
#coding: UTF-8
#@document_it

def document_it(func):
  def new_function(*args,**kwargs):
    print('Running function:', func.__name__)
    print('Positional arguments:', args)
    print('Kewword arguments:', kwargs)
    result = func(*args,**kwargs)
    print('Result:', result)
    return result
  return new_function

#@document_it
def bsearch(v,list,l=None):
  if l == 0 or list == []:
    return False
  if l==None:
    l = len(list)
  
  import math
  T = math.ceil(math.log2(l))
  t = 0
  wid = l
  offset = 0
  while t <= T:
    if wid == 0:
        return False
    pos = wid//2 + offset
    w = list[pos]
    if wid == 1:
        if v == w:
            return True
        else:
            return False
    else:
        if v == w:
            return True
        elif v < w:
            wid = wid//2
        else:
            wid = wid//2 - 1 + wid%2
            offset = pos + 1
    t+=1



def exe():
    n = int(input())
    S = list(map(int,input().split()))
    q = int(input())
    T = map(int,input().split())
    ans = 0

    for t in T:
        if bsearch(t,S,n):
            ans += 1

    print(ans)

if __name__ == '__main__':
    exe()


Measured memory_bytes: 16732
# -*- coding: utf-8 -*-
N = int(input())
H = [int(j) for j in input().split()]

flag = 1

if N == 2:
    if H[0]>H[1]:
        H[0] -= 1
else:
    for i in range(N-2,-1,-1):
        if H[i]>H[i+1]:
            H[i] -= 1

for i in range(N-1):
    if H[i]>H[i+1]:
        flag = 0

if flag == 1:
    print('Yes')
else:
    print('No')

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

int main(){
  string temp,h;
  int m,i,n,j;
  while (1){
    cin>>h;
    if (h=="-")break;
    cin>>n;
    temp="";
    for (i=0;i<n;i++){
      cin>>m;
      for (j=0;j<h.size();j++){
        temp+=h[(j+m)%h.size()];
      }
      h=temp;
      temp="";
    }
    cout<<h<<endl;
  }
}



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

int main() {
  int n; cin >>n;
  string s;cin>>s;
  int m;cin>>m;
  for(int i=0;i<s.size();i++){
    if(s[i]!=s[m-1])cout<<'*';
    else cout<<s[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

const ll P = 1e9+7;
int main(){
	ll N;
	int K;
	cin >> N >> K;

	map<ll, ll> divm;
	for(ll i=1; i*i<=N; i++){
		divm[i] = N/i;
		if(i*i!=N) divm[N/i] = i;
	}
	vector<ll> div;
	for(auto p: divm) div.push_back(p.first);

	int ndiv = div.size();
	vector<ll> dp(ndiv);
	dp[0] = 1;
	for(int i=0; i<=K; i++){
		vector<ll> next(ndiv);
		ll s = dp[0];
		next[ndiv-1] = s;
		for(int j=1; j<ndiv; j++){
			s += dp[j]*(div[j]-div[j-1])%P;
			s %= P;
			next[ndiv-1-j] = s;
		}
		dp = next;
	}

	cout << dp[0] << endl;

	return 0;
}


Measured memory_bytes: 5752
//    https://www.youtube.com/watch?v=Dx6OQ7RvDXc

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;	// 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shesh               "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define mest(a,b)           memset(a,b,sizeof(a))
int main()
{
    fast;
    ll t,n,m,i,j,k,l,temp,flag,len,shit,ans=0;
    cin>>n>>k;
    while(n){
        ans++;
        n/=k;
    }
    cout<<ans;
}


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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int>m(n);
  int count=0;
  for(int i=0; i<n; i++){
    cin >> m[i];
    x-=m[i];
  }
  sort(m.begin(),m.end());
  while(x>=m[0]){
    x-=m[0];
    count++;
  }
  
   
   
  cout << count+n << endl;
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            double N = double.Parse(Console.ReadLine());
            if(N % 2 == 0)
            {
                Console.WriteLine((N / 2) / N);
            }
            else
            {
                Console.WriteLine(((int)N / 2 + 1) / N);
            }

        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 27612
#include<iostream>
#include <iomanip>

int main(void)
{
	int a, b;
	std::cin >> a >> b;
	std::cout << a/b << " " << a%b << " " << std::fixed << std::setprecision(5) << (double)a/(double)b << std::endl;
	return 0;
}


Measured memory_bytes: 3296
<?php
  fscanf(STDIN, "%d %d %d %d", $A, $B, $C, $D);

  $A--;

  $E = lcm($C, $D);
  // echo $E . PHP_EOL;

  $AC = intdiv($A, $C);
  $AD = intdiv($A, $D);
  $AE = intdiv($A, $E);

  // echo "AC AD AE $AC $AD $AE \n";

  $AA = $A - $AC - $AD + $AE;

  // echo "AA: " . $AA . PHP_EOL;

  $BC = intdiv($B, $C);
  $BD = intdiv($B, $D);
  $BE = intdiv($B, $E);

  // echo "BC BD BE $BC $BD $BE \n";

  $BB = $B - $BC - $BD + $BE;

  // echo $BB . PHP_EOL;

  echo $BB - $AA;

  //最大公約数
  function gcd($m, $n){
      if($n > $m) list($m, $n) = array($n, $m);

      while($n !== 0){
          $tmp_n = $n;
          $n = $m % $n;
          $m = $tmp_n;
      }
      return $m;
  }

  //最小公倍数
  function lcm($m, $n){
      return $m * $n / gcd($m, $n);
  }


Measured memory_bytes: 4604
#include <stdio.h>
int main(){
    int a, b, c, i=0;
    scanf("%d %d %d", &a, &b, &c);
    
    for(int x = a; x <= b; x++){
        if(c % x == 0){
            i++;
        }
    }
    printf("%d\n", i);
    
    return 0;
}


Measured memory_bytes: 2104
s = list(map(int,input().split()))
N = s[0]
M = s[1]
K = s[2]

a = list(map(int,input().split()))
b = list(map(int,input().split()))

asum = [0]
bsum = [0]
apsum = 0
bpsum = 0
for times in a:
  apsum += times
  asum.append(apsum)
for times in b:
  bpsum += times
  bsum.append(bpsum)

nums = []
i = 0
j = M
for i in range(N+1):
  if asum[i]>K:
    pass
  else:
    while asum[i]+bsum[j] > K:
      j += -1
    nums.append(i+j)
print(max(nums))

Measured memory_bytes: 50656
n=int(input())
la=[]
lz=[]
for i in range(n):
    s=list(input())
    sa=''
    sz=''
    for j in s:
        if j=='?':
            sa+='a'
            sz+='z'
        else:
            sa+=j
            sz+=j
    la.append(sa)
    lz.append(sz)
t=input()
p=1
q=1
for i in la:
    if t>=i:
        p+=1
for i in lz:
    if t>i:
        q+=1
ans=[i for i in range(q,p+1)]
print(*ans)
    

Measured memory_bytes: 47704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull  = unsigned long long;



int main()
{


   ll N,K; cin >> N >> K;

   N%=K;
   cout << min(N, K-N)<<endl;
    return 0;
}


Measured memory_bytes: 256
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int k,n; cin>>k>>n;
	vi vec;
	for(int i=0;i<n;i++)
	{
		int x; cin>>x; vec.pb(x);
	}
	int ans=int(1e9);
	for(int i=0;i<n;i++)
	{
		int l = vec[i];
		int r = vec[(i+n-1)%n];
		if(l>r) r+=k;
		ans=min(ans,r-l);
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <stdlib.h>
#define M 2000001
#define VM 10000

int main(){

  unsigned short *a,*b;
  int d[VM+1];
  int n,i,j;

  scanf("%d",&n);

  a=malloc(sizeof(short)*n+1);
  b=malloc(sizeof(short)*n+1);

  for(i=0;i<=VM;i++)d[i]=0;

  for(j=0;j<n;j++){
    scanf("%u",&a[j+1]);
    d[a[j+1]]++;

  }
  for(i=1;i<=VM;i++)d[i]=d[i]+d[i-1];

  for(j=n;j>=1;j--){
    b[d[a[j]]]=a[j];
    d[a[j]]--;
  }

  for(i=1;i<=n;i++){
    printf("%u",b[i]);
    if(i<n)printf(" ");
  }
  printf("\n");



  return 0;
}



Measured memory_bytes: 9656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long  n,T;
    cin>>n>>T;
    long long  m=INT_MAX;
    int  f=0;
    for(long long  i=0;i<n;i++)
    {
        long long  c,d;
        cin>>c>>d;
        if(d<=T)
        {
           m=min(m,c);
           f=1;
        }
    }
    if(f==0)
    {
        cout<<"TLE"<<endl;
    }
    else{
      cout<<m<<endl;  
    }
    
return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 

void solve(std::vector<long long> A){
    if(A[0]+A[1]+A[2]>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}
 
signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


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

int cnt[55560];

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

    for(int i=2;i<=55555;i++){
        if(cnt[i]) continue;
        for(int j=2*i;j<=55555;j+=i) cnt[j]++;
    }

    int c = 0;
    for(int i=2;i<=55555 && c<n;i++){
        if(i % 5 == 1 && !cnt[i]){
            cout << i << ' ';
            c++;
        }
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 512
main :: IO ()
main = print . solve  =<< input

input :: IO (Int, [[Int]])
input = do
    [n, w] <- readInts
    carriages <- mapM (const readInts) [0..n-1]
    return (w, carriages)
    where
        readInts = flip fmap getLine $ map read . words

solve :: (Int, [[Int]]) -> Int
solve (maxW, cs) = solve' (replicate (maxW + 1) 0) cs
    where
        solve' dp [] = last dp
        solve' dp ([v, w]:cs) =
            let
                values :: [(Maybe Int, Int)]
                values = zip (replicate w Nothing ++ map Just dp) dp 
                dp' = flip map values $ \(prevSmallV, prevV) -> maybe prevV (max prevV . (v +)) prevSmallV
            in solve' dp' cs


Measured memory_bytes: 190516
N = int(input())
stones = [l for l in input()]

cnt = 0
memo = N-1
for i in range(N):
    for j in range(memo, i , -1):
        if stones[i] == 'R':
            break
        else :
            if stones[j] == 'R':
                stones[i] = 'R'
                stones[j] = 'W'
                cnt += 1
                break
    memo = j
    if memo == i:
        break
            
print(cnt)
            

Measured memory_bytes: 10996
#include<stdio.h>

int main(void){
int i,tate,yoko,a,b,temp ;
int array[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30} ;

scanf("%d %d",&tate,&yoko);

for(i=0; i<yoko; i++){
scanf("%d,%d",&a,&b);
a--;//for array index
b--;//for array index
temp = array[a] ;//swap values
array[a] = array[b] ;
array[b] = temp ;
}

for(i=0; i<tate; i++){
printf("%d\n",array[i]);
}

return 0 ;
}

Measured memory_bytes: 1028
package main

import (
  "fmt"
)

func main() {
  var k, x int
  
  fmt.Scanf("%d %d", &k, &x)
  
  for i := x - (k - 1); i <= x + (k - 1); i++ {
    if i == x + (k - 1) {
      fmt.Printf("%d\n", i)
    } else {
    fmt.Printf("%d ", i)
    }
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h> 
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll ans=a[0]-1;
  ll x=2;
  REP(i,1,n){
    if(a[i]==x){
      x=a[i]+1;
      continue;
    }
    ans+=(a[i]+x-1)/x-1;
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1024
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;
#define int long long
const int N = (int) 1e6 + 6, mod = (int) 0;
int ans[N], a[N], s[N], t, res[N], sum[N], pl[N];
pair<int, int> sr[N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, ss = 0;
    cin >> n;
    for (int j = 0; j < n; ++j) {
        cin >> a[j];
        ss += a[j];
    }
    for (int j = 0; j < n; ++j) {
        if (t == 0 || (t > 0 && a[s[t - 1]] < a[j])) {
            s[t++] = j;
        }
        sr[j] = make_pair(a[j], j);
    }
    sort(sr, sr + n);
    for (int i = n - 1; i >= 0; --i) {
        int j = sr[i].second;
        pl[j] = n - i;
        sum[j] = sum[sr[i + 1].second] + a[j];
    }
    res[0] = ss;
    for (int j = t - 2; j >= 0; --j) {
        int i = s[j];
        res[j + 1] = sum[i] - a[i] * pl[i];
    }
    for (int j = 0; j < t - 1; ++j)
        res[j] -= res[j + 1];
    for (int j = 0; j < t; ++j) {
        ans[s[j]] = res[j];
    }
    for (int j = 0; j < n; ++j)
        cout << ans[j] << '\n';
}



Measured memory_bytes: 21120
#include<bits/stdc++.h>
#define   ll    long long int
#define   sz    1000100
#define   pb    push_back
#define   py    printf("Yes\n")
#define   pn    printf("No\n")
#define   sc(a) scanf("%lld",&a)
#define   p    1000000007
const  double pi=acos(-1);

using namespace std;


ll bigmod(ll x,ll y)
{
    ll res=1;
    x=x%p;

    while(y>0)
    {
        if(y&1)
        {
            res=(res*x)%p;

        }
        y=y>>1;
        x=(x*x)%p;
    }

    return res;

}

ll find_ncr(ll n, ll r)
{
    ll m=max(r,n-r);
    ll i,j,s,d=1,k;
    s=1;

    for(i=m+1;i<=n;i++)
    {
        s=((s%p)*(i%p))%p;
    }

    m=min(r,n-r);

    for(i=1;i<=m;i++)
    {
        k=bigmod(i,p-2);
        d=((d%p)*(k%p))%p;
    }

    k=(s%p*(d%p))%p;

    return k;
}

int main()
{

    ll n,m,a,b,x,y,c,i,j,d,k,tw;

    cin>>n>>a>>b;

    tw=bigmod(2LL,n)-1;



    a=find_ncr(n,a);
    b=find_ncr(n,b);

    tw=(tw%p-(a%p+b%p)%p)%p;
    tw=(tw+p)%p;

    cout<<tw<<endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int A,B,C;
		Scanner sc=new Scanner(System.in);
		A=sc.nextInt();
		B=sc.nextInt();
		C=sc.nextInt();
		if(C<=B&&C>=A) {
			System.out.println("Yes");
		}else if(C>=B&&C<=A) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22740
import java.util.Scanner;

public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    String s = sc.nextLine();

    if ("A".equals(s)) {
      System.out.println("T");
    } else if ("C".equals(s)) {
      System.out.println("G");
    } else if ("G".equals(s)) {
      System.out.println("C");
    } else if ("T".equals(s)) {
      System.out.println("A");
    }
    

  }

}


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

ll solve(ll wei[],ll val[],ll n,ll i,ll w)
{
    ll a=0,b;
    if(i<0)
        return 0;
    if(i==0)
    {
        if(w-wei[0]>=0)
            return val[0];
         //else
           // return 0;
            //cout<<"hello\n";
    }
    if(w-wei[i]>=0)
        a=val[i]+solve(wei,val,n,i-1,w-wei[i]);
        //cout<<"A="<<a<<endl;
        b=solve(wei,val,n,i-1,w);
        //cout<<"B="<<b<<endl;
    return max(a,b);
}
ll solve_dp(ll wei[],ll val[],ll n,ll w)
{
   ll ans[n+1][w+1];
   ll i,j;
   for(i=0;i<=n;i++)
   {
       for(j=0;j<=w;j++)
       {
           if(i==0||j==0)
           {
               ans[i][j]=0;
           }
           else if(wei[i-1]<=j)
           {
               ans[i][j]=max(val[i-1]+ans[i-1][j-wei[i-1]],ans[i-1][j]);
           }
           else
            ans[i][j]=ans[i-1][j];
       }
   }
    return ans[n][w];
}
int main()
{
     ll n,w,i;
    cin>>n>>w;
    ll wei[n],val[n];
    for(i=0;i<n;i++)
    {
        cin>>wei[i]>>val[i];
    }
    ll ans=solve_dp(wei,val,n,w);
    cout<<ans<<endl;
}


Measured memory_bytes: 79104
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a: Vec<i32> = (0..n).map(|_| input()).collect();

    let mut v = vec![0; n];
    for i in (0..n).rev() {
        let mut k = i + 1;
        let mut t = 0;
        while k <= n {
            t += v[k - 1];
            k += i + 1;
        }

        if a[i] != t % 2 {
            v[i] = 1;
        }
    }

    let m: i32 = v.iter().sum();
    println!("{}", m);
    if m > 0 {
        for i in 0..n {
            if v[i] > 0 {
                print!("{} ", i + 1);
            }
        }
        println!("");
    }
}


Measured memory_bytes: 7036
<?php

while (true) {
    $stdin = preg_split('/ /', trim(fgets(STDIN)));
    $a = intval($stdin[0]);
    $op = $stdin[1];
    $b = intval($stdin[2]);
    
    switch ($op) {
        case '?':
            return;
            break;
        case '+':
            printf("%d\n", $a + $b);
            break;
        case '-':
            printf("%d\n", $a - $b);
            break;
        case '*':
            printf("%d\n", $a * $b);
            break;
        case '/':
            printf("%d\n", $a / $b);
            break;
    }
}

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

using namespace std;

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

	int n;
	cin >> n;
	int b[n+1];
	b[0]=1000000; b[n]=1000000;
	for(int i=1; i<n; i++){
		cin >> b[i];
	}
	vector<int> a(n);
	for(int i=1; i<n+1; i++){
		a.push_back(min(b[i],b[i-1]));
	}
	int sum=0;
	for(auto x:a){
		sum += x;
	}
	cout << sum;
	return 0;
}

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

using namespace std;

char sd[200000];int len,S1[200000],S2[200000],q;
int main()
{
	scanf("%s",sd); len=strlen(sd);
	for(int i=0;i<len;i++) S1[i+1]=(sd[i]=='A'? 2:1)+S1[i];
	scanf("%s",sd); len=strlen(sd);
	for(int i=0;i<len;i++) S2[i+1]=(sd[i]=='A'? 2:1)+S2[i];
	scanf("%d",&q); while(q--)
	{
		int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d);
		if((S1[b]-S1[a-1])%3==(S2[d]-S2[c-1])%3)
			puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 1408