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

ll calc(vector<ll> &dp, vector<vector<ll>> &edges, ll vert){
    if(dp[vert] != -1){
        return dp[vert];
    }
    ll max_till_here = 0;
    for(auto i : edges[vert]){
        max_till_here = max(max_till_here, 1 + calc(dp, edges, i));
    }
    return dp[vert] = max_till_here;
}

int main(){
    ll N, M;
    cin>>N>>M;
    vector <vector<ll>> edges(N + 1);
    vector <ll> dp(N + 1, -1);
    for(ll i = 0; i < M; i++){
        ll p, q;
        cin>>p>>q;
        edges[q].push_back(p);
    }
    ll ans = 0;
    
    for(int i = 0; i <= N; i++){
    ans = max(ans, calc(dp, edges, i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12544
from bisect import bisect
N, M = map(int, input().split())
A = sorted([int(i) for i in input().split()])
BC = [[int(i) for i in input().split()] for i in range(M)]
BC = sorted(BC, key=lambda x:-x[1])
ans = 0
offset=0

for b, c in BC:
    i = bisect(A, c, lo=offset)
    i = min(i-offset, b)
    ans += c * i
    offset += i

print(ans+sum(A[offset:]))


Measured memory_bytes: 30968
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            int cur = 1, size = 0;
            for (int i = 0; i < n; i++) {
                if (arr[i] == cur) {
                    cur++;
                    size++;
                }
            }
            pw.println(size == 0 ? -1 : n - size);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main() {
  int N, turn = -1;
  cin >> N;
  int64_t L1 = 2, L2 = 1, lucas = 1;
  for (int i = 1; i < N; i++) {
    turn *= -1;
    if (turn == 1) {
      L1 += L2;
      lucas = L1;
    }
    else {
      L2 += L1;
      lucas = L2;
    }
  }
  cout << lucas << endl;
}

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i<3; i++) {
        if(s[i] == 'R' ) cnt++;
    }

    int ans = 0;

    if(cnt == 3) ans = 3;
    else if(cnt == 2) {
        if(s[1] == 'S') ans = 1;
        else ans = 2;
    }
    else if(cnt == 1) ans = 1;
    else ans = 0;

    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#ifndef M_PI
#define M_PI (3.1415926535897932384626433832795)
#endif
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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

typedef struct _state{
  int ne,pos,time,len,bal;
  bool operator<(const _state&r)const{return len>r.len;};
}state;
int p[41],t[41];

int vis[4][40];

main(){
  int n;
  while(cin>>n,n){
    rep(i,n)cin>>p[i]>>t[i];
    memset(vis,0,sizeof(vis));
    priority_queue<state> Q;
    int ans=INT_MAX/2;

    Q.push((state){0,0,0,0,0});
    while(!Q.empty()){
      state tt=Q.top();Q.pop();
      //cout<<tt.ne<<' '<<tt.time<<' '<<tt.len<<' '<<tt.bal<<endl;
      int ne=tt.ne;
      if(tt.ne==n){
	ans=min(ans,tt.len+tt.pos);
	continue;
      }
      if(vis[tt.bal][tt.ne])continue;
      vis[tt.bal][tt.ne]=1;
      if(tt.bal<=2 && tt.time+abs(p[tt.ne]-tt.pos)*(tt.bal+1)<=t[ne])
	Q.push((state){ne+1,p[ne],t[ne],tt.len+abs(tt.pos-p[ne]),tt.bal+1});

      if(tt.time+tt.pos*(tt.bal+1)+p[ne]<=t[ne])
	Q.push((state){ne+1,p[ne],t[ne],tt.len+tt.pos+p[ne],1});
    }

    if(ans<INT_MAX/2)cout<<"OK "<<ans<<endl;
    else{
      cout<<"NG ";
      int i=0;
      for(;i<n;i++){
	bool ok=false;
	rep(j,4)
	  ok|=vis[j][i];
	if(ok)continue;
	break;
      }
      cout<<i<<endl;
    }
  }
}
	       

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

int f(int x) {
    int cnt = 1;
    for (; x > 0; x--) cnt *= x;
    return cnt;
}

int main() {
    double sum = 0;
    int n; cin >> n;
    vector<vector<int>> p;
    vector<int> x(n), y(n), a(n);
    rep(i, n) cin >> x.at(i) >> y.at(i);

    rep(i, n) a.at(i) = i;

    do {
        p.push_back(a);
    } while (next_permutation(a.begin(), a.end()));

    
    for (int i = 0; i < f(n); i++) {
        for (int j = 0; j < n - 1; j++) {
            sum += sqrt(pow(x.at(p.at(i).at(j)) - x.at(p.at(i).at(j+1)), 2) + pow(y.at(p.at(i).at(j)) - y.at(p.at(i).at(j+1)), 2));
        }
    }
    put(sum / f(n));
}

Measured memory_bytes: 3256
from math import factorial
 
def cmb(n, r):
  return factorial(n) // (factorial(n - r) * factorial(r))


N, K = map(int, input().split())

for i in range(1, K+1):
    try:
        ans = cmb(N - K + 1, i) * cmb(K - 1, i - 1) % (10**9+7)
        print(ans)
    except:
        print(0)

Measured memory_bytes: 3316
/*
長方形の描画
*/

#include<stdio.h>
int main(void){
  int h,w;/*長方形の縦、横*/
  int i,j;/*長方形の縦、横*/

  while(1){
    scanf("%d %d",&h,&w);
    if(h == 0 && w == 0){
      break;
    }
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


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

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;
 
#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define EACH(it, a) for(auto it = (a).begin(); it != (a).end(); ++it)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair

#define INF (1LL << 60)

Int f(VInt v)
{
	int n = SIZE(v);
	if(n == 1) return v[0] == 1 ? 1 : -1;

	Int mn[n], mx[n];
	int i;
	FOR(i, 0, n)
	{
		mn[i] = 1;
		mx[i] = INF;
	}
	mn[0] = mx[0] = 1;
	mn[n - 1] = mx[n - 1] = v[n - 1];
	bool change = true;
	while(change)
	{
		change = false;
		FOR(i, 1, n)
		{
			if(mn[i] < mn[i - 1] - v[i - 1])
			{
				mn[i] = mn[i - 1] - v[i - 1];
				change = true;
			}
			if(mx[i] > 2*(mx[i - 1] - v[i - 1]))
			{
				mx[i] = 2*(mx[i - 1] - v[i - 1]);
				change = true;
			}
		}
		RFOR(i, n, 1)
		{
			if(mn[i - 1] < (mn[i] + 1)/2 + v[i - 1])
			{
				mn[i - 1] = (mn[i] + 1)/2 + v[i - 1];
				change = true;
			}
			if(mx[i - 1] > mx[i] + v[i - 1])
			{
				mx[i - 1] = mx[i] + v[i - 1];
				change = true;
			}
		}
		FOR(i, 0, n) if(mx[i] < mn[i]) return -1;
	}
	Int res = 0;
	FOR(i, 0, n) res += mx[i];
	return res;
}

void SolveTest(int test)
{
	int n;
	cin >> n;
	VInt v(n + 1);
	int i;
	FOR(i, 0, n + 1) cin >> v[i];
	cout << f(v) << endl;
}

int main()
{
	int T, t;
	T = 1;
	FOR(t, 0, T) SolveTest(t);
	return 0;
};

Measured memory_bytes: 5584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
        double max = 0, min = 0;
        double tmp;

        while ( cin >> tmp )
        {
                if ( min == 0 )
                {
                        min = tmp;
                        max = tmp;
                }
                else if ( tmp > max )
                {
                        max = tmp;
                }
                else if ( tmp < min )
                {
                        min = tmp;
                }
        }

        cout << max - min << endl;

        return 0;
}



Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		long c = 0;
		for(int i = 1; i < a; i++){
			c += i;
		}
		System.out.print(c);

	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
int cnt[300005] = {};
int cnt2[300005] = {};
int cnt3[300005] = {};
void solve(long long N, std::vector<long long> A)
{
  rep(i, N) cnt[A[i]]++;
  vector<int> a;
  vector<int> hist;
  rep(i, 300005)
  {
    if (cnt[i])
    {
      cnt2[cnt[i]]++;
    }
  }
  map<lli, lli> m;
  lli sum = 0;
  lli used = 0;
  rep(i, 300005) used += cnt2[i];
  //cout << used << endl;
  rep(i, 300005)
  {
    sum += cnt2[i] * i;
    used -= cnt2[i];
    if (i)
      cnt3[i] = (sum + i * used) / i;
    // sum_i min(i,) * cnt[i]
    //cout << cnt3[i] << endl;
  }
  lli cur = N;
  for (int k = 1; k <= N; k++)
  {
    while (cur >= 0 && cnt3[cur] < k)
      cur--;

    cout << (cur > 0 ? cur : 0) << endl;
  }
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int X, A;
		cin >> X >> A;
		if (X < A) {
			ce(0)
		}
		else {
			ce(10)
		}
    return 0;
}



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

struct coor {
    int x, y;
    coor(const int& y_ = 0, const int& x_ = 0) : y(y_), x(x_) {}
    bool operator==(coor& a) { return x == a.x && y == a.y;}
    bool in(int& H, int&W){
        return 0 <= y && y < H && 0 <= x && x < W; 
    }
};

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

void ClearDist(){
    #define rep(i, N) for(int i = 0; i < N; i++)
    
    const int N = 51;
    rep(a,N)rep(b,N)rep(c,N)rep(d,N) dist[a][b][c][d] = -1;
}

int solve(int W, int H){
    int tx, ty;
    int kx, ky;
    cin >> tx >> ty; tx--, ty--;
    cin >> kx >> ky; kx--, ky--;
    vector<vector<int>> grid(H, vector<int>(W));
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            cin >> grid[h][w];
        }
    }
    
    ClearDist();
    dist[ty][tx][ky][kx] = 0;
    coor taka = coor(ty, tx);
    coor kazu = coor(ky, kx);
    int ans = (taka == kazu ? 0 : 100);
    queue<pair<coor, coor>> que;
    que.push({taka, kazu});
    
    while(!que.empty()){
        tie(taka, kazu) = que.front();
        que.pop();

        for(int i = 0; i < 4; i++){
            coor n_taka = coor(taka.y + dy[i], taka.x + dx[i]);
            coor n_kazu = coor(kazu.y - dy[i], kazu.x - dx[i]);
            
            if(!n_taka.in(H, W) && !n_kazu.in(H, W)) continue;

            if(!n_taka.in(H, W) || grid[n_taka.y][n_taka.x] == 1) n_taka = taka;
            if(!n_kazu.in(H, W) || grid[n_kazu.y][n_kazu.x] == 1) n_kazu = kazu;
            if(n_taka == taka && n_kazu == kazu) continue;

            int& nxt = dist[n_taka.y][n_taka.x][n_kazu.y][n_kazu.x];
            if(nxt != -1) continue;

            nxt = dist[taka.y][taka.x][kazu.y][kazu.x] + 1;
            if(n_taka == n_kazu) ans = min(ans, nxt);
            if(nxt < 100) que.push({n_taka, n_kazu});
        }
        
    }
    
    return ans;
}

int main(){
    int W, H;
    while(cin >> W >> H, W != 0){
        int ans = solve(W, H);
        if(ans >= 100) cout << "NA" << endl;
        else cout << ans << endl;
    }
}


Measured memory_bytes: 30232
/************************* In the name of Allah *************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef string          str;
typedef pair<ll,ll>     pll;

#define F               first
#define S               second
#define pb              push_back
#define sep             ' '
#define endl            '\n'
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MOD = 1e9 + 7,
         INF = 1e18,
         MAXN = 1e5 + 10;

int main(){
    fast_io
    int a, b;
    cin >> a >> b;
    int aa = 1;
    int ans = 0;
    while (aa < b)
    {
        aa += a - 1;
        ans ++;
    }
    cout << ans;
    return 0;
}

/*
 __  __       _         _ _  _____ _           _                __ _
|  \/  |     | |       | (_)/ ____| |         | |              / _(_)
| \  / | __ _| |__   __| |_| (___ | |__   ___ | | _____  _   _| |_ _
| |\/| |/ _` | '_ \ / _` | |\___ \| '_ \ / _ \| |/ / _ \| | | |  _| |
| |  | | (_| | | | | (_| | |____) | | | | (_) |   < (_) | |_| | | | |
|_|  |_|\__,_|_| |_|\__,_|_|_____/|_| |_|\___/|_|\_\___/ \__,_|_| |_|
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    ll n;cin>>n;
    ll sum=0;
    while(n>sum){
        sum+=1000;
    }
    cout<<sum-n<<endl;
    return 0;
}



Measured memory_bytes: 3568
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans = 0

for A in range(A+1):
    for B in range(B+1):
        for C in range(C+1):
            if 500*A + 100*B + 50*C == X:
                ans = ans+1

print(ans)

Measured memory_bytes: 3060
len_lst = input()
val = input()
cos = input()
value = list(map(int, val.split(" ")))
cost = list(map(int, cos.split(" ")))
diff = [value[i] - cost[i] for i in range(int(len_lst))]
plus = [i for i in diff if i>0]
print(sum(plus))

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>

using namespace std;
//debug

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

#define pb push_back

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;



#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()



int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	ll m = *min_element(all(A));
	ll cnt = N - count(all(A), m);
	 cout << ceil((double)(cnt ) / (K - 1)) ;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

      int ans = c-(a-b);
      if(ans<0) {
        System.out.println(0);
      }else {
        System.out.println(ans);
      }
	}
}


Measured memory_bytes: 21844
n = int(input())
a_li = list(map(int, input().split(" ")))
dif = 1000
ave = sum(a_li) / n
for i in range(n):
    if dif > abs(a_li[i] -ave):
        dif = abs(a_li[i] -ave)
        ans = i    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define alpha_size 26


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    
    
    int s, w;
    cin >> s >> w;
    if (w >= s)
      cout << "unsafe" << endl;  
    else
      cout << "safe" << endl;  
   
}


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

int main(){
    char token[100]={};
    unsigned long long h=0,w=0;
    unsigned long long count=0,w_num=0;
    while(fgets(token, sizeof(token), stdin)!=NULL){
        h=atoi(strtok(token, " "));w=atoi(strtok(NULL, " "));
        if(h==1||w==1){
            printf("1");
            return 0;
        }
        if (h%2==0) {
            if (w%2==0) {
                w_num=w/2;
                count=w_num*h;
            }
            else {
                w_num=w/2+1;
                count=(w_num*2-1)*(h/2);
            }
        }
        else {
            if (w%2==0) {
                w_num=w/2;
                count=(w_num*2)*(h/2)+w_num;
            }
            else {
                w_num=w/2+1;
                count=(w_num*2-1)*(h/2)+w_num;
            }
        }
        printf("%lld",count);
    }
    return 0;
}




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

using namespace std;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define pb			    push_back

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    ll n;
    cin >> n;
    ll ans, tmp;
    ans = tmp = 0;
    ans = n / 500;
    ans *= 1000;
    tmp = n % 500;
    tmp /= 5;
    ans += (5 * tmp);
    cout << ans;

    return 0;
}










Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main () {
	int n,m,j;
	int *a;


	cin >> n >> m;
	a = new int[n];

	for(int i=0;i<n;i++)a[i]=0;

	for(int i=0;i<2*m;i++){
		cin >> j;
		a[j-1]++;
	}

	for(int i=0;i<n;i++){
		cout << a[i] << endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int partition(int *A ,int p ,int r){
  int x = A[r];
  int i = p-1;
  int tmp;
  for(int j=0;j<r;j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i+1;
}

int main(){
  int n,q;
  int A[100000];

  while(scanf("%d",&n) != EOF){
    char c = ' ';
    for(int i=0;i<n;i++){
      scanf("%d",&A[i]);
    }
    q = partition(A,0,n-1);
    for(int i=0;i<n;i++){
      if(i == n-1)
        c = '\n';
      if(i == q)
        printf("[%d]%c",A[i],c);
      else
        printf("%d%c",A[i],c);
    }
  }
  return 0;
}



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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int X;int V[4];
int Y,Z;
int T[55],E[55];

double dp[55][5010];

signed main(){
    while(cin>>X>>Y>>Z,X||Y||Z){
        memset(T,0,sizeof(T));
        memset(dp,0,sizeof(dp));
        rep(i,X)cin>>V[i];
        rep(i,Z){
            int a;cin>>a;
            cin>>T[a]>>E[a];
        }

        double ans=0;

        dp[0][0]=1;
        rep(i,Y){
            rep(j,i*100+1)dp[Y][j]=0;
            for(int j=Y-1;j>=i;j--){
                rep(k,i*100+1){
                    rep(l,X){
                        int t=j+V[l];
                        int c=k;
                        chmin(t,Y);
                        if(T[t]==1){
                            t+=E[t];
                            chmin(t,Y);
                        }
                        else if(T[t]==2){
                            c+=E[t];
                        }
                        else if(T[t]==3){
                            c-=E[t];
                            if(c<0)c=0;
                        }
                        dp[t][c]+=dp[j][k]/X;
                    }
                    dp[j][k]=0;
                }
            }
            rep(j,i*100+101)ans+=dp[Y][j]*j;
        }
        printf("%lld\n",(int)ans);
    }
    return 0;
}

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

int main(){
    string s; cin >> s;
    int N = s.size();
    vector<long> c(N+1,0), d(N+1,0);
    d[0] = 10 - ( (int) s[N-1] - '0');
    c[0] = (int) s[N-1] - '0';
    for (int i = 1; i < N; i++)
    {
        int val =  (int) s[N-1-i] - '0';
        c[i] = min(c[i-1] + val, d[i-1] + val + 1);
        d[i] = min(c[i-1] + 10 - val, d[i-1] + 10 - val -1);
    }
    cout << min(c[N-1], d[N-1]+1) << endl;
}


Measured memory_bytes: 17028
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    #include<string>
    #include<stdlib.h>
    using namespace std ;
    int main(){
      string day;
      cin>>day;
      day=day.substr(0,3)+"8"+day.substr(4) ;
      cout<<day<<endl;
      return 0;
    }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
int x;
  cin>>x;
  if(x>40 || x<-40)
    cout<<"No"<<endl;
  else if(x>=30)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  return 0;
    
}


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

int main() {
    string S;
    cin >> S;
    int ans = S.size();
    rep(i,2) {
        int cnt = 0;
        rep(j, S.size()) {
            if((j%2==0) ^ (S[j] == (char)(i+'0'))) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
map<ll,ll>m;
int main() {
	ll n;
	cin>>n;
	ll a[n],ans=0ll;
	for(ll i=0ll;i<n;i++)
		cin>>a[i];
	for(ll i=n-1ll;i>=0ll;i--){
		ans+=m[i+a[i]];
		m[i-a[i]]++;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 27940
#include<cstdio>
#include<cmath>
using namespace std;

int main(void){
	int a =0;int b=0;
	scanf("%d %d",&a,&b);
	int co = b;
	int count=0;
	while(co/10!=0){
		co/=10;
		count++;
	}
	int ans = a*pow(10,count+1)+b;

	int m =sqrt(ans);
	
	if(m*m==ans) printf("Yes");
	else printf("No");
	return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
const int maxN = 1e5 + 10;
using namespace std;

map<string, int> mp;

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

    char s;
    cin >> s;

    if('A' <= s && s <= 'Z')
        cout << "A";
    else if('a' <= s && s <= 'z')
        cout << "a";

}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A, B, T;
    cin >> A >> B >> T;
    
    int t = A;
    int sum = 0;
    
    while(t <= T + 0.5){
        t += A;
        sum += B;
    }
    
    cout << sum << endl;
    
    
}


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

int main() {
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++){cin>>h[i];}
	unordered_map<long long,long long>  mp;
	for(int i=0;i<n;i++){
	    int x=(i+h[i]);
	    mp[x]++;
	}
	long long res=0;
	for(int i=0;i<n;i++){
	    int y=i-h[i];
	    if(mp.find(y)!=mp.end()){
	        res+=mp[y];
	    }
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 12176
<?php

$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
    $a[] = intval(fgets(STDIN));
}

for($i = 0; $i < $n; $i++){
    if($a[$i] > $i){
        echo -1;exit;
    }
}
$c = 0;
for($i = 1; $i < $n; $i++){
    $d = $a[$i] - $a[$i-1];
    if($d <= 0){
        $c+=$a[$i];
    }elseif($d == 1){
        $c++;
    }else{
        echo -1;exit;
    }
}
echo $c;


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N, T;
	vector<llong> A;

	cin >> N >> T;
	A.resize(N);
	for(int i = 0; i < N; i++)
		cin >> A[i];

	llong score = -inf, many = 0;
	llong mini = A[0];
	for(int i = 1; i < N; i++){
		if(score == A[i] - mini)
			many++;
		else if(score < A[i] - mini)
			score = A[i] - mini, many = 1;

		mini = min(mini, A[i]);
	}

	cout << many << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, l; cin >> n >> l;
    vector<string> a(n);
    for (string &s : a) {
        cin >> s;
    }
    sort(a.begin(), a.end());
    for (auto &s : a) {
        cout << s;
    }
    cout << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
/*int solve(int n){
	int sum=0;
	while(n>0){
		sum += n%10;
		n /= 10;
	}
	return sum;
}*/

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

	int mil=0,tho=0,hun=0,ten=0,one=0;
	int cnt=0;
	for(int i=A;i<=B;i++){
		int tmp = i;
		one = tmp%10; tmp /= 10;
		ten = tmp%10; tmp /= 10;
		hun = tmp%10; tmp /= 10;
		tho = tmp%10; tmp /= 10;
		mil = tmp%10; tmp /= 10;
		if((one==mil) && (ten==tho)) cnt++;
		//cout<<cnt<<endl<<endl;
	}

	cout<< cnt <<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int t, d, l;

  while(cin>>t>>d>>l, t){
    int x, a=0, z=0;
    for(int i=0;i<t;i++){
      cin>>x;
      if(x>=l){
        if(a>0)z++;
        a=d;
      }
      else{
        if(a>0) z++; 
        a--;
      }
    }
    cout<<z<<endl;
  }
}

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

int main()
{
 
    // input matrix size
    int n,m,l;
    cin>>n>>m>>l;

    // input matrix A data
    vector<vector<long >> A(n,vector<long>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>A.at(i).at(j);
        }
    }

    // input matrix B data
    vector<vector<long >> B(m,vector< long>(l));
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>B.at(i).at(j);
        }
    }

    // multiple matrix A*B=C
    vector<vector<long >> C(n,vector< long>(l));
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
                long cij=0;
            for(int k=0;k<m;k++){
                cij+=A.at(i).at(k)*B.at(k).at(j);
            }
                C.at(i).at(j)=cij;
        }
    }

    // output table data
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j==l-1)
                cout<<C.at(i).at(j);
            else
                cout<<C.at(i).at(j)<<' ';
        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    vi a(3); cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    ll ans = 0;

    // 3つとも異なるor2, 3番目の数値が同じ場合
    if(a[1] != a[2]){
        ans += a[2]-a[1];
        a[0] += a[2]-a[1];
        a[1] = a[2];
        
    }
    // 1, 2番目に大きい数値が同じ場合
    if(a[1] == a[2] && a[0] != a[1]){
        ans += ceil((a[1]-a[0])/2.0);
        if(a[1]%2 != a[0]%2) ans++; 
    }

    // 結果の出力
    cout << ans << endl;
}

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


