akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  string str;
  int ans=0;
  while(getline(cin,str)){
    int len = str.size();
    string numstr="";
    bool flag=false;
    for(int i=0;i<len;i++){
      if(str[i]>='0' && str[i]<='9'){
	numstr += str[i];
	flag = true;
      }
      else if(flag){
	flag = false;
	istringstream iss(numstr);
	int num=0;
	iss >> num;
	ans += num;
	numstr = "";
      }
    }
    istringstream iss(numstr);
    int num=0;
    iss >> num;
    ans += num;
    numstr = "";
  }
  cout << ans << endl;
}
     

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 1 ; i <= n ; i++)
using namespace std;
int main(){
  
  int n;
  cin >> n;
  vector<int> aaa(n+1);
  vector<int> cont(n+1);
  
  rep(i,n){
    cin >> cont.at(i);
  }
  
  for(int i = n/2 + 1 ; i <= n ; i++){
    aaa.at(i) = cont.at(i);
  }
  
  for(int i = n/2 ; i >=1 ; i--){
    
    int a = n/i;
    int sum = 0;
    rep(j,a){
      if(aaa.at(j*i) == 1){
        sum++;
        sum %= 2;
      }
    }
    if(sum == cont.at(i)){
      aaa.at(i) = 0;
    }
    else{
      aaa.at(i) = 1;
    }
  }
  int num = 0;
  rep(i,n){
    num += aaa.at(i);
  }
  cout << num << endl;
  vector<int> bbb(0);
  
  rep(i,n){
    
    if(aaa.at(i) == 1){
      bbb.push_back(i);
    }
  }
  for(int i = 0 ; i < bbb.size() ; i++){
    cout << bbb.at(i) << " ";
  }
}

Measured memory_bytes: 3064
import sys
def g(c,i):
 a=[0]*9
 for j in e+[i]:a[j-1]+=1
 return a
def f(c):
 if sum(c)in c:return 1
 if 5 in c:return 0
 if 4 in c:
  k=c.index(4);c[k]-=3
  if f(c):return 1
  c[k]+=3
 if 3 in c:
  k=c.index(3);c[k]-=3
  if f(c):return 1
  c[k]+=3
 for i in range(7):
  if c[i]and c[i+1]and c[i+2]:
   c[i]-=1;c[i+1]-=1;c[i+2]-=1
   if f(c):return 1
   c[i]+=1;c[i+1]+=1;c[i+2]+=1
for e in sys.stdin:
 e=list(map(int,e.strip()))
 a=[i for i in range(1,10)if f(g(e,i))]
 if a:print(*a)
 else:print(0)


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

int main() {
  string S;
  cin>>S; 
  for(int i=0;i<3;i++){
  if(S.at(i)==S.at(i+1)){
    cout<<"Bad"<<endl;
    break;
  }
      if(i==2){
    cout<<"Good"<<endl;
  } 
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr long long int mod = 1e9 + 7;
using container = vector<Int>;

int main() {

	Int N, M; cin >> N >> M;
	vector<bool> aced(N, false);
	container wa_num(N, 0);

	Int ac_num = 0;

	rep(i, M) {
		Int p;
		string S;
		cin >> p >> S;
		p--;
		if (!aced[p]) {
			if (S == "WA") {
				wa_num[p]++;
			}
			else {
				aced[p] = true;
				ac_num++;
			}
		}
	}

	Int ans = 0;
	rep(i, N) {
		if (aced[i])ans += wa_num[i];
	}

	cout << ac_num << " " << ans << endl;

}

Measured memory_bytes: 1152
def main():
    N, T = map(int, input().split())
    ans = 10000
    for _ in range(N):
        c, t = map(int, input().split())
        if t <= T:
            ans = min(ans, c)

    if ans == 10000:
        print('TLE')
    else:
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc081_a.cpp
 * time   : Wed Apr 29 22:58:50 2020
 * quest  : A - Placing Marbles
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  char a, b, c;
  cin >> a >> b >> c;
  cout << ((int(a + b + c) == 144) ? 0 : (int(a + b + c) == 145) ? 1 : (int(a + b + c) == 146) ? 2 : 3) << "\n";
  return 0;
}


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

struct node{
    string s;
    bool operator <(const node &a)const {
        return s<a.s;
    }
};

int main(){
    ios_base::sync_with_stdio();
    string str;int k;cin>>str>>k;
    int len=str.length();
    set<string>s;
    priority_queue<node>q;
    if(len<=5){
        for(int i=0;i<len;i++){
            string k;
            for(int j=i;j<len;j++){
                k+=str[j];
                s.insert(k);
            }
        }
        set<string>::iterator it;
        for(it=s.begin();it!=s.end()&&(--k);it++) ;cout<<*it<<endl;
    }
    else {
        int sum=0;map<string,int>mp;
        for(int i=0;i<len;i++) {
            string s;
            for(int j=i;j<len;j++){
                s+=str[j];node tmp;
                if(!mp[s]) mp[s]++,tmp.s=s,q.push(tmp),sum++;
                if(sum>=5) break;
            }
            if(sum>=5) break;
        }
        for(int i=0;i<len;i++){
            string s;
            for(int j=i;j<len&&j<=i+5;j++){
                s+=str[j];
                if(mp[s]) continue;
                node tmp=q.top();
                if(tmp.s>s){
                    q.pop();
                    mp[s]++;tmp.s=s;
                    q.push(tmp);
                }
            }
        }
        k=5-k;
        while(!q.empty()&&k--) q.pop();
        cout<<q.top().s<<endl;
    }
    return 0;
}


Measured memory_bytes: 2432
import java.util.*;

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

        String S = scanner.next();
        String T = scanner.next();

        if(S.length() < 1 || 10 < S.length()) {
            System.out.println("No");
            return;
        }

        StringBuilder sb = new StringBuilder(T);
        
        sb.setLength(sb.length() - 1);

        if(S.equals(sb.toString())) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        

    }
}

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

