akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
//#define ordered_set         tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
/*

    order_of_key (k) : Number of items strictly smaller than k .
    find_by_order(k) : K-th element in a set (counting from zero).

*/
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 3e18;

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
signed main()
{
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        
        vi fun;
        while(n)
        {
            int rem=n%26;
            
            if(rem==0)
            {
                fun.pb(26);
                n--;

            }
            fun.pb(rem);
            n/=26;
        }
        reverse(all(fun));
       // cout<<fun<<"\n";
        // for(int i=0;i<fun.size();i++)
        // {
        //     if(fun[i]==0)
        //     {
        //         fun[i]=26;
        //         fun[i-1]--;
        //     }
        // }
        for(int i=0;i<fun.size();i++)
        {
            if(fun[i]==0)continue;
            char ch='a'+(fun[i]-1);
            cout<<ch;
        }
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||

|| A year from now you may wish you had started today ||
*/



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double EPS = 1e-7;
const long long mod = 1000000007 ;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define HelloFile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define ll long long
#define ld long double
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define dist(a,b) ( pow(a.X - b.X, 2) + pow( a.Y - b.Y, 2 ) )
typedef tuple <int, int, int> line;
typedef complex <double> point;
typedef vector <point> polygon;
ll n, arr[100005][4], dp[100005][4];
int main()
{
    Hello
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < 3; j++)
            cin >> arr[i][j];
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            ll maxx = 0;
            for(int k = 0; k < 3; k++)
            {
                if( k == j )
                    continue;
                maxx = max(maxx, arr[i][j] + dp[i - 1][k]);
            }
            dp[i][j] += maxx;
        }
    }
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
    return 0;
}


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

int main()
{
    int x, res;
    cin >> x;

    int j = 8;
    for(int i = 600; i <= 2000; i += 200, --j)
    {
        if(x < i)
        {
            res = j;
            break;
        }
    }

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;++i)
char s[201010];
int main()
{
    int n;
    int a,b,c,d;
    int res=0;
    scanf("%d",&n);
    scanf("%d%d%d%d",&a,&b,&c,&d);
    scanf("%s",s);
    for(int i=a-1;i<max(c,d);i++){
        if(s[i]=='#'&&s[i-1]=='#'){
            printf("No\n");
            return 0;
        }
    }
    if(s[c-1]=='#'||s[d-1]=='#')
    {
        printf("No\n");
        return 0;
    }
    int  flag=0;
    for(int i=b-1;i<min(c,d);i++){
        if(s[i]=='.'&&s[i-1]=='.'){
            if(i+1<n){
                if(s[i+1]=='.')
                    flag=1;
            }
        }
    }
    if(c>d){
        if(flag)
            printf("Yes\n");
        else
            printf("No\n");
    }
    else
        printf("Yes\n");
    return 0;
}



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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    multiset<int, greater<int>> ms;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      ms.insert(a[i]);
    }
    for (int i = 0; i < n; i++) {
      ms.erase(ms.find(a[i]));
      cout << *ms.begin() << '\n';
      ms.insert(a[i]);
    }
    return 0;
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;