struct SCC{
  Int n;
  vector<vector<Int> > G,rG,T,C;
  vector<Int> vs,used,blg;
  SCC(){}
  SCC(Int n):n(n),G(n),rG(n),used(n),blg(n){}
  
  void add_edge(Int from,Int to){
    G[from].emplace_back(to);
    rG[to].emplace_back(from);
  }
  
  void dfs(Int v){
    used[v]=1;
    for(Int u:G[v])
      if(!used[u]) dfs(u);
    vs.emplace_back(v);
  }
  
  void rdfs(Int v,Int k){
    used[v]=1;
    blg[v]=k;
    C[k].emplace_back(v);
    for(Int u:rG[v])
      if(!used[u]) rdfs(u,k);
  }
  
  Int build(){
    for(Int v=0;v<n;v++)
      if(!used[v]) dfs(v);
    
    fill(used.begin(),used.end(),0);
    Int k=0;
    for(Int i=vs.size()-1;i>=0;i--){
      if(!used[vs[i]]){
        T.emplace_back();
        C.emplace_back();
        rdfs(vs[i],k++);
      }
    }
    for(Int v=0;v<n;v++)
      for(Int u:G[v])
        if(blg[v]!=blg[u])
          T[blg[v]].push_back(blg[u]);
    
    for(Int i=0;i<k;i++){
      sort(T[i].begin(),T[i].end());
      T[i].erase(unique(T[i].begin(),T[i].end()),T[i].end());
    }
    return k;
  }
};


