akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_114
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Read();
            int min = int.MaxValue;
            for(int i = 0; i <= s.Length - 3; i++)
            {
                int val = int.Parse(s.Substring(i, 3));
                min = Math.Min(Math.Abs(val - 753), min);
            }

            Console.WriteLine(min);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
    int x;
    cin >> x;
    for(ll i = -200; i < 200; i++) {
        for(ll j = -200; j < 200; j++) {
            if(i*i*i*i*i-j*j*j*j*j==x){
                cout << i << ' ' << j << endl;
                return 0;
            }
        }
    }

}

Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#define PI 3.141592653589793

using namespace std;

int main() {
  string str;
  int to;
  double x,y,direction,r,theta;
  x = 0;
  y = 0;
  r = 0;
  theta = 0;
  direction = 90;
  while(cin >> str) {
    to = str.find(",",0);
    r = (double)strtol(str.substr(0,to).c_str(),NULL,10);
    theta = strtol(str.substr(to+1).c_str(),NULL,10);
    if( r == 0 && theta == 0) break;
    //cout << direction << endl;
    x += r * cos(direction * (PI / 180.0));
    y += r * sin(direction * (PI / 180.0));
    direction -= (double)theta;
    str = "0";
  }
  cout << (int)x << endl << (int)y << endl;
}

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

int k,n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n>>k;
    vector <int> p(n);
    for (int i=0; i<n; i++){
        cin>>p[i];
    }
    
    sort(p.begin(),p.end());
    int res=0;
    for (int i=0; i<k; i++)
        res+=p[i];
    
    
    cout<<res;
    
    
    
    
    return 0;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

