akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
src = [list(map(int, input().split())) for _ in range(M)]


lst_city = [[] for _ in range(N+1)]
for i, (p, y) in enumerate(src):
    lst_city[p].append((y, i))


ans = [None] * M
for pi, cities in enumerate(lst_city):
    for order, (y, i) in enumerate(sorted(cities)):
        ans[i] = str(pi).zfill(6) + str(order + 1).zfill(6)
print(*ans, sep="\n")

Measured memory_bytes: 55316
#include<bits/stdc++.h>
#define FIO "sample"
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

template<typename T> inline void Max(T &x,T y){if(x<y) x=y;}
template<typename T> inline void Min(T &x,T y){if(x>y) x=y;}

const int maxn=30;
int n;
int a[8]={6, 2, 10, 3, 9, 4, 8, 12};
int b[8]={2, 10, 3, 9, 4, 8, 6, 12};

int main()
{
#ifdef dxymaster
	freopen(FIO".in","r",stdin);
	freopen(FIO".out","w",stdout);
#endif

	n=read();
	if(n==3) return puts("2 5 63"),0;
	if(!(n&1)) goto second;
	for(int i=0;i<n;i++)
	{
		printf("%d%c",a[i&7],(i==n-1)?'\n':' ');
		a[i&7]+=12;
	}
	goto end;
second:;
	for(int i=0;i<n;i++)
	{
		printf("%d%c",b[i&7],(i==n-1)?'\n':' ');
		b[i&7]+=12;
	}
end:;
#ifdef dxymaster
	cerr<< " Time: " << (double) clock() / CLOCKS_PER_SEC << "s			It Runs So Fast!" << endl;
#endif

	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e9 + 5;
const int MAXM = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EXP = 1e-8;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == b && c != a) || (a == c && b != a) || (b == c && a != b))
        cout << "Yes";
    else
    {
        cout << "No";
    }
}


Measured memory_bytes: 256
# coding: utf-8
# coding: Shift_JIS
# coding: EUC-JP
# coding: cp932
import math

while 1:
    n = int(input())
    if n == 0:
        break
    a = list(map(int,input().split()))
    ave = sum(a)/len(a)

    ans = 0
    for i in range(n):
        ans += (a[i]-ave)**2
    ans /= n

    print("%.10f"%math.sqrt(ans))





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