template <typename T>
vector<T> dijkstra(Int s,vector<vector<pair<Int, T> > > & G){  
  const T INF = numeric_limits<T>::max();    
  using P = pair<T, Int>;
  Int n=G.size();
  vector<T> d(n,INF);
  vector<Int> b(n,-1);
  priority_queue<P,vector<P>,greater<P> > q;
  d[s]=0;
  q.emplace(d[s],s);
  while(!q.empty()){
    P p=q.top();q.pop();
    Int v=p.second;
    if(d[v]<p.first) continue;
    for(auto& e:G[v]){
      Int u=e.first;
      T c=e.second;
      if(d[u]>d[v]+c){
        d[u]=d[v]+c;
        b[u]=v;
        q.emplace(d[u],u);
      }
    }
  }
  return d;
}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> p(n);
  for(Int i=0;i<n;i++) cin>>p[i];
  
  SCC scc(n);
  for(Int i=0;i<n;i++){
    if(p[i]==0) continue;
    scc.add_edge(i,i+p[i]);    
  }
  scc.build();

  vector<Int> nx(n,0);
  for(Int v=0;v<n;v++) nx[v]=v+p[v];

  auto calc=
    [&](Int v,auto func)->Int{
      if(nx[v]<0) return nx[v];
      if(p[v]==0) return v;
      if(scc.C[scc.blg[v]].size()>1u) return nx[v]=-1;   
      return nx[v]=func(nx[v],func);
    };  

  using P = pair<Int, Int>;
  vector<vector<P> > G(n);
  for(Int i=0;i+1<n;i++){
    if(scc.C[scc.blg[i]].size()>1u) continue;    
    for(Int j=1;j<=6;j++){
      Int k=min(i+j,n-1);
      Int u=calc(k,calc);
      if(~u) G[i].emplace_back(u,1);
    }
  }
  
  cout<<dijkstra(0,G)[n-1]<<endl;
  return 0;
}



