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

using namespace std;

#define int long long

int pow_exp(int a,int b,int n)
{
    a%=n;
    int result=1;
    while(b>0)
    {
        if(b&1)
            result=result*a%n;
        a=a*a%n;
        b>>=1;
    }
return result;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int n;
    cin>>n;
    int mod=1e9+7;
    int a1=pow_exp(10,n,mod);
    int a2=pow_exp(8,n,mod);
    int a3=pow_exp(9,n,mod)*2;
    int a4=(a3%mod-a2%mod+mod)%mod;
    int ans=(a1%mod-a4%mod+mod)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,m; cin >> n >> m;
  //vector<int> t(n,0);
  vector<vector<int>> v(m);
  for(int i=0;i<m;i++){
    int k; cin >> k;
    for(int j=0;j<k;j++){
      int s; cin >> s;
      v[i].push_back(s);
    }
  }
  vector<int> p;
  for(int i=0;i<m;i++){
    int x; cin >> x;
    p.push_back(x);
  }
  
  int ans = 0;
  for(int bit=0;bit<(1<<n);bit++){
    vector<int> sw(n,0);
    for(int i=0;i<n;i++){
      if(bit & (1<<i)) sw[i] = 1;
    }
    bool flag = true;
    for(int i=0;i<m;i++){
      int cnt = 0;
      for(auto c:v[i]){
        if(sw[c-1]) cnt++;
      }
      if((cnt-p[i])%2!=0) flag = false;
    }
    if(flag) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e3+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  

 void solve() {
  	  int n,k;
  	  cin>>n>>k;
  	  set<int> st;
  	  
  	  while(k--) {
		   int d;
		     cin>>d;
		     rep(i,0,d) {
				   int x;
				   cin>>x;
				   st.insert(x);
				 }
		  }
		  cout<<n-sz(st)<<endl;
  	  
						   
 }

    
int32_t main() {
	cool;
	int t=1;

	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
   int n, reverse = 0, t;
   scanf("%d", &n);

   t = n;

   while (t != 0)
   {
      reverse = reverse * 10;
      reverse = reverse + t%10;
      t = t/10;
   }

   if (n == reverse)
      printf("Yes");
   else
      printf("No");

   return 0;
}






Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int a[3],n,i,j,k,work;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[0]);
    scanf("%d",&a[1]);
    scanf("%d",&a[2]);
    for(j=0;j<3;j++){
      for(k=0;k<2;k++){
	if(a[k]>a[k+1]){
	  work=a[k];
	  a[k]=a[k+1];
	  a[k+1]=work;
	}
      }
    }
    if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]) printf("YES\n");
    else printf("NO\n");
  }
  return(0);
}

Measured memory_bytes: 580
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	int num[200000] = {};
	for (int i = 0; i < N; i++)cin >> num[i];
	if (N % 2) {
		for (int i = N - 1; i >= 0; i -= 2)cout << num[i] << " ";
		for (int i = 1; i < N; i += 2)cout << num[i] << " ";
		cout << endl;
		return 0;
	}
	for (int i = N - 1; i >= 0; i -= 2)cout << num[i] << " ";
	for (int i = 0; i < N; i += 2)cout << num[i] << " ";
	cout << endl;
	return 0;
}

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

ll MOD = 1000000007;

int main()
{
  string s;
  cin >> s;
  int n = s.size(), d = 13;
  vector<vector<ll>> dp(n+1, vector<ll>(d));
  //vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(d, vector<int>(2, 0)));
  
  dp[0][0] = 1;
  rep(i, n) rep(j, d)
  {
    if(s[i] != '?')
    {
      int c = s[i]-'0';
      int ni = i+1, nj = (j*10+c)%d;
      dp[ni][nj] = (dp[ni][nj]+dp[i][j])%MOD;
    }
    else
    {
      rep(k, 10)
      {
        int ni = i+1, nj = (j*10+k)%d;
        dp[ni][nj] = (dp[ni][nj]+dp[i][j])%MOD;
      }
    }
  }
  cout << dp[n][5] << endl;
  
  return 0;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define X first
#define Y second
#define pb push_back
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define vi vector<int>
#define vii vector<vector<int>>

struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};
int32_t main(){ fast;
	int n, q; cin>>n>>q;
	dsu a(n);
	while(q--){
		int t, u, v; cin>>t>>u>>v;
		if(t==0){
			a.merge(u, v);
		}
		else{
			if(a.same(u, v)){
				puts("1");
			}
			else puts("0");
		}
	}
}


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