int main(){
    int N,M;
    cin>>N>>M;
    int A[N],total = 0;
    for(int i = 0 ; i<N; i++){
        cin>>A[i];
        total+=A[i];
    }
    float ratio = ((float)1/(4*M));
    int flag = 0;
    for(auto x: A){
        if(x>=(total*ratio))flag++;
    }
    flag>=M?cout<<"Yes":cout<<"No";
    return 0;
}

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

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int A, B, C;
    cin >> A >> B >> C;

    bool ok = false;

    rep(i, 10000) {
	int num = (i + 1) * A;
	if (num % B == C) {
	    ok = true;
	    break;
	}
    }

    cout << (ok ? "YES" : "NO") << endl;

    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vec(H, vector<char>(W));
  vector<char> vecH(W, '.');
  vector<char> R(0);
  
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++) {
      cin >> vec.at(i).at(j);
    }
  }
  
  int count = 0;
  for (int i = 0; i < H; i++) {
    if (vec.at(i) != vecH) {
      for (int j = 0; j < W; j++) {
        R.push_back(vec.at(i).at(j));
      }
      count++;
    }
  }
  
  vector<vector<char>> R2(W, vector<char>(count));
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < count; j++) {
      R2.at(i).at(j) = R.at(j * W + i);
    }
  }
  
  int count2 = 0;
  vector<char> vecW(count, '.');
  vector<char> R3(0);
  for (int i = 0; i < W; i++) {
    if (R2.at(i) != vecW) {
      for (int j = 0; j < count; j++) {
      	R3.push_back(R2.at(i).at(j));
      }
      count2++;
    }
  }
  
  vector<vector<char>> R4(R2.at(0).size(), vector<char>(count2));
  for (int i = 0; i < R2.at(0).size(); i++) {
    for (int j = 0; j < count2; j++) {
      R4.at(i).at(j) = R3.at(j * count + i);
    }
  }
  
  for (int i = 0; i < R4.size(); i++) {
    for (int j = 0; j < R4.at(0).size(); j++) {
      cout << R4.at(i).at(j);
    }
    cout << endl;
  }

}


Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main(){
  int ans = 0;
  string s;
  while(cin >>s){
    for(int i=0; i<s.size(); i++){
      if(s[i]!=s[s.size()-i-1]) break;
      if(i == s.size()-1) ans++;
    }
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1184
// ~maqsat~
/*    
**    “Anyone who has never made a mistake has never tried anything new.”
**    © Albert Einstein
*/

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

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

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

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e10 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

bool was[N];

map<ii, int> m;

vector<vector<int>> g(N);

inline void dfs(int v, int col) {
	int c = 0;
	was[v] = true;

	for(int to: g[v]) {
		if(!was[to]) {
			if(c + 1 == col) c += 2, m[{v, to}] = m[{to, v}] = c, dfs(to, c);
			else c++, m[{v, to}] = m[{to, v}] = c, dfs(to, c);
		}
	}
}

int main() {
    fre("");
    ACCELERATE;
	
	int n;
	cin >> n;

	vector<ii> v(n+1);
	for(int i = 0; i < n-1; i++) {
		int a, b;
		cin >> a >> b;

		g[a].pb(b);
		g[b].pb(a);

		v[i] = {a, b};
	}

	int ans = 0;
	for(int i = 1; i <= n; i++) ans = max(ans, sz(g[i]));

	dfs(1, 0);

	cout << ans << '\n';
	for(int i = 0; i < n-1; i++) {
		cout << m[v[i]] << '\n';
	}
    return 0;
}
/*
 
*/


Measured memory_bytes: 19456
#include<bits/stdc++.h>
using namespace std;
int main()
{   long long int n,m,c=0,i,x,t;
    cin>>n;
    long long int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    long long int max=arr[0];
    for(i=0;i<n-1;i++)
    {
        if(arr[i+1]<max)
        {
            c+=max-arr[i+1];
        }
        else
        {
            max=arr[i+1];
        }//printf("%lld\n",c);
    }printf("%lld\n",c);
    //printf("%lld\n",c);
    
    
    
    
    
	
}

Measured memory_bytes: 5272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll lcm=(c*d)/__gcd(c,d);
    ll count1=((b)/c-(a-1)/c);
    ll count2=((b)/d-(a-1)/d);
    ll count3=((b)/lcm-(a-1)/lcm);
    cout<<(b-a+1)-(count1+count2-count3)<<endl;
}


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

void fnInput(int64_t& rnNum)
{
  cin >> rnNum;
}

int fnDigitsCheck(int64_t nDivisor)
{
  int nDigitCnt = 0;
  while (nDivisor)
  {
    nDigitCnt++;
    nDivisor /= 10;
  }

  return nDigitCnt;
}

int fnMultiplCheck(int64_t nNum)
{
  int nMinDigit = fnDigitsCheck(nNum);
                                           // int型 n では n * n が int型の範囲を
  for (int64_t n = 2; n * n <= nNum; n++)  // 超えて桁落ちが発生し TLE となる
  {                                        // nNum の平方根を超えない整数～nNum
    if (nNum % n != 0)  continue;          // を左記の検査を行うと TLE となる
    int64_t nOtr = nNum / n;
    nMinDigit = min(nMinDigit, fnDigitsCheck(nOtr));
  }
  return nMinDigit;
}

int main()
{
  int64_t nNum;
  
  fnInput(nNum);
  cout << fnMultiplCheck(nNum) << 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;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int a,b,ans;
  cin >> a >> b;
  ans += a-1;
  if(a <= b) ans++;
  cout << ans << endl;
}

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

const ll INF = 1e15;

int main() {
  ll n, m, s, t;
  cin >> n >> m >> s >> t;
  s--, t--;

  vector<vector<pair<ll, ll>>> costS(n), costY(n);
  vector<ll> toS(n), toY(n);

  for (ll i = 0; i < m; i++) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    costY[u].push_back(make_pair(a, v));
    costY[v].push_back(make_pair(a, u));
    costS[u].push_back(make_pair(b, v));
    costS[v].push_back(make_pair(b, u));
  }

  for (ll i = 0; i < n; i++) {
    toS[i] = toY[i] = INF;
  }

  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;
  que.push(make_pair(0, s));
  toY[s] = 0;
  while (!que.empty()) {
    pair<ll, ll> tmp = que.top();
    que.pop();
    if (toY[tmp.second] < tmp.first) continue;
    for (ll i = 0; i < costY[tmp.second].size(); i++) {
      if (toY[costY[tmp.second][i].second] >
          tmp.first + costY[tmp.second][i].first) {
        toY[costY[tmp.second][i].second] =
            tmp.first + costY[tmp.second][i].first;
        que.push(make_pair(toY[costY[tmp.second][i].second],
                           costY[tmp.second][i].second));
      }
    }
  }

  que.push(make_pair(0, t));
  toS[t] = 0;
  while (!que.empty()) {
    pair<ll, ll> tmp = que.top();
    que.pop();
    if (toS[tmp.second] < tmp.first) continue;
    for (ll i = 0; i < costS[tmp.second].size(); i++) {
      if (toS[costS[tmp.second][i].second] >
          tmp.first + costS[tmp.second][i].first) {
        toS[costS[tmp.second][i].second] =
            tmp.first + costS[tmp.second][i].first;
        que.push(make_pair(toS[costS[tmp.second][i].second],
                           costS[tmp.second][i].second));
      }
    }
  }

  vector<ll> ans(n);
  for (ll i = 0; i < n; i++) {
    ans[i] = 1e15 - toY[i] - toS[i];
  }
  for (ll i = n - 2; i >= 0; i--) {
    ans[i] = max(ans[i + 1], ans[i]);
  }
  for (ll i = 0; i < n; i++) cout << ans[i] << endl;
}

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