int main()
{
   int n, t[110], m, p, tt, sum=0, temp=0;
   cin >> n;
   for(int i = 0; i < n; i++)
   {
       cin >> t[i];
       sum+=t[i];
   }
   cin >> m;
   while(m--)
   {
       cin >> p >> tt;
       temp=sum;
       temp-=t[p-1];
       temp+=tt;
       cout << temp << endl;
   }
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, a[112345];

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

    int res = 0;

    bool used[112345] = {false};

    for (int i = 30; i >= 0; i--)
    {
        int cnt = 0;
        int exa = -1;
        REP(j, n)
        {
            if ((a[j] == (1 << i)) && !used[j])
                exa = j;
            if (a[j] & (1 << i))
            {
                cnt++;
                a[j] -= (1 << i);
            }
        }

        if (cnt % 2)
        {
            if (exa == -1)
            {
                cout << -1 << endl;
                return 0;
            }
            else
            {
                used[exa] = true;
                a[exa]--;
                a[exa] += (1 << i);
                res++;
            }
        }
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    string ans = "";
    for (int i = 0; i < N; i++) {
        ans += 'a';
    }
    bool f = true;
    for (int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
        if (ans[s - 1] == 'a') {
            ans[s - 1] = char('0' + c);
        } else if (int(ans[s - 1]) - '0' != c) {
            f = false;
            break;
        }
        // cout << ans << endl;
    }

    // if (N != 1) {
    //     if (ans[0] == '0') {
    //         f = false;
    //     }
    //     for (int i = 0; i < ans.length() - 1; i++) {
    //         if (ans[0] == '0') {
    //             f = false;
    //             break;
    //         } else if (ans[0] == 'a') {
    //             ans.erase(0, 1);
    //         }
    //     }

    // }
    if (N != 1) {
        if (ans[0] == '0') {
            f = false;
        } else if (ans[0] == 'a') {
            ans[0] = '1';
        }
    } else {
        if (ans[0] == 'a') {
            ans[0] = '0';
        }
    }

    for (char& a : ans) {
        if (a == 'a') {
            a = '0';
        }
    }

    // cout << ans.length() << endl;

    if (f && ans.length() > 0) {
        cout << ans << endl;
    } else {
        cout << "-1" << endl;
    }
    return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if ( !(c >= a) ) {
        cout << "No";
    }
    else if ( !(b >= c) ) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
}


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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ; 
ll _abs (ll x ) { return (x>0?x:-x); }

const int N=1e5+5; 
vector<int> adj[N]; 
int dp[N] ; 
int solve( int u ){
    int& r= dp[u]; 
    if( r != - 1 )return r ; 
    r=0; 
    for(int v : adj[u]){
        r = max( solve( v )+1 , r ); 
    }
    return r; 
}

int main(){ 
    int n , m ; 
    cin>>n>>m; 
    for(int i=0;i<m;i++){
        int a, b ; 
        cin>>a>>b; 
        adj[a].pb(b); 
    }
    int ans = 0 ; 
    memset(dp,-1,sizeof dp); 
    for(int i = 1;i<=n;i++){
        if( dp[i]==-1)ans = max(ans,solve(i)); 
    }
    cout<<ans<<endl; 
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main() {
    vector<bool> V(26, false);
    string S;
    cin >> S;
    for(auto x : S) {
        V[x - 'a'] = true;
    }
    rep(i, 26) {
        if(!V[i]) {
            cout << char('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}


Measured memory_bytes: 512
using System;
using System.Linq;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int k = arr[1];
    var a = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).Take(k).Sum();
    Console.WriteLine(a);
  }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007

const ll mod = 1e9 + 7;

ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vl v(n);
	for (ll i = 0; i < n; i++)
		cin >> v[i];
	vl suf(n);
	suf[n - 1] = v[n - 1];
	for (ll i = n - 2; i >= 0; i--)
		suf[i] = (suf[i + 1] + v[i]) % mod;
	ll ans = 0;
	for (ll i = 0; i < n - 1; i++)
		ans = (ans + (v[i] * suf[i + 1]) % mod) % mod;
	cout << ans << "\n";
}


Measured memory_bytes: 6364
#include <stdio.h>
int main()
{
  int z[106],n,b,i,ch,h;
  scanf("%d %d",&n,&b);
  for(i=0;i<n;i++){
    scanf("%d",&z[i]);
  }
  for(i=1;i<=b;i++){
    h=0;
    while(1){
      if(h==n-1)break;
      if(z[h]%i>z[h+1]%i){
	ch=z[h];
	z[h]=z[h+1];
	z[h+1]=ch;
	h++;
      }else h++;
    }
  }
  for(i=0;i<n;i++)printf("%d\n",z[i]);
  return 0;
}
    

Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val t = sc.next()
    val a = sc.nextInt()
    val b = sc.nextInt()
    val u = sc.next()
    println(problem154a(s, t, a, b, u))
}

fun problem154a(s: String, t: String, a: Int, b: Int, u: String): String {
    return if (s == u) (a - 1).toString() + " " + b else a.toString() + " " + (b - 1)
}

Measured memory_bytes: 29472
// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;   
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int MAXN = (int)2e5 + 5;

int arr[MAXN];

int n, k;

void solve() {
	scanf("%d %d", &n, &k);

	for (int i = 1; i <= n; ++i) {
		scanf("%d", &arr[i]);
	}

	ordered_set<int> S;
	int ans = 1;
	ll inv = 0;	

	for (int i = 1; i <= k; ++i) {
		S.insert(arr[i]);
		inv += S.size() - S.order_of_key(arr[i]) - 1;
	}

	bool frst = (inv > 0);    

	for (int i = 2; i + k - 1 <= n; ++i) {
		bool ok = 0;

	 	if (arr[i - 1] != *S.begin()) {
	 		ok = 1;
	 	}

	   	inv -= S.order_of_key(arr[i - 1]);
	 	S.erase(arr[i - 1]);
	 	S.insert(arr[i + k - 1]);
	 	inv += S.size() - S.order_of_key(arr[i + k - 1]) - 1;

	 	if (arr[i + k - 1] != *S.rbegin()) {
	 		ok = 1;
	 	}

	 	if (ok) {
	 		if (inv == 0) {
	 			ans += frst;
	 			frst = 0;
	 		}
	 		else {
	 			++ans;
	 		}
	 	}
	}

	printf("%d\n", ans);
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S seconnd
#define int ll
#define PB push_back

int n;
string s;
map<pair<string,string>,int> ma;
int ans=0;

void f(string t,string u,int m){
  if(m==s.size()/2){
    ma[make_pair(t,u)]++;
    return;
  }

  f(t,u+s[m],m+1);
  f(t+s[m],u,m+1);
}


void g(string t,string u,int m){
  if(m==s.size()/2){
    ans+=ma[make_pair(t,u)];
    return;
  }

  g(t,u+s[m],m+1);
  g(t+s[m],u,m+1);
}



signed main(){
  cin>>n>>s;

  string t="",u="";
  f(t,u,0);
  reverse(all(s));
  
  string a="",b="";
  g(a,b,0);

  cout<<ans<<endl;

}

Measured memory_bytes: 87808
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 1000000000;

int main(){
    int n;
    cin >> n;
    
    int N = n * 100 / 108;
    int M1 = N * 108 / 100, M2 = (N+1)*108/100;
  
    if(M1 == n){
        cout << N << endl;
    }else if(M2 == n){
      cout << N + 1<< endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int s;
    s=a*b;
    if(s<c)
    {
        cout<<s<<endl;
        return 0;
    }
    else if(s>c) 
    {
        cout<<c<<endl;
        return 0;
    }
    else
    {
        cout<<s<<endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
 
int main() {
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i=0;i<n;i++) cin >> p[i];
    int m=0;
    for (int i=0;i<k;i++) m+=p[i];
    int tm=m;
    for (int i=k;i<n;i++) {
        tm=tm+p[i]-p[i-k];
        if (tm>m) m=tm;
    }
    cout << fixed << setprecision(10) << 1.0*(m+k)/2 << endl;
}

Measured memory_bytes: 1024
import heapq

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

checked = {(0, 0, 0)}
h = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]


def push(i, j, k):
    if i < X and j < Y and k < Z and (i, j, k) not in checked:
        heapq.heappush(h, (-(A[i] + B[j] + C[k]), i, j, k))
        checked.add((i, j, k))


for _ in range(K):
    s, i, j, k = heapq.heappop(h)
    print(-s)
    push(i + 1, j, k)
    push(i, j + 1, k)
    push(i, j, k + 1)


Measured memory_bytes: 4980
//#define C
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
#if false
        var N = int.Parse(ReadLine());
        var a = new int[N];
        var b = new int[N];
        var c = new int[N];
        for (int i = 0; i < N; i++)
        {
            var l = ReadLine().Split().Select(int.Parse).ToArray();
            a[i] = l[0];
            b[i] = l[1];
            c[i] = l[2];
        }
#endif
        var XYZK = ReadLine().Split().Select(int.Parse).ToArray();
        var X = XYZK[0];
        var Y = XYZK[1];
        var Z = XYZK[2];
        var K = XYZK[3];
        var A = ReadLine().Split().Select(long.Parse).OrderByDescending(x => x).ToArray();
        var B = ReadLine().Split().Select(long.Parse).OrderByDescending(x => x).ToArray();
        var C = ReadLine().Split().Select(long.Parse).OrderByDescending(x => x).ToArray();
        var c = new long[X * Y];
        for (int i = 0; i < X; i++)
        {
            for (int j = 0; j < Y; j++)
            {
                c[i * Y + j] = A[i] + B[j];
            }
        }
        Array.Sort(c);
        var l = Math.Min(c.Length, 3000);
        var d = new long[l * Z];
        for (int i = 0; i < l; i++)
        {
            for (int j = 0; j < Z; j++)
            {
                d[i * Z + j] = c[c.Length - 1 - i] + C[j];
            }
        }
        Array.Sort(d);
        var f = 0;
        for (int i = d.Length - 1; i >= 0; i--)
        {if (f >= K) return;
            WriteLine(d[i]);
            f++;
        }
    }
}


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

int main(){
	int n ; cin >> n ;
	set<int> s ;
	for(int i=0;i<n;i++){
		int a ; cin >> a ;
		if(s.count(a)) s.erase(a) ;
		else s.insert(a) ;
	}
	cout << s.size() << endl ;
}


Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n,x;
  cin >> n >> x;
  int N=n;
  if(x==1 || x==2*N-1){
    cout << "No" << endl;
    return 0;
  }
  if(N==2){
      cout<<"Yes"<<endl;
      cout << 1 << endl;
      cout << 2 << endl;
      cout << 3 << endl;
      return 0;
  }
  cout<<"Yes"<<endl;
  if(x>=n){
    for(int i=x-n+1;i<=2*n-1;i++) cout<<i<<endl;
    for(int i=1;i<x-n+1;i++) cout<<i<<endl;
  }else{
    for(int i=n+x-1;i>=1;i--) cout<<i<<endl;
    for(int i=2*n-1;i>n+x-1;i--) cout<<i<<endl;
  }
}

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

int main(){
	int a, b, c, k;
  	cin >> a >> b >> c >> k;
  
  	while(a >= b){
    	b = b * 2;
      	k--;
    }
  	
  	while(b >= c){
    	c = c * 2;
      	k--;
    }
  
  	if(k >= 0) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{

    static class Room{
        int num;
        Map<Integer, Room> joint = new HashMap<>();
        int mark = -1;
        Room(int num){
            this.num = num;
        }
    }

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        Map<Integer, Room> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            map.put(i + 1, new Room(i + 1));
        }

        for(int i = 0; i < m; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();

            map.get(a).joint.put(b, map.get(b));
            map.get(b).joint.put(a, map.get(a));
        }

        ArrayDeque<Room> q = new ArrayDeque<>();

        q.add(map.get(1));

        while(!q.isEmpty()){
            Room room = q.poll();

            for(Room i : room.joint.values()){
                if(i.mark == -1){
                    i.mark = room.num;
                    q.add(i);
                }
            }
        }

        map.remove(1);

        StringBuilder sb = new StringBuilder();
        sb.append("Yes\n");

        for(int i = 1; i < n; i++){
            sb.append(map.get(i + 1).mark).append("\n");
        }
        System.out.println(sb);

    }
}


