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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

LL sumOfDigits(LL n)
{
  LL sum = 0;
  while(0 < n)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  inline T root(T x)
  {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  inline bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

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

int t, x;

void input()
{
  cin >> t >> x;
}

void solve()
{
  cout << (double)t/x;
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll K;
    cin >> K;
    ll num = 7;
    rep(0, i, K + 10)
    {
        if (num % K == 0)
        {
            cout << i + 1 << endl;
            return 0;
        }
        num *= 10;
        num += 7;
        num %= K;
    }
    cout << "-1" << endl;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		int d = Integer.parseInt(sa[2]);
		int hw = h * w;
		int[] x = new int[hw + 1];
		int[] y = new int[hw + 1];
		for (int i = 0; i < h; i++) {
			sa = br.readLine().split(" ");
			for (int j = 0; j < w; j++) {
				int a = Integer.parseInt(sa[j]);
				x[a] = i;
				y[a] = j;
			}
		}
		int q = Integer.parseInt(br.readLine());
		int[] l = new int[q];
		int[] r = new int[q];
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			l[i] = Integer.parseInt(sa[0]);
			r[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		long[] sum = new long[hw + 1];
		for (int i = 1; i <= d; i++) {
			int cx = x[i];
			int cy = y[i];
			for (int j = i + d; j <= hw; j += d) {
				int val = Math.abs(x[j] - cx) + Math.abs(y[j] - cy);
				sum[j] = sum[j - d] + val;
				cx = x[j];
				cy = y[j];
			}
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			pw.println(sum[r[i]] - sum[l[i]]);
		}
		pw.flush();
	}
}


Measured memory_bytes: 46452
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    ll A, B, N;
    in(A); in(B); in(N);
    ll i = N;
    ll ans;
    ans = (A * i) / B - A * (i / B);
    i -= i%B;
    i--;
    ans = max(ans, (A * i) / B - A * (i / B));
    out(ans);


	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll X, A, B;
    cin >> X >> A >> B;
    ll diff = B - A;
    if (diff <= 0) {
        cout << "delicious" << endl;
    } else if (diff <= X) {
        cout << "safe" << endl;
    } else {
        cout <<"dangerous" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair <int,int> P;
string mp[501];
int m,n,used[30];
vector <P>  a[30];

int saiki(int);

bool check_x(int y,int x1,int x2){
  for(int i=x1+1;i<x2;i++)
    if(mp[y][i]!='.'&&!saiki(mp[y][i]-'A'))return 0;
  return 1;
}

bool check_y(int y1,int y2,int x){
  for(int i=y1+1;i<y2;i++)
    if(mp[i][x]!='.'&&!saiki(mp[i][x]-'A')) return 0;
  return 1;
}


int saiki(int ch){  
  int x1=a[ch][0].x,x2=a[ch][1].x;
  int y1=a[ch][0].y,y2=a[ch][1].y;
  int res=0;
  if(used[ch])return 0;
  used[ch]=1;
  
  if(x1==x2&&y2-y1!=1) res=check_y(y1,y2,x1);
  if(y1==y2&&x2-x1!=1) res=check_x(y1,x1,x2);

  if(x1!=x2&&y1!=y2) {
    if(x1<x2){
      res=check_x(y1,x1,x2+1)&check_y(y1,y2,x2);
      res|=check_y(y1,y2+1,x1)&check_x(y2,x1,x2);
    }
    else{
      swap(x1,x2);
      res=check_x(y1,x1-1,x2)&check_y(y1,y2,x1);
      res |=check_y(y1,y2,x2)&check_x(y2,x1,x2+1);
      swap(x1,x2);
    }
  }
    

  if(res) mp[y1][x1]=mp[y2][x2]='.',a[ch].clear();
  used[ch]=0;
  return res;
}

int main(){

  cin>>m>>n;
  for(int i=0;i<m;i++)cin>>mp[i];

  int ans=0;
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
      if(mp[i][j]!='.')a[mp[i][j]-'A'].push_back(P(j,i)),ans++;
  
  int flg=1;
  while(flg){
    flg=0;
    for(int i=0;i<30;i++)if(a[i].size() && saiki(i)) flg=1;
  }

  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++) if(mp[i][j]!='.') ans--;

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

Measured memory_bytes: 1484
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

string solve()
{
    string N;
    cin >> N;
    if (N[0] == N[2]) {
        return "Yes";
    }
    return "No";
}

int main()
{
    do {
        cout << solve() << endl;
    } while (DEBUG);
}


Measured memory_bytes: 256
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    veci H(N);
    REP(i,N) cin >> H[i];

    int ans = 0;
    for(int i = 1; i < N; i++) {
        bool ok = true;
        for(int j = 0; j < i; j++) {
            if(H[i] < H[j]) {
                ok = false;
                break;
            }
        }
        if(ok) ans++;
    }
    ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    bool can=false;
    rep(i,0,3){
        if(s[i]=='7')can=true;
    }
    if(can)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;   
}   

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

template <typename K, typename V = null_type> 
using ord_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
const int M = 998244353;

int h,w,k;
vector<vector<long long>> m;
queue<pair<int,int>> q;
const vector<pair<int,int>> dir = {{0,1}, {0,-1}, {1,0}, {-1,0}};

void hey(int x, int y){
    long long cost = m[x][y] + 1;
    for(int i = 0; i < dir.size(); i++){
        pair<int,int> p = dir[i];
        int xx = x, yy = y;
        xx += p.first;
        yy += p.second;
        int cnt = 1;
        while(xx < h && xx >= 0 && yy < w && yy >= 0 && cnt <= k){
            if(m[xx][yy] < cost) break;
            if(m[xx][yy] > cost){
                m[xx][yy] = cost;
                q.push({xx,yy});
                
            }
            cnt++;
            xx += p.first;
            yy += p.second;
        }
    }
}


int main(){
    SPEED;
    cin >> h >> w >> k;
    int x1,x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--;y1--;y2--;x2--;
    m.assign(h, vector<long long>(w));

    for(int i = 0; i < h; i++){
        string s;
        cin >> s;

        for(int j = 0; j < w; j++){
            if(s[j] == '@') m[i][j] = -1;
            else m[i][j] = INT_MAX;
        }
    }
    m[x1][y1] = 0;
    
    q.push({x1,y1});
    int cur = 0;
    while(!q.empty()){
        auto p = q.front();
        q.pop();
        if(m[p.first][p.second] < cur){
            assert(1 == 0);
        }
            
        cur = max((long long)cur, m[p.first][p.second]);
        hey(p.first, p.second);
    }
    
    if(m[x2][y2] == INT_MAX) cout << -1 << "\n";
    else  cout << m[x2][y2] << "\n";
}


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

struct edge {
    int to;
    int cost;
};
vector<vector<edge>> G(pow(10, 5) + 1);

void dfs(int s, vector<int> &color) {
    for (auto e : G[s]) {
        if (color[e.to] != -1)
            continue;
        if (e.cost % 2 == 0)
            color[e.to] = color[s];
        else if (color[s] == 0)
            color[e.to] = 1;
        else
            color[e.to] = 0;
        dfs(e.to, color);
    }
}

int main() {
    int N;
    cin >> N;
    G.resize(N, vector<edge>());
    vector<int> color(N, -1);
    int s;
    rep(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }

    int ma = 0;
    rep(i, N) {
        if (G[i].size() > ma) {
            ma = G[i].size();
            s = i;
        }
    }

    color[s] = 0;
    int cnt = 0;
    dfs(s, color);

    rep(i, N) { cout << color[i] << endl; }
}

Measured memory_bytes: 8320
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  int w;
  cin >> w;
  for(int i=0;i<S.size();i++){
    if(i==0){
      cout << S[0];
      continue;
    }
    if(i%w==0){
      cout << S[i];
    }
  }
  return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)

ans = 0
for i in range(2**(n-1)):
    c = 10
    tmp = int(s)
    res = 0
    for j in range(n-1):
        if ((i>>j)&1):
            res+=tmp%c
            tmp=tmp//c
            c=10
        else:
            c*=10
    ans+=res+tmp
print(ans)

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

int main() {
 string S;
  cin >> S;
  if(S[0]==S[1] && S[2]==S[3] && S[0]!=S[2]){
   cout << "Yes" << endl; 
  }
  else if(S[0]==S[2] && S[1]==S[3] && S[0]!=S[1]){
   cout << "Yes" << endl; 
  }
  else if(S[0]==S[3] && S[1]==S[2] && S[0]!=S[1]){
   cout << "Yes" << endl; 
  }
  else{
   cout << "No" << endl; 
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    
    unordered_map<int,int> mp;
    ll ans = 0;
    rep(i, N) {
        int A;
        cin >> A;
        ++mp[A];
        ans+=A;
    }
    
    int Q;
    cin >> Q;
    rep(i,Q){
        int B,C;
        cin >> B >> C;
        int diff = C-B;
        ans+=diff*mp[B];
        mp[C]+=mp[B];
        mp[B]= 0;
        cout << ans << endl;
    }
}


Measured memory_bytes: 6992
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    vector<int> list;
    int tmp=1;int cnt=1;
    while(tmp<=1000000){
        list.push_back(tmp);
        cnt++;
        tmp=cnt*(cnt+1)*(cnt+2)/6;
    }
    int len = list.size();
    vector<int> dp(1000001,0);vector<int> oddsdp(1000001,0);
    REP(i,1000001){
        dp[i]=i;oddsdp[i]=i;
    }
    REP(i,len){
        REP(j,1000001){
            if(j - list[i]>=0)dp[j] = min(dp[j-list[i]]+1,dp[j]);
        }
        //printf("%d\n",list[i]);
    }
    REP(i,len){
        if(list[i]%2 == 0)continue;
        REP(j,1000001){
            if(j-list[i]>=0)oddsdp[j]=min(oddsdp[j-list[i]]+1,oddsdp[j]);
        }
        //printf("%d\n",oddsdp[40]);
    }
    int n;scanf("%d",&n);
    while(n){
        int ans1,ans2;
        ans1 =dp[n];ans2=oddsdp[n];
        printf("%d %d\n",ans1,ans2);
        scanf("%d",&n);
    }
}


Measured memory_bytes: 10564
n, k = map(int, input().split())
D = {}
for _ in range(n):
    a, b = map(int, input().split())
    if a in D:
        D[a] += b
    else:
        D[a] = b
K = sorted(D.keys())
i = 0
while k > 0:
    k -= D[K[i]]
    i += 1
print(K[i - 1])


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int main(){
   int N,K;cin >> N >> K;
   int L[N];
   rep(i,N)cin >> L[i];
   sort(L,L+N);
   reverse(L,L+N);
   int ans = 0;
   rep(i,K){
      ans += L[i];
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

#define all(x) x.begin(),x.end()
int INF = 1e9;

struct dinic{

	struct edge{
		int to,cap,rev;
		edge(){}
    	edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
	};

	int n;
	vector<vector<edge> > G;
	vector<int> level;
	vector<int> iter;

	dinic(){};
	dinic(int V):n(V),G(n),level(n),iter(n){}

	void add_edge(int from,int to,int cap){
		G[from].push_back(edge(to,cap,(int)G[to].size()));
		G[to].push_back(edge(from,0,(int)G[from].size()-1));
	}

	//sからの層グラフつくり
	void bfs(int s){
		//fill(all(level),-1);
		level.assign(level.size(),-1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while(!que.empty()){
			int v = que.front();
			que.pop();
			for(int i = 0; i < (int)G[v].size(); i++){
				edge e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0){
					level[e.to] = level[v]+1;
					que.push(e.to);
				}
			}
		}
	}

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

	int max_flow(int s,int t,int lim){
		int flow = 0;
		for(; ;){
			bfs(s);
			if(level[t] < 0 || lim == 0){
				return flow;
			}
			//fill(all(iter),0);
			iter.assign(iter.size(),0);
			int f;
			while((f = dfs(s,t,INF)) > 0){
				flow += f;
				lim -= f;
			}
		}
	}
};


int main(){
	int V,E;
	cin >> V >> E;

	dinic din(V);
	for(int i = 0; i < E; i++){
		int u,v,c;
		cin >> u >> v >> c;
		din.add_edge(u,v,c);
	}

	cout << din.max_flow(0,V-1,INF) << endl;
}


Measured memory_bytes: 3144
import sys

while True:
  n = sys.stdin.readline()
  if n == "0\n": break
  n = int(n)
  l = []
  for i in range(n):
    l.append(int(raw_input().rstrip()))
  max_sum=-100000000
  for i in range(-1, n):
    sm = 0
    for j in range(i+1, n):
      sm += l[j]
      if max_sum < sm:
        max_sum = sm
  print max_sum

Measured memory_bytes: 6344
#include <iostream>
#include <vector>

int main(){
    int n;
    std::cin >> n;

    long long ans;
    long long l, r;
    for(int i = 0; i < n; ++i){
        std::cin >> l >> r;
        ans += r - l + 1;
    }    

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
	ll x;
	cin>>x;
	return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
vector <vector <int> > g;
vector <int> val;
vector <int> a;
 int dfs(vector <bool> &visited,int s);
 vector <int> test;
  vector <int> ans;
  void rerooting(int s,vector <bool> &visited);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll r=nxtl(),c=nxtl();
    if(r==1||c==1)
    {
        cout<<"1\n";
        return 0;
    }
    ll test=r*c;
    if(test%2==0)
        test/=2;
    else
    {
        test=((r*(c-1))/2);
        test+=(r/2);
        test++;
    }
    cout<<test<<endl;

    return 0;   
}


 
 


Measured memory_bytes: 256
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
import java.io.*;
public class Main
{
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader (System.in));
		String s = br.readLine();
		int k = Integer.parseInt(s);
		
		s = br.readLine();
		int n = s.length();
		if(n <= k)
		    System.out.println(s);
		else
		{
		    for(int i=0; i<k; i++)
		        System.out.print(s.charAt(i));
		    System.out.println("...");
		}
	}
}


Measured memory_bytes: 32332
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL INF=100000000000;
string u="abcdefghijklmnopqrstuvwxyz";


int main(){
    string s;
    cin >> s;
    cout << "2018";
    for(int i=4;i<s.length();i++){
        cout << s[i];
    }
    cout << "\n";
    return 0;
}

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

ll gcd(ll a1, ll a2){
    ll r;
    while (a2 != 0){
        r = a1 % a2;
        a1 = a2;
        a2 = r;
    }
    return a1;
}

ll lcm(ll a1, ll a2){
    ll d = gcd(a1, a2);
    a2 /= d;
    return a1 * a2;
}

int main(){
    ll a1, a2, n;
    cin >> n;
    cin >> a1;
    rep(i, n-1){
        cin >> a2;
        a1 = lcm(a1, a2);
    }
    cout << a1 << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>

using namespace std;

int n, p, x;
long long ans;

int main() {
  cin >> n;
  cin >> p;
  for (int i = 2; i <= n; i++) {
    cin >> x;
    ans += max(0, p - x);
    p = max(p, x);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int n = in();
  vi p(n);
  rep(i,n) cin >> p[i];

  int cnt = 0;
  rep(i,n) {
    if (p[i] != i + 1) cnt++;
  }

  if (cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    map<ll, ll> m;
    for (ll i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        m[a]++;
    }
    vector<ll> v;
    for (auto i : m)
    {
        v.push_back(i.second);
    }
    sort(ALL(v));
    ll ans = 0;
    ll mm = v.size() - k;
    if (mm < 0)
    {
        cout << 0 << endl;
        exit(0);
    }
    for (ll i = 0; i < mm; i++)
    {
        ans += v[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 14964
import sys
input=sys.stdin.readline
r,c,k=map(int,input().split())
l=[0]*((r+1)*(c+1))
for i in range(k):
  a1,a2,a3=map(int,input().split())
  l[a1*(c+1)+a2]=a3
dp0=[[0 for i in range(c+1)] for j in range(r+1)]
dp1=[[0 for i in range(c+1)] for j in range(r+1)]
dp2=[[0 for i in range(c+1)] for j in range(r+1)]
dp3=[[0 for i in range(c+1)] for j in range(r+1)]
for i in range(r):
  for j in range(c):
    x=l[i*(c+1)+j+1]
    y=l[(i+1)*(c+1)+j]
    dp3[i+1][j+1]=max(dp2[i][j+1]+x,dp3[i][j+1],dp2[i+1][j]+y,dp3[i+1][j])
    dp2[i+1][j+1]=max(dp2[i][j+1]+x,dp3[i][j+1],dp1[i+1][j]+y,dp2[i+1][j])
    dp1[i+1][j+1]=max(dp2[i][j+1]+x,dp3[i][j+1],dp0[i+1][j]+y,dp1[i+1][j])
    dp0[i+1][j+1]=max(dp2[i][j+1]+x,dp3[i][j+1],dp0[i+1][j])
z=l[r*(c+1)+c]
print(max(dp2[r][c]+z,dp3[r][c]))

Measured memory_bytes: 462212
#include<stdio.h>
int main(){
    double f3;
  int a,b,f1,f2;
  scanf("%d %d" ,&a , &b);

  f1 = a / b;
  f2 = a % b;
  
  f3 = 1.0 * a / b;
  printf("%d %d %.5f\n",f1,f2,f3);
  return 0;
}


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

using namespace std;

std::string S;

void solve (){
    if((S[2] == S[3]) && (S[4] == S[5])){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}


int main() {
    cin >> S;
    solve();
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
const ll mod = 1000000007;
int main(){
	ll N, A, B;
	cin >> N >> A >> B;
	if(A*N < B){
		cout << A*N << endl;
	} else {
		cout << B << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,d=1000000,cou=0;
  cin>>a>>b;
  for(int i=0;i<a;i++){
    cin>>c;
    b-=c;
    cou++;
    d=min(c,d);
  }
  cou+=b/d;
  cout<<cou<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
#define skip continue
#define ll long long
long long a,b,c,d=0,e=0,i,f=0,g=0,j,k=0,l=0,r,z,m,p,df[101];
string t,x,q,s;
//double ;
vector<ll>v,u,w,dv[101];
//vector<string>;
map<string,ll>n;
set<ll>y;
void dfs(ll x){
    df[x]=1;
    for(ll i=0;i<dv[x].size();i++){
        if(df[dv[x][i]]==0){
            df[dv[x][i]]=1;
            dfs(dv[x][i]);
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>a;
    cout<<1-a;
}

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

using namespace std;

string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s;
	if(s[(int)(s.size()) - 1] == 's')
		s += "es";
	else
		s += "s";
	return cout << s << endl, 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;
    vector<int> l(q), r(q);
    rep(i, q) cin >> l[i] >> r[i];
    
    vector<int> A(n);
    rep(i, n - 1) {
        if (s[i] == 'A' && s[i + 1] == 'C') {
            A[i + 1] = A[i] + 1;
        }
        else {
            A[i + 1] = A[i];
        }
    }

    rep(i, q) {
        int ans = A[r[i] - 1] - A[l[i] - 1];
        put(ans);
    }

    return 0;
}

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

int main() {
	int K,X,min,max;
	cin>>K>>X;
	min = X-(K-1);
	max = X+(K-1);
	if(min < -1000000) min = -1000000;
	if(max > 1000000) max = 1000000;
	for (int i = min; i <= max; i++) cout<<i<<' ';
	cout<<endl;
}


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

using namespace std;

#define ll long long
#define LL unsigned long long 
#define vec(x) vector<x>
#define emb(x)  emplace_back(x)
#define fall(x) x.begin(),x.end()
#define fo(a,b) for(int i=a; i < b; i++)
#define fset(x) setprecision(x) << fixed
#define fast ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);


int main(){
	
	
	fast
	
	int k;
	cin>>k;
	
	
	int a = 0;
	fo(a,k){
		cout << "ACL";
	}
	cout << endl;

	return 0;
	}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int argc, char * argv [])
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    size_t k, t;
    cin >> k >> t;

    vector<size_t> a(t);
    cin >> a;

    const auto acc = accumulate(begin(a), end(a), (size_t) 0);
    const auto inf = *max_element(begin(a), end(a));
    const auto rest = acc - inf;

    cout << (inf < rest + 1 ? 0 : inf - rest - 1) << '\n';

    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>
//#include <ctime>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 500100, MAXK = 20;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
 	freopen((s+".out").c_str(),"w",stdout);
}

int r, c, k;
ll dp[3100][3100][5];
ll v[3100][3100];

int main() {
    setIO();

    cin >> r >> c >> k;
    REP(k) {
        int i, j; cin >> i >> j;
        ll w; cin >> w;
        v[i][j] = max(v[i][j], w);
    }

    FOR(i, 1, r) FOR(j, 1, c) FOR(m, 0, 3) {
        dp[i][j][m] = dp[i][j-1][m];
        FOR(n, 0, 3) dp[i][j][m] = max(dp[i][j][m], dp[i-1][j][n]);
        if (m > 0) {
            dp[i][j][m] = max(dp[i][j][m], dp[i][j-1][m-1] + v[i][j]);
            FOR(n, 0, 3) dp[i][j][m] = max(dp[i][j][m], dp[i-1][j][n] + v[i][j]);
        }
    }

    ll ans = 0ll;
    FOR(n, 0, 3) ans = max(ans, dp[r][c][n]);
    cout << ans << "\n";

	return 0;
}


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

typedef long long ll;
const ll mod=1e9+7;
const ll N=2e5+1;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	string s;
	int n;
	cin>>n>>s;
	int r=0,w=0;
	for(char ch:s) ch=='R'?r++:w++;
	int ans=r;
	int nr=0,nw=0;
	for(int i=0;i<n;i++){
		s[i]=='R'?nr++:nw++;
		ans=min(ans,max(nw,r-nr));
	}
	cout<<ans;
}


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

int main(void){


    int a,b;
    string op;
    while( op != "?"){
    cin >> a >> op >> b;
    if(op == "+") cout << a + b << endl;
    if(op == "-") cout << a - b << endl;
    if(op == "*") cout << a * b << endl;
    if(op == "/") cout << a / b << endl;
    }
    return 0;
}    



Measured memory_bytes: 3132
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
b = inpl()
res = 0
for i in range(n):
    if a[i] > b[i]:
        res += b[i] - a[i]
    elif b[i] - a[i]:
        res += (b[i] - a[i])//2
print('Yes' if res >= 0 else 'No')

Measured memory_bytes: 6648
#include<stdio.h>

int main(){
  char num[4];
  int i;
  //for(i = 0; i < 3; i ++){
    scanf("%s", num);
  //}

  if(num[0] == num[2]){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
/*
 * e.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 1000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int ts[MAX_N];

/* subroutines */

/* main */

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

  int tsum = 0;
  
  for (int i = 0; i < n; i++) {
    cin >> ts[i];
    tsum += ts[i];
  }
  sort(ts, ts + n);

  int ans = 0;
  int mint0 = ts[0], mint1 = ts[1];

  while (n >= 4) {
    int maxt0 = ts[n - 1], maxt1 = ts[n - 2];

    int s0 = maxt0 + maxt1 + mint0 * 2;
    int s1 = maxt0 + mint1 * 2 + mint0;
    ans += (s0 <= s1) ? s0 : s1;

    n -= 2;
  }

  if (n == 3) ans += ts[2] + ts[1] + ts[0];
  else if (n == 2) ans += ts[1];
  else ans += ts[0];

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1164
N=int(input())

XY=[[] for _ in range(N)]
for i in range(N):
  A=int(input())
  for j in range(A):
    XY[i].append(list(map(int,input().split())))

ans=0
for k in range(2**N):
  hu=list(map(int,bin(k)[2:].zfill(N)))
  j=0
  for i in range(len(XY)):
    if hu[i]==1:
      for x,y in XY[i]:
        if hu[x-1]!=y:
          j=1
  if j==0:
    ans=max(ans,hu.count(1))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void minDist(const vector<string>& plane, char wall, int y0, int x0, vector<vector<int> >& dist)
{
    int dy[] = {0, 0, -1, 1};
    int dx[] = {-1, 1, 0, 0};

    int h = plane.size();
    int w = plane[0].size();
    dist.assign(h, vector<int>(w, -1));

    queue<pair<int, int> > q;
    q.push(make_pair(y0, x0));
    dist[y0][x0] = 0;
    int n = 1;
    while(!q.empty()){
        queue<pair<int, int> > q1;
        while(!q.empty()){
            int y = q.front().first;
            int x = q.front().second;
            q.pop();
            for(int i=0; i<4; ++i){
                int y1 = y + dy[i];
                int x1 = x + dx[i];
                if(0 <= y1 && y1 < h && 0 <= x1 && x1 < w && plane[y1][x1] != wall && dist[y1][x1] == -1){
                    q1.push(make_pair(y1, x1));
                    dist[y1][x1] = n;
                }
            }
        }
        ++ n;
        q = q1;
    }
}

void solve(vector<string>& plane, string& pattern)
{
    int h = plane.size();
    int w = plane[0].size();

    int ay, ax, by, bx;
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            if(plane[i][j] == 'A'){
                ay = i;
                ax = j;
            }else if(plane[i][j] == 'B'){
                by = i;
                bx = j;
            }
        }
    }

    vector<vector<int> > dist;
    minDist(plane, '#', ay, ax, dist);

    int dy[] = {0, 0, 1, 0, 0, 0, 0, 0, -1};
    int dx[] = {0, 0, 0, 0, -1, 0, 1, 0, 0};
    int n = pattern.size();
    int move = 0;
    while(move < 400){
        for(int i=0; i<n; ++i){
            by += dy[pattern[i]-'0'];
            bx += dx[pattern[i]-'0'];
            by = max(0, min(h-1, by));
            bx = max(0, min(w-1, bx));
            ++ move;
            if(dist[by][bx] != -1 && dist[by][bx] <= move){
                cout << move << ' ' << by << ' ' << bx << endl;
                return;
            }
        }
    }
    cout << "impossible" << endl;
}

int main()
{
    for(;;){
        int h, w;
        cin >> h >> w;
        if(h == 0)
            return 0;

        vector<string> plane(h);
        for(int i=0; i<h; ++i)
            cin >> plane[i];
        string pattern;
        cin >> pattern;
        solve(plane, pattern);
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#include <math.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
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); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;
static const ll MOD = 1000000007;

int arr[MAX];
ll FACT[MAX*10];
ll IFACT[MAX*10];

// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK)
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

ll C(ll n, ll r)
{
    if(n < 0 || r < 0 || r > n)return 0;
    if(r > n / 2)r = n - r;
    return FACT[n]*IFACT[n-r]%MOD*IFACT[r]%MOD;
}

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    int x, y;
    cin >> x >> y;
    ll m12 = 0;
    ll m21 = 0;
    while(!(x==0 && y==0)){
        if(x*2 == y){
            x-=1;
            y-=2;
            m21 ++;
        }
        else if(x == y*2){
            x-=2;
            y-=1;
            m12 ++;
        }
        else{
            x-=3;
            y-=3;
            m12++;
            m21++;
        }
        if(x <0 || y <0){
            cout << "0" << endl;
            return 0;
        }
    }
    
    
    int N = MAX*10;
    FACT[0] = 1;
    IFACT[0] = 1;
    for(int i = 1;i <= N;i++){
        FACT[i] = FACT[i-1] * i % MOD;
        IFACT[i] = modinv(FACT[i], MOD);
    }
    
    ll res = C(m12 + m21, m21);
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 15872
import fractions
n = int(input())
lis = list(map(int,input().split()))
cou = 1
for i in range(n):
  cou = (cou * lis[i])//fractions.gcd(cou, lis[i])
cou -= 1
print(sum([cou % lis[i] for i in range(n)]))

Measured memory_bytes: 5344
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

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

	string s;
	cin >> s;

	int ans = 0;

	string prev = "";
	string cur = "";
	trav(c, s){
		cur.push_back(c);
		if(cur != prev){
			prev = cur;
			++ans;
			cur = "";
		}
	}
	cout << ans << endl;

}


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

int N, M, p;

int left(int s, int g) {
    if (g <= s) {
        return 100 * (s - g);
    } else {
        return 100 * (N - (g - s));
    }
}

int right(int s, int g) {
    if (g <= s) {
        return 100 * (N - (s - g));
    } else {
        return 100 * (g - s);
    }
}
int main() {
    
    cin >> N >> M >> p;
    vector<int> d(M);
    for (int i = 0; i < M; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int l = -1;
    int r = -1;

    int kl = 200 * N;
    int kr = 200 * N;
    int idx = -1;
    for (int i = 0; i < M; i++) {
        if (kl > left(p, d[i])) {
            kl = left(p, d[i]);
            l = d[i];
        }
        if (kr > right(p, d[i])) {
            kr = right(p, d[i]);
            r = d[i];
        }
    }
    //cout << l << " " << r << "\n";
    int ans = min(left(p, r), right(p, l)); // 全て左回りまたは右回り
    for (int i = 0; i < M; i++) {
        int t1; // d[i]<-p d[i]->p p->d[i-1]
        if (i == 0) {
            t1 = 2 * left(p, d[i]) + right(p, d[M - 1]);
        } else {
            t1 = 2 * left(p, d[i]) + right(p, d[i - 1]);
        }
        int t2;
        if (i == M - 1) {
            t2 = 2 * right(p, d[i]) + left(p, d[0]);
        } else {
            t2 = 2 * right(p, d[i]) + left(p, d[i + 1]);
        }
        ans = min(ans, min(t1, t2));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int main() {
	int n;
	std::cin >> n;
	std::vector<std::string> vec;
	bool ans = true;

	for (int i = 0; i < n; ++i) {
		std::string str;
		std::cin >> str;
		vec.push_back(str);
	}

	for (int i = 0; i < n; ++i) {
		if (i != 0) {
			if (vec[i][0] != vec[i - 1][vec[i - 1].size() - 1]) {
				ans = false;
			}
		}
		if (i != n - 1) {
			if (vec[i][vec[i].size() - 1] != vec[i + 1][0]) {
				ans = false;
			}
		}
	}

	for (int i = 0; i < n; ++i) {
		int a = 0;
		for (int j = 0; j < n; ++j) {
			if (vec[i] == vec[j]) {
				a++;
			}
		}
		if (a > 1) {
			ans = false;
		}
	}

	if (ans) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define F first
#define S second
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<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;



int main()
{
    ll n;
    cin >> n;
    vll a(n);
    map<ll, ll> idx;
    rep(i,n){
        ll ai;
        cin >> ai;
        a[i] = ai;
        idx[ai] = i;
    }
    vll b(n);
    copy(all(a), b.begin());
    sort(all(b));
    ll ans = 0;
    rep(i,n){
        ans += (abs(idx[b[i]] - i)%2);
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 , -1};
signed main() {
    int N;
    cin >> N;
    vector<pair<pair<string,int>,int>> vec(N);
    vector<int>ans(N);
    for(int i = 0; i < N; i++) {
        string S;
        int P;
        cin >> S >> P;
        vec[i].first.first = S;
        vec[i].first.second = -P;
        vec[i].second = i;
    }
    sort(vec.begin(),vec.end());
    for(int i = 0; i < N; i++) {
        cout << vec[i].second+1 << endl;
    }
}


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

using namespace std;

int main()
{
    int n,max1=0,max2=0,i;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n-1;i++)
    {
        if(a[i]>=a[i+1])
        {
            max1++;
            continue;
        }
        else
        {
            max2=max(max1,max2);
            max1=0;
        }

    }
    max2=max(max1,max2);
    cout<<max2<<endl;


    return 0;
}


Measured memory_bytes: 640