#define int         long long
#define mp          make_pair
#define pb          push_back
#define vi          vector<int>
#define vii         vector<pair<int,int>>
#define mi          map<int,int>
#define mii         map<pair<int,int>,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define hellhsh     444440583533
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i];
#define si(x)       cin>>x;
#define sii(x,y)    cin>>x>>y;
#define ahell   998244353
#define p(x)   printf("%I64d",x)
#define aut(x,u) for(auto x:u)
#define pri     queue<pii>
#define forn(k) for(int i=0;i<k;i++)
#define N 200007
#define fl 1.0000000000
#define ms(a,n) memset(a,n,sizeof(a))
#define INF 10000000000007
using namespace std;
int x,y,m,k;
int n;
vii list[1006];
bool comp(int a,int b)
{
  return a>b;
}
void solve()
{
int q1=0,i,j;
int x,y=0,ct=0;
int a,b,c;
cin>>x>>y>>a>>b>>c;
int p[a],q[b],r[c];
rep0(p,a);
rep0(q,b);
rep0(r,c);
sort(p,p+a,comp);
sort(q,q+b,comp);
sort(r,r+c,comp);
int l1=x-1,l2=y-1,l3=0;
int sum=0;
for(i=0;i<x;i++)
  sum+=p[i];
for(i=0;i<y;i++)
  sum+=q[i];
while(l3<c&&(l1>=0||l2>=0))
{
  if(l1<0||l2<0)
  { if(l1>=0)
    {if(r[l3]>p[l1])
    { sum+=(r[l3]-p[l1]);
     l1--;
    }else break;
  }
   if(l2>=0)
   {if(r[l3]>q[l2])
    { sum+=(r[l3]-q[l2]);
     l2--;
    }else break;
  }}
  else if(r[l3]>min(p[l1],q[l2]))
  {
    sum+=(r[l3]-min(p[l1],q[l2]));
    if(p[l1]>q[l2])l2--;
    else l1--;
  }
  else break;
  l3++;
}
cout<<sum;

}
main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i,j,k,test=1;

  //cin>>test;
  while(test--)
  {
      solve();
      //cout<<"\n";
 }

}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,res=0;

void f(ll m){
	if(n/m==n%m) res+=m;
}

int main(){
	cin>>n;
	for(ll i=1;i*i<=n;i++) if(n%i==0){
		if(i-1>0) f(i-1);
		if(i*i<n) f(n/i-1);
	}
	cout<<res<<endl;
}

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