Measured memory_bytes: 47916
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n, k;
    cin>>n>>k;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    int need = 0;
    for(int i = 1 ; i < n ; i++ ){
        if(a[i] + a[i-1] > k){
            int r = a[i] + a[i-1] - k;
            need +=r ;
            if(r <= a[i]){
                a[i] -= r;
            }else {
                a[i] = 0;
            }
        }
    }
    cout<<need<<endl;

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
s=list(input())
t=list(input())
S,T=len(s),len(t)
t=t+['?']
if S<T:
  print('UNRESTORABLE')
  exit()
count=[0]*S
for i in range(T+1):
  if t[i] in s:
    x=s.index(t[i])
    if all(s[x-i+j]=='?' or s[x-i+j]==t[j] for j in range(T)):
      count[x-i]=1   
if max(count)==0:
  print('UNRESTORABLE')
  exit()
count=count[::-1]
x=count.index(1)
x,j=S-x-1,0
for i in range(S):
  if (i<x or i>x+T-1):
    if s[i]=='?':
      s[i]='a'
  else:
    s[i]=t[j]
    j+=1
print(''.join(s))

Measured memory_bytes: 3064
using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] dlm = " ".ToCharArray();
            string[] data = Console.ReadLine().Split(dlm);

            int a = int.Parse(data[0]);
            int b = int.Parse(data[1]);

            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else if (a > b)
            {
                Console.WriteLine("a > b");
            }
            else if (a == b)
            {
                Console.WriteLine("a == b");
            }
        }
    }
}