Measured memory_bytes: 101908
#include<stdio.h>

int main(){

    int N;
    scanf("%d", &N);

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

    int judge = A[0];

    for (int i = 1; i < N; i++){
        judge = judge ^ A[i];
    }

    if(judge == 0){
        printf("Yes");
    }else{
        printf("No");
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  int ans[n];
  int cnt=0;
  int k=3;
  while(cnt!=n){
    while(true){
      int u=0;
      rep(i,k){
        if(i>1&&k%i==0)u++;
      }
      if(u==0)break;
      else k+=10;
    }
    ans[cnt]=k;
    k+=10;
    cnt++;
  }
  rep(i,n-1)cout << ans[i] << " ";
  cout << ans[n-1] << endl;
}  


Measured memory_bytes: 256
import itertools
n=int(input())
p=list(map(str, input().split())) 
q=list(map(str, input().split())) 

l = []
for i in range(1,n+1):
    l.append(str(i))

cnt = 1
for v in itertools.permutations(l, n):
    if p == list(v):
        a = cnt

    if q == list(v):
        b = cnt
    cnt = cnt + 1

print(abs(a-b))

Measured memory_bytes: 3064
s = input()
a = int(s[:2])
b = int(s[2:])

if 0 < a < 13:
    if 0 < b < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0 < b < 13:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 61896
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int,int>

const int N=1e5+5;
int a[N],mini=0,n;
int dp[N];

int main()
{  cool;
   cin>>n;
   for(int i=1;i<=n;i++)
   	  cin>>a[i];
dp[1]=0;
dp[2]=abs(a[1]-a[2]);

for(int i=3;i<=n;i++)
   { dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]), dp[i-1]+abs(a[i]-a[i-1]));

   }

   cout<<dp[n]; 	
     	 	 
 
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<pair<ll, ll>> X(N);
    rep(i, N) cin >> X[i].first >> X[i].second;
    if(N == 1) {
        cout << 1 << endl;
    } else {
        map<pair<ll, ll>, ll> m;
        rep(i, N) {
            rep(j, N) {
                if(i == j) continue;
                m[pair<ll, ll>{X[i].first - X[j].first, X[i].second - X[j].second}]++;
            }
        }
        vector<ll> A;
        transform(m.begin(), m.end(), back_inserter(A), [](pair<pair<ll, ll>, ll> x) { return x.second; });
        sort(A.begin(), A.end());
        cout << N - A.back() << endl;
    }
    return 0;
}