int gcd(int a, int b) {
    int r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

int main()
{
    int n, l;
    vector <int> a;
    cin >> n;
    a.resize(n);
    l = 0;
    for (int i=0; i<n; ++i){
        cin >> a[i];
        if(i == 0){
            l = a[i];
        }
        else {
            l = lcm(a[i], l);
        }
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 3104
<>;@D=(1)x2e6;$s=.5;($%^=$_)?$P[$%]+=($D[$%]+=$P[$%]*(-$c[$%]+($c[$%]=$0)))%=$=:($0++,$s*=2)%=$==1e9+7for split$",<>;$s+=$_ for@P;print$%?$D[$%]:$s%$=

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

class Main {

    static int[] A;
    static int n,k;

    static int binarySearch(int l, int r){
        while (r - l > 1){
            int mid = (l + r) / 2;
            if ( check(mid) >= n) r = mid;
            else l = mid;
        }
        return r;
    }

    static int check(int p){
        int i = 0;
        for (int j = 0; j < k; j++) {
            int s = 0;
            while(s + A[i] <= p){
                s += A[i++];
                if (i == n) return n;
            }
        }
        return i;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));

        String[] sl = br.readLine().trim().split("\\s+");

        n = Integer.parseInt(sl[0]); // # of packages
        k = Integer.parseInt(sl[1]); // # of trucks
        A = new int[n];

        for (int i = 0; i < n; i++)
            A[i] = Integer.parseInt(br.readLine());

        br.close();
        System.out.println(binarySearch(0,100000 * 100000));
    }
}



Measured memory_bytes: 35312
#include <stdio.h>

void islandin (int island[2500][2],int i,int j,int island_count){
    island[island_count][0] = i;
    island[island_count][1] = j;
}





int main(int argc, const char * argv[]) {
    
    
    int w,h,i=0,j=0,k=0,l=0,y;
    int table[52][52]={0};
    int island[2500][2],island_count=0,island_count1=0,x,island_count2 = 0,count=0;
    while (1) {
        
        
        scanf("%d %d",&w,&h);
        
        
        if (!w && !h) {
            break;
        }
        
        for (i=1; i<=h; i++) {
            for (j=1; j<=w; j++) {
                scanf("%d",&table[i][j]);
                
            }
        }
        
        for (i=1;i<=h;i++) {
            for (j=1; j<=w; j++) {
                if (table[i][j]==1) {
                    islandin(island,i,j,island_count);
                    island_count++;
                    table[i][j] = 0;
                    while (1){
                        island_count1=island_count;
                        for (x=0; x<island_count1; x++) {
                            for (k=-1; k <=1; k++) {
                                for (l=-1; l<=1; l++) {
                                    if (table[k+island[x][0]][l+island[x][1]] == 1) {
                                        islandin(island,(island[x][0]+k),(island[x][1]+l),island_count);
                                        island_count++;
                                        table[island[x][0]+k][island[x][1]+l]=0;
                                    }
                                }
                            }
                        }
                        if (island_count==island_count1) {
                            island_count2++;
                            island_count=0;
                            for (y=0; y<island_count; y++) {
                                island[y][0]=0;
                                island[y][1]=0;
                            }
                            break;
                        }
                    }
                }
            }
        }
        printf("%d\n",island_count2);
        island_count=0;
        island_count2=0;
    }
    return 0;
}

Measured memory_bytes: 636
#include <cstdio>
#include <cstring>
#include <algorithm>
 
using namespace std;
 
#define MOD (100000)
 
int mask;
int y, x;
char map[32][32];
int idx[1 << 20];
int memo[20][20][17712];
 
int countWay(int pos, int bit)
{
    if (pos == x * y){
        return (1);
    }
    int ny = pos / x, nx = pos % x;
     
    int ret = memo[ny][nx][idx[bit]];
    if (ret == -1){
        ret = 0;
        int nbit;
        if (map[ny][nx] == 'J' || map[ny][nx] == '?'){
            nbit = bit;
            if (nbit & 1) nbit -= 1;
            nbit = ((nbit << 1) | 1) & mask;
            ret = (ret + countWay(pos + 1, nbit)) % MOD;
        }
        if (map[ny][nx] == 'O' || map[ny][nx] == '?'){
            nbit = (bit << 1) & mask;
            ret = (ret + countWay(pos + 1, nbit)) % MOD;
        }
        if (map[ny][nx] == 'I' || map[ny][nx] == '?'){
            if (!((bit >> (x - 1)) & 1) || nx == x - 1){
                nbit = bit;
                if (nbit & 1) nbit -= 1;
                nbit = (nbit << 1) & mask;
                ret = (ret + countWay(pos + 1, nbit)) % MOD;
            }
        }
    }
     
    return (memo[ny][nx][idx[bit]] = ret);
}
 
int main()
{
    int p;
    scanf("%d %d", &y, &x);
     
    p = 1;
    for (int i = 0; i < y; i++){
        scanf("%s", map[i]);
        for (int j = 0; j < x; j++){
            if (map[i][j] == '?'){
                p *= 3;
                p %= MOD;
            }
        }
    }
    int ct = 0;
    for (int i = 0; i < 1 << 20; i++){
        bool flag = true;
        for (int j = 0; j < 20; j++){
            if (((i >> j) & 1) && (i >> (j + 1)) & 1){
                flag = false;
                break;
            }
        }
        if (flag) idx[i] = ct++;
    }
     
    mask = (1 << x) - 1;
    memset(memo, -1, sizeof(memo));
     
    printf("%d\n", (p - countWay(0, 0) + MOD) % MOD);
     
    return (0);
}

Measured memory_bytes: 31188
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()

const ll INF = 1e18;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 100+2;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

struct Edge {
  int to;  /// 辺の行き先
  ll cap; /// 辺の容量 
  int rev; /// G[e.to][e,rev]は逆辺の構造体にアクセスする
};

vector<Edge> G[MAX];
int level[MAX];
int iter[MAX];

void add_edge(int from, int to, ll cap) { /// from-to間の流量をcapで設定、お互いにアクセス可能にする
  Edge e1, e2;
  e1.to = to; e1.cap = cap; e1.rev = (int)(G[to].size()); 
  e2.to = from; e2.cap = 0; e2.rev = (int)(G[from].size()); 
  G[from].push_back(e1);
  G[to].push_back(e2);
}

void bfs(int s) { /// sから他の辺への距離（コストではなく経由するエッジの数）
  Fill(level, -1);
  level[s] = 0;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int x = q.front(); q.pop();
    FORE (e, G[x]) {
      if (e.cap > 0 && level[e.to] < 0) {
        level[e.to] = level[x] + 1;
        q.push(e.to);
      }
    }
  }
}