#define int long long

int ans=0;


int m=1000000007;
  
 

int32_t main()
{
	int h,w;
  cin>>h>>w;
  int dp[h+1][w+1];
  vector<string>v;
  for(int i=0; i<h; i++)
  {
    string t;
    cin>>t;
    v.push_back(t);
  }
  
  /*for(int i=0; i<h; i++)
  
  {
  	cout<<v[i];
  	cout<<"\n";
  }
  
  */
  
  
  int i=0;
  while(i<w&&v[0][i]=='.')
  {
    dp[0][i]=1;
    i++;
  }

  for(i; i<w;i++)
     dp[0][i]=0;
  
  
  i=0;
   while(i<h&&v[i][0]=='.')
  {
    dp[i][0]=1;
    i++;
  }
  for(i; i<h;i++)
     dp[i][0]=0;
     
     
    
  
    for(i=1; i<h; i++)
      for(int j=1; j<w; j++)
      {
        if(v[i][j]=='#')
          dp[i][j]=0;
        else
        {
          dp[i][j]=(dp[i-1][j]%m+dp[i][j-1]%m)%m;
          
        }
      }
  cout<<dp[h-1][w-1]%m;
   /*for(i=0; i<h; i++)
   {    for(int j=0; j<w; j++)
       cout<<dp[i][j]<<" ";
    cout<<"\n";
   }

  */      
  
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int n;
  cin>>n;
  lint result=0;
  cin>>result;
  rep(i,n-1){
    lint a;
    cin>>a;
    result=gcd(result,a);
  }
  cout<<result;
}

Measured memory_bytes: 256
N = list(map(int,list(input())))
give = [""]
oturi = [""]
N.reverse()
N.append(0)
for i in range(len(N)):
    if N[i] > 5 or (N[i] == 5 and N[i+1] >= 5):
        N[i+1] += 1
        oturi .append(str(10-N[i]))
        give.append("0")
    else:
        give.append(str(N[i]))
        oturi.append("0")
give.reverse()
oturi.reverse()
give = ("".join(give))
oturi = ("".join(oturi))
#print(give,oturi)
ans = 0
for i in give:
    ans += int(i)
for i in oturi:
    ans += int(i)

print(ans)

Measured memory_bytes: 101936
from queue import Queue

k = int(input())

#  print(k)

q = Queue()

for i in range(1, 10):
  q.put(i)

ans = 0
for j in range(k):
  ans = q.get()
  f = ans % 10
  n = ans * 10 + f
  
  if f != 0:
    q.put(n-1)
  
  q.put(n)
  
  if f != 9:
    q.put(n+1)
print(ans)

Measured memory_bytes: 57044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n-1; i++){
        cin >> a.at(i+1);
    }

    vector<int> res(n);
    for(int i=1; i<n; i++){
        res.at(a.at(i)-1) ++;
    }
    rep(i,n){
        cout << res.at(i) << endl;
    }
}

Measured memory_bytes: 4828
//
// Z-algorithm
//   res[i] := S[i:] と S[0: ] との最長共通部分列の長さ
//
// verified:
//   ARC 060 F - 最良表現
//     https://atcoder.jp/contests/arc060/tasks/arc060_d
//


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }


vector<int> Zalgo(const string &S) {
    int N = (int)S.size();
    vector<int> res(N);
    res[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k, j -= k;
    }
    return res;
}


vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n%i == 0LL) {
            res.push_back(i);
            long long temp = n/i;
            if (i != temp) res.push_back(temp);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    string str; cin >> str;
    int n = (int)str.size();
    vector<long long> divs = divisor(n);
    long long syuuki = n;
    for (auto d : divs) {
        bool ok = true;
        for (int j = 0; j + d < n; ++j) {
            if (str[j] != str[j+d]) ok = false;
        }
        if (ok) syuuki = min(syuuki, d);
    }
    if (syuuki == n) cout << 1 << endl << 1 << endl;
    else if (syuuki == 1) cout << n << endl << 1 << endl;
    else {
        auto lcp = Zalgo(str);
        string str2 = str;
        reverse(str2.begin(), str2.end());
        auto lcp2 = Zalgo(str2);

        //COUT(lcp);
        
        vector<int> cannot_cut(n*2, 0);
        for (int d = 1; d < n; ++d) {
            if (cannot_cut[d]) continue;
            for (int dd = d*2; dd < n; dd += d) {
                if (lcp[d] >= dd - d) cannot_cut[dd] = true;
                if (lcp2[d] >= dd - d) cannot_cut[n-dd] = true;
            }
        }
        int con = 0;
        for (int i = 1; i < n; ++i) if (!cannot_cut[i]) ++con;
        cout << 2 << endl << con << endl;
    }
}


Measured memory_bytes: 9220
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define ll long long
#define ss second
#define ff first
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define mod 1000000007
#define w(x) ll x; cin>>x; while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define fo(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define re(i, j) fo(i, 0, j, 1)
#define pi 3.1415926535897932384626433832795
#define all(cont) cont.begin(), cont.end()
#define countbit(x) __builtin_popcount(x)
#define mod 1000000007
#define lo lower_bound
#define de(n) ll n;cin>>n;
#define def(a,n) ll n;cin>>n;ll a[n];re(i,n){cin>>a[i];}
#define defi(a,n,k) ll n;cin>>n; ll k;cin>>k;ll a[n];re(i,n){cin>>a[i];}
#define deb(x) cout<<#x<<"="<<x<<endl;
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define nl cout<<endl;
using namespace std;
void cp()
{
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); 
    #ifndef ONLINE_JUDGE  
    freopen("input.txt", "r", stdin);  
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
    //cp();
    //w(x)
    de(a);
    de(b);
    re(i,3)
    {
        if(a==i+1)
        continue;
        else if(b==i+1)
        continue;
        else
        {
            cout<<i+1;
        } 
    }
    return 0;
}

Measured memory_bytes: 3584
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n;
vector<int> a[MAXN];
ll t[MAXN * 8], lazy[MAXN * 8];

void build(int k, int l, int r) {
    if (l > r) return;
    if (l == r) {
        t[k] = 0;
        return;
    }
    int m = (l + r) >> 1;
    build(k*2, l, m);
    build(k*2+1, m+1, r);
    t[k] = t[k*2] + t[k*2+1];
}

void lazyUpdate(int k, int l, int r) {
    if (l > r) return;
    if (lazy[k] == 0) return;
    t[k] += lazy[k] * (r - l + 1);
    if (l < r) {
        lazy[k*2] += lazy[k];
        lazy[k*2+1] += lazy[k];
    }
    lazy[k] = 0;
}

ll get(int k, int l, int r, int u, int v) {
    lazyUpdate(k, l, r);
    if (l > r || r < u || v < l) return -1e18;
    if (u <= l && r <= v) return t[k];
    int m = (l + r) >> 1;
    return get(k*2, l, m, u, v) + get(k*2+1, m+1, r, u, v);
}