Measured memory_bytes: 15900
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int min = 0;
		
		while(true){
			if (Math.abs(a-b) <= w){
				System.out.println(min);
				break;
			}else{
				min+=1;
				w++;
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 23892
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    cout<<(in()>=30?"Yes":"No")<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}



// TODO: write
int main() {   
  string s;cin>>s;
  if(s[0] == s[1] && s[1] == s[2])print("No");
  else print("Yes");
  return 0;
}



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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr <<">>>>>>"<< #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

int main()
{
	
string s;
int c=0,an=0;
cin>>s;
for(int i=0;i<(int)s.size();i++)
if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){c++;an=max(an,c);}
else{an=max(an,c);c=0;}
cout<<an<<endl;

}



Measured memory_bytes: 3600
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	long long x;
	cin>>x;
	double prop=0.01;
	long long s=100;
	long long t=0;
	while(s<x){
		s=s+floor(s*prop);
//		cout<<s<<endl;
//		prop*=1.01;
		t++;
	}
	cout<<t<<endl;
	return 0;
} 

Measured memory_bytes: 3588
N,K = map(int,input().split())

ans=0
i=K

while i<=N+1:
      min=i*(i-1)/2
      max=(N+1)*N/2-(N-i+1)*(N-i)/2
      ans+=((max-min)+1)
      i+=1