ll dfs(int s, int t, ll f) { /// sからtへ行くルートの最大流量、これ以上ルートがないとき0
  if (s == t) return f;

  FOR (i, iter[s], G[s].size()) {
    iter[s] = i;
    Edge& e = G[s][i];
    if (e.cap > 0 && level[s] < level[e.to]) {
      int d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }

  return 0;
}

ll dinic(int s, int t) { /// sからtへの最大流量を返す
  ll flow = 0;
  while (1) {
    Fill(iter, 0);
    bfs(s);
    if (level[t] == -1) return flow;
    int f = dfs(s, t, INF);
    flow += f;
  }
}

int N, M;
ll a[MAX];

int main() {

  cin >> N;
  int S = N; /// 使う方のノード
  int T = N+1; /// 使わない方のノード

  ll pos_sum = 0;
  REP (i, N) {
    cin >> a[i];
    pos_sum += max(0ll, a[i]);
    if (a[i] >= 0) add_edge(S, i, a[i]);
    else add_edge(i, T, -a[i]);
  }

  REP (i, N) {
    FOR (j, i+1, N) if ((j+1)%(i+1) == 0) add_edge(j, i, INF);
  }

  ll ans = pos_sum - dinic(S, T);
  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
#include<iostream>

int a = 0 , b = 0 , c = 0 , i = 0 , j = 0 ;

int main()
{
	std::cin >> a >> b >> c ;
	for(;i == 0;)
	{
		i = 1 ;
		if(a > b)
		{
			j = a ;
			a = b ;
			b = j ;
			i = 0 ;
		}
		if(b > c)
		{
			j = b ;
			b = c ;
			c = j ;
			i = 0 ;
		}
	}
	std::cout << a << " " << b << " " << c << std::endl ;
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int K, N;
  std::cin >> K >> N;
  std::vector<int> A(N);
  rep(i, N) {
    std::cin >> A[i];
  }
  int d = A[0] + ( K - A[N - 1]);
  rep(i, N) {
    d = std::max(d, A[i + 1] - A[i]);
  }
  std::cout << K - d << '\n';
}


Measured memory_bytes: 1024
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    int ses[h+2][w+3];
    f(j,1,a)
    {
        f(i,1,h)
        {
            if(i<=b)ses[i][j]=0;
            else ses[i][j]=1;
        }
    }
     f(j,a+1,w)
    {
        f(i,1,h)
        {
            if(i<=b)ses[i][j]=1;
            else ses[i][j]=0;
        }
    }
    f(i,1,h)
    {
        f(j,1,w)
        {
            cout<<ses[i][j];
        }
        cout<<endl;
    }
    return 0;

}





































Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const ll inf = 10010010001LL;
vi G[100100];
ll d[100100][3];

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
  int n,m;
  cin >> n >> m;
  rep(i,m){
    int u,v;
    cin >> u >> v;
    u--;v--;
    G[u].push_back(v);
    //G[v].push_back(u);
  }
  int s,t;
  cin >> s >> t;
  s--;t--;
  Fill(d,inf);
  queue<P> q; 
  d[s][0] = 0;
  q.push(P(s,0));
  while(!q.empty()){
    auto up = q.front();
    q.pop();
    for(auto v:G[up.fi]){
      int z = (up.se+1)%3;
      if(d[v][z] > d[up.fi][up.se]+1){
        d[v][z] = d[up.fi][up.se]+1;
        q.push(P(v,z));
      }
    }
  }
  // rep(i,n){
  //   rep(k,3)cout<<d[i][k]<<" ";
  //   cout<<endl;
  // }
  ll ans = d[t][0] == inf?-1:d[t][0]/3;
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
    string s, t;
    cin >> s >> t;

    int count = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s.at(i) != t.at(i))
        {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

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



int main(){
  int N,K;
  cin>>N>>K;
  
  vector<int> vec(N);
  int sum=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a>=K) sum++;
  }
  cout<<sum<<endl;
    
    
    
}