class Graph{
	private:
	int n;
	vvp g;
	public:
	int DIJ(int s,int t){
		priority_queue<P> q;
		vi d(n,inf);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			P p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i.first,D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d[t];
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
		g[t].push_back({s,c});
	}
};

int h,w;
vs a;

int main(){
	cin>>h>>w;
	a=vs(h);
	Graph g(h*w);
	int t=0;
	for(int i=0;i<h;i++) cin>>a[i];
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(a[i][j]=='.'){
		t++;
		for(int k=0;k<4;k++){
			int x=i+dx[k],y=j+dy[k];
			if(0<=x&&x<h&&0<=y&&y<w&&a[x][y]=='.') g.add_edge(i*w+j,x*w+y,1);
		}
	}
	int d=g.DIJ(0,h*w-1);
	if(d==inf) cout<<-1<<endl;
	else cout<<t-d-1<<endl;
}

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

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

  if (isupper(a))
    cout << 'A' << endl;
  else
    cout << 'a' << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define ia(n, a) rp(ia_i, 0, n) cin >> a[ia_i]
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    string n;
    cin >> n;
    string s[10] = {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};
    ce(s[n[n.size() - 1] - '0']);
}

Measured memory_bytes: 3596
#include <stdio.h>

int main()
{
    int n;
    int i;
    int max;
    int tmp;
    int answer=1;
    scanf("%d",&n);
    scanf("%d",&max);
    for(i = 0; i < n-1; i++)
      {
        scanf("%d",&tmp);
        if (tmp >= max) {
            answer = answer +1;
            max = tmp;
        }
      }
    printf("%d\n",answer);
    return 0;
}

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

vector<int> struct_sum(int H, int W, int h, int w)
{
  vector<int> s(W+1, 0), a(W);
  for (int xt = W; xt > W - w; --xt) {
    if (xt % w == 0) {
      for (int x = w; x < W; x += w) {
        s[x] = s[x-w] - 1;
      }
    } else {
      s[xt] = 1;
      for (int x = xt - w; x > 0; x -= w) {
        s[x] = s[x+w] + 1;
      }
    }
  }

  for (int i = 0; i < W; ++i) {
    a[i] = s[i+1] - s[i];
  }
  return a;
}

int main(int argc, char *argv[])
{
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  if (H % h == 0 && W % w == 0) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  bool r = false;
  if (W % w == 0) {
    r = true;
    int t;
    t = H; H = W; W = t;
    t = h; h = w; w = t;
  }

  vector<int> a = struct_sum(H,W,h,w);

  if (r) {
    for (vector<int>::iterator it = a.begin(); it != a.end(); ++it) {
      for (int x = 0; x < H /* ==W */; ++x) {
        if (x > 0) cout << " ";
        cout << *it;
      }
      cout << endl;
    }
    return 0;
  }

  for (int y = 0; y < H; ++y) {
    for (vector<int>::iterator it = a.begin(); it != a.end(); ++it) {
      if (it != a.begin()) cout << " ";
      cout << *it;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {

    public static void main(String[] args) {
        exec();
    }

    static void exec() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);

        int sum = 0;
        for (int i = 0; i < k; i++) {
            sum += a[i];
        }

        System.out.println(sum);
    }
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;

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

  ll cur = 1;
  REP(i, n){
    if(cur == a[i])
      cur++;
  }

  if(cur == 1)
    cout << -1 << endl;
  else
    cout << n-(cur-1) << endl;
}


Measured memory_bytes: 1792
#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 ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    vector<vi> a(3, vi(3));
    rep(i, 3) rep(j, 3) cin >> a[i][j];
    int n;
    cin >> n;
    vi b(n);
    rep(i, n) cin >> b[i];
    vector<vector<bool>> v(3, vector<bool>(3));
    rep(i, 3) rep(j, 3) rep(k, n) if(a[i][j] == b[k]) v[i][j] = true;
    bool f = false;
    rep(i, 3) {
        bool t = true;
        rep(j, 3) t &= v[i][j];
        f |= t;
    }
    rep(j, 3) {
        bool t = true;
        rep(i, 3) t &= v[i][j];
        f |= t;
    }
    f |= (v[0][0] & v[1][1] & v[2][2]);
    f |= (v[0][2] & v[1][1] & v[2][0]);
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}

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

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int n = 0;
	long long ans = 1;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif

	for(int i = 1; i <= n; i++){
		ans *= i;
	}

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