int main(void) {
    int r;
    cin >> r;

    cout << 3 * r * r << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    vector<int> t(N);
    rep(i,N) cin >> s.at(i) >> t.at(i);
    string X;
    cin >> X;

    int cnt=0;

    rep(i,N){
        if(s.at(i)==X){
            cnt = i;
            break;
        }
    }
    int ans = accumulate(t.begin()+cnt+1,t.end(),0);
    //int ans = accumulate(t.begin(),t.end(),0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair <int,ii>
#define iil pair<ll,ll>
#define iiil pair<ll,iil>
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define s(v) sort(v.begin(),v.end())
#define pf printf
#define sf scanf
#define MIN INT_MIN
#define MAX INT_MAX
#define Accepted 0
#define GCD(x,y)  __gcd(x, y)
#define endl "\n"
using namespace std;
/**
const int maxn = 1e5 * 3;
int vis[maxn],l[maxn];
int indegree[maxn];
vector<int> graph[maxn];
vector<int> order;
vector<int> cst[maxn];

int gx[]= {2,2,-2,-2,1,-1,1,-1};
int gy[] ={1,-1,1,-1,2,2,-2,-2};

void DFS(int a,bool tpsort){
        vis[a] = 1;
    for(int i=0;i<graph[a].size();i++){
        int r = graph[a][i];
            if(vis[r]==0){
                DFS(r,tpsort);
            }
    }
    if(tpsort)order.push_back(a);
}

int vis[maxn],l2[maxn];

void BFS(int root){
    memset(vis,0,sizeof(vis));
    memset(l,0,sizeof(l));
    vis[root] = 1;
    l[root] = 0;
    queue <int> q;
    ans = 0;
    mx = root;
    q.push(root);
    while(!q.empty()){
        int cur = q.front();
        q.pop();
        int p = graph[cur].size();
        for(int i=0;i<p;i++){
            int r = graph[cur][i];
            if(vis[r]==0){
                vis[r] = 1 ;
                l[r] = l[cur] + cst[cur][i];
                if(l[r]>ans){
                    ans = l[r];
                    mx = r;
                }
                q.push(r);
            }
        }
    }
   // cout<< ans <<endl;
}

**/

int main(){
    //fast
    int n,val;  cin >> n;
    vector<int> v;

    for(int i=0;i<2*n;i++){
        cin>>val;
        v.pb(val);
    }

    s(v);
    int sum = 0;
    for(int i=0;i<2*n;i+=2){
        sum+=v[i];
    }
        cout << sum << endl;



    return Accepted;
}


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


int main(){
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 0;
  for(int i = min(a,b);i>=1;i--){
    if(a%i==0&&b%i==0){
      cnt++;
    }
    if(cnt==k){
      cout << i << endl;
      return 0;
    }
  }
}


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

using namespace std;


int main() {
  
      int n;
      scanf("%d",&n);
       
      int flag=0;
      while(n!=0)
      {
        if(n%10==9)
        {
          flag=1;
          break;
        }
        
        n/=10;
      }
  
  if(flag==1)
     printf("Yes");
  
  else
     printf("No");
   
  
  return 0;
  
  
} 

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<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;
  vvll a(n, vll(3));
  rep(i, n) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }

  vvll dp(n + 1, vll(3));
  rep(i, n) {
    rep(j, 3) {
      rep(k, 3) {
        if (j == k)
          continue;
        chmax(dp[i + 1][j], dp[i][k] + a[i][j]);
      }
    }
  }
  ll ans = 0;
  rep(i, 3) {
    chmax(ans, dp[n][i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

struct UFT{    //O(loga(n))
    int n;
    vi d, r;
    UFT(int n) : n(n), d(n, -1), r(n, 0){};
    int root(int i){
        if(d[i] < 0) return i;
        return d[i] = root(d[i]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    bool unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;

        if(r[x] < r[y]) swap(x, y);
        else if(r[x] == r[y]) r[x]++;
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    int size(int i){
        return -d[root(i)];
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    rep(i, n) {
        cin >> v[i];
        --v[i];
    }
    UFT uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        uf.unite(a, b);
    }
    int ans = 0;
    rep(i, n) {
        if(uf.same(v[i], i)) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll L,A;
    cin >> L;
    ll dp[L][5];
    cin >> A;
    dp[0][0]=A;
    if(A==0)dp[0][1]=2;else dp[0][1]=A%2;
    dp[0][2]=(A+1)%2;
    if(A==0)dp[0][3]=2;else dp[0][3]=A%2;
    dp[0][4]=A;
    ll tmp,i;
    for(i=1;i<L;i++){
      cin >> A;
      tmp =dp[i-1][0];
      dp[i][0]=tmp+A;
      tmp = min(tmp,dp[i-1][1]);
      if(A==0)dp[i][1]=tmp+2;else dp[i][1]=tmp+A%2;
      tmp = min(tmp,dp[i-1][2]);
      dp[i][2]=tmp+(A+1)%2;
      tmp = min(tmp,dp[i-1][3]);
      if(A==0)dp[i][3]=tmp+2;else dp[i][3]=tmp+A%2;
      tmp = min(tmp,dp[i-1][4]);
      dp[i][4]=tmp+A;
    }
    tmp=dp[L-1][0];
    for(i=1;i<5;i++){
      tmp=min(tmp,dp[L-1][i]);
    }
    cout << tmp;
    return 0;
}


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

int main() {
    for(;;) {
        int n, m, p;
        std::cin >> n >> m >> p;
        if (n == 0 && m == 0 && p == 0) {
            break;
        }
        std::vector<int> xs(n);
        for(int i = 0; i < n; ++i) {
            std::cin >> xs[i];
        }
        int sum = 0;
        for(int x : xs) {
            sum += x;
        }
        if (xs[m-1] == 0) {
            printf("0\n");
        }
        else {
            int res = sum * (100 - p) / xs[m-1];
            printf("%d\n", res);
        }
    }
}



Measured memory_bytes: 3092
# -*- coding:utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))
    A = {}
    for i in range(1, N+1):
        A[i] = True  # 踏める
    for i in range(M):
        a = int(input())
        A[a] = False  # 踏めない
    MOD = 10**9+7

    # dp[i] := i段目までの場合の数
    dp = [0] * (N+1)
    dp[0] = 1

    for i in range(1, N+1):
        if A[i] is False: continue

        dp[i] += dp[i-1]
        if i-2 >= 0:
            dp[i] += dp[i-2]
        dp[i] %= MOD
    
    print(dp[N]%MOD)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 16188
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll logx=30;
const ll N=4e5+5;
const ll M=3e5+5;
const ll mod=1e9+7;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

ll fp[N],fq[N];

int main()
{
  ll n;
  cin>>n;
  ll a[n];
  set<ll> s;
  ll mini=INF;
  vector<pair<ll,ll> > v;
  for(ll i=0;i<n;i++){cin>>a[i];}
  for(ll i=0;i<n;i+=2){fp[a[i]]++;}
  for(ll i=1;i<n;i+=2){fq[a[i]]++;s.insert(a[i]);}
  for(auto i:s){v.pb(mp(fq[i],i));}
  sort(all(v));
  reverse(all(v));
  for(ll i=1;i<N;i++)
  {
    ll down=n/2;
    ll cur=(n/2)-fp[i];
    for(auto j:v)
    {
      if(j.s==i){continue;}
      down=(n/2)-j.f;
      break;
    }
    mini=min(mini,cur+down);
  }
  cout<<mini<<endl;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int pow(int a, int b) {
    if(b == 0) return 1;
    if(b%2) return a*pow(a, b-1);
    else return pow(a*a, b/2);
}

void nope() {
    cout << -1 << endl;
    exit(0);
}

int32_t main() {

    int m, k; cin >> m >> k;

    int num = pow(2LL, m);

    if(m == 1) {
        if(k == 0) {
            cout << "0 0 1 1\n";
        } else {
            nope();
        }
        return 0;
    }
    
    if(k >= num) {
        nope();
    } else {
        for(int i = 0; i < num; ++i) {
            if(i != k) cout << i << " ";
        }
        cout << k << " ";
        for(int i = num-1 ; i >= 0; --i) {
            if(i != k) cout << i << " ";
        }
        cout << k << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1792
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		Scanner sc=new Scanner(System.in);
		int n=Integer.parseInt(sc.nextLine());
		System.out.println((n%2==0)? n : n*2);
		}

	static void disp(long[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cpp(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    ll n;
    cin >> n;

    vector<ll> s(n);
    rep(i, n) scanf("%lld", &s[i]);


    ll ans = 0;
    for(int C = 1; C <= n-1; ++C){
        ll sum = 0;
        int l = 0, r = n-1;
        if((n-1)%C){
            while(l+C < n-1){
                sum += s[l]+s[r];
                chmax(ans, sum);
                l += C; r -= C;
            }
        }
        else{
            while(l < r){
                sum += s[l]+s[r];
                chmax(ans, sum);
                l += C; r -= C;
            }
        }
    }
    ppp(ans);


    return 0;
}


Measured memory_bytes: 1152
N, K = map(int, input().split())
a = [-1] + list(map(int, input().split()))

MOD = 10**9 + 7

dp = [[0]*(K+1) for _ in range(N+1)]
for i in range(N+1):
    dp[i][0] = 1

for i in range(N):
    for j in range(K):
        if j - a[i+1] >= 0:
            dp[i+1][j+1] = (dp[i+1][j] + dp[i][j+1] - dp[i][j - a[i+1]]) % MOD
        else:
            dp[i+1][j+1] = (dp[i+1][j] + dp[i][j+1]) % MOD

print(dp[N][K])

Measured memory_bytes: 119532
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[] array=new String[N];
    for(int i=0;i<N;i++){
      array[i]=sc.next();
    }

    String ans="";
    sort(array,N,L);
    for(int i=0;i<N;i++){
      ans+=array[i];
    }
    System.out.println(ans);
  }

  public static void sort(String[] array,int N,int L){
    for(int i=0;i<N-1;i++){
      int index=i;
      for(int j=i+1;j<N;j++){
        int count=0;
        for(int s=0;s<L;s++){
          if((array[j].charAt(s))<(array[index].charAt(s)) && count==0){
           // System.out.println(array[j]+" "+array[index]+" "+s);
            //System.out.println((int)(array[j].charAt(s))+" "+(int)(array[index].charAt(s)));
            index=j;
            break;
          }else if((array[j].charAt(s))==(array[index].charAt(s))) ;
          else count++;
        }
      }
      if(i!=index){
        String temp=array[index];
        array[index]=array[i];
        array[i]=temp;
      }
    }
  }
}


Measured memory_bytes: 23636
a, b = map(int, input().split())
s = list(input())

if s[a] != "-":
    result = "No"
elif len([x for x in s if x in [str(x) for x in range(10)]]) + 1 == len(s):
    result = "Yes"
else:
    result = "No"
print(result)

Measured memory_bytes: 9032
#coding: utf-8
import math
import heapq
import bisect
#from scipy.misc import comb

MOD = 10**9+7

N = int(input())

A = []
for i in range(N):
    a = tuple(map(int, input().split()))
    A.append(a)
A = sorted(A,key=lambda x:x[1])

t = 0
for a in A:
    if a[0]+t <= a[1]:
        t += a[0]
    else:
        print("No")
        exit()

print("Yes")

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

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt(x) __builtin_popcount(x)
#define lbit(x) __builtin_ffsll(x)
#define rbit(x) __builtin_clzll(x)
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()

template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
// const double PI = atan(1.0) * 4.0;
const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238

ll N;

signed main() {
    LCIN(N);
    SCIN(S);
    S.erase(unique(All(S)), S.end());
    cout << S.size() << "\n";
}


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

int n, m;
double a, b, p, c, d, q, t;

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a >> b >> p >> c >> d >> q;

		t = sqrt((a - c) * (a - c) + (b - d) * (b - d));

		if (p + q < t)
			m = 0;
		else if (p - q > t)
			m = 2;
		else if (q - p > t)
			m = -2;
		else
			m = 1;

		cout << m << endl;
	}
}



Measured memory_bytes: 3144
//package jp.atcoder.mujin_pc_2017;

import java.io.*;
import java.math.*;
import java.util.*;
import java.text.*;

class Solver{
    private Scanner stdin;
    private PrintWriter stdout;
    
    public void run(){
        stdin = new Scanner(new BufferedInputStream(System.in));
        stdout = new PrintWriter(new BufferedOutputStream(System.out));
        
        while(stdin.hasNextInt()){
            int n = stdin.nextInt();
            List<Integer> a = new ArrayList<Integer>(n);
            int curr=0;
            for(int i=1; i<=n; i++){
                int pos=stdin.nextInt();
                a.add(n-curr);
                curr=Math.max(curr, i-(pos+1)/2);
            }
            long ans=1L, prev=0L;
            long mod=1000000007;
            for(int i=n-1; i>=0; i--){
                //stdout.printf("a[%d]=%d\n", i, a.get(i));
                ans=ans*(a.get(i)-(n-i-1))%mod;
            }
            stdout.println(ans);
        }
        
        stdin.close();
        stdout.close();
    }
}

public class Main {
    public static void main(String[] args)throws Exception{
        Solver solver = new Solver();
        solver.run();
    }
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> a;
	for(int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		a.push_back(x);
	}
	
	sort(a.begin(), a.end());
	
	int ans = 0;
	int cnt = 0;
	
	while(n > cnt)
	{
		if(a[cnt] > n)
		{
			ans++;
			cnt++;
		}
		else
		{
			int num = 0;
			while(a[cnt] == a[cnt + num])
			{
				num++;
			}
			
			if(num < a[cnt])
			{
				ans += num;
			}			
			else
			{
				ans += (num - a[cnt]);
			}
			
			cnt += num;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
struct interval {
    ll s, f;
    interval(ll s, ll f) : s(s), f(f) {}
};
bool compare_f(const interval &x, const interval &y) { return x.f < y.f; }
vector<interval> interval_scheduling(vector<interval> J) {
    vector<interval> A;
    sort(J.begin(), J.end(), compare_f);
    ll f = LLONG_MIN;
    for(int i = 0; i < J.size(); ++i) {
        if(J[i].s >= f) {
            A.push_back(J[i]);
            f = J[i].f;
        }
    }
    return A;
}
int main() {
    ll n;
    cin >> n;
    vector<ll> x(n), l(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> l[i];
    }
    vector<interval> J;
    for(int i = 0; i < n; i++) {
        interval tmp(x[i] - l[i], x[i] + l[i]);
        J.push_back(tmp);
    }
    auto ans = interval_scheduling(J);
    cout << ans.size() << endl;
}

Measured memory_bytes: 8048
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define btinpct(x) __builtin_popcountll((x))
mt19937 rng(8);    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?b:gcd(b%a,a); }

#define ll long long int 
#define ld long double
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (200006)
ll n, k, A[MAXN];
struct node {
	pi key;
	ll prior, sz;
	node *l, *r;
	node(pi _key) {
		key=_key, prior=rand(0, 1e18), sz=1, l=r=0;
	}
}; typedef node* pnode;
ll inline cnt(pnode t) {return t?t->sz:0;}
void split(pnode t, pnode &l, pnode &r, pi key) {
	if(!t) return void(l=r=0);
	if(t->key <= key)
		split(t->r, t->r, r, key), l=t;
	else
		split(t->l, l, t->l, key), r=t;
	if(l) l->sz = cnt(l->l) + cnt(l->r) + 1;
	if(r) r->sz = cnt(r->l) + cnt(r->r) + 1;
}
void insert(pnode &t, pnode k) {
	if(!t) return void(t=k);
	if(t->prior > k->prior) {
		if(t->key > k->key) insert(t->l, k);
		else insert(t->r, k);
	} else {
		if(t->key > k->key) {
			split(t->l, k->l, t->l, k->key);
			t->sz = cnt(t->l) + cnt(t->r) + 1;
			k->r = t;
			t = k;
		} else {
			split(t->r, t->r, k->r, k->key);
			t->sz = cnt(t->l) + cnt(t->r) + 1;
			k->l=t;
			t=k;
		}
	}
	t->sz = cnt(t->l) + cnt(t->r) + 1;
}
ll query(pnode t, pi key) {
	if(!t) return 0;
	if(t->key <= key)
		return cnt(t->l) + 1 + query(t->r, key);
	else
		return query(t->l, key);
}
/*
	ans += query(treap, pi(sum-i*k, LLINF));
	insert(treap, new node(pi(sum-i*k, co++)));
*/ 
int main()
{
	FAST
	cin>>n>>k;
	FOR(i,1,n) cin>>A[i];
	ll sum = 0, ans = 0, co = 0;
	pnode treap; treap=new node(pi(0, co++));
	FOR(i,1,n) {
		sum += A[i];
		ans += query(treap, pi(sum-i*k, LLINF));
		insert(treap, new node(pi(sum-i*k, co++)));
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
stack<int>st;
int num[100];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        while(!st.empty()) st.pop();
        memset(num,0,sizeof(num));
        if(n==0) printf("0\n");
        else
        {
            while(n!=0)
            {
                int ans=n%(-2);
                n/=(-2);
                if(ans<0)
                {
                    ans-=-2;
                    n++;
                }
                st.push(ans);
            }
            int i=0;
            while(!st.empty())
            {
                int s=st.top();
                st.pop();
                num[i++]=s;
            }
            for(int j=0;j<i;j++)
                printf("%d",num[j]);
            printf("\n");
        }
    }
}


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

int main(void){
    // Your code here!
    int n;
    
    cin >> n;
    
    string s[n];
    
    rep(i,n){
        cin >> s[i];
    }
    
    
    int a1=0,a2=0,a3=0,a4=0;
    
    rep(i,n){
        if(s[i] == "AC")a1++;
        else if(s[i] == "WA")a2++;
        else if(s[i] == "TLE")a3++;
        else a4++;
    }
    
    
    
    cout << "AC x " << a1 << endl;
    cout << "WA x " << a2 << endl;
    cout << "TLE x " << a3 << endl;
    cout << "RE x " << a4 << endl;
    
    
    
}


Measured memory_bytes: 6752
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
  int X,Y;
  int Money[3] = {300000,200000,100000};
  int sum = 0;
  cin >> X >> Y;
  if(X == 1 && Y == 1) sum += 400000;
  if(X > 0 && X < 4) sum += Money[X-1];
  if(Y > 0 && Y < 4) sum += Money[Y-1];
  cout<<sum<<endl;
  return 0;
}


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

// #define int long long
#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 SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#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);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

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 pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

bool G[15][15];

ll bitcount(ll x){
  if(x==0) return 0;
  return bitcount(x>>1)+(x&1);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  vll a(n);
  rep(i,n) cin>>a[i];
  sort(a.rbegin(),a.rend());
  ll ans=0;
  rep(i,k) ans+=a[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri Jun  5 16:50:04 2020

@author: NEC-PCuser
"""

N, K = map(int, input().split())
ab_list = []
for i in range(N):
    a, b = map(int, input().split())
    ab_list.append([a,b])

ab_list.sort()


count = 0
for i in range(0, N):
    count += ab_list[i][1]
    
    if (count >= K):
        print(ab_list[i][0])
        break


Measured memory_bytes: 20100
#include <iostream>
#include <cassert>
using namespace std;
 
int a, b;
 
int main() {
	cin >> a >> b;
	assert(a >= 1 && a <= 12);
	assert(b >= 1 && b <= 30);
	if (a <= b) cout << a << endl;
	else cout << a - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    int A = stoi(a);
    int B = stoi(b);

    if(A == B) { cout << "Draw" << endl; }
    else if((A > B && B != 1) || A == 1) { cout << "Alice" << endl; }
    else { cout << "Bob" << endl; }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll unsigned long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000
ll power(ll x,ll n)
{ll x1=0;
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x);
       //  if(result>=1000000001) return 0;
        x=(x*x);
      //   if(x>=1000000001) return 0;
        n=n/2;
    }
    return result;
}
int vowel(char x){
    if(x=='a') return 1;
    if(x=='e') return 1;
    if(x=='i') return 1;
    if(x=='o') return 1;
    if(x=='u') return 1;
    return 0;
}
int main(){
   IOS;
ll t;t=1;//cin>>t;

while(t--){
ll  n;
cin>>n;
ll a[n];
ll b[n];ll x=0;
for(ll i=0;i<n;i++) cin>>a[i]>>b[i];
for(ll i=0;i<n-2;i++){
    if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
        x=1;break;
    }
    
}
if(x) cout<<"Yes";
else cout<<"No";

} 
    
    

    
return 0;    
}

Measured memory_bytes: 3636
if __FILE__ == $0
	while a = gets
		num = []
		num = a.split(nil)
		num = num.map{|n| n.to_f}
		a = num[0]
		b = num[1]
		c = num[2]
		d = num[3]
		e = num[4]
		f = num[5]
		y = (c * d - a * f) / (b * d - a * e)
		x = (c - b * y) / a
		puts "#{sprintf("%.03f", x)} #{sprintf("%.03f", y)}"
	end
end

Measured memory_bytes: 8608
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n,a;
    cin>>n>>a;
    int amari=n%500;
    if(amari<=a)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

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

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	
	vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1));
	for (int i = 1; i <= s.length(); i++) {
		for (int j = 1; j <= t.length(); j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}

	if (dp[s.length()][t.length()] == 0) {
		cout << "" << endl;
		return 0;
	}

	int len = dp[s.length()][t.length()];
	vector<char> ans(len);
	int ps = s.length() - 1, pt = t.length() - 1;
	while (len > 0) {
		if (s[ps] == t[pt]) {
			len--;
			ans[len] = s[ps];
			ps--;
			pt--;
		}
		else if (dp[ps + 1][pt + 1] == dp[ps][pt + 1]) {
			ps--;
		}
		else {
			pt--;
		}
	}
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 35584
#include <stdio.h>
#include <stdlib.h>

struct Node{
  int key;
  struct Node *parent;
  struct Node *left;
  struct Node *right;
};

#define NIL NULL
typedef struct Node* NodePointer;
NodePointer root;

void inOrder(NodePointer);
void preOrder(NodePointer);
void print(void);
void insert(int);
NodePointer makeNode(int);
int find(int);
NodePointer findNode(int);
NodePointer treeSuccessor(NodePointer);
NodePointer treeMinimum(NodePointer);
NodePointer treeMaximum(NodePointer);
void deleteNode(int);

int main(){
  int Q,i,x;
  char order[7];
  scanf("%d",&Q);
  for(i = 0 ; i < Q ; i++){
    scanf("%s",order);
    if(order[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }else if(order[0] == 'f'){
      scanf("%d",&x);
      puts(find(x) ? "yes" : "no");
    }else if(order[0] == 'd'){
      scanf("%d",&x);
      deleteNode(x);
    }else{
      print();
    }
  }
  return 0;
}

void inOrder(NodePointer x){
  if(x == NIL){ return; }
  inOrder(x->left);
  printf(" %d",x->key);
  inOrder(x->right);
}

void preOrder(NodePointer x){
  if(x == NIL){ return; }
  printf(" %d",x->key);
  preOrder(x->left);
  preOrder(x->right);
}

void print(){
  inOrder(root); printf("\n");
  preOrder(root); printf("\n");
}

void insert(int key){
  NodePointer x = root,y = NIL;
  NodePointer z = makeNode(key);
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

NodePointer makeNode(int key){
  NodePointer newNode = malloc(sizeof(struct Node));
  newNode->key = key;
  newNode->left = newNode->right = NIL;
  return newNode;
}

int find(int key){
  NodePointer x = root;
  while(x != NIL){
    if(key < x->key){
      x = x->left;
    }else if(key > x->key){
      x = x->right;
    }else{
      return 1;
    }
  }
  return 0;
}

NodePointer findNode(int key){
 NodePointer x = root;
  while(x != NIL){
    if(key < x->key){
      x = x->left;
    }else if(key > x->key){
      x = x->right;
    }else{
      return x;
    }
  }
  return NIL;
}

NodePointer treeSuccessor(NodePointer x){
  NodePointer y;
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

NodePointer treeMinimum(NodePointer x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

NodePointer treeMaximum(NodePointer x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

void deleteNode(int key){
  NodePointer x,y;
  NodePointer z = findNode(key);
  if(z == NIL){ return; }
  if(z->left == NIL || z->right == NIL){
    y = z;
  }else{
    y = treeSuccessor(z);
  }
  if(y->left != NIL){
    x = y->left;
  }else{
    x = y->right;
  }
  if(x != NIL){
    x->parent = y->parent;
  }
  if(y->parent == NIL){
    root = x;
  }else if(y == y->parent->left){
    y->parent->left = x;
  }else{
    y->parent->right = x;
  }
  if(y != z){
    z->key = y->key;
  }
  free(y);
}

Measured memory_bytes: 19364
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
*/
#include<bits/stdc++.h>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second

void solve()
{
  int a,b,m;
  cin >> a >> b >> m;
  int r[a];
  int mc[b],c[m];
  int minr=mod,minm=mod;
  f(i,a)
  {
    cin >> r[i];
    if(r[i]<minr)
    {
      minr=r[i];
      // pos1=i;
    }
  }
  f(i,b)
  {
    cin >> mc[i];
    if(mc[i]<minm)
    {
      minm=mc[i];
      // pos2=i;
    }
  }
  int ans;
  ans=(minr+minm);
  f(i,m)
  {
    int x,y;
    cin >> x >> y >> c[i];
    if((r[x-1]+mc[y-1]-c[i])<ans)
      ans=(r[x-1]+mc[y-1]-c[i]);
  }
  cout << ans << '\n';
  return;
}

signed main()
{
  FAST;
	int T=1;
	// cin >> T;
	while(T--)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int L[100100], R[100100];
  for(int i=0; i<m; i++) cin >> L[i] >> R[i];
  int minn = L[0];
  int maxx = R[0];
  for(int i=0; i<m-1; i++){
    minn = max(minn,L[i+1]);
    maxx = min(maxx,R[i+1]);
    if(minn>maxx) {
      cout << 0 << endl;
      return 0;
    }
    //cout << minn << " " << maxx << endl;
  }
  cout << maxx - minn + 1 << endl;
}

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

using namespace std;

int n, m, p[100005], ans[100005];
vector<pair<int, int>> v[100005];
int ta;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", p + i, &ta);
		v[p[i]].emplace_back(ta, i);
	}
	for (int i = 1; i <= n; i++) {
		sort(v[i].begin(), v[i].end());
		for (int j = 0; j < v[i].size(); j++)
			ans[v[i][j].second] = j + 1;
	}
	for (int i = 0; i < m; i++)
		printf("%06d%06d\n", p[i], ans[i]);
	return 0;
}

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

int main()
{

    //  #ifndef oj
    //freopen("in", "r", stdin);
    //freopen("out.txt","w",stdout);
    //#endif
    // system("cls");
    //getchar();

    string s;
    cin>>s;
    if(s=="SAT")
        cout<<1<<endl;
    else 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;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,ans = 0;
	string s[610];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> s[i];
		s[i] += s[i];
	}
	for(int i = 0;i < n;i++) s[i + n] = s[i];
	for(int sa = -(n - 1);sa <= n - 1;sa++){
		int sum = 0;
		bool calced = false;
		for(int a = 0;a < n;a++){
			int b = a + sa;
			if(b < 0 || n <= b) continue;
			if(!calced){
				for(int i = 0;i < n;i++){
					for(int j = i + 1;j < n;j++) sum += (s[a + i][b + j] == s[a + j][b + i]);
				}
				calced = true;
			}
			else{
				for(int i = 1;i < n;i++){
					sum = sum - (int)(s[a + i - 1][b - 1] == s[a - 1][b + i - 1]) + (int)(s[a + n - 1 - i][b + n - 1] == s[a + n - 1][b + n - 1 - i]);
				}
			}
			if(sum == n * (n - 1) / 2) ans++;
		}
	}
	cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int>data(n);
  for(int i = 0;i < n;i++){
    cin >> data[i];
  }
  reverse(data.begin(),data.end());
  for(int i = 0;i < n;i++){
    cout << data[i];
    if(i != n-1) cout << " ";
  }
  cout << "" << endl;
}



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

long long int A[3];

int main(void) {
  int five = 0;
  int seve = 0;
  for (int i=0; i<3; i++){
      cin >> A[i];
      if (A[i] == 5) five++;
      if (A[i] == 7) seve++;
  }
  if (five == 2 && seve == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO"  << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static  ll INF = 1e9;
using namespace std;

signed main(){
	ll n;
	cin>>n;
	ll ans=0;
	vector<ll>a(n+1),b(n);
	rep(i,n+1)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n){
		ans+=min(a[i],b[i]);
		if(a[i]<b[i]){
			ans+=min(a[i+1],b[i]-a[i]);
			ll sub=min(a[i+1],b[i]-a[i]);
			a[i+1]-=sub;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 12 15:50:41 2019

@author: shinjisu
"""


import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def dmp(x):
    global debug
    if debug:
        print(x)
    return x


# ABC 100 B Ringo's Favorite Numbers
def abc100b():
    D, N = getIntList()
    if N % 100 == 0:
        return (N+1) * 100**D  # WA N==100のとき正しくない 101*100**D
    else:
        return N * 100**D


# ABC 101 B digit sum
def abc101b():
    N = getInt()
    sm = 0
    n = N
    while n > 0:
        sm += n % 10
        n //= 10
    if N % sm == 0:
        return 'Yes'
    else:
        return 'No'


# ABC 102 B Maximum Difference
def abc102b():
    N = getInt()
    A = getIntList()
    return max(A) - min(A)


# ABC 104 B AcCepted
def abc104b():
    S = input()
    WA = 'WA'
    AC = 'AC'
    ALPHABET = [chr(i+ord('a')) for i in range(26)]
    dmp(ALPHABET)

    if S[0] != 'A':
        dmp(('A',WA))
        return WA

    cFound = False
    for i in range(1, len(S)):
        if S[i] in ALPHABET:
            pass
        elif S[i] == 'C':
            if i >= 2 and i <= len(S)-2 and not cFound:
                cFound = True
            else:
                dmp(('C',WA))
                return WA
        else:
            dmp(('alpha',WA))
            return WA
    else:
        if cFound:
            return AC
        else:
            return WA


debug = False  # True False
print(abc104b())


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define debug(x) cerr << #x << ": " << x << "\n";
#define INF (1<<29) //53687091
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=(int) 1e5;
static const int MOD=(int) 1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
int R;

void solve(){
    if(R<1200) cout<< "ABC" <<"\n";
    else if(R<2800) cout<< "ARC" <<"\n";
    else cout<<"AGC"<<"\n";
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin >> R;
    solve();
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;
queue<long long int>que[200005];
long long int num[200005],h,w,n,x[200001],y[200001],res=9999999,can=0;
pair<long long int ,long long int>pa[200005];
const long long int mod=1000000007;
int main(){
	cout << fixed << setprecision(18);
	string str[300];
	cin>>h>>w>>n;
	res=h;
	for(int i=1;i<=n;i++){
		cin>>x[i]>>y[i];
		pa[i].first=x[i];
		pa[i].second=y[i];
	}
	sort(pa+1,pa+n+1);
	for(int i=1;i<=n;i++){
		if(pa[i].first==pa[i].second-can){
			can=can-1;	
		}else if(pa[i].first>pa[i].second-can){
			cout<<pa[i].first-1<<endl;
			return 0;	
		}
		
	}
	cout<<res<<endl;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int main() {
	int x;
	cin >> x;
	cout << 48 - x << endl;
	return 0;
}

Measured memory_bytes: 256