Measured memory_bytes: 3784
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	int n;
	cin >> n;
	int dp[100050] = {};
	vector<int> s;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s.push_back(a);
	}
	dp[0] = 0;
	dp[1] = dp[0] + abs(s[0]-s[1]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 2] + abs(s[i - 2] - s[i]), dp[i-1]+abs(s[i-1]-s[i]));
	}
	cout << dp[n-1];
}

Measured memory_bytes: 1276
n, a, b, c, d = map(int, input().split())
S = input()
if S.find('##', a, c) != -1 or S.find('##', b, d) != -1:
    print('No')
    exit()

if c > d:
    if S.find('...', b-2, d+1) == -1:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 3572
#include <stdio.h>

int N;
int p[4], t[4];

int memo[128];

int asumikana(int tukutta) {
	int answer = 999999999;
	int i;
	if (tukutta >= N) return 0;
	if (memo[tukutta]) return ~memo[tukutta];
	for (i = 0; i < 4; i++) {
		int candidate = asumikana(tukutta + t[i]) + p[i];
		if (candidate < answer) answer = candidate;
	}
	return ~(memo[tukutta] = ~answer);
}

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < 4; i++) {
		if (scanf("%d", &p[i]) != 1) return 1;
	}
	for(i = 0; i < 4; i++) {
		if (scanf("%d", &t[i]) != 1) return 1;
	}
	printf("%d\n", asumikana(0));
	return 0;
}



Measured memory_bytes: 2144
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

a = readInt()
b = readInt()

if a>b:
	print("GREATER")
elif a<b:
	print("LESS")
else:
	print("EQUAL")

Measured memory_bytes: 3444
order = input()
forw = int(order[:2])
back = int(order[2:])
flg_f = 0
flg_b = 0
 
if forw<=12 and forw != 0:
  flg_f = 1
if back<=12 and back != 0:
  flg_b = 1

if flg_f + flg_b == 2:
  print('AMBIGUOUS')
elif flg_f == 1:
  print('MMYY')
elif flg_b == 1:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
#include<numeric>

using namespace std;

using ll = long long;

struct DSU {
    vector<int> parent;
    vector<vector<int> > set_size;
    set<int> roots;
    int len;

    DSU() {}

    DSU(const int n, const int m) : len(n + m) { assign(n, m); }

    void assign(const int n, const int m) {
        parent.resize(len);
        set_size.assign(2, vector<int>(len, 0));
        // debug();
        fill(set_size[0].begin(), set_size[0].end() - m, 1);
        // debug();
        fill(set_size[1].begin() + n, set_size[1].end(), 1);
        // debug();
        iota(parent.begin(), parent.end(), 0);
        roots.insert(parent.begin(), parent.end());
    }

    bool check(const int a, const int b) { return root(a) == root(b); }

    int root(int x) {
        while (x != parent[x]) {
            x = parent[x] = parent[parent[x]];
        }
        return x;
    }

    int size() { return roots.size(); }

    ll size(const int i) { 
        const int r = root(i);
        return ll(set_size[0][r]) * set_size[1][r]; 
    }

    bool join(int a, int b) {
        a = root(a), b = root(b);

        if (a == b) {
            return false;
        }
        const int net_size_a = set_size[0][a] + set_size[1][a],
            net_size_b = set_size[0][b] + set_size[1][b];
        if (net_size_a < net_size_b) {
            swap(a, b);
        }

        roots.erase(b);
        set_size[0][a] += set_size[0][b];
        set_size[1][a] += set_size[1][b];
        parent[b] = a;
        return true;
    }

    void debug() {
        cerr << "Roots: ";
        for (int r : roots) {
            cerr << r << ' ';
        }
        cerr << '\n';

        cerr << "Sizes:\n";
        for (int i = 0; i < len; i++) {
            cerr << '(' << set_size[0][i] << ", " << set_size[1][i] << ")\n";
        }
    }
};

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

    int n = 1e5, m = 1e5, q;
    cin >> q;
    DSU d(n, m);
    // d.debug();
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        d.join(x - 1, n + y - 1);
        // d.debug();
    }
    ll res = 0;
    for (int r : d.roots) {
        res += d.size(r);
    }
    res -= q;
    cout << res << '\n';
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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