void update(int k, int l, int r, int u, int v, int val) {
    lazyUpdate(k, l, r);
    if (l > r || r < u || v < l) return;
    if (u <= l && r <= v) {
        lazy[k] += val;
        lazyUpdate(k, l, r);
        return;
    }
    int m = (l + r) >> 1;
    update(k*2, l, m, u, v, val);
    update(k*2+1, m+1, r, u, v, val);
    t[k] = t[k*2] + t[k*2+1];
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n-1) {
        int u, v;
        cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    build(1,1,n);

    ll res = 0;
    FOR(i,1,n) {
        update(1,1,n,1,i,1);
        FOR(j,0,SZ(a[i])-1) {
            int v = a[i][j];
            if (v < i) update(1,1,n,1,v,-1);
        }
        res += t[1];
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 23156
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static private final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static private final int upper(long v) {return (int)(v >> 32);}
	static private final int lower(long v) {return (int)(v & 0xFFFFFFFF);}

	//-----------------------------------------

	static private final long load(int end, int length) {
		return pair(end, length);
	}
	static private final int end(long load) {
		return upper(load);
	}
	static private final int length(long load) {
		return lower(load);
	}
	static private final long score(int count, int last) {
		return pair(count, last);
	}
	static private final int count(long score) {
		return upper(score);
	}
	static private final int last(long score) {
		return lower(score);
	}

	//------------------------------------------

	public void exec() throws Exception{
		final long a = sc.nextLong();
		final long b = sc.nextLong();
		final long x = sc.nextLong();

		double bl = 0;
		double al = 0;

		if(b*a*a < 2*x) {
			//半分より多いケース
			err.println("H");
			al = a;
			bl=2.0*(1.0*b -(1.0*x)/(1.0*a*a));
		}else {
			//半分より少ないケース
			err.println("L");
			bl = b;
			al = (2.0*x)/(1.0*a*b);
		}
		err.println(al+"/"+bl);
		out.println(Math.toDegrees(Math.atan(bl/al)));

	}
}


Measured memory_bytes: 23508
#include <cstdio>
#include <algorithm>
using namespace std;
int l,n,m;
int d[111111];
int main(void){
  while(1){
    scanf("%d",&l); if(!l) break;
    scanf("%d%d",&n,&m);
    for(int i = 1; i < n; i++){
      scanf("%d",d+i);
    }
    d[0] = 0;
    d[n] = l;
    sort(d,d+n+1);
    int sum = 0;
    for(int i = 0; i < m; i++){
      int k;
      scanf("%d",&k);
      int *p = upper_bound(d,d+n+1,k);
      //printf("p:%d\nk:%d\n",*p,k);
      int ret = 1<<29;
      for(int j = 0; j < 2; j++){
	int a = *(p-j);
	a -= k;
	if(a<0) a=-a;
	a = min(a,l-a);
	ret = min(ret,a);
      }
      sum += ret;
    }
    printf("%d\n",sum);
  }
}

Measured memory_bytes: 1436
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
vector<int> G[MAXN];
int dp[MAXN];
int dfs(int x,int f)
{
	for(int v:G[x])
		if(v != f)
			dfs(v,x);
	
	static int tdp[MAXN];
	dp[x] = 0;
	int cnt = 0;
	for(int v:G[x])
		if(v != f)
			tdp[cnt++] = dp[v];
	sort(tdp,tdp+cnt,greater<int>());
	for(int i=0;i<cnt;i++)
		dp[x] = max(dp[x] , tdp[i]+i+1);
	return dp[x];
}
int main()
{
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	for(int i=2;i<=n;i++) {
		int f;
		cin >> f;
		G[f].push_back(i);
	}
	cout << dfs(1,0) << endl;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define SUM(a) accumulate(all(a),int(0))
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  string s; cin >> s;
  int n = s.size();
  bool f = true;
  rep(i,n){
    if(s[i] == 'U' or s[i] == 'D') continue;
    if(i%2==0 and s[i] == 'R') continue;
    if(i%2==1 and s[i] == 'L') continue;
    f = false;
  }
  if(f) cout << "Yes";
  else cout << "No";
  cout << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<20)
typedef pair<int,int> P;

int N,M;
vector<P> bri[111];

int prim(){
  bool used[111];
  int ans = 0;
  memset(used,false,sizeof(used));
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0,0));
  while(!que.empty()){
    P p = que.top(); que.pop();
    int cost = p.first;
    int now = p.second;
    if(used[now]) continue;
    used[now] = true;
    ans += cost;
    for(int i=0;i<bri[now].size();i++){
      int next = bri[now][i].second;
      int to = bri[now][i].first;
      que.push(P(next,to));
    }
  }
  return ans;
}

int main(){
  while(cin >> N >> M ,N){
    for(int j=0;j<M;j++){
      int a,b,c;
      cin >> a >> b >> c;
      bri[a].push_back(P(b,c));
      bri[b].push_back(P(a,c));
    }
    cout << prim() << endl;
    for(int i=0;i<111;i++){
      bri[i].clear();
    }
  }
}