Measured memory_bytes: 3816
n,m=map(int,input().split())
a=list(map(int,input().split()))
l=[[0 for _ in range(2)] for _ in range(m)]
for i in range(m):
    l[i][0],l[i][1]=map(int,input().split())
a.sort()
l.sort(key=lambda x:x[1],reverse=True)
ans=0
cnt=0
idx=0
idx2=0
l1=[0 for i in range(n)]
cnt=0
#全てのBを大きい順にN個並べた列を作る
for i in range(m):
    if cnt+l[i][0]<n:
        for j in range(cnt,cnt+l[i][0]):
            l1[j]=l[i][1]
    elif cnt+l[i][0]>=n:
        for j in range(cnt,n):
            l1[j]=l[i][1]
    cnt+=l[i][0]
    if cnt>n:
        break
ans=0
for  i in range(n):
    if a[i]<l1[i]:
        ans+=l1[i]
    else:
        ans+=a[i]
print(ans)

Measured memory_bytes: 26668
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int H, W;
char s[55][55];

int dfs(int x, int y) {
  int count = 0;
  queue<P> que;

  que.push(P(x, y));
  s[x][y] = '.';
  while(!que.empty()) {
    count++;
    P p = que.front(); que.pop();
    REP(i, 4) {
      int nx = dx4[i] + p.first; int ny = dy4[i] + p.second;
      if(0 <= nx && nx < H && 0 <= ny && ny < W && s[nx][ny] == '#') {
        que.push(P(nx, ny));
        s[nx][ny] = '.';
      }
    }
  }
  return count;
}

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

  cin >> H >> W;
  REP(i, H) REP(j, W) cin >> s[i][j];

  bool f = true;
  REP(i, H) REP(j, W) {
    if(s[i][j] == '#') {
      if(dfs(i, j) == 1) f = false;
    }
  }

  cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); if (n == 0) cout << endl; REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s, t;
    cin >> s >> t;
    int n = sz(s);
    int m = sz(t);
    for (int i = n - m; i >= 0; i--) {
        string ans;
        bool ok = true;
        REP(j, n) {
            if (i > j or i + m <= j) {
                if (s[j] == '?') ans += 'a'; else ans += s[j];
            } else {
                if (s[j] == '?') ans += t[j - i]; else {
                    if (s[j] == t[j - i]) ans += s[j]; else {
                        ok = false;
                        break;
                    }
                }
            }
        }
        if (ok) {
            cout << ans << endl;
            return;
        }
    }
    cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 3624