print(int((ans)%(10**9+7)))

Measured memory_bytes: 9132
#include <stdio.h>
int main(){
  int n,a,b;
  scanf("%d",&n);
  if(n==1)
    printf("Hello World\n");
  else if(n==2){
  	scanf("%d",&a);
  	scanf("%d",&b);
    printf("%d\n",a+b);
  }
  return 0;
}

Measured memory_bytes: 128
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

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

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

signed main() {
    int N;
    cin >> N;

    int A[N];
    int B[N];
    int C[N];

    int B_sum[N+1];
    fill(B_sum, B_sum + N + 1, 0);

    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N; i++) cin >> C[i];

    sort(B, B + N);
    sort(C, C + N);

    for (int i = N; i >= 0; i--) B_sum[i-1] = B_sum[i] + N - (int)(upper_bound(C, C + N, B[i-1]) - C);

    int ret = 0;

    for (int i = 0; i < N; i++) {
        ret += B_sum[upper_bound(B, B + N, A[i]) - B];
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    rep(i,N){cin>>A.at(i);A.at(i)--;}
    vector<ll> town(0);
    town.pb(0);
    set<ll> kita;
    kita.insert(0);
    bool roop=true;
    ll from,to;
    while(roop){
        ll now=town.at(sz(town)-1);
    //cout<<now<<" ";
        ll nex=A.at(now);
    //cout<<nex<<endl;
        if(kita.count(nex)){
            to=sz(town)-1;
            rep(j,sz(town)){
                if(town.at(j)==nex){
                    from=j;
                    break;
                }
            }
            roop=false;
        }
        else{
            town.pb(nex);
            kita.insert(nex);
        }
    }
    ll ans;
    if(K<from){ans=town.at(K);}
    else{
        K-=from;
        K%=(to-from+1);
        K+=from;
        ans=town.at(K);
    }

    ans++;

    cout<<ans<<endl;
    //rep(i,sz(town)){cout<<town.at(i)<<" ";}
}


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

