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

int H, W, K;
char S[310][310];
int ans[310][310];

int main() {
    cin >> H >> W >> K;
    vector<pair<int, int> > st;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
            if (S[i][j] == '#') {
                st.push_back(make_pair(i, j));
            }
        }
    }

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

    for (int i = 0; i < K; i++) {
        int x = st[i].first;
        int y = st[i].second;
        ans[x][y] = i+1;

        for (int j = x-1; j >= 0; j--) {
            if (S[j][y] == '.' && ans[j][y] == -1) {
                ans[j][y] = i+1;
            }
            else {
                break;
            }
        }

        for (int j = x+1; j < H; j++) {
            if (S[j][y] == '.' && ans[j][y] == -1) {
                ans[j][y] = i+1;
            }
            else {
                break;
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (ans[i][j] == -1) {
                if (j == 0) {
                    ans[i][j] = ans[i][j+1];
                }
                else {
                    ans[i][j] = ans[i][j-1];
                }
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = W-1; j >= 0; j--) {
            if (ans[i][j] == -1) {
                if (j == W-1) {
                    ans[i][j] = ans[i][j-1];
                }
                else {
                    ans[i][j] = ans[i][j+1];
                }
                
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;

const int N = 200010;

struct Edge {
  int to, capa, next;
} e[N];

int h[N], sum = 0, n, m;
bool vis[N];
int cmt, cnt, col[N], c[3];
bool falun;

inline int color(const int &x) {
  if (x >= 3) return x - 3;
  if (x < 0) return x + 3;
  return x;
}

void add_edge(int u, int v, int w) {
  e[++sum].to = v;
  e[sum].capa = w;
  e[sum].next = h[u];
  h[u] = sum;
}

void dfs(int u) {
  c[col[u]]++;
  vis[u] = 1;
  cnt++;
  for (int tmp = h[u]; tmp; tmp = e[tmp].next) {
    cmt += (e[tmp].capa == 1);
    int v = e[tmp].to;
    if (!vis[v])
      col[v] = color(col[u] + e[tmp].capa), dfs(v);
    else if (col[v] != color(col[u] + e[tmp].capa))
      falun = 0;
  }
}

int main() {
  int u, v;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    add_edge(u, v, 1);
    add_edge(v, u, -1);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    memset(c, 0, sizeof(c));
    cmt = cnt = 0;
    falun = 1;
    dfs(i);
    if (!falun)
      ans += 1ll * cnt * cnt;
    else if (c[0] && c[1] && c[2])
      ans += 1ll * c[0] * c[1] + 1ll * c[1] * c[2] + 1ll * c[2] * c[0];
    else
      ans += cmt;
  }
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  string s;
  if(n < m){
    rep(i, m){
      cout << n;
    }
    cout << endl;
  }else if(m < n){
    rep(i, n){
      cout << m;
    }
    cout << endl;
  }else{
    rep(i, m){
      cout << m;
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
using namespace std ;
const long long int inf=1e18L+7;
ll n, w;
std::vector<pair<ll,ll>> inp;
/*vector<vector<ll>> dp;

ll knapsack(int i=0,int curr_wt = w)
{
    if(i == n) return 0;
    if(dp[i][curr_wt] == -1)
    {
        ll ans = knapsack(i+1,curr_wt);
        if(curr_wt - inp[i].first >=0)
        {
            ans = max (ans , knapsack(i+1,curr_wt - inp[i].first) + inp[i].second);
        }
        dp[i][curr_wt] = ans;
        return ans;
    }
    else return dp[i][curr_wt];
}

ll babli()
{
    for(int i=0;i<n-1;i++)
    {
        for(int j=i;j<n-1;j++)
        {
            if(inp[j].second/(long double)(inp[j].first) < inp[j+1].second/(long double)(inp[j+1].first))
            {
                swap(inp[j],inp[j+1]);
            }
        }
    }
    
    ll wt=w,value = 0;
    for(int i=0;i<n;i++)
    {
        wt-=inp[i].first;
        if(wt<0) return value;
        value += inp[i].second;
    }
    return value;
}

ll bottoms_up_knapsack ()
{
    for(int i=0;i<=w;i++)
    {
        dp[0][i] = 0;
    }
    for(int i=0;i<=n;i++)
    {
        dp[i][0] = 0;
    }
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            ll ans = dp[i-1][j];
            if(j-inp[i-1].first>=0)
            {
                ans = max(ans,dp[i-1][j-inp[i-1].first] + inp[i-1].second);
            }
            dp[i][j] = ans;
        }
    }
    return dp[n][w];
}
*/
ll final_knapsack()
{
    ll sum_max = 0;
    for(auto ele:inp) sum_max += ele.second;
    vector<ll> final_dp(sum_max + 1,inf);
    final_dp[0] = 0;
    
    for(int i=0;i<n;i++)
    {
        for(int j=sum_max;j>=inp[i].second;j--)
        {
            final_dp[j] = min(final_dp[j],final_dp[j-inp[i].second] + inp[i].first); 
        }
    }
    for(int i=sum_max;i>=0;i--)
    {
        if(final_dp[i]<=w) return i;
    }
}

int main()
{
    cin>>n>>w; 
    inp.resize(n);
    
    for(int i=0;i<n;i++)
    {
        cin>>inp[i].first;
        cin>>inp[i].second;
    }
    //dp.assign(n+1,vector<ll> (w+1,-1));
    //cout<<knapsack()<<endl;
    cout<<final_knapsack()<<endl;
    //cout<<bottoms_up_knapsack()<<endl;
    /*for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
}

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

using namespace std;
typedef long long LL;
int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
const int N = 1750001;
const int mod = 998244353;
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}
void put(int x) {
	if(x < 0) x = -x, putchar('-');
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int ans, jc[N], inv[N];

int add(int x, int y) {
	x += y;
	return x >= mod ? x - mod : x;
}
int dec(int x, int y) {
	x -= y;
	return x < 0 ? x + mod : x;
}
int pow_mod(int a, int k) {
	int ans = 1;
	while(k) {
		if(k & 1) ans = (LL)ans * a % mod;
		a = (LL)a * a % mod, k /= 2;
	} return ans;
}
int C(int n, int m) {
	if(n < m) return 0;
	return (LL)jc[n] * inv[m] % mod * inv[n - m] % mod;
}

int main() {
	int n = read(), m = read();
	int lim = 3 * m / 2 + n - 1;
	jc[0] = 1; for(int i = 1; i <= lim; i++) jc[i] = (LL)jc[i - 1] * i % mod;
	inv[lim] = pow_mod(jc[lim], mod - 2); for(int i = lim; i >= 1; i--) inv[i - 1] = (LL)inv[i] * i % mod;
	for(int i = 0; i <= m; i++) if((3 * m - i) % 2 == 0) ans = add(ans, (LL)C(n, i) * C((3 * m - i) / 2 + n - 1, n - 1) % mod);
	for(int i = 0; i <= m; i++) if((m - i) % 2 == 0) ans = dec(ans, (LL)C(n, i) * C((m - i) / 2 + n - 1, n - 1) % mod * n % mod);
	for(int i = 0; i <= m; i++) if((m - i) % 2 == 0) ans = add(ans, (LL)C(n - 1, i) * C((m - i) / 2 + n - 2, n - 2) % mod * n % mod);
	put(ans), puts("");
	return 0;
}



Measured memory_bytes: 13952
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();

		long[] pa = new long[(int)a];
		long[] pb = new long[(int)b];
		long[] pc = new long[(int)c];
		for(int i = 0; i < a; i++){
			pa[i] = scanner.nextInt();
		}
		for(int i = 0; i < b; i++){
			pb[i] = scanner.nextInt();
		}
		for(int i = 0; i < c; i++){
			pc[i] = scanner.nextInt();
		}
		Arrays.sort(pa);
		Arrays.sort(pb);
		Arrays.sort(pc);
//		long[] xSet = new long[x];
//		long[] ySet = new long[y];
		long[] allSet = new long[x+y];
		int cnt = 0;

		for(int i = 0; i < x; i++){
//			xSet[i] = pa[a-1-i];
			allSet[cnt] = pa[a-1-i];
			cnt++;
		}
		for(int i = 0; i < y; i++){
//			ySet[i] = pb[b-1-i];
			allSet[cnt] = pb[b-1-i];
			cnt++;
		}
		Arrays.sort(allSet);
		int limit = Math.min(pc.length, allSet.length);
		for(int i = 0; i < limit; i++){
			if(allSet[i] < pc[c-1-i]){
				allSet[i] = pc[c-1-i];
			}else{
				break;
			}
		}


		System.out.println(Arrays.stream(allSet).sum());

		scanner.close();
	}

}


Measured memory_bytes: 99056
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <iomanip>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = 1e5 + 10;
const int maxm = 1e5 + 10;
const int mod = 1e9 + 7;
const int inf = 1e9;

int a[maxn];
bool mark[maxn];

bool ok (int x) {
    while (x % 2 == 0)
        x /= 2;
    while (x % 3 == 0)
        x /= 3;
    return (x == 1);
}

int main() {
    ios_base::sync_with_stdio(false);
    int N = 30000;
    int n;
    cin >> n;
    if (n == 3) {
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }
  cout << 2 << " " << 3 << " " << 4 << " " << 9 << " ";
    n -= 4;
    for (int i = 4; n > 1 and 2 * i + 2 <= N; i += 3) {
      cout << i * 2 << " " << 2 * i + 2 << " ";
        n -= 2;
    }
    for (int i = 5; n > 1 and 3 * i <= N; i += 4) {
      cout << 3 * i << " " << 3 * i + 6 << " ";
        n -= 2;
    }
    for (int i = 6; n > 0 and i <= N; i += 6) {
      cout << i << " ";
        n --;
    }
    cout << endl;
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N,tickets;
  cin >> N >> tickets;
  priority_queue<long long> pq;
  froop1(0,N){
    long long a;
    cin >> a;
    pq.push(a);
  }
  froop1(0,tickets){
  	long long b = pq.top();
    pq.pop();
    pq.push(b / 2);
  }
 	long long sum = 0;
  while(!pq.empty()){
    sum += pq.top();
    pq.pop();
  }
  cout << sum << endl;
}

Measured memory_bytes: 4312
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long s;
  cin >> s;
  for (int i=2;i<100010;i++) {
    if (s==1||s==2||s==4) {cout << i+2 << endl;return 0;}
    if (s==8) {cout << i+3 << endl;return 0;}
    if (s%2==0) {s=s/2;} else {s=3*s+1;} 
  }
  
}


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

int main(){
    int n,ans;
    ans = 0;
    cin >> n;
    vector<int> P(n);
    rep(i,n) cin >> P[i];
    rep(i,n-2) if (P[i] < P[i+1] && P[i+1] <  P[i+2]) ans ++;
    else if((P[i] > P[i+1]) && (P[i+1] > P[i+2])) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {
  
ll r; cin>>r;
  cout<<r*r<<endl;
  
  
  
}

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

int h, w;
int ch, dh;
int cw, dw;

vector<string> s;

// ただの辺
struct edge {
    int to;
    long long cost;
    // 引数一つの時は距離1
    edge(int t, long long c = 1) : to(t), cost(c) {}
};

// dijkstra
// depend:edge
vector<long long> dijkstra(vector<vector<edge>> g, int start) {
    using P = pair<long long, long long>;
    vector<long long> res(g.size(), LLONG_MAX);
    res[start] = 0;
    priority_queue<P, vector<P>, greater<P>> pq;  // first:距離、second:行き先
    pq.push({0, start});
    while (!pq.empty()) {
        long long dist = pq.top().first, now = pq.top().second;
        pq.pop();
        if (res[now] < dist) continue;
        for (auto e : g[now]) {
            if (res[e.to] <= res[now] + e.cost) continue;
            res[e.to] = res[now] + e.cost;
            pq.push(make_pair(res[e.to], e.to));
        }
    }
    return res;
}

int p2i(int x, int y) {
    return x * w + y;
}

bool isValid(int x, int y) {
    return x >= 0 && x < h && y >= 0 && y < w && s[x][y] == '.';
}

int main() {
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--, cw--, dh--, dw--;
    s.resize(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }
    vector<vector<edge>> g(h * w);
    vector<pair<int, int>> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                continue;
            }
            for (auto e : dir) {
                int nx = i + e.first, ny = j + e.second;
                if (!isValid(nx, ny)) {
                    continue;
                }
                g[p2i(i, j)].push_back(edge(p2i(nx, ny), 0));
            }
            for (int p = -2; p <= 2; p++) {
                for (int q = -2; q <= 2; q++) {
                    if (p == 0 && q == 0) {
                        continue;
                    }
                    int nx = i + p, ny = j + q;
                    if (!isValid(nx, ny)) {
                        continue;
                    }
                    g[p2i(i, j)].push_back(edge(p2i(nx, ny), 1));
                }
            }
        }
    }
    auto dist = dijkstra(g, p2i(ch, cw));
    lint ans;
    if (dist[p2i(dh, dw)] == LLONG_MAX) {
        ans = -1;
    } else {
        ans = dist[p2i(dh, dw)];
    }
    cout << ans << endl;
}

Measured memory_bytes: 332144
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.printf("%d %d\n", a*b,2*a+2*b);
    }
}


Measured memory_bytes: 26192
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

int main(void) {
  int a, b, t;
  cin >> a >> b >> t;
  cout << (t / a) * b << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
#include <utility>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	int h, w;
	cin >> h >> w;
	vs board(h);
	rep(i, h) {
		cin >> board.at(i);
	}
	rep(i, h + 2) {
		rep(j, w + 2) {
			if (i == 0 or i == h + 1) {
				cout << "#";
				continue;
			}
			if (j == 0 or j == w + 1) {
				cout << "#";
				continue;
			}
			cout << board.at(i - 1).at(j - 1);
		}
		cout << endl;
	}
	return 0;
}


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

void fib(int h[],int dp[],int n){
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }   
}

int main(){
    int n;
    cin>>n;
    int h[n],i,dp[n];
    for(i=0;i<n;i++){
        cin>>h[i];
    }
    int s=0;
    fill_n(dp,n,-1);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    fib(h,dp,n);
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
N, Y = map(int, input().split())
a = -1
b = -1 
c = -1

for i in range(N+1):
    for j in range(N+1-i):
        if Y - (10000*i + 5000*j) == 1000*(N-i-j):
            a = i
            b = j
            c = N - i -j
            break

print(a, b, c)

Measured memory_bytes: 3060
<?php
fscanf(STDIN, '%d %d %d', $a, $b, $x);

$ans = null;
if ($a * $a * $b / 2 <= $x) {
    $ans = atan(2 * ($a * $a * $b - $x) / ($a * $a * $a));
} else {
    $ans = M_PI / 2 - atan(2 * $x / ($a * $b * $b));
}

printf('%.10f', $ans * 180 / M_PI);


Measured memory_bytes: 4728
N, M = map(int , input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1 and M == 2:
    print(0)
elif N == 2 and M == 1:
    print(0)
elif N == 1 or M == 1:
    print(N*M - 2)
else:
    print((N-2) * (M-2))

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


int main(){
	int n,m,l;
	int i,j,k;
	int A[100][100], B[100][100];
	long C[100][100]={0};
	
	cin >> n >> m >> l ;
	
	for(i = 0; i<n; i++){
		for(j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	
	for(i = 0; i<m; i++){
		for(j=0; j<l; j++){
			cin >> B[i][j];
		}
	}
			
	for(i = 0 ; i < n ; i++){
		for(j = 0; j < l ; j++){
			for(k = 0; k < m; k++){
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}	
	
	for(i = 0; i<n; i++){
		for(j=0; j<l; j++){
			cout << C[i][j];
			if(j != l -1){
				cout << " " ;
			}
		}
		cout << endl;
	}
	

    return 0;
}

Measured memory_bytes: 3204
# include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	fast;
    int n;
    cin>>n;
    int dp[n+1][3]={}, arr[n+1][3]={}, flag=0;
    for(int i=1; i<=n; i++){
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    dp[1][0] = arr[1][0];
    dp[1][1] = arr[1][1];
    dp[1][2] = arr[1][2];
    int pm_ind, mx_ind;
    mx_ind = (int)(max_element(arr[1], arr[1]+3)-arr[1]);
    for(int i=2; i<=n; i++){

        for(int j=0; j<3; j++){
            if(mx_ind==j){
                dp[i][j] = arr[i][j] + max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
            }
            else{
                dp[i][j] = arr[i][j] + dp[i-1][mx_ind];
            }

        }
        mx_ind = (int)(max_element(dp[i], dp[i]+3)-dp[i]);
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
//    for(int i=2; i<=n; i++){
//        for(int j=0; j<3; j++){
//            cout<<dp[i][j]<<" ";
//        }
//        cout<<endl;
//        }
    return 0;
}



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> num(4, 0);
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        if(s == "AC"){
            num[0]++;
        }else if(s == "WA"){
            num[1]++;
        }else if(s == "TLE"){
            num[2]++;
        }else if(s == "RE"){
            num[3]++;
        }
    }
    cout << "AC x " << num[0] << endl;
    cout << "WA x " << num[1] << endl;
    cout << "TLE x " << num[2] << endl;
    cout << "RE x " << num[3] << endl;

    
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
int main(){
  ll N,i;scanf("%lld",&N);
  ll A[N],ans[N];
  for(i=0;i<N;i++) scanf("%lld",&A[i]);
  ans[0] = accumulate(A,A+N,0LL);
  for(i=1;i<N;i+=2) ans[0] -= A[i]*2;
  for(i=1;i<N-1;i++) ans[i] = A[i-1]*2-ans[i-1];
  ans[N-1] = A[N-1]*2-ans[0];
  for(i=0;i<N;i++) printf("%lld ",ans[i]);
  printf("\n");
}

Measured memory_bytes: 5384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
using namespace std;

int main() {
	long long N, i=1,j;
	vector<long long> NN;
	cin >> N;

	while(N>=0){
		NN.push_back(i);
		N -= i;
		//cout << i << endl;
		i++;
	}
	for (j = 0; j < i-1; j++) {
		if (NN[j] != N*-1) {
			cout << NN[j] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  
  if(a<=b) co(a);
  else co(a-1);
  
  return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

template<class T> inline bool chmin(T& a, const T b) { if (a>b) { a=b; return true; } return false; }
template<class T> inline bool chmax(T& a, const T b) { if (a<b) { a=b; return true; } return false; }

#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    ll a;
    cin>>a;
    ll ans = a+pow(a,2) + pow(a,3);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4084
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

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

int N;
int main(void){
    cin >> N;
    cout << (10000-N)%1000 << endl;
    return 0;
}



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

int N, a[100001], c[100001], L, R;

const int MAX = 100002;
const int mod = 1e9 + 7;

// fac[]・・・a! finv[]・・・(a!)^(-1) inv[]・・・a^(-1)

long long fac[MAX], finv[MAX], inv[MAX];

void pre_comb(void){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<MAX; i++){
		fac[i] = fac[i-1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod/i) % mod;
		finv[i] = finv[i-1] * inv[i] % mod;
	}
}

long long comb(int n, int k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
	pre_comb();
	cin >> N;
	fill(c, c+N+1, -1);
	for(int i=0; i<N+1; i++){
		cin >> a[i];
		if(c[a[i]] != -1){
			L = c[a[i]];
			R = i;
		}else{
			c[a[i]] = i;
		}
	}
	for(int k=1; k<=N+1; k++){
		long long dup = comb(L+N-R, k-1);
		cout << (comb(N+1, k) - dup + mod) % mod << endl;
	}
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cmath>
 
using namespace std;
 
int n;
int x[25], y[25], r[25], c[25], b[25];
int dp[1<<24];
 
bool chackOverLap(int i, int j){
    int dist1 = pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2);
    int dist2 = pow(r[i]+r[j], 2);
    return dist2 > dist1;
}
 
int main(void){
    while(1){
        cin >> n;
        if(!n) break;
        for(int i=0; i<n; i++){
            cin >> x[i] >> y[i] >> r[i] >> c[i];
            b[i] = 0;
            for(int j=0; j<i; j++){
                if(chackOverLap(i, j)) b[i] |= (1<<j);
            }
        }
 
        int S = (1<<n);
        fill(dp, dp+S, -1);
        dp[0] = 0;
 
        int ans = 0;
        for(int i=0; i<S; i++){
            if(dp[i] == -1) continue;
            ans = max(ans, dp[i]);
            for(int j=0; j<n-1;j ++){
                if((i & (1<<j)) != 0 || (i & b[j]) != b[j]) continue;
                for(int k=j+1; k<n; k++){
                    if(c[j] != c[k] || (i & (1<<k)) != 0 || (i & b[k]) != b[k]) continue;
                    int next = i | (1<<j) | (1<<k); 
                    dp[next] = max(dp[next], dp[i]+2);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 68616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll h, w, n;
    cin >> h >> w >> n;
    vector<ll> a(n, 0);
    rep1(i, n) cin >> a[i];
    vector<vector<ll> > color(h, vector<ll>(w));
    ll ndx = 0;
    for (ll i=0; i<(h); i++){
        for (ll j=0; j<(w); j++){
            ll x, y;
            x = i;
            if (x%2==0) y = j;
            else y = w-1 - j; 
            color[x][y] = ndx+1;
            a[ndx]--;
            if (a[ndx]==0) ndx++;
        }
    }
    for (ll i=0; i<(h); i++){
        for (ll j=0; j<(w); j++){
            if (j<w-1) cout << color[i][j] << " ";
            else cout << color[i][j] << endl;
        }
    }
    //printf("%.12f", ans);
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll x,y;
  cin >> x >> y;
  pr(max({x+y,x-y,x*y}));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
string S,T;
void input()
{
  cin>>S>>T;
}
  void solve()
{
 
    T.pop_back();
  if(S==T)
  
    cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  
}
int main()
{
  input();
   solve();
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int retu[8][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};

int main(){
    int N;
    string S, T;
    cin >> N >> S >> T;
    for(int i = 0; i < N; i++){
        cout << S[i] << T[i];
    }
    cout << endl;
}


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

typedef long long LL;
typedef pair<int, int> II;

const int N = 100;
int n, m, a[N][N];
char S[N][N];

int main() {
    #ifdef LOCAL
        freopen("Data.inp", "r", stdin);
        freopen("Data.out", "w", stdout);
    #endif

    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf("%s", S[i] + 1);

    for (int i = 1, j = 1; i <= n; ++i) {
        while (j <= m && S[i][j] == '#') {
            a[i][j] = 1;
            j++;
        }
        j--;
    }

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (a[i][j] == 0 && S[i][j] == '#') {
                puts("Impossible");
                return 0;
            }
    puts("Possible");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  double a,b;
  double y;
  int x;
  cin>>a>>b;
  y=(a+b)/2;
  x=(a+b)/2;
  if(x==y){
  cout<<x<<endl;
  }else{
  cout<<x+1<<endl;
  }
 
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll a,b,c,k;cin>>a>>b>>c>>k;
    if(a>=k) ans=k;
    else if(a+b>=k) ans=a;
    else ans=a-(k-a-b);
    cout << ans << endl;
    
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	while(cin>>s){
		int n=s.size();
		int a=0,b=0,c=0;
		
		//JOI
		int ans=0;
		for(int i=0;i<n;i++){
			if(s[i]=='J'){
				if(i==0 || s[i-1]!='J'){
					a=0;
					b=0;
					c=0;
				}
				a++;
				b=0;
				c=0;
			}else if(s[i]=='O'){
				if(i==0 || s[i-1]=='I'){
					a=0;
					b=0;
					c=0;
				}
				b++;
				c=0;
				if(b>a){
					a=0;
					b=0;
					c=0;
				}
			}else{
				c++;
				if(c>a||c>b){
					a=b=c=0;
				}
			}
			if(a>=b&&b==c)
				ans=max(ans,c);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1984
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.InputStreamReader;
import java.io.InputStream;

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

    static class ATakahashiCalendar {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int m = in.nextInt(), d = in.nextInt();

            int answer = 0;
            for (int t = 2; t <= 9; t++) {
                for (int o = 2; o <= 9; o++) {
                    if (t * 10 + o <= d && t * o <= m) {
                        answer++;
                    }
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 21588
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define endl "\n"
#define sz(u) (int)(u.size())
typedef long long ll;
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    string s;
    cin>>n>>s;
    if(n%2==0){
        if(s.substr(0,n/2)==s.substr(n/2,n)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int L = Integer.parseInt(sc.next());
        int R = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int result = 0;

        for (int i = L; i <= R; i++) {
            if (i % d == 0) {
                result++;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);
        out.flush();
        sc.close();
    }
}

Measured memory_bytes: 35708
#include <stdio.h>
 
int main(void){
    char s1[4];
    char s2[4];
    scanf("%s%s",s1,s2);
    if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0]) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N>>B;
    if(N<=5){
        B = 0;
        cout<<B<<endl;
        return 0;
    }
    if(N<=12){
        B = B/2;
        cout<<B<<endl;
        return 0;
    }
    cout<<B<<endl;
}

Measured memory_bytes: 256
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N=[int(x) for x in input().split()]
if N[1]==1 or N[1]==0:
  sum1=0
else:
  sum1 = comb(N[1], 2)
if N[0]==1 or N[0]==0:
  sum2=0
else:
    sum2 = comb(N[0], 2)
print(sum1+sum2)


Measured memory_bytes: 3060
str = input()
flg=0
for n in range(0,len(str)-2):
  if(str[n]==str[n+1]):
    print(n+1,n+2)
    flg =1
    break
  elif (str[n]==str[n+2]):
    print(n+1,n+3)
    flg=1
    break
if flg ==0:
  if str[len(str)-2]== str[len(str)-1]:
    print(len(str)-1,len(str))
  else:
    print(-1,-1)
    
  

Measured memory_bytes: 70432
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>
 
int main(void){
	int h, w;
	std::cin >> h >> w;
	std::vector<std::string> map(h);
	std::vector<std::vector<int>> cnt(h);
	for(int i=0;i<h;i++)std::cin >> map[i];
	for(int i=0;i<h;i++){
		cnt[i].resize(w);
		int s = 0;
		for(int j=0;j<w;j++){
			if(map[i][j] == '#'){
				for(int k=s;k<j;k++){
					cnt[i][k] = j-s;
				}
				s = j+1;
			}
		}
		for(int k=s;k<w;k++){
			cnt[i][k] = w-s;
		}
	}
	
	for(int i=0;i<w;i++){
		int s = 0;
		for(int j=0;j<h;j++){
			if(map[j][i] == '#'){
				for(int k=s;k<j;k++){
					cnt[k][i] += j-s-1;
				}
				s = j + 1;
			}
		}
		for(int k=s;k<h;k++){
			cnt[k][i] += h-s-1;
		}
	}
	int ans = 0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(map[i][j] == '#')continue;
			ans = std::max(cnt[i][j], ans);
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 20096
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
typedef vector<int> VI;
#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )

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

    const double rate  = 1.05;
    int debt = 100000;

    int n;
    cin >> n;
    
    REP(i, 0, n) {
        debt *= rate;
        debt = ceil(debt / 1000.0) * 1000;
    }
    
    cout << debt << endl;

    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    double r, g;
    std::cin >> r >> g;
    // g = (r + p) / 2
    // r + p = 2 * g -> p = 2 * g - r
    std::cout << (2 * g - r) << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
const int mod = 1000000007;
typedef long long ll;
//------------------------------------------------------------------------

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

  int h,w,n; cin >> h >> w >> n;
  int tmp = min(w,h);
  int tmp2 = max(w,h);
  
  int num=0;
  int ans=0;
  while(num<n){
    num+=tmp2;
    ans++;
  }
  
  cout << ans << endl;
    
  

  return 0;
}



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

using namespace std;

int main()
{
    // 初期値
    int house[4][3][10];

    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                house[i][j][k] = 0;
            }
        }
    }

    // 入力

    int n, b, f, r, v;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> b >> f >> r >> v;
        house[b - 1][f - 1][r - 1] += v;
    }

    // 表示
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                cout << " " << house[i][j][k];
                {
                    /* code */
                }

                if (k == 9)
                {
                    cout << endl;
                }

                if (j == 2 && k == 9 && i != 3)
                {
                    cout << "####################" << endl;
                }
            }
        }
    }
}


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

int main(){
	int a='a'-'A';
	
	string s;
	getline(cin,s);
	
	for(int i=0;i<s.size();i++){
		if(s[i]>='a'&&s[i]<='z')s[i]-=a;
	}
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define int ll


int h,w;
int n;
int a[501][501];
vector<P> ans1,ans2;


void f(){
  int x=1,y=1;
  while(1){
    if(y==h&&(h%2&&x==w||h%2==0&&x==1)) break;

    if(a[y][x]%2){
      n++;
      ans1.push_back(P(y,x));
    }
    if(y%2&&x==w||y%2==0&&x==1){
      if(a[y][x]%2){ 
        ans2.push_back(P(y+1,x));
        a[y+1][x]++;
      }
      y++;
    }
    else if(y%2){
      if(a[y][x]%2){ 
        ans2.push_back(P(y,x+1));
        a[y][x+1]++;
      }
      x++;
    }
    else {
      if(a[y][x]%2){ 
        ans2.push_back(P(y,x-1));
        a[y][x-1]++;
      }
      x--;
    }
  }
}


signed main(){
  cin>>h>>w;
  rep(i,h){
    rep(j,w){
      cin>>a[i+1][j+1];
    }
  }

  f();

  cout<<n<<endl;

  rep(i,ans1.size()){
    cout<<ans1[i].first<<' '<<ans1[i].second<<' '<<ans2[i].first<<' '<<
    ans2[i].second<<endl;
  }

}

Measured memory_bytes: 8164
#include <bits/stdc++.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 ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

namespace Printer{
    void print(vector<int> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    void print(vector<vector<int> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};

//--global--//



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

bool rused[101], bused[101];

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n;
    cin >> n;
    vector<pair<int, int> > red;
    vector<pair<int, int> > blue;
    rep(i, n){
        int a, b; cin >> a >> b;
        red.push_back(make_pair(b, a));
    }
    rep(i, n){
        int a, b; cin >> a >> b;
        blue.push_back(make_pair(a, b));
    }

    sort(ALL(blue));
    sort(ALL(red), greater<pair<int, int> >() );

    int cnt = 0;
    rep(i, blue.size()){
        if(bused[i] == true) continue;
        pair<int, int> nowB = blue[i];
        rep(j, red.size()){
            if(rused[j] == true) continue;
            pair<int, int> nowR = red[j];
            if(nowR.first < nowB.second && nowR.second < nowB.first){
                // Printer::print(nowB);
                // Printer::print(nowR);
                bused[i] = true;
                rused[j] = true;
                cnt++;
                break;
            }
        }
    }

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


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

#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)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n) {
    llong ans = x;
    if (n == 0) return 1;

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

    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

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

    char target[3];
    for (int i = 0; i < 3; ++i) {
        target[i] = S[i];
    }

    sort(target, target + 3);

    if (target[0] == 'a' && target[1] == 'b' && target[2] == 'c') cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define pi acos(-1)
#define pb push_back
#define fr first
#define sc second
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define r0 return 0

using namespace std;

int main()
{
     ll a,b,c,d;

     cin>>a>>b>>c;

     d=a+b+c;

     if(d>=22)cout<<"bust"<<endl;
     else cout<<"win"<<endl;
}


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

#define ll long long

int main()
{
    int n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    if(n==1)
    	{
    		cout<<"Yes";
    		return 0;
    	}
    arr[0]--;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]==arr[i+1])
        	continue;
        else if(arr[i]<=arr[i+1])
        	arr[i+1]--;
        else
        {
        	cout<<"No";
        	return 0;
        }
    }
    cout<<"Yes";
} 

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;

int main(void) {
	int n, r;
	cin >> n >> r;
	
	if( n < 10 ) cout << r + (100 * (10 - n)) << endl;
	else cout << r << endl;
	
	return 0;
}


Measured memory_bytes: 256
class Node:
    def __init__(self, val, next_node = None):
        self.value = val
        self.next = next_node
        
class que:
    def __init__(self):
        self.start = None
        self.last = None
    def append(self, num):
        new_node = Node(num)
        if self.start == None:
            self.start = new_node
            self.last = new_node
        else:
            self.last.next = new_node
            self.last = new_node
    def popleft(self):
        return_node = self.start
        self.start = return_node.next
        return return_node.value
    def isempty(self):
        return self.start == None
    def print_vals(self):
        node = self.start
        output =""
        while node != None:
            output += str(node.value)
            node = node.next
        print(output)
        
       
n, p = map(lambda x:int(x), input().split(' '))
processes = que()
for i in range(n):
    name, time = input().split(' ')
    time = int(time)
    processes.append((name, time))
all_time = 0
while not processes.isempty():
    name, time = processes.popleft()
    if time <= p:
        all_time += time
        print(f'{name} {all_time}')
    else:
        all_time += p
        processes.append((name, time - p))


Measured memory_bytes: 19964
import sys; input = sys.stdin.buffer.readline
import numpy as np
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = 2 ** 63 - 1

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	h = np.array(getlist() + [0] * K, dtype = np.int64)
	
	DP = np.full(N + K, INF, dtype = np.int64)
	DP[0] = 0
	for i in range(N):
		DP[i + 1:i + K + 1] = np.minimum(DP[i + 1:i + K + 1],
			DP[i] + np.abs(h[i] - h[i + 1:i + K + 1]))

	print(DP[N - 1])

if __name__ == '__main__':
	main()

Measured memory_bytes: 21344