while(s=gets.gsub(/\d+/){|k|?1*k.to_i})!~/#/
n=s.reverse.index ?/
a,b,c,d=gets.split.map(&:to_i)
s[n*a-n+b-1]=?1
s[n*c-n+d-1]=?b
$><<s.gsub(/1+/,&:size)
end

Measured memory_bytes: 8736
//
//  main.cpp 行列累乗
//  DPr
#include <iostream>
#include <vector>
using namespace std;
int n;
const int mod = 1e9+7;
using ll=long long;

struct Matrix {
    vector<vector<long long>> m;
    
    Matrix() {
        m.resize(n, vector<long long>(n));
    }
    
    Matrix operator* (Matrix b) {
        Matrix pdt;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    pdt.m[i][j] += m[i][k]*b.m[k][j];
                    pdt.m[i][j] %= mod;
                }
            }
        }
        return pdt;
    }
};
Matrix graph,z;
void f(ll k){
    if(k==0)return;
    if (k%2==1) graph = (graph*z);
    z = (z*z);
    k /= 2;
    f(k);
}
int main(int argc, const char * argv[]) {
    ll k;
    cin>>n>>k;
    vector<vector<ll>> foo(n,vector<ll>(n)); // 行列データを入れる
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin >> foo[i][j];
        }
    }
    graph.m = z.m = foo;
    k--;
    f(k);
    long long ans=0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ans = (ans + graph.m[i][j])%mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(){
	int n,dum,temp;
	vector<int> a;
	vector<int> dig;
	//vector<int> ans;
	int ans[3]={100000000,100000000,100000000};
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&dum);
		a.push_back(dum);
		temp=0;
		while(dum!=0){
			dum=dum/10;
			temp++;
		}
		dig.push_back(temp);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i!=j){
				temp=1;
				for(int k=0;k<dig[j];k++){
					temp*=10;
				}
				dum=a[i]*temp+a[j];
				if(ans[0]>=dum){
					ans[2]=ans[1];
					ans[1]=ans[0];
					ans[0]=dum;
				}
				else if(ans[1]>=dum){
					ans[2]=ans[1];
					ans[1]=dum;
				}
				else if(ans[2]>=dum){
					ans[2]=dum;
				}
			}
		}
	}
	printf("%d\n",ans[2]);
}


Measured memory_bytes: 3348
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 
*/

f([],[],0).
f([X|Xs], [Y|Ys], Z) :- X \= Y, f(Xs, Ys, Z2), Z is Z2 + 1, !.
f([X|Xs], [Y|Ys], Z) :- f(Xs, Ys, Z).

main :-
    get_chars(S),
    get_chars(T),
    f(S, T, X),
    writeln(X).