import fractions
from functools import reduce

N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7


def lcm_base(x, y):
    return ((x * y) // fractions.gcd(x, y))


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


min_AB = lcm(*A)

ans = 0
for a in A:
    ans += min_AB // a

print(ans % mod)


Measured memory_bytes: 6108
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <deque>
#include <math.h>
#include <map>
#include <bitset>
#include <queue>
#include <list>1
#include <utility>
 
//#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ld = long double;
using p = pair<int, int>;
using Graph = vector<vector<char>>;
#define rep(i,n)  for(int i = 0; i < n ; i++)
#define chmax(x,y) x = max(x,y);
int dx[4]{ -1,0,1,0 };
int dy[4]{ 0,1,0,-1 };
const ll INF = 1e18;
ll dp[200005][4]; // i番目までの個数でj個余分な×を選んだ際の和の最大値
 
//  ABC F 162
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int k = 1 + n % 2;
	rep(i, n + 1) {
		rep(j, k + 1) {
			dp[i][j] = -INF;
		}
	}
	dp[0][0] = 0;
	rep(i, n) {
		rep(j, k + 1)
		{
			chmax(dp[i + 1][j + 1], dp[i][j]);
			ll now = dp[i][j];
			if ((i + j) % 2 == 0) { now += a[i]; }
			chmax(dp[i + 1][j], now);
		}
	}
	ll ans = dp[n][k];
	cout << ans << endl;
}

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