Measured memory_bytes: 1204
#include "bits/stdc++.h"
using namespace std;
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define pb push_back
#define nl cout << "\n"
#define endl "\n"
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c.size())
#define mp make_pair
#define mt make_tuple
#define get(x,c) get<x>(c)
#define trav(a,x) for(auto a=x.begin() ; a!=x.end() ; a++)
#define rep(i,n) for(int i=0 ; i<n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pll>
#define f first
#define s second

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x,ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x,ll ex ,ll md) {ll ans = 1ll;while(ex > 0){if(ex & 1ll) ans = (ans*x)%md; ex >>= 1ll;x=(x*x)%md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e5 + 11;
ll l , r , d;
void solve(){
    cin>>l>>r>>d;
    vll a;
    for(ll i =d ; i<=r ; i+=d) a.pb(i);
    sort(all(a));
    ll ans = 0;
    rep(i ,sz(a)){
        if(a[i] >= l && a[i] <= r) ans++;
    }
    cout << ans << endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC = 1;
    // cin >> NTC;
    ll PTC = 0;
    while(PTC++ < NTC){
        // cout << "Case #" << PTC << ":" << ' ';
        solve();
        cout << "\n";
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,ans;
int main(){
    scanf("%lld %lld %lld",&a,&b,&c);
    if(c>a+b) ans=a+b+b+1;
    else ans=b+c;
    printf("%lld",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#define P pair<int, bool>


using namespace std;
const long long int MOD=1e9+7;
int n, q, ruiseki[27][500009];

int main(){
  string s;
  vector<P> v[27];
  cin >> n >> s >> q;
  for(int i=0;i<26;i++){
    ruiseki[i][0] = 0;
    for(int j=0;j<n;j++){
      ruiseki[i][j+1] = ruiseki[i][j];
      if(s[j] == 'a'+i){
        ruiseki[i][j+1]++;
      }
    }
  }
  for(int i=0;i<q;i++){
    int type;
    cin >> type;
    if(type==1){
      int iq;
      char cq;
      cin >> iq >> cq;
      v[s[iq-1]-'a'].push_back(P(iq, false));
      v[cq-'a'].push_back(P(iq, true));
      s[iq-1] = cq;
    }
    else if(type==2){
      int ret=0, iq, cq;
      cin >> iq >> cq;
      for(int j=0;j<26;j++){
        int check=0;
        check+=ruiseki[j][cq] - ruiseki[j][iq-1];
        for(int k=0;k<v[j].size();k++){
          if(iq <= v[j][k].first && v[j][k].first<=cq){
            if(v[j][k].second)check++;
            else check--;
          }
        }
        if(check>0)ret++;
      }
      cout << ret << endl;
    }
  }
}


Measured memory_bytes: 52356
#include "bits/stdc++.h"

using namespace std;

typedef long long LL;
typedef long double LD;



int main()
{
  string S;
  cin >> S;

  string K = "";
  string G = "";
  bool flag = true;
  for (LL i = 0; i < S.length(); ++i) {
    if (((i + 1) % 2) == 1) {
      if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {

      }
      else {
        flag = false;
        break;
      }
    }
    else {
      if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {

      }
      else {
        flag = false;
        break;
      }
    }
  }

  if (flag) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }

  return 0;
}






Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_C&lang=jp
#include<bits/stdc++.h>
using namespace std;
int a,b;
string op;
int main(void){
  while(cin>>a>>op>>b){
    if(op=="?")break;
    if(op=="+")cout<<a+b<<endl;
    else if(op=="-")cout<<a-b<<endl;
    else if(op=="*")cout<<a*b<<endl;
    else if(op=="/")cout<<a/b<<endl;
  }

  return 0;
}



Measured memory_bytes: 3104
from itertools import product

N = int(input())
*V, = map(int, input().split())
*C, = map(int, input().split())

ans = -10**18
for p in product([0, 1], repeat=N):
    res = 0
    for i, e in enumerate(p):
        if e:
            res += V[i] - C[i]
    ans = max(ans, res)
print(ans)

Measured memory_bytes: 42092
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int n, T[5001], dp[5001];
	while(cin >> n, n)
	{
		for(int i = 0; i < n; i++)
		{
			cin >> T[i];
		}

		memset(dp, -1, sizeof(dp));

		dp[0] = T[0];

		for(int i = 1; i < n; i++)
		{
			dp[i] = max(dp[i-1] + T[i], T[i]);
		}

		int res = -10000000;
		
		for(int i = 0; i < n; i++)
		{
			res = max(res, dp[i]);
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 1200
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


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

struct Node *root, *NIL;

void insert(int k){
struct  Node *y=NIL;
struct  Node *x=root;
struct  Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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


void inorder(struct Node *u){
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}


void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n,i,x;
  char *com;
  char *pri="print";
  char *ins="insert";

  com = (char *)malloc(7*sizeof(char));
   

   scanf("%d",&n);
  

  for(i=0;i<n;i++){
     scanf("%s",com);
     if(strncmp(com,ins,6)==0){
       scanf("%d",&x);
       insert(x);
     }
     else if(strncmp(com,pri,5)==0){
       inorder(root);
       printf("\n");
       preorder(root);
       printf("\n");
     }
  }

  return 0;
}





Measured memory_bytes: 25128
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

vector<int>E[660];
vector<int>Er[660];
double dp[660],p[660];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		E[s].pb(t);
		Er[t].pb(s);
	}


	for (int i = N - 2; i >= 0; i--) {
		int sz = E[i].size();
		fore(x, E[i]) {
			dp[i] += (dp[x] + 1.0);
		}
		dp[i] /= (double)sz;
	}

	p[0] = 1.0;
	for (int i = 1; i < N; i++) {
		fore(x, Er[i])p[i] += p[x] / (double)(E[x].size());
	}

	double ans = dp[0];
	for (int i = 0; i < N - 1; i++) {
		if (E[i].size() >= 2) {
			fore(x, E[i]) {
				double sz = E[i].size();
				double diff = dp[i] - (sz*dp[i] - (dp[x] + 1)) / (sz - 1);
				ans = min(ans, dp[0] - p[i] * diff);
			}
		}
	}
	cout << setprecision(20) << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
def resolve():
    n = int(input())
    s = [int(input()) for i in range(n)]
    s = sorted(s)
    total = sum(s)
    i = 0
    while total % 10 == 0 and i < n:
        if (s[i] % 10) != 0:
            total -= s[i]
        i += 1
    if total % 10 == 0:
        print(0)
    else:
        print(total)
resolve()

Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x) {
    S[++top] = x;
}

int pop() {
    top--;
    return S[top+1];
}

int main(void) {
    int a, b;
    top = 0;
    char s[100];

    while(scanf("%s", s) != EOF) {
        if(s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        } else if(s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if(s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }

    printf("%d\n", pop());

    return 0;
}

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

int main(){
   int N, X;
   cin >> N >> X;
   vector<int> L(N+1);
   for (int i=1; i<N+1; i++)
      cin >> L.at(i);

   vector<int> D(N+2);
   D.at(1) = 0;
   for (int i=2; i<N+2; i++)
      D.at(i) = D.at(i-1) + L.at(i-1);

   int cnt = N+1;
   for (int i=1; i<N+2; i++)
      if (D.at(i) > X) {
         cnt = i-1;
         break;
      }

   cout << cnt << endl;
}



Measured memory_bytes: 256
/*  ex6_2
    hangan2020 */

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

int main(void){
    char eng_str[IS] = {};
    int len, inbetween_no;

    fgets(eng_str, IS, stdin);
    len = strlen(eng_str);
    //printf("%d\n", len);
    inbetween_no = len - 3; // Length include null at the end of string
    //printf("%d\n", inbetween_no);
    printf("%c%d%c\n", eng_str[0], inbetween_no, eng_str[len - 2]);

    return 0;
}

Measured memory_bytes: 128
import sys

x,n=map(int,input().split())

if n==0:
  print(x)
  sys.exit()

p=list(map(int,input().split()))


cnt=1
a=0
b=0

for i in range(101):
  #print(x-i)
  #print(x+i)
  if (x-i) not in p:
    print(x-i)
    break

  if (x+i) not in p:
    print(x+i)
    break


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

int main() {
	int a,b;
	char s[11];
	bool c = false;
	cin >> a >> b;
	cin >> s;
	if (s[a] == '-' && s[a + b + 1] == NULL) {
		s[a] = '0';
		for (int i = 0; i < a+b+1; i++) {
			if (s[i] >= '0' && s[i] <= '9') {
				c = true;
			}
			else {
				c = false;
				break;
			}
		}
	}
	if (c==true) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    int L, N;
    cin >> L >> N;
    cout << N << endl;
    rep(i, N) {
        int X, W;
        cin >> X >> W;
        cout << -X << " " << W << endl;
    }
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int can = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'R') can++;
        else{
            ans = max(ans,can);
            can = 0;
        }
    }
    ans = max(ans,can);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
  
using namespace std;
  
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
  
int a,b;
while(cin>>a && cin>>b){

if(a==0 && b==0) break;


if(a>=b) cout<<b<<" "<<a<<endl;
else cout<<a<<" "<<b<<endl;

}
  
return 0;
  
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
long long n,m,p,ans=1;
int main()
{
	cin>>n>>m;
	if(n==0||m==0)
	cout<<"Zero"<<endl;
	if(n>0&&m>0)
	cout<<"Positive"<<endl;
	else if(n>0&&m<0)cout<<"Zero"<<endl;
	else if(n<0&&m>0)cout<<"Zero"<<endl;
	else if(n<0&&m<0)
	{
		if((n-m)%2==0)
		cout<<"Negative"<<endl;
		else cout<<"Positive"<<endl;
	}
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a[i];
  }
  
  int sum = 0;
  for (int i=0; i<N; i++) {
    sum += a[i];
  }
  
  cout << sum - N << endl;  
  
}

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

using namespace std;

int main(){
    string s, t;
    cin >> s;
    char temp;
    
    if(s.length() == 3){
        for(int i = 0; i < s.length()/2; i++){
        temp = s[i];
        s[i] = s[s.length()-1-i]; 
        s[s.length()-1-i] = temp;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 1005, MOD = 1000000007;
typedef long long i64;

class Matrix {
public:
  i64 num[5][5];
  int n, m;
  Matrix(int _n = 0, int _m = 0) {
    n = _n, m = _m;
    memset(num, 0, sizeof num);
  }
  inline friend Matrix operator * (const Matrix &a, const Matrix &b) {
    Matrix c = Matrix(a.n, b.m);
    for (int i = 0; i < a.n; ++i)
      for (int j = 0; j < b.m; ++j)
	for (int k = 0; k < a.m; ++k)
	  c.num[i][j] = (c.num[i][j] + a.num[i][k] * b.num[k][j] % MOD) % MOD;
    return c;
  }
} R, T;

int H, W, tot;
char S[MAX_N][MAX_N];
i64 K;

int main() {
  scanf("%d%d%lld", &H, &W, &K);
  K--;
  if (K == -1) {
    puts("1");
    return 0;
  }
  
  for (int i = 1; i <= H; ++i) {
    scanf("%s", S[i] + 1);
    for (int j = 1; j <= W; ++j) tot += S[i][j] == '#';
  }
  
  int horizon = 0, vertical = 0;
  for (int i = 1; i <= H; ++i)
    if (S[i][1] == '#' && S[i][W] == '#') {
      horizon++;
    }
  for (int i = 1; i <= W; ++i)
    if (S[1][i] == '#' && S[H][i] == '#') {
      vertical++;
    }
  
  if (vertical && horizon) {
    puts("1");
  } else if (!vertical && !horizon) {
    i64 result = 1;
    for (i64 x = tot; K; K >>= 1, x = x * x % MOD)
      if (K & 1) result = result * x % MOD;
    printf("%lld\n", result);
  } else {
    if (horizon) {
      for (int i = 1; i <= H; ++i)
    	for (int j = i <= W ? i + 1 : 1; j <= W; ++j)
    	  swap(S[i][j], S[j][i]);
      swap(H, W), swap(horizon, vertical);
    }

    int temp = 0;
    for (int i = 1; i <= W; ++i)
      for (int j = 2; j <= H; ++j)
    	if (S[j][i] == '#' && S[j - 1][i] == '#') temp++;
    Matrix R = Matrix(1, 2), T = Matrix(2, 2);
    R.num[0][0] = R.num[0][1] = 1;
    T.num[0][1] = -temp, T.num[1][1] = tot, T.num[0][0] = vertical;
    for (; K; K >>= 1, T = T * T)
      if (K & 1) R = R * T;
    printf("%lld\n", (R.num[0][1] + MOD) % MOD);
  }
  
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int c[10][10];

void warshall_floyd() {
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    return;
}

int main(){
    int H, W;
    cin >> H >> W;
    
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }

    warshall_floyd();

    int sum = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int A;
            cin >> A;
            if (A != -1) sum += c[A][1];
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
A,B,K = map(int,input().split())
turn = 0
for i in range(K) :
    if turn == 0 :
        if A % 2 != 0 :
            A -= 1
        p = A // 2
        A -= p
        B += p
        turn = 1
    else :
        if B % 2 != 0 :
            B -= 1
        q = B // 2
        B -= q
        A += q
        turn = 0
print(A,B)
    

Measured memory_bytes: 3060
import sys

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

global ll
ll=['a','b','c','d','e','f','g','h','i','j']

def mm(sl, i, m):
	if len(sl)==i:
		print(''.join(sl))
		return
	for j in range(m+1):
		sl[i]=ll[j]
		mm(sl, i+1, m)
	sl[i]=ll[m+1]
	mm(sl, i+1, m+1)
	

def main():
	n = int(input())
	sl=['a']*n
	mm(sl, 1, 0)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main() {
  //vector<int> b(101);
  //b.at(0)=1;
  int N, M;
  int i;
  cin >> N >> M;
  vector<pair<long int, long int>> drink(N);
  for (i=0; i<N; i++) {
    cin >> drink.at(i).first >> drink.at(i).second;
  }
  sort(
    drink.begin(), 
    drink.end(), 
    [](const pair<int, int>& x, const pair<int, int>& y) 
    {return x.first < y.first;}
  );
  int m=0;
  long int S=0;
  i=0;
  while (m<M) {
    m += drink.at(i).second;
    S += drink.at(i).first * drink.at(i).second;
    //cout << m << ":" << S << ":" << drink.at(i).first << ":" << drink.at(i).second << endl;//////////////////
    i++;
  }
  S -= drink.at(i-1).first * (m-M);
  cout << S << endl;
  return 0;
}


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

n, m = map(int, input().split())
city = []
for i in range(m):
    p, y = map(int, input().split())
    city.append((p, y, i))
city.sort(key=lambda x: x[1])
city.sort(key=lambda x: x[0])

ans = [''] * m
p_prev = 0
k = 1
for j in range(m):
    p, y, i = city[j]
    ans[i] += '0' * (6 - len(str(p))) + str(p)
    if p == p_prev:
        k += 1
    else:
        k = 1
        p_prev = p
    ans[i] += '0' * (6 - len(str(k))) + str(k)

for i in range(m):
    print(ans[i])

Measured memory_bytes: 73308