int main()
{
    string s;
    cin>>s;
    if(s=="SUN") cout<<7<<endl;
    if(s=="MON") cout<<6<<endl;
    if(s=="TUE") cout<<5<<endl;
    if(s=="WED") cout<<4<<endl;
    if(s=="THU") cout<<3<<endl;
    if(s=="FRI") cout<<2<<endl;
    if(s=="SAT") cout<<1<<endl;
    
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N) {
        cin >> d[i];
    }
    set<int> d2(d.begin(), d.end());
    cout << d2.size() << endl;
    return 0;
}

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

int main(){
  int N,K; cin>>N>>K;
  cout<<N-K+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
vector< int > z_algorithm(const string &s) {
  vector< int > prefix(s.size());
  for(int i = 1, j = 0; i < s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while(i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int) s.size();
  return prefix;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> S;
  rep(i,0,N){
    T=S.substr(i);
    auto P=z_algorithm(T);
    M=P.size();
    rep(j,0,M)if(i+P[j]-1<i+j)chmax(sum,P[j]);
  }
  Out(sum);
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {

    int n;
    cin >> n;
    vector<ll> acum(n);

    cin >> acum[0];
    fo(i, n - 1) {
        int a;
        cin >> a;
        acum[i + 1] = a + acum[i];
    }

    ll menor = INFLL;
    fo(i, n - 1) {
        menor = min(menor, abs(acum[i] - (acum[n - 1] - acum[i])));
    }

    cout << menor << endl;

    return 0;
}

Measured memory_bytes: 1792
N=int(input())
S=input()
R=0;G=1;B=2
C=["R","G","B"]
X=[[[0 for i in range(N+1)]for x in range(2)] for c in range(3)]
for c in range(3):
    for i in range(N):
        if S[i]==C[c]:
            X[c][0][i+1]=X[c][0][i]+1
        else:
            X[c][0][i+1]=X[c][0][i]
    for i in range(N-1,-1,-1):
        if S[i]==C[c]:
            X[c][1][i]=X[c][1][i+1]+1
        else:
            X[c][1][i]=X[c][1][i+1]
ans=0
for i in range(N):
    c=-1
    for cc in range(3):
        if C[cc]==S[i]:
            c=cc
            break
    for seq in [((c+1)%3,(c+2)%3),((c+2)%3,(c+1)%3)]:
        x,y=seq
        ans+=X[x][0][i]*X[y][1][i]
for i in range(N):
    x=0
    while(i+2*x<N):
        j=i+x
        k=i+2*x
        if len({S[i],S[j],S[k]})==3:
            ans-=1
        x+=1
print(ans)


Measured memory_bytes: 68888
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int l = sc.nextInt();
    String[] s = new String[n];
    for(int i=0;i<n;i++){
      s[i] = sc.next();
    }
    Arrays.sort(s);
    String m="";
    for(int i=0;i<n;i++) m+=s[i];
    System.out.println(m);
  }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b,c,d;cin>>a>>b>>c>>d;
  int l=max(a,c);
  int r=min(b,d);
  int ans=r-l;
  if(ans<0)ans=0;
  cout(ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
pair<int,int> event[5000000];
int now[100001];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int at=0;
	for(int i=1;i<=a;i++){
		event[at++]=make_pair(i-b+1,i);
		event[at++]=make_pair(i+1,-i);
		for(int j=1;j*j<=i;j++){
			if(i%j==0){
				int c=i/j;
				if(j<b){
					event[at++]=make_pair(i-b+1,j);
					event[at++]=make_pair(i-j+1,-j);
					event[at++]=make_pair(i+j-b+1,j);
					event[at++]=make_pair(i+1,-j);
				}
				if(c<b){
					event[at++]=make_pair(i-b+1,c);
					event[at++]=make_pair(i-c+1,-c);
					event[at++]=make_pair(i+c-b+1,c);
					event[at++]=make_pair(i+1,-c);
				}
			}
		}
	}
	std::sort(event,event+at);
	int ret=0;
	int right=0;
	int left=0;
	for(int i=1;i<=a-b+1;i++){
		while(event[right].first<=i){
			if(event[right].second>0){
				now[event[right].second]++;
				if(now[event[right].second]==1)ret++;
			}
			right++;
		}
		while(event[left].first<=i){
			if(event[left].second<0){
				now[-event[left].second]--;
				if(now[-event[left].second]==0)ret--;
			}
			left++;
		}
		//for(int j=1;j<=10;j++)printf("%d ",now[j]);

		printf("%d",ret);
		if(i<a-b+1)printf(" ");
		else printf("\n");
	}
}

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

int main() {
	string s;
	cin >> s;
	for (int i = 0; i + 1 < s.size(); i++)
		if (s[i] == s[i + 1])
			return cout << i + 1 << ' ' << i + 2, 0;
	for (int i = 0; i + 2 < s.size(); i++)
		if (s[i] == s[i + 2])
			return cout << i + 1 << ' ' << i + 3, 0;
	cout << "-1 -1";
}


Measured memory_bytes: 3736
#include <stdio.h>

int main() {
    int n, val500=0, val5=0, mult500=0, mult5=0, total=0, novovalor=0;
    scanf("%d", &n);
    val500 = n/500;
    novovalor = n-(val500*500);
    val5 = novovalor/5;
    mult500 = val500*1000;
    mult5 = val5*5;
    total = mult500+mult5;
    printf("%d\n", total);

    return 0;
}



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

#define push_back pb;
typedef long long ll;


int main()
{
    ll a, b,c,k;
    cin >> a >> b >> c >> k;
    if(a >= k)
        cout << k;
    else if(a+b >= k)
        cout << a;
    else
        cout << a - (k - a - b);
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    vector<pair<double, double>> s(n);
    vector<double> a(n);
    rep(i, n) cin >> s[i].first; 
    rep(i, n) cin >> s[i].second;

    double p1 = 0, p2 = 0, p3 = 0, p_inf = 0;

    rep(i, n)
    {
        double c = abs(s[i].first - s[i].second);
        p1 += c;
        p2 += pow(c, 2);
        p3 += pow(c, 3);
        a.push_back(c);
    }

    p_inf = *max_element(ALL(a));

    cout << fixed << setprecision(7) << p1 << endl;
    cout << fixed << setprecision(7) << sqrt(p2) << endl;
    cout << fixed << setprecision(7) << cbrt(p3) << endl;
    cout << fixed << setprecision(7) << p_inf << endl;

    return 0;
}


Measured memory_bytes: 3484
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		cnt += i >= 1 && i <= 9;
		cnt += i >= 100 && i <= 999;
		cnt += i >= 10000 && i <= 99999;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

long long N, M, K;
long long A[200001], B[200000];


int main() {
  cin >> N >> M >> K;
  A[0] = 0;
  rep(i, N) {
    cin >> A[i+1];
  }
  rep(i, M) {
    cin >> B[i];
  }

  rep(i, N) {
    A[i+1] += A[i];
  }

  rep(i, M-1) {
    B[i+1] += B[i];
  }

  long long ans = 0;

  rep(i, N+1) {
    long long key = K - A[i];
    if(key < 0) continue;
    long long ind = upper_bound(B, B+M, key) - B;
    ans = max(ans, i + ind);
    // cout << ans << endl;
  }

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

Measured memory_bytes: 6688
#include<iostream>
using namespace std;
int main()
{
	char a3[4];
	int a,b;
	bool a1=false,a2=false;
		cin>>a3[0];
	
		cin>>a3[1];
        a=(a3[0]-'0')*10+a3[1]-'0';

		cin>>a3[2];
	
		cin>>a3[3];
        b=(a3[2]-'0')*10+a3[3]-'0';
    
    if(a<=12 && a>0)
    {
    	a1=true;
	}
	
	if(b<=12 && b>0)
	{
		a2=true;
	}
	
	if(a1 && !a2)
	{
		cout<<"MMYY";
	}
	
	if(a2 && !a1)
	{
		cout<<"YYMM";
	}
	
	if(a2 && a1)
	{
		cout<<"AMBIGUOUS";
	}
	
	if(!a1 && !a2)
	{
		
		cout<<"NA";
	}
	
	return 0;

} 

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  ll x;cin>>x;
  ll ans = x/11*2;
  x = x%11+5;
  ans += x/6;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()

  println(ntl_1_a(n))
}

private fun ntl_1_a(n: Long): String {
  var na = n

  val pairList = mutableListOf<Pair<Long, Long>>()
  val sqrt = Math.sqrt(n.toDouble()).toLong()
  for (i in 2L..sqrt) {
    if (na % i != 0L) continue

    var ex = 0L
    while (na % i == 0L) {
      ex++
      na /= i
    }
    pairList.add(Pair(i, ex))
  }
  if (na != 1L) pairList.add(Pair(na, 1))

  var ans = ""
  for (p in pairList) {
    for (i in 0 until p.second) {
      ans += " " + p.first
    }
  }

  return n.toString() + ":" + ans
}



Measured memory_bytes: 27680
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val d = (0 until n).map { sc.next().toInt() }
    println(problemnikkei20192b(n, d))
}

fun problemnikkei20192b(n: Int, d: List<Int>): Long {
    if (d[0] != 0) return 0

    val mod = fun(n: Long) = n % 998244353
    val groped = d.sorted().groupBy { it }.toList()
    if (groped[0].second.size != 1) return 0
    var ans = 1L
    for (i in 1 until groped.size) {
        if (groped[i].first != groped[i - 1].first + 1) return 0
        for (j in 0 until groped[i].second.size) {
            ans = mod(ans * groped[i- 1].second.size)
        }
    }
    return ans
}

Measured memory_bytes: 84568
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,int> P;
int main(void){
  int n,m,i,j,co[1010];
  bool u[1010]={false};
  vector<P> g[110];
  cin >> n >> m;
  for (i=0;i<m;i++){
    int a,b;
    cin >> a >> b >> co[i];
    g[a].push_back(P(b,i));
    g[b].push_back(P(a,i));
  }
  
  const int INF=1e9;
  for (i=1;i<=n;i++){
    int d[110],from[110];
    priority_queue<P,vector<P>,greater<P>> pque;
    pque.push(P(0,i));
    for (j=1;j<=n;j++) d[j]=INF;
    d[i]=0;
    while (!pque.empty()){
      P y=pque.top();
      pque.pop();
      int ds=y.first,is=y.second;
      if (d[is]<ds) continue;
      for (j=0;j<g[is].size();j++){
        int ne=g[is][j].first;
        if (d[ne] > d[is]+co[g[is][j].second]){
          d[ne]=d[is]+co[g[is][j].second];
          from[ne]=g[is][j].second;
          pque.push(P(d[ne],ne));
        }
      }
    }
    for (j=1;j<=n;j++) if (j!=i) u[from[j]]=true;
  }
  
  int ans=0;
  for (i=0;i<m;i++) if (!u[i]) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int maxn=10000+10;
int V,E;
vector<int> g[maxn];
vector<int> rg[maxn];
vector<int> rs;
int vis[maxn];
int check[maxn];


void dfs(int u)
{
    vis[u]=1;
    for(int i=0;i<g[u].size();i++)
    {
        int v=g[u][i];
        if(!vis[v]) dfs(v);
    }
    rs.push_back(u);

}
void rdfs(int u,int k)
{
    vis[u]=1;
    check[u]=k;
    for(int i=0;i<rg[u].size();i++)
    {
        int v=rg[u][i];
        if(!vis[v]) rdfs(v,k);
    }
}
void scc()
{
    memset(vis,0,sizeof(vis));
    int k=0;
    for(int i=0;i<V;i++)
    {
        if(!vis[i]) dfs(i);
    }
    memset(vis,0,sizeof(vis));
    for(int i=rs.size()-1;i>=0;i--)
    {
        if(!vis[rs[i]]) rdfs(rs[i],k++);
    }

}
int main(void){
//   freopen("in.txt","r",stdin);
   scanf("%d%d",&V,&E);
   int u,v;
   for(int i=0;i<E;i++)
   {
       scanf("%d%d",&u,&v);
       g[u].push_back(v);
       rg[v].push_back(u);
   }
   scc();
   int q;
   scanf("%d",&q);
   while(q--)
   {
       scanf("%d%d",&u,&v);
       printf("%d\n",check[u]==check[v]?1:0);
   }

  return 0;
}

Measured memory_bytes: 4292
k = int(input())
Qs = [tuple(map(int, input().split())) for _ in range(k)]
from itertools import permutations
Lis = [(i, j) for i in range(8) for j in range(8)]

def dfs(idx, lis):
    if idx==8:
        return lis
    Xs = set([x for x, y in lis])
    Ys = set([y for x, y in lis])
    Dif = set([x-y for x, y in lis])
    xDif = set([(8-x)-y for x, y in lis])
    ans = False
    for i in range(8):
        if i in Xs: continue
        for j in range(8):
            if j in Ys: continue
            if i-j in Dif: continue
            if (8-i)-j in xDif: continue
            lis.append((i, j))
            ans = dfs(idx+1, lis)
            if ans:
                return ans
            lis.pop()
    else:
        return False

chess = [['.']*8 for _ in range(8)]
for x, y in dfs(k, Qs):
    chess[x][y] = 'Q'
for i in range(8):
    print(''.join(chess[i]))
    
    
        


Measured memory_bytes: 5660
a = int(input())

x = [0] * (a+1)
for xi in range(1,101):
    for yi in range(1,101):
        for zi in range(1,101):
            result = xi**2 + yi**2 + zi**2 + xi*yi + yi*zi + zi*xi
            if result <= a:
                x[result] += 1 
for i in range(1, a+1):
    print(x[i])

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
    bool flag=false;
    ll K,A,B;
    cin>>K>>A>>B;
    for(ll i=A;i<=B;i++){
        if(i%K==0){flag=true; break;}
    }
    if(flag){cout<<"OK"<<endl;}
    else{cout<<"NG"<<endl;}
}


Measured memory_bytes: 3636