using namespace std;

#define INF 1e9

int MOD=1e9+7;

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

    int d,n;
    cin>>d>>n;
    if(n==100)n++;

    cout<<n;

    for(int i=0;i<d;i++)cout<<"00";
    cout<<endl;
    
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

H,W = map(int,readline().split())

grid = [readline().rstrip() for i in range(H)]

visited = set()
ans = 0
from collections import deque
cases = ((0,1),(0,-1),(1,0),(-1,0))
for i in range(H):
  for j in range(W):
    if (i,j) in visited:
      continue
    if grid[i][j] == ".":
      continue
    q = deque()
    black = 0
    white = 0
    q.append([i,j,1])
    aim = ".#"
    while q:
      y,x,isblack = q.popleft()
      if (y,x) in visited:
        continue
      if aim[isblack] != grid[y][x]:
        continue
      visited.add((y,x))
      if isblack:
        black += 1
      else:
        white += 1
      isblack ^= 1
      for c in cases:
        if 0 <= y + c[0] < H and 0 <= x + c[1] < W:
          q.append([y + c[0],x + c[1],isblack])
    ans += black * white
print(ans)

Measured memory_bytes: 21508
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#define LL long long
#include<stack>
using namespace std;
int const maxn=1e6+10;
struct bkn{
    int next,to;
    LL w;
}e[maxn*2];
int tot=1,head[maxn];
LL dp[maxn];
int vis[maxn];
int n,m;
void add(int x,int y,LL w){
    e[tot].to=y,e[tot].next=head[x],e[tot].w=w,head[x]=tot++;
}
void dfs(int x){
    vis[x]=1;
    for (int i=head[x];i;i=e[i].next){
        int y=e[i].to;
        LL v=e[i].w;
        if (!vis[y]){
            dp[y]=dp[x]+v;
            dfs(y);
        }
        else if (dp[y]!=dp[x]+v) {
            cout<<"No"<<endl;
            exit(0);
        }
    }
}
int main(){
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++){
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);
        add(y,x,w);
        add(x,y,-w);
    }
    for (int i=1;i<=n;i++){
        if (!vis[i]) dfs(i);
    }
    cout<<"Yes"<<endl;
}



Measured memory_bytes: 16768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,a,i,m=0;
	ll b,cnt[123456],k;
	fill(cnt,cnt+123456,0ll);
	cin >> n >> k;
	for(i=0; i<n; ++i){
		cin >> a >> b;
		cnt[a] += b;
		m = max(m,a);
	}
	for(i=1; i<=m; ++i){
		cnt[i] += cnt[i-1];
	}
	for(i=0; i<=m; ++i){
		if(cnt[i] < k){
			continue;
		}
		cout << i << endl;
		break;
	}
	return 0;
}

Measured memory_bytes: 1152
# 桁DPと思い込んで終了しました
# BFSでいける、というtwを見かけてなるほどとなった
# これは絶対を走査するときわざわざ0から9まで見ているのと、せっかくbfsなのにソートするようにしているので微妙な例だと思われ

from collections import deque
k = int(input())
arr = set()
for i in range(1, 10):
    arr.add(i)

for i in range(1, 10):
    tmp_arr = deque()
    tmp_arr.append(str(i))
    while len(tmp_arr) > 0:
        cur = tmp_arr.popleft()
        arr.add(int(cur))
        if len(cur) == len("3234566667"):
            next
        target = int(cur[-1])
        for i in range(0, 10):
            if abs(target - i) <= 1:
                next_num = cur + str(i)
                if int(next_num) > 3234566667:
                    continue
                tmp_arr.append(next_num)
arr = sorted(arr)
print(arr[k - 1])


Measured memory_bytes: 12592