Measured memory_bytes: 3056
#include<bits/stdc++.h>
#define szxb 200010
#define F(a,b,c,d,e) for(register int (a)(b);((e)?((a)<=(c)):((a)>=(c)));(a)+=(d))
using namespace std;
int n,a[szxb];
inline void print(int x){putchar(32),printf("%d",x);return;}
signed main()
{
    scanf("%d",&n);
    F(i,1,n,1,1){scanf("%d",&a[i]);}printf("%d",a[n]);
    F(i,(n-2),1,-2,0){print(a[i]);}F(i,(1+(n&1)),n,2,1){print(a[i]);}
    return putchar(10),0;
}

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

int main() {
    int l, r, d;
    cin >> l >> r >> d;

    int ans = r / d - l / d;
    if (l % d == 0) ans++;

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

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



int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> x(N), y(N);
    // (x[i], y[i]) を黒に塗るという条件にデータを変形
    for( int i = 0; i < N; ++i ){
        char c;
        cin >> x[i] >> y[i] >> c;
        if( c == 'W' ) y[i] += K;
        x[i] %= 2*K, ++x[i];  // 多次元累積和を取るために 1-index にする
        y[i] %= 2*K, ++y[i];
    }


    // 市松模様を黒い部分の左下で特徴付ける
    // 全ての i について、(x[i], y[i]) を黒として含むような塗り方の K*K 通りのマスを
    // +1 すると、その最大値が答えになる
    // 高速化するために、2次元累積和を用いる
    int numBlack[2001][2001] = {};  // 2K * 2K で考えても良いが、4K * 4K にすると
                                    // 累積和を2回計算するだけで良くなり楽になる  

    // 2次元累積和 
    for( int i = 0; i < N; ++i ) numBlack[x[i]][y[i]] += 1;
    for( int i = 1; i <= 2*K; ++i ){
        for( int j = 1; j <= 2*K; ++j ){
            numBlack[i][j] += numBlack[i][j-1];
        }
    }
    for( int i = 1; i <= 2*K; ++i ){
        for( int j = 1; j <= 2*K; ++j ){
            numBlack[i][j] += numBlack[i-1][j];
        }
    }

    // 最大値の探索
    int ans = 0;
    for( int i = 0; i <= K; ++i ){
        for( int j = 0; j <= K; ++j ){
            int a = numBlack[i][j];
            int b = numBlack[i][j] - numBlack[i+K][j] - numBlack[i][j+K] + numBlack[i+K][j+K];
            int c = numBlack[2*K][j] - numBlack[i+K][j];
            int d = numBlack[i][2*K] - numBlack[i][j+K];
            int e = numBlack[i+K][j+K] - numBlack[2*K][j+K] - numBlack[i+K][2*K] + numBlack[2*K][2*K];
            int tmp = a+b+c+d+e;
            ans = max( ans, max(tmp, N-tmp) );
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//オーバーフローに注意 long long　にする
//'1'+=16;      で大文字Aに
//'大文字'+=32;  で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,w,d,mod;
int sum[400040];
int check[2222];
vector<pair<int,int> >a;
main(){
    cin>>n>>w>>d;
    mod=2*(d+w);
    for(int i=0;i<n;i++)
    {
        int x,y;char f;cin>>x>>y>>f;
        if(f=='E')
        {
            a.push_back(make_pair(d+x+y,(mod-x-d+y)%mod));
        }
        else if(f=='W')a.push_back(make_pair((mod-x+d-y)%mod,(mod+d+x-y)%mod));
        else if(f=='N')a.push_back(make_pair((mod-x-d+y)%mod,(mod-x+d-y)%mod));
        else a.push_back(make_pair(d+x-y,d+x+y));
        check[i*2]=a[i].first;
        check[i*2+1]=a[i].second;
    }
    int ans=1e9;
    for(int index=0;index<2*n;index++)
    {
        int id=check[index];
        vector<pair<int,int> >m;
        int now=1;
        for(int i=0;i<n;i++)
        {
            bool inc=0;
            if(a[i].first<=id&&id<=a[i].second)inc=1;
            else if(a[i].first>a[i].second&&(id<=a[i].second||id>=a[i].first))inc=1;
            if(!inc)
            {
                m.push_back(make_pair((a[i].second+mod-id)%mod,(a[i].first+mod-id)%mod));
            }
        }
        sort(m.begin(),m.end());
        int p=-114514;
        for(int i=0;i<m.size();i++)
        {
            if(m[i].second>p)
            {
                now++;
                p=m[i].first;
            }
        }
        ans=min(ans,now);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		long h=sc.nextLong();
		long c=0;
		long i=0;
		while(h>0) {
			h/=2;
			if(c==0) {
				c=1;
				i++;
			}else {
				i = i*2;
				c += i;
			}
		}
		System.out.println(c);
		sc.close();
	}
}


Measured memory_bytes: 23892
#include<stdio.h>

void insertionSort(int *A, int N)
{
    int v, j;
    for(int i = 0; i < N; i++)
    {
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v)
        {
            A[j+1] = A[j];
            j--;
            A[j+1] = v;
        }
        for(int k = 0; k < N; k++){
            printf("%d", A[k]);
            if(k != N-1){
                printf(" ");
            }
        }
        printf("\n");
    }
}

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



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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    cout << min(A,B) + min(C,D) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef long long ll;

ll d;
ll c[29];
ll a[369][29];
ll t[369];
ll b[29];
ll b2[29];
ll now[369];

int main()
{
    srand(time(NULL));
    scanf("%lld", &d);
    for(ll i = 1; i <= 26; i++)
    {
        scanf("%lld", &c[i]);
    }
    for(ll i = 1; i <= d; i++)
    {
        for(ll j = 1; j <= 26; j++)
        {
            scanf("%lld", &a[i][j]);
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= d; i++)
    {
        ll mx = -4e18, mi = 0;
        for(ll ii = 1; ii <= 26; ii++)
        {
            t[i] = ii;
            ll ans2 = 0;
            ll tt = b[t[i]];
            b[t[i]] = i;
            for(ll j = 1; j <= 26; j++)
            {
                ans2 -= (i - b[j]) * c[j];
            }
            ans2 += a[i][t[i]];
            if(mx < ans2) mx = ans2, mi = ii;
            b[t[i]] = tt;
        }
        t[i] = mi;
        b[t[i]] = i;
        for(ll j = 1; j <= 26; j++)
        {
            ans -= (i - b[j]) * c[j];
        }
        ans += a[i][t[i]];
        now[i] = mi;
    }
    ll k = 1000;
    while(k--)
    {
        ll x = rand() % 26 + 1;
        ll y = rand() % d + 1;
        ll ans2 = 0;
        ll t2 = now[y];
        now[y] = x;
        for(ll i = 1; i <= d; i++)
        {
            b[now[i]] = i;
            for(ll j = 1; j <= 26; j++)
            {
                ans2 -= (i - b2[j]) * c[j];
            }
            ans2 += a[i][now[i]];
        }
        if(ans2 < ans) now[y] = t2;
        else ans = ans2;
    }
    for(ll i = 1; i <= d; i++) printf("%lld\n", now[i]);
    return 0;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> T keta(T num){ T k=0; while(num>0){ num/=10; k++; } return k; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n, x;
    ll a[100010];
    cin >> n >> x;
    rep(i, n){
        cin >> a[i];
    }

    ll res = 0;
    if(a[0] > x){
        res += a[0]-x;
        a[0] = x;
    }

    reps(i, 1, n-1){
        if(a[i] + a[i-1] > x){
            res += a[i] + a[i-1] - x;
            a[i] = x - a[i-1];
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int num = stdin.nextInt();
		int[] x = new int[num + 2];
		int allCost = 0;
		int prev = 0;
		for (int i = 1; i <= num; i++) {
			x[i] = stdin.nextInt();
			allCost += Math.abs(x[i] - prev);
			prev = x[i];
		}
		allCost += Math.abs(prev);

		for (int i = 1; i <= num; i++) {
			int cost = allCost - Math.abs(x[i] - x[i - 1]) - Math.abs(x[i + 1] - x[i]) + Math.abs(x[i + 1] - x[i - 1]);
			System.out.println(cost);
		}
	}

}


Measured memory_bytes: 68580
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let a: usize = read!();
    let b: usize = read!();

    let max = a.min(b);
    let min = (a - a.min(n - b)).min(b - b.min(n - a));

    println!("{} {}", max, min);
}


Measured memory_bytes: 2112
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

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

    long long dp[2][L.length() + 1];
    dp[0][0] = 0;
    dp[1][0] = 1;

    for (int i = 0; i < L.length(); i++) {
        if (L[i] == '0') {
            dp[0][i + 1] = 3 * dp[0][i] % MOD;
            dp[1][i + 1] = dp[1][i] % MOD;
        } else {
            dp[0][i + 1] = (3 * dp[0][i] % MOD + dp[1][i]) % MOD;
            dp[1][i + 1] = 2 * dp[1][i] % MOD;
        }
    }

    cout << (dp[0][L.length()] + dp[1][L.length()]) % MOD << endl;

    return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<list>
#include<algorithm>
using namespace std;

#define NMAX 2000000+10

int main(int argc,char* argv[]){
  std::ios_base::sync_with_stdio(false);
  int n,x;
  string inp;
  list<int> data;
  list<int>::iterator iter,fun;

  cin>>n;

  while(n--){
    cin>>inp;

    if(inp[6]=='F') data.pop_front();
    else if(inp[6]=='L') data.pop_back();
    else{
      cin>>x;
      if(inp[0]=='i') data.push_front(x);
      else{
	fun=find(data.begin(),data.end(),x);
	if(fun!=data.end()) data.erase(fun);
      }
    }
  }

  iter=data.begin();
  cout<<*iter++;
  while(iter!=data.end()){
    cout<<" "<<*iter++;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 32464
#include <math.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <ostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _lcint;
#define REP(i, n) for (_lcint i = 0; i < n; i++)
#define FOR(i, a, b) for (_lcint i = (_lcint)(a); i < (_lcint)(b); i++)
#define FORREV(i, a, b) for (_lcint i = (_lcint)(b)-1; i >= (_lcint)(a); i--)
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)  \
  cout << #v << ": "; \
  REP(i, v.size()) cout << " " << v[i] << endl;

#define ALL(a) (a).begin(), (a).end()
#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// permutation
ll mPn(ll m, ll n) {
  ll a = 1;
  REP(i, n) { a *= m - i; }
  return a;
}

// excrametion
ll exc(ll m) {
  ll a = 1;
  FOR(i, 1, m) { a *= i + 1; }
  return a;
}

// combination
ll mCn(ll m, ll n) {
  ll a = 1, b = 1;
  REP(i, n) {
    a *= m - i;
    b *= n - i;
  }
  return a / b;
}

ll eculidean(ll a, ll b) {
  ll c = a % b;
  if (c == 0) {
    return b;
  }
  return eculidean(b, c);
}

int main() {
  int N;
  cin >> N;
  ll A[N];
  ll M = 0;

  REP(i, N) { cin >> A[i]; }

  ll e = A[0];
  FOR(i, 1, N) {
    ll big = max(e, A[i]);
    ll lit = min(e, A[i]);
    e = eculidean(big, lit);
  }

  cout << e << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

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

  vector<ll> a(n);
  vector<ll> justi(n);
  vector<vector<pair<ll,ll>>> calc(n,vector<pair<ll,ll>>(n,make_pair(0,0)));
  rep(i,n){
    cin >> a[i];
    rep(j,a[i]){
      cin >> tmp1 >> tmp2;
      tmp1--;
      calc[i][j] = make_pair(tmp1,tmp2);
    }
  }
  ll ans = 0;
  rep(i,1 << n){
    tmp1 = i;
    ll sum = 0;
    rep(j,n){
      if(tmp1 & 1){
        justi[j] = 1;
        sum++;
      }else{
        justi[j] = 0;
      }
      tmp1 = tmp1 >> 1;
    }
    if(i == 3){
      rep(k,n){
        //cout << justi[k] << " ";
      }
      //cout << endl;
    }
    bool can = true;
    rep(j,n){
      if(justi[j]){
        rep(k,a[j]){
          if(justi[calc[j][k].first] != calc[j][k].second){
            can = false;
            break;
          }
        }
      }else{

      }
    }
    if(can){
      chmax(ans,sum);
    }
  }
  cout << ans << endl;
}


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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;


int main(){
    ll a,b,c;
    std::cin >> a>>b>>c;
    ll k;
    std::cin >> k;
    if(k%2==0)std::cout << a-b << std::endl;
    else std::cout << b-a << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main()
{
  int n;
  string s;
  cin >> n >> s;
  
  vector<int> w(n + 1, 0), b(n + 1, 0);
  for (int i = 0; i < n; i++) {
    if (s[i] == '#') {
      b[i + 1] = b[i] + 1;
      w[i + 1] = w[i];
    } else {
      b[i + 1] = b[i];
      w[i + 1] = w[i]+ 1;
    }
  }
  int res = INT_MAX;
  for (int i = 0; i <= n; i++) {
    int cnt = b[i] - b[0] + w[n] - w[i];
    res = min(res, cnt);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2180
fn main() {
    // N M C
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();

    let mut food = vec![n; m];

    for _ in 0..n {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        let _ = iter.next().unwrap();

        for a in iter {
            food[a.parse::<usize>().unwrap() - 1] -= 1;
        }
    }

    let mut ans = 0;
    for food in food.iter() {
        if *food == 0 {
            ans+=1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
L = []
for m in ["S", "H", "C", "D"]:
    for i in range(1, 14):
        L.append((m, i))
n = int(input())
for i in range(n):
    mark, rank = input().split()
    rank = int(rank)
    L.remove((mark, rank))
for rest in L:
    print(rest[0], rest[1])


Measured memory_bytes: 5596
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

dp = defaultdict(lambda: -float('inf'))
dp[(0, 0, 0)] = 0

for i, a in enumerate(A, start=1):
    j = i // 2
    for x in range(j - 1, j + 2):
        dp[(i, x, 0)] = max(dp[(i - 1, x, 0)], dp[(i - 1, x, 1)])
        dp[(i, x, 1)] = dp[(i - 1, x - 1, 0)] + a

print(max(dp[(N, N // 2, 0)], dp[(N, N // 2, 1)]))

Measured memory_bytes: 300168
import java.util.Scanner;

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

		for(int i = 1; i <= n; i++) {
			if(i % 3 == 0 || Integer.toString(i).indexOf("3") >= 0) {
				System.out.printf(" %d", i);
			}
		}
		System.out.println("");

		scan.close();
	}
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> mine(h+2, vector<char>(w+2, '.'));
  rep(i,h) rep(j,w) cin >> mine[i+1][j+1];
  
  rep(i,h) {
    rep(j,w) {
      if (mine[i+1][j+1] == '#') {
        cout << '#';
        continue;
      }

      int count = 0;
      rep(a,3) rep(b,3) if (mine[i+a][j+b] == '#') count++;
      cout << count;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	double dept=100000;
	int n=Integer.parseInt(input.readLine());
	for(int i=0;i<n;i++)
	    {
		dept=dept*1.05;				
		if((int)(dept%1000)>0)
	    {
		dept=(int)(dept+1000-dept%1000);
	    }
	    }
	
	dept=(int)(dept-dept%1000);
	System.out.println((int)dept);
    }
}

Measured memory_bytes: 16856
n=int(input())
t=[]
for i in range(n-1):
  t.append(list(map(int,input().split())))


for i in range(n):
  s=0
  for j in range(i,n-1):
    s=max(t[j][1],((s-1)//t[j][2]+1)*t[j][2])+t[j][0]
  print(s)

Measured memory_bytes: 9168
a,b,c,d = map(int, input().split())
x=[0]*101
cnt=0
for i in range(a,b+1):
    x[i]=1
for i in range(c,d+1):
    if x[i]==1:
        cnt+=1
if cnt==0:
    print(cnt)
else:
    print(cnt-1)


Measured memory_bytes: 9112
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


int main() {
	string s;
	rep(i, 0, 3) {
		cin >> s;
		cout << (char)(s[0] - ('a' - 'A'));
	}
	cout << endl;


	return 0;
}

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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

int mod(int n) {
	return n % 13;
}

int MOD = (int)1e9 + 7;

int modd(int n) {
	return n % MOD;
}

int dp[(int)1e5 + 3][15];
string s;

int f(int pos, int mm) {

	if(pos == s.size()) {
		return (mm == 5);
	}

	int &ret = dp[pos][mm];
	if(ret != -1)
		return ret;


	ret = 0;
	if(s[pos] != '?') {
		return ret = modd(f(pos + 1, mod(mm * 10 + (s[pos] - '0'))));
	}

	for(int i = 0; i <= 9; i++) {
		ret = modd(ret + f(pos + 1, mod(mm * 10 + i)));
	}
	return ret;
}

signed main () {
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  memset(dp, -1, sizeof dp);

  cin >> s;

  cout << f(0, 0) << endl;
}

Measured memory_bytes: 20048
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	ll x = 0 ;
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		char c ; cin >> c ;
		x += (c=='I'?1:-1) ;
		ans = max(ans,x) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 3652
N,M=map(int,input().split())
B=[list(map(int,input().split())) for i in range(M)]

A=sorted(B,key=lambda x:x[1])

ans=0
removed=-1
for i in range(M):
  if A[i][0] > removed:
    ans+=1
    removed=A[i][1]-1
print(ans)
  

Measured memory_bytes: 29852
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 2019;

ll max_sum = 0;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

ll mypow(ll x, ll n) {
    if (n == 0) return 1;
    if (n%2 == 0) return mypow(((x%mod)*(x%mod))%mod, n/2);
    else return ((x%mod) * mypow(((x%mod)*(x%mod))%mod, (n-1)/2))%mod;
}

int main(){
    ll A, B, N;
    cin >> A >> B >> N;
    ll x;
    if (N >= B) x = B - 1;
    else x = N;
    cout << (ll)(A * ((double)x/(double)B)) << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<char> a[10];
  vector<char> ans;
  a[0].push_back('.');
  a[0].push_back(',');
  a[0].push_back('!');
  a[0].push_back('?');
  a[0].push_back(' ');
  a[1].push_back('a');
  a[1].push_back('b');
  a[1].push_back('c');
  a[2].push_back('d');
  a[2].push_back('e');
  a[2].push_back('f');
  a[3].push_back('g');
  a[3].push_back('h');
  a[3].push_back('i');
  a[4].push_back('j');
  a[4].push_back('k');
  a[4].push_back('l');
  a[5].push_back('m');
  a[5].push_back('n');
  a[5].push_back('o');
  a[6].push_back('p');
  a[6].push_back('q');
  a[6].push_back('r');
  a[6].push_back('s');
  a[7].push_back('t');
  a[7].push_back('u');
  a[7].push_back('v');
  a[8].push_back('w');
  a[8].push_back('x');
  a[8].push_back('y');
  a[8].push_back('z');
  char x;
  int n;
  cin>>n;
  
  scanf("%c",&x);
  int memo=-1,count=-1,z=0;
  for(int i=0;i<n;i++){
    while(1){
      scanf("%c",&x);
      if('0'<=x &&x<='9'){
	z=x-'0';
	if(z!=0){
	  memo=z;
	  count++;
	}
	else{
	  memo--;
	  if(memo==-2){
	    memo=-1;
	    continue;
	  }
	  count%=a[memo].size();
	  cout<<a[memo][count];
	  memo=-1;
	  count=-1;
	}
      }
      else{
	cout<<endl;
      break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3208
#include <iostream>
using namespace std;
int main(){
    int a, b, c,  
        d, e, f,  
        g, h, i;
    cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
    if(a-b!=d-e||d-e!=g-h||a-b!=g-h||
       b-c!=e-f||e-f!=h-i||h-i!=b-c||
       c-a!=f-d||f-d!=i-g||i-g!=c-a||
       a-d!=b-e||b-e!=c-f||c-f!=a-d||
       d-g!=e-h||e-h!=f-i||f-i!=d-g||
       g-a!=h-b||h-b!=i-c||i-c!=g-a||
       a+e+i!=c+d+h||a+e+i!=b+f+g||g+b+f!=c+d+h||
       c+e+g!=f+h+a||c+e+g!=b+d+i||f+h+a!=b+d+i
    ){
        puts("No");
        return 0;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 3604
s=gets.chomp
t=gets.chomp

h = {}

i = 0
while i < s.length
  c = s[i]
  unless h[c]
    h[c] = []
  end
  h[c] << i+1

  i += 1
end

i = 0
j = 0
t.each_char do |c|
  unless h[c]
    p -1
    exit 0
  end

  idx = h[c].bsearch {|x| i < x}
  if idx
    i = idx
  else
    j += 1
    i = h[c][0]
  end
  # p [c,j,i]
end

ret = j*s.length + i
p ret



Measured memory_bytes: 3324
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    // cout << s << "," << t << endl;
    if (s < t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
int n,m,i,j;
scanf("%d %d",&n,&m);
int A[n][m],b[m],c[n];

for(i=0;i<n;i++){
    for(j=0;j<m;j++){
        A[i][j]=0;
        b[j]=0;
        c[i]=0;}
}

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



    for(j=0;j<m;j++){
     scanf("%d",&b[j]);
     }

 for(i=0;i<n;i++){
    for(j=0;j<m;j++){
     c[i]+=A[i][j]*b[j];
     }}



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





return 0;


}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,a[310][310],sum;
bool used[310][310];
signed main(){
	cin>>n;
	rep(i,n){
		rep(j,n){
			cin>>a[i][j];
			sum+=a[i][j];
		}
	}
	rep(i,n){
		rep(j,n){
			if(i==j)continue;
			rep(k,n){
				if(i==k)continue;
				if(j==k)continue;
				if(a[i][j]>a[i][k]+a[k][j]){
					cout<<-1<<endl;
					return 0;
				}
				if(a[i][j]==a[i][k]+a[k][j]&&!used[i][j]){
					sum-=a[i][j];
					used[i][j]=true;
				}
			}
		}
	}
	cout<<sum/2<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

using  ll  = long long;

int main()
{
	string n;
	cin >> n;
	for (char c : n) {
		if (c == '1') {
			cout << 9;
		}
		else {
			cout << 1;
		}
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll h,w;cin>>h>>w;
  vector<vector<char> >a(h,vector<char>(w));
  rep(i,h){
    rep(j,w)cin>>a[i][j];
  }
  ll count=0;
  rep(i,h){
    rep(j,w){
      if(a[i][j]=='#')count++;
    }
  }
  if(count==h+w-1)cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int a[3][3];
    bool ok[3][3];
    int n;
    int b;
    for (int i = 0;i < 3;i++)
    {
        for (int j = 0;j < 3;j++)
        {
            cin >> a[i][j];
            ok[i][j] = false;
        }
    }
    cin >> n;
    for (int ii = 0;ii < n;ii++)
    {
        cin >> b;
        for (int i = 0;i < 3;i++)
        {
            for (int j = 0;j < 3;j++)
            {
                if (b == a[i][j]) ok[i][j] = true;
            }
        }
    }

    bool ans = false;
    if (ok[0][0])
    {
        if(ok[0][1]&&ok[0][2])ans=true;
        if(ok[1][0]&&ok[2][0])ans=true;
        if(ok[1][1]&&ok[2][2])ans=true;
    }
    if (ok[1][0]&&ok[1][1]&&ok[1][2])ans=true;
    if (ok[2][0]&&ok[2][1]&&ok[2][2])ans=true;
    if (ok[0][1]&&ok[1][1]&&ok[2][1])ans=true;
    if (ok[0][2]&&ok[1][2]&&ok[2][2])ans=true;
    if (ok[2][0]&&ok[1][1]&&ok[0][2])ans=true;
    if(ans)cout <<"Yes"<<endl;
    else cout <<"No"<<endl;
}


Measured memory_bytes: 256