Measured memory_bytes: 58176
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	ll A,B;
	cin>>A>>B;
	if(A-B*2<0){
		cout<<0;
	}else{
		cout<<A-B*2;
	}
	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++)
typedef long long ll;


int N;
vector<int> X;


void input() {
    cin >> N;
    X = vector<int>(N);
    rep(i, N) cin >> X[i];
}


int main() {
    input();
    ll ans = 1e9;
    for (int i = 1; i <= 100; i++) {
        ll v = 0;
        for (int x : X) {
            v += (x - i) * (x - i);
        }
        ans = min(ans, v);
    }
    cout << ans << endl;
}


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

int N, M;
ll x[1010];
ll y[1010];
ll z[1010];

void Main()
{
	cin >> N >> M;
	rep(i,N) {
		cin >> x[i] >> y[i] >> z[i];
	}
	ll res = 0;
	vector<ll> vec;
	rep (i,2) {
		rep(j, 2) {
			rep(k, 2) {
				rep(l,N) {
					vec.push_back((pow(-1, i)) * x[l] + (pow(-1, j)) * y[l] + (pow(-1, k)) * z[l]);
				}
				sort(vec.rbegin(), vec.rend());
				ll tmp = 0;
				rep(l,M) {
					tmp += vec[l];
				}
				res = max(res, tmp);
				vec.clear();
			}
		}
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int k = Integer.parseInt(str[1]);
    int[] h = new int[n];
    for(int i=0; i<n; i++) {
      h[i] = Integer.parseInt(in.readLine());
    }
    
    Arrays.sort(h);
    
    int min = 1000000000;
    for(int i=0; i<n-k+1; i++) {
      min = Math.min(min,h[i+k-1]-h[i]);
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 42628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,k,t;
	char a[10000],b[10000],c[10000];
	scanf("%s",a);
	scanf("%s",b);
	for(i=0;i<strlen(a);i++)
	{
		k=0;
		for(j=strlen(b)-i;j<strlen(b);j++,k++)
		{
			c[k]=b[j];
		}
		for(t=0;t<j-i;t++,k++)
		{
			c[k]=b[t];
		}
		if(strcmp(c,a)==0)
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
} 

Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

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

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        if(temp%2==0&&temp%3!=0&&temp%5!=0)
        {
            cout<<"DENIED";
            return 0;
        }
    }
    cout<<"APPROVED";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef unsigned long long int lint;
const lint C = 1000000007;

lint POW(lint M, lint N)
{
	lint ret;
	if (N == 0)return 1;
	else
	{
		ret = POW(M, N / 2);
		if (N % 2 == 0)ret = (ret*ret)%C;
		else ret = (((ret*ret)%C)*M)%C;
	}
	return ret;
}

int main()
{
	lint n, m;
	cin >> m >> n;
	lint t = 1;
	cout << POW(m, n) << endl;
	return 0;
}

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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;
const int maxN = 4e6 + 1;

int fact[maxN], rev[maxN];

int mod_pow(int a, int b) {
	if (!b) return 1;
	if (b % 2) return a * mod_pow(a, b - 1) % MOD;
	int q = mod_pow(a, b / 2);
	return q * q % MOD;
}

int C(int n, int k) {
	return (fact[n] * rev[k] % MOD) * rev[n - k] % MOD;
}

int f(int r, int c) {
	int ans = 0;
	for (int i = r + 1; i > 1; i--) {
		ans = (ans + C(i + c, c)) % MOD;
	}
	return ans;
}

void solve() {
	fact[0] = 1;
	for (int i = 1; i < maxN; i++) fact[i] = fact[i - 1] * i  % MOD;
	for (int i = 0; i < maxN; i++) rev[i] = mod_pow(fact[i], MOD - 2);
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	cout << (f(r2, c2) - f(r2, c1 - 1) - f(r1 - 1, c2) + f(r1 - 1, c1 - 1) + 5 * MOD) % MOD;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 62720
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        for(int i = 1; i <= 3500; i++){
            for(int j = 1; j <= 3500; j++){
                int p = n * i * j;
                int q = 4 * i * j - n * i - n * j;
                if(q > 0 and p % q == 0){
                    cout << i << ' ' << j << ' ' << p / q << '\n';
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 31488
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    unsigned long long a,b,n,x,ans,ans1,ans2,ans3;
    cin>>a>>b>>n;
    x = n-1;
    ans1 = (a*x)/b-a*(x/b);
    x = n;
    ans2 = (a*x)/b-a*(x/b);
    ans = max(ans1,ans2);
    x = min(b-1,n);
    ans3 = (a*x)/b-a*(x/b);
    ans = max(ans,ans3);
    cout<<ans<<endl;
}


Measured memory_bytes: 3152
import sys

N = float(input())
t = 3
prime_number = []
while t <= N / 15.0:
    l = []
    for i in range(t+1):
        if i != 0:
            if t % i == 0:
                l.append(i)
    if l == [1, t]:
        prime_number.append(t)
    t += 1
n = len(prime_number)
ans = 0
if n < 3:
    print(0)
    sys.exit()
else:
    for i in prime_number:
        for j in prime_number:
            if j != i:
                for k in prime_number:
                    if k != i and k != j:
                        if i * j * k <= N:
                            ans += 1
ans = ans / 6
if N >= 189:
    ans += 2
elif N >= 135:
    ans += 1
print(int(ans))

Measured memory_bytes: 3064
import math

il = [int(k) for k in input().split()]
A = il[0]
B = il[1]
H = il[2]
M = il[3]

h = ((H + (M/60))/12) * 360
m = (M/60) * 360

k = abs(h-m)

# print("k = "+str(k))

if k > 180:
    k = 360 - k

radian = math.radians(k)

resut = math.sqrt(A**2 - 2*A*B*math.cos(radian) + B**2)
print(resut)


Measured memory_bytes: 9520
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

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

  using M = Mint<int, 998244353>;
  using Poly = vector<M>;

  M ans{0};
  Poly dp(s+1,0);
  for(int a:as){
    dp[0]+=M(1);
    for(int i=s-a;i>=0;i--)
      dp[i+a]+=dp[i];
    ans+=dp[s];
  }

  cout<<ans<<newl;
  return 0;
}


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

using namespace std;

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

int main() {
  int N;
  cin >> N;
  cout << (N/3) << endl;
  return 0;
}


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

#ifdef LOCAL

template<class T, class U>
ostream& operator<<(ostream& os, pair<T, U> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<template<class, class...> class C, class... A>
typename enable_if<!is_same<C<A...>, string>::value, ostream&>::type
operator<<(ostream& os, class C<A...> c) {
	auto i = c.begin();
	while (i != c.end()) {
		os << " {"[i == c.begin()] << *i;
		os << ",}"[++i == c.end()];
	}
	return os;
}

#define debug(x) cerr << #x << " = " << x << endl;
#else
#define debug(...) {}
#endif

const int N = 100;
long long infLL = 1e18;
int inf = 1e9;

char res[300][300];

int main() {
	ios_base::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < N / 2; i ++) {
		for (int j = 0; j < N; j ++) {
			res[i][j] = '.';
		}
	}
	for (int i = N / 2; i < N; i ++) {
		for (int j = 0; j < N; j ++) {
			res[i][j] = '#';
		}
	}
	for (int i = 0; i <= (b-1) / (N / 2); i ++) {
		for (int j = 0; j <= min(N - 1, 2 * (b - 1 - i * (N/2)) - 1); j += 2) {
			res[2 * i][j] = '#';
		}
	}
	for (int i = 0; i <= (a-1) / (N / 2); i ++) {
		for (int j = 0; j <= min(N - 1, 2 * (a - 1 - i * (N/2)) - 1); j += 2) {
			res[N/2 + 2 * i + 1][j] = '.';
		}
	}
	cout << N << " " << N << "\n";
	for (int i = 0; i < N; i ++) {
		string s = string(res[i]);
		cout << s << "\n";
	}
}


Measured memory_bytes: 256
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)
a=0
while 1:
    x=0
    for i in range(n):
        if len(l[i])==1:
            l[l[i][0]].remove(i)
            l[i]=[]
            x+=1
    if x==0:break
    a+=x
print(a)

Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 100000
#define SE 2000000000

typedef struct C {
  char suit;
  int value;
} Card;

Card L[MAX/2+2], R[MAX/2+2];

void merge(Card A[], int left, int mid, int right){
  int i, j, k, n1, n2;
  
  n1 = mid - left;
  n2 = right - mid;
  for( i = 0 ; i < n1 ; i++ ){
    L[i] = A[left+i];
  }
  for( i = 0 ; i < n2 ; i++ ){
    R[i] = A[mid+i];
  }
  L[n1].value = R[n2].value = SE;
  i = j = 0;
  for( k = left ; k < right ; k++ ){
    if( L[i].value <= R[j].value ){
      A[k] = L[i];
      i = i +1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }

}

void mergeSort(Card A[], int left, int right){
  int mid;
  if( left + 1 < right ){
    mid = ( left + right ) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(Card A[], int p, int r){
  int i, j;
  Card x, t;
  x = A[r];
  i = p-1;
  for( j = p ; j < r ; j++ ){
    if( A[j].value <= x.value ){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  return i + 1;
}

void quickSort(Card A[], int p, int r){
  int q;
  if( p < r ){
    q = partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}

int main(){
  int n, i, v;
  Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ){
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, 0, n);
  quickSort(B, 0, n-1);

  for( i = 0 ; i < n ; i++ ){
    if( A[i].suit != B[i].suit ) stable = 0;
  }

  if( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for( i = 0 ; i < n ; i++ ){
    printf("%c %d\n", B[i].suit, B[i].value);
  }

  return 0;
}



Measured memory_bytes: 4072
import math
a, b, C = map(int, input().split())
print('%f' % (0.5 * a * b * math.sin(math.radians(C))))
c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(C)))
print('%f' % (a + b + c))
print('%f' % (b * math.sin(math.radians(C))))



Measured memory_bytes: 5712
N = int(input())
S = input()
r,g,b = 0,0,0
for i in S:
  if i == 'R':
    r += 1
  elif i == 'G':
    g += 1
  else:
    b += 1
minus = 0
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = 2 * j - i
    if k >= N:
      continue
    if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
      minus += 1
print(r*g*b - minus)

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
constexpr long long mod=1000000007;
constexpr long long mod998=998244353;


int N,M,A[1000],B[1000],C[1000],D[1000],E[1000],F[1000];
long long res;
vector<long long>H,W;
vector<vector<int>>U,L;
vector<vector<bool>>vis;

int id(vector<long long>&V,long long x){
	return lower_bound(V.begin(),V.end(),x)-V.begin();
}

int main(){
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>A[i]>>B[i]>>C[i];
	}
	for(int i=0;i<M;i++){
		cin>>D[i]>>E[i]>>F[i];
	}
	for(int i=0;i<N;i++){
		H.push_back(A[i]);
		H.push_back(B[i]);
		W.push_back(C[i]);
	}
	for(int i=0;i<M;i++){
		H.push_back(D[i]);
		W.push_back(E[i]);
		W.push_back(F[i]);
	}
	H.push_back(0);
	W.push_back(0);
	H.push_back(-1111111111);
	H.push_back(1111111111);
	W.push_back(-1111111111);
	W.push_back(1111111111);
	sort(H.begin(),H.end());
	sort(W.begin(),W.end());
	H.erase(unique(H.begin(),H.end()),H.end());
	W.erase(unique(W.begin(),W.end()),W.end());
	U=L=vector<vector<int>>(H.size(),vector<int>(W.size(),0));
	vis=vector<vector<bool>>(H.size(),vector<bool>(W.size(),false));
	for(int i=0;i<N;i++){
		L[id(H,A[i])][id(W,C[i])]++;
		L[id(H,B[i])][id(W,C[i])]--;
	}
	for(int i=0;i<M;i++){
		U[id(H,D[i])][id(W,E[i])]++;
		U[id(H,D[i])][id(W,F[i])]--;
	}
	for(int i=1;i<H.size()-1;i++){
		for(int j=1;j<W.size()-1;j++){
			L[i][j]+=L[i-1][j];
			U[i][j]+=U[i][j-1];
		}
	}
	queue<pair<int,int>>que;
	que.push({id(H,0),id(W,0)});
	while(!que.empty()){
		int x,y;
		x=que.front().first;
		y=que.front().second;
		que.pop();
		if(x==0||x==H.size()-1||y==0||y==W.size()-1){
			puts("INF");
			return 0;
		}
		if(!vis[x][y]){
			vis[x][y]=true;
			res+=(H[x+1]-H[x])*(W[y+1]-W[y]);
			if(!U[x][y])que.push({x-1,y});
			if(!L[x][y])que.push({x,y-1});
			if(!U[x+1][y])que.push({x+1,y});
			if(!L[x][y+1])que.push({x,y+1});
		}
	}
	cout<<res<<endl;
}


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

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

	int n,a;
	cin >> n >> a;
	
	int eat;
	int l = a;
	int r = a+n-1;

	if(r<=0) eat=r;
	else if(l>=0) eat=l;
	else eat=0; 
	
	int answer=(r+l)*(r-l+1)/2-eat;
	cout << answer;

	return 0;
}

Measured memory_bytes: 3620