akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>

using namespace std;
const int isFF = 1;
const int isBLOCK = 2;

typedef unordered_map<int, unordered_map<int, int>> rel;
class Rel {
  rel _rel;
public:
  void set(int left, int right, int value) {
    auto first = min(left, right);
    auto second = max(left, right);
    _rel[first][second] = value;
  };

  int get(int left, int right) {
    auto first = min(left, right);
    auto second = max(left, right);
    auto itr = _rel.find(first);
    if (itr == _rel.end()) {
      return 0;
    }

    return _rel[first][second];
  };
};

class Node {
public:
  int index;
  set<int> adj;
};

pair<vector<vector<int>>, vector<int>> findPaths(vector<Node>& nodes) {
  vector<vector<int>> paths;
  vector<int> gchecked(nodes.size(), -1);
  gchecked.shrink_to_fit();

  for (const Node& n : nodes) {
    bool already_in = gchecked[n.index] != -1;
    if (already_in) {
      continue;
    }

    vector<int> p;
    stack<const Node*> stk;
    stk.push(&n);
    while(!stk.empty()) {
      auto t = stk.top();
      p.push_back(t->index);
      stk.pop();
      
      gchecked[t->index] = paths.size();
      for (auto i : t->adj) {
        if (gchecked[i] == -1) {
          gchecked[i] = paths.size();
          stk.push(&nodes[i]);
        }
      }
    }
    paths.push_back(p);
  }

  return make_pair(paths, gchecked);
}

int main() {

  int N, M, K;
  cin >> N >> M >> K;

  unordered_map<int, unordered_map<int, int>> blocks;
  unordered_map<int, unordered_map<int, int>> friends;
  vector<Node> nodes(N);
  vector<int> result(N, 0);
  for (int i = 0; i < nodes.size(); ++i) {
    nodes[i].index = i;
  }

  int left, right;
  for (int i = 0; i < M; ++i) {
    cin >> left >> right;
    nodes[left-1].adj.insert(right-1);
    nodes[right-1].adj.insert(left-1);
    --result[left-1];
    --result[right-1];
    // friends[left][right] = isFF;
    // friends[right][left] = isFF;
  }
  for (int i= 0; i<K; ++i) {
    cin >> left >> right;
    blocks[left - 1][right - 1] = isBLOCK;
    blocks[right - 1][left - 1] = isBLOCK;
  }

  auto paths_and_belongs = findPaths(nodes);
  
  auto paths = paths_and_belongs.first;
  auto belongs = paths_and_belongs.second;

  for (auto& p : paths) {
    for (auto outer = p.begin(); outer != p.end(); ++outer) {
      int same_bl = 0;
      int same_fr = 0;
      for (auto& bl : blocks[*outer]) {
        if (belongs[bl.first] == belongs[*outer]) {
          ++same_bl;
        }
      }
      // for (auto& fr : friends[*outer]) {
      //   if (belongs[fr.first] == belongs[*outer]) {
      //     ++same_fr;
      //   }
      // }
      result[*outer] += p.size() - same_bl -same_fr- 1;
    }
  }
  for (int i = 0; i < N - 1; ++i) {
    cout << result[i] << " ";
  }
  cout << result[N - 1] << endl;
  return 0;
}



Measured memory_bytes: 44428
#include<iostream>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define MAX 10000

class Data
{
public:
	Data* parent = this;
	int height = 1;
	void Find(Data* other)
	{
		Data* temp = this;
		Data* temp_other = other;
		while (1)
		{
			if (temp == temp->parent)break;
			temp = temp->parent;
		}
		while (1)
		{
			if (temp_other == temp_other->parent) break;
			temp_other = temp_other->parent;
		}
		if (temp == temp_other)cout << 1 << endl;
		else cout << 0 << endl;
	}
	void Unite(Data* other)
	{
		Data* temp = this;
		Data* temp_other = other;
		while (1)
		{
			if (temp == temp->parent)break;
			temp = temp->parent;
		}
		while (1)
		{
			if (temp_other == temp_other->parent) break;
			temp_other = temp_other->parent;
		}
		if (temp_other->height > temp->height)
		{
			temp->parent = temp_other;
		}
		else if (temp_other->height == temp->height)
		{
			temp->parent = temp_other;
			temp_other->height++;
		}
		else
		{
			temp_other->parent = this;
		}
	}
};
int main()
{
	Data data[MAX];
	int n, q;
	cin >> n >> q;
	REP(i, q)
	{
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0)data[x].Unite(&data[y]);
		else
		{
			data[x].Find(&data[y]);
		}
	}
	return 0;
}

Measured memory_bytes: 3252
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>

#include <map>
 
using namespace std;
typedef long long ll; 


ll ans,mx,sum,mn=1e18,flag;

int main(){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	sort(a,a+n);
	k--;
	for(ll i=0; i<n; i++){
		if(i+k <n){
			flag = a[i+k]-a[i];
			mn=min(mn,flag);
		}
	}
	cout<<mn<<endl;
	
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef int64_t LL;
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7;
int main()
{
  int N;
  LL A=0,x;
  cin>>N;
  vector<LL> bit(60,0);
  while(cin>>x){rep(i,60)bit.at(i)+=x>>i&1;}
  rep(i,60)A=fmod(A+fmod(((N-bit.at(i))*bit.at(i)%MOD*pow(2,i)),MOD),MOD);
  return cout<<A<<endl,0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/




int main(void) {
  ll i, j, k;
  
  ll D;
  cin >> D;
  ll c[26];
  ll s[366][26];
  
  for(i=0; i<26; i++) cin >> c[i];
  for(i=0; i<D; i++) {
    for(j=0; j<26; j++) {
      cin >> s[i][j];
    }
  }
  
  srand((unsigned)time(NULL)); rand();
  for(i=0; i<365; i++) pt((ll)(1+26*(rand()/(RAND_MAX+1.0))));
  
  
  
}



Measured memory_bytes: 3712
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

int retl(int K,int L){
    int tmp=0;
    while(pow(2,tmp) * L < K){
        tmp++;
    }
    return tmp;
}

struct A{
    string s;
    int p;
    int order;
};


int main(){
    int X,A;
  
    

    cin  >> X>>A;
   
    int ans;
    if(X<A){
        ans=0;
    }else{
        ans=10;
    }

  
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll dp[500][500];
int a[500];
ll cost[500][500];

int main(){
	int n;scanf("%d",&n);
	memset(dp,0x3f,sizeof(dp));
	rep(i,n){
		scanf("%d",&a[i]);
		dp[i][i]=0;
	}
	rep(i,n){
		ll sum=0;
		for(int j=i;j<n;j++){
			sum+=a[j];
			cost[i][j]=sum;
		}
	}
	for(int i=2;i<=n;i++){
		rep(j,n-i+1){
			int k=j+i-1;
			for(int t=j;t<k;t++){
				dp[j][k]=min(dp[j][k],dp[j][t]+dp[t+1][k]+cost[j][k]);
			}
		}
	}
	cout<<dp[0][n-1]<<endl;
}

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


long long int play(vector<int>& seqs){
    int size = seqs.size();

    vector<vector<vector<long long int>> > records = vector<vector<vector<long long int> > >(size, vector<vector<long long int> >(size, vector<long long int>(2, 0)));


    for(int left = size-1; left >= 0; left--)
        for(int right = left; right < size; right++)
            for(int player = 0; player < 2; player++){

                if(left == right){
                    records[left][right][player] = seqs[left];
                    continue;
                }

                int competiter = player ^ 1;
                long long int better;
                long long int get_left = -records[left+1][right][competiter]+seqs[left];
                long long int get_right = -records[left][right-1][competiter]+seqs[right];

    //            if(player == 0)
                    better = max(get_left, get_right);
      //          else
        //            better = min(get_left, get_right);

                records[left][right][player] = better; 
            
                //cout << "l=" << left << " r=" << right << " p=" << player <<" better=" << better << "\n";
            }

    return records[0][size-1][0];
}

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

    vector<int> seqs(n);

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

    long long int result = play(seqs);  
    cout << result << "\n";

    return 0;
}


Measured memory_bytes: 493696
#include<stdio.h>
int main(void)
{
	int a[29],flg[31],i,j;
	for(i=1;i<=30;i++){
		flg[i]=0;
	}
	for(i=0;i<28;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<28;i++){
		flg[a[i]]=1;
	}
	for(i=1;i<=30;i++){
		if(flg[i]==0){
			printf("%d\n",i);
		}
	}
	return 0;
}	

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 1000;
ll mod = INF;

char g[maxn+5][maxn+5];
bool used[maxn+5][maxn+5];
int dis[maxn+5][maxn+5];
int h,w;
ll ans=0;
ll ch,cw;
ll dh,dw;
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};

int main(){

    cin >> h>>w;
    cin >> ch>>cw;
    cin >> dh>>dw;
    ch--;cw--;dh--;dw--;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> g[i][j];
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            dis[i][j]=-1;
        }
    }

    queue<pair<int,int>> que;
    queue<pair<int,int>> searched;
    queue<pair<int,int>> souko;
    que.push(make_pair(ch,cw));
    souko.push(make_pair(ch,cw));
    used[ch][cw]=true;
    int cost=0;
    dis[ch][cw]=cost;


    while(true){

        while(!souko.empty()){
            searched.push(souko.front());
            souko.pop();
        }

        while(!que.empty()){
            pair<int,int> arg=que.front();que.pop();
            for(int i=0;i<4;i++){
                int ny=arg.first+dy[i],nx=arg.second+dx[i];
                if(0<=ny&&ny<h&&0<=nx&&nx<w&&!used[ny][nx]&&g[ny][nx]=='.'){
                    dis[ny][nx]=cost;
                    used[ny][nx]=true;
                    que.push(pair<int,int>(ny,nx));
                    searched.push(pair<int,int>(ny,nx));
                }
            }
        }

        if(searched.empty())break;

        cost++;

        while(!searched.empty()){
            pair<int,int> arg=searched.front();searched.pop();
            for(int ny=arg.first-2;ny<=arg.first+2;ny++){
                for(int nx=arg.second-2;nx<=arg.second+2;nx++){
                    if(0<=ny&&ny<h&&0<=nx&&nx<w&&!used[ny][nx]&&g[ny][nx]=='.'){
                        dis[ny][nx]=cost;
                        used[ny][nx]=true;
                        que.push(make_pair(ny,nx));
                        souko.push(make_pair(ny,nx));
                    }
                }
            }
        }
    }

    // for(int i=0;i<h;i++){
    //     for(int j=0;j<w;j++){
    //         cout << dis[i][j]<<" ";
    //     }
    //     cout << endl;
    // }

    cout << dis[dh][dw]<<endl;

    return 0;
}

Measured memory_bytes: 9488
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int H, W;
	cin >> H >> W;
	vector<vector<char>> S(H, vector<char>(W));
	cin.ignore();
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			cin >> S[i][j];
		}
		cin.ignore();
	}

	vector<vector<vector<int>>> counter(H, vector<vector<int>>(W, vector<int>(2)));
	int max_count = 0;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if (S[i][j] == '#')
			{
				counter[i][j][0] = 0;
				counter[i][j][1] = 0;
				continue;
			}
			if (i > 0 && S[i - 1][j] != '#')
			{
				counter[i][j][0] = counter[i - 1][j][0];
			}
			else
			{
				counter[i][j][0] = 0;
				for (int k = i; k < H && S[k][j] != '#'; ++k)
				{
					++counter[i][j][0];
				}
			}
			if (j > 0 && S[i][j - 1] != '#')
			{
				counter[i][j][1] = counter[i][j - 1][1];
			}
			else
			{
				counter[i][j][1] = 0;
				for (int k = j; k < W && S[i][k] != '#'; ++k)
				{
					++counter[i][j][1];
				}
			}
			max_count = max(max_count, counter[i][j][0] + counter[i][j][1] - 1);
		}
	}

	cout << max_count << endl;

	return 0;
}


Measured memory_bytes: 223232
def left(i)
  return i*2-1
end

def right(i)
  return i*2
end

def max_heapify(heap,i)
  l=left(i)
  r=right(i)

  if l < heap.length and heap[l] > heap[i-1]
    largest = l
  else
    largest = i-1
  end
  if r < heap.length and heap[r] > heap[largest]
    largest = r
  end

  if largest != i-1
    heap[i-1], heap[largest] = heap[largest], heap[i-1]
    max_heapify(heap, largest+1)
  end
end

def build_max_heap(heap)
  heap.length.downto(1) do |i|
    max_heapify(heap, i)
  end
end

heap_size = STDIN.gets()
heap = STDIN.gets().split(' ').map{ |i| i.to_i }

build_max_heap(heap)

print " #{heap.join(' ')}\n"

Measured memory_bytes: 64588
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
        int a,b,c,ans=0;
        cin >> a >> b >> c;
        for(int i=a;i<=b;i++){
                if(c%i == 0){
                        ans++;
                }
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3076
from time import time
stime = time()
 
from copy import copy
from random import randint
 
def get_fav_contest(s, t):
    s = copy(s)
    t = copy(t)
    dc = 0
    d = len(t)
    for i in range(1, d):
        dc += s[i][t[i]]
        ca[t[i]] = i
        dc -= sum([c[i2] * (i - ca[i2]) for i2 in range(1, 27)])
    return dc
 
d = int(input())
c = [0] + list(map(int, input().split(' ')))
 
s = [[]] + [[0] + list(map(int, input().split(' '))) for _ in range(d)]
 
t = 0 # 算出結果
tl = [0]
 
ca = [0] * (1 + 26) # 放置された不満の数々
cat = [] # 不満度の最適な算出のための一時配列
cat2 = []
 
for i in range(1, d + 1):
    cat = [0]
    for i2 in range(1, 27):
        cat2 = copy(ca)
        cat2[i2] = i
        cat.append(s[i][i2] + sum(c[i3] * (i - ca[i3]) for i3 in range(1, 27)))
    t = cat.index(max(cat))
    ca[t] = i
    tl.append(t)
 
default_t = get_fav_contest(s, tl)
 
ch = 0 # 適当に選んだ日
temp1 = 0 # 一時的に保存する場所
tempt = 0
while time() - stime < 1.95:
    ch = randint(1, 365)
    temp1 = tl[ch]
    tl[ch] = randint(1, 26)
    tempt = get_fav_contest(s, tl)
    if tempt < default_t:
        tl[ch] = temp1
    else:
        default_t = tempt
print('\n'.join(map(str, tl[1:])))

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

int main()
{
    int N;
    string  A[110];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
        if(A[i] == "Y"){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b,c,i,k,spa,data[3];
	scanf("%d %d %d",&a,&b,&c);
	data[0]=a;
	data[1]=b;
	data[2]=c;
	for(i=0;i<3;i++){
		if(data[i]>=1 && data[i]<=10000){
			for(k=i+1;k<3;k++){
				if (data[i]>data[k]) {
        				spa=data[i];
        				data[i]=data[k];
        				data[k]=spa;
      				}
			}
		}
	}
	printf("%d %d %d\n",data[0],data[1],data[2]);
	return 0;
}
		

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

long long int s(int N, int M, int fx,int fy,int fz,long long int x[],long long int y[],long long int z[]){
  long long int a[N];
  for (int i=0; i<N; i++){
    a[i]=(long long int)fx*x[i]+(long long int)fy*y[i]+(long long int)fz*z[i];
  }
  sort(a,a+N,greater<long long int>());
  long long int res;
  res=0;
  for (int i=0; i<M;i++){
    res+=a[i];
  }
  return res;

}

int main(){
  int N,M;
  cin>>N>>M;
  long long int x[N],y[N],z[N];
  for (int i=0; i<N;i++){
    cin>>x[i]>>y[i]>>z[i];
  }
  cout<<max({
    s(N,M,1,1,1,x,y,z),
    s(N,M,1,1,-1,x,y,z),
    s(N,M,1,-1,1,x,y,z),
    s(N,M,1,-1,-1,x,y,z),
    s(N,M,-1,1,1,x,y,z),
    s(N,M,-1,1,-1,x,y,z),
    s(N,M,-1,-1,1,x,y,z),
    s(N,M,-1,-1,-1,x,y,z)}
  )<<endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] x = new long[n];
        long[] y = new long[n];
        long[][] p = new long[n][2];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextLong();
            y[i] = sc.nextLong();
            p[i] = new long[]{x[i], y[i]};
        }
        Arrays.sort(x);
        Arrays.sort(y);
        Arrays.sort(p, (a,b)->Long.compare(a[0], b[0]));
        int[][] a = new int[n][n];
        for (int i = 0; i < n; i++) {
            long ty = p[i][1];
            for (int j = 0; j < n; j++) {
                if(0 < i) a[i][j] += a[i-1][j];
                if(0 < j) a[i][j] += a[i][j-1];
                if(0 < i && 0 < j) a[i][j] -= a[i-1][j-1];
                if(ty == y[j]) a[i][j]++;
            }
        }
        long ans = Long.MAX_VALUE;
        for (int i = 0; i <= n-k; i++) {
            for (int j = 0; j <= n-k; j++) {
                for (int ii = k-1; ii < n-i; ii++) {
                    for (int jj = k-1; jj < n-j; jj++) {
                        int c = a[i+ii][j+jj];
                        if(0 < i) c -= a[i-1][j+jj];
                        if(0 < j) c -= a[i+ii][j-1];
                        if(0 < i && 0 < j) c += a[i-1][j-1];
                        if(c < k)continue;
                        long tmp = (x[i+ii] - x[i]) * (y[j+jj] - y[j]);
                        if(tmp < ans) ans = tmp;
                    }
                }
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 26964
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m,x;cin>>n>>m>>x;
	ll i,j;
	ll s=(1<<(n))-1;
	vector<vector<ll>> v(n,vector<ll> (m+1));
	for(i=0;i<n;i++){
		for(j=0;j<=m;j++)
			cin>>v[i][j];
	}
	ll mn=INT_MAX;
	bool f=false;
	for(i=0;i<=s;i++){
		vector<ll> dp(m,0);
		ll c=0;
		for(j=0;j<n;j++){
			if((i>>j)&1==1){
				c+=v[j][0];
				for(ll k=1;k<=m;k++) 
					dp[k-1]+=v[j][k];
			}
		}
		for(j=0;j<m;j++) if(dp[j]<x) break;

			if(j==m){
				f=true;
				mn=min(mn,c);
			}
	}
	if(!f) cout<<-1;
	else 
	cout<<mn<<endl;
	
	return 0;
} 

Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
#define N 100005

typedef struct pp
{
    char sum[100];
    int t;
}P;

P Q[N];
int head,tail,n;

void num(P x)
{
    Q[tail]=x;
    tail = (tail+1)%N;

}

P tum()
{
    P x=Q[head];
    head =(head+1)%N;
    return x;
}
int min(int a,int b){return a<b ? a:b;}

int main()
{
  int elt=0,c;
    int i,q;
    P u;
    scanf("%d%d",&n,&q);

    for(i=1;i<=n;i++)
    {
      scanf("%s %d",Q[i].sum,&Q[i].t);

        
    }
    head=1;tail=n+1;
    
    while(head!=tail){
        u=tum();
        c=min(q,u.t);
        u.t-=c;
        elt+=c;
        if(u.t>0)num(u);
        
        else{
	  printf("%s %d\n",u.sum,elt);
        }
        
    }
    return 0;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  cin >> s;
  bool flag = false;
  bool ans = false;
  rep(i, 0, (ll)s.size()) {
    if(s[i] == 'C') flag = true;
    if(flag and s[i] == 'F') ans = true;
  }
  cout << ( ans ?"Yes" :"No") << "\n";
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int n;
	std::cin >> n;
	int a[n];

	for (int i = n-1;i >= 0;i--) {
		std::cin >> a[i];
	}
	for (int i=0;i < n;i++) {
		std::cout << a[i];
		if (i == n - 1) { break; }
		std::cout << " ";
	}
	std::cout << std::endl;
    return 0;
}

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

int main(void){
    int n,m,A[100][100],b[100],c[100];
    
    cin >> n >> m;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++) cin >> A[i][j];
    for(int i = 0; i < m; i++) cin >> b[i];
    
    for(int i = 0; i < n; i++){
        c[i] = 0; 
        for(int j = 0; j < m; j++){
            c[i] += A[i][j]*b[j];
        }
    }

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



Measured memory_bytes: 3132
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int w,a,b; cin >> w >> a >> b;
	if (a + w < b) {
		cout << b - a - w << endl;
	}
	else if (b + w < a){
		cout << a - b - w << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N,H = map(int,input().split())

huru=[]
nage=[]
for i in range(N):
    h,n=input().split()
    huru.append(int(h))
    nage.append(int(n))
    
hmax = max(huru)
hmax_n = nage.pop(huru.index(hmax))
nage.sort(reverse = True)
cnt = 0

while H > 0:
  for i in range(len(nage)):
    a = nage[i]
    if a > hmax :
      cnt += 1
      H -= a
      if H <= 0:
        break
    else:
      break
    if H <= hmax_n:
      cnt += 1
      H -= hmax_n
      break

  if H > 0:
    if hmax < hmax_n:
      cnt += -(-(H - hmax_n) // hmax) + 1
      H = -1
    else:
      cnt += -(-(H) // hmax)
      H = -1
      
print(int(cnt))

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll D, T, S; cin >> D >> T >> S;
  string result = D<=T*S ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll c[10][10];
ll d[10][10];
vector<llvec> A;

ll warshall_froyd(){
  rep(k, 10){
    rep(i, 10){
      rep(j, 10){
        c[i][j] = min(c[i][k] + c[k][j], c[i][j]);
      }
    }
  }
}

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll H, W;
  cin >> H >> W;
  rep(i, 10){
    rep(j, 10){
      cin >> c[i][j];
    }
  }
  fill(d[0], d[10], 1e15);
  rep(i, H){
    llvec B(W);
    rep(j, W){
      cin >> B[j];
    }
    A.push_back(B);
  }
  warshall_froyd();
  ll ans=0;
  rep(i, H){
    rep(j, W){
      if(A[i][j]<0)continue;
      ans += c[A[i][j]][1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
import numpy as np

N,M = map(int,input().split())
A = np.array(list(map(int,input().split())))

target = np.sum(A)
ans = 0
for i in range(N):
    if A[i] >= target/(4*M):
        ans += 1
print('Yes') if ans >= M else print('No')


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

using namespace std;

int main() {
    int n, k, q, a;
    cin >> n >> k >> q;
    vector<int> scores(n, k-q);
    for (int i=0; i<q; ++i) {
        cin >> a;
        ++scores[a-1];
    }
    for (auto& e : scores) {
        if (e > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 1152
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.math.*;
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
     
    public static void println(Object ...x){
        for(Object o:x){
            System.out.println(o);
        }
    }
    public static void print(Object ...x){
        for(Object o:x){
            System.out.print(o);
            System.out.print(" ");
        }
        System.out.println();
    }
    public static void fprint(Object x){
        System.out.println(x);
    }
    
    public static void main(String[] args) 
    { 
        FastReader fs=new FastReader();
        long mod =1000000007;
        int n=fs.nextInt();
        long k=fs.nextLong();
        int[] arr =new int[n];
        int t1=0,t2=0;
        for(int i=0;i<n;i++){
            arr[i]=fs.nextInt();
        }
        for(int i=1;i<n;i++){
            for(int j=0;j<i;j++){
                if(arr[j]>arr[i]){
                    t1+=1;
                }
            }
        }
        Arrays.sort(arr);
        for(int i=1;i<n;i++){
            for(int j=0;j<i;j++){
                if(arr[j]<arr[i]){
                    t2+=1;
                }
            }
        }
        long ans1=(t1*k)%mod;
        long base=(k*(k-1)/2)%mod;
        long ans2=(t2*base)%mod;
        long fans=(ans1+ans2)%mod;
        print(fans);
    } 
} 


Measured memory_bytes: 23124
#include<stdio.h>
#include<string.h>
int main(){
char s[3];
  int i,count=0;
  scanf("%[^\n]s", s);

  if(s[0]=='R' && s[1]=='R' && s[2]=='R')
    count=3;
    else if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R') )
    count=2;
    else if(s[0]=='S' && s[1]=='S' && s[2]=='S' )
    count=0;
    else
    count=1;
  
  printf("%d",count);
  
}

Measured memory_bytes: 1728
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> A;

  ll a;
  ll sum = 0;
  ll rui[N + 1];
  memset(rui, 0, sizeof(rui));

  for (int i = 0; i < N; ++i) {
    cin >> a;
    sum += a;
    A.push_back(a);
    rui[i + 1] = sum;
  }

  vector<ll> nums;

  for (int len = 1; len <= N; ++len) {
    for (int i = len; i <= N; ++i) {
      ll v = rui[i] - rui[i - len];
      nums.push_back(v);
    }
  }
  
  ll ans = 0;

  for (int s = 63; s >= 0; --s) {
    vector<ll> cand;

    for (int i = 0; i < nums.size(); ++i) {
      ll v = nums[i];

      if ((v >> s & 1) == 1) {
        cand.push_back(v);
      }
    }

    if (cand.size() >= K) {
      ans += pow(2, s);
      nums = cand;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6396
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split()))  for _ in range(q)]
A=[int(i) for i in range(1,m+1)]
from itertools import combinations_with_replacement
ans=0
for l in list(combinations_with_replacement(A,n)):
  t=0
  for a,b,c,d in abcd:
    if l[b-1]-l[a-1]==c:t+=d
  ans=max(t,ans)
print(ans)


Measured memory_bytes: 21548
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>
#include <map>
using namespace std;

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

using namespace std;

int main(){
    int n;
    while(cin>>n && n){
        map<int,int> M;
        rep(i,n){
            int m,a,b;
            cin>>m>>a>>b;
            M[a]+=m; M[b]-=m;
        }
        int cur=0;
        bool ok = true;
        for(auto e : M){
            cur+=e.second;
            if(cur > 150){
                ok=false;
                break;
            }
        }
        puts(ok ? "OK" : "NG");
    }
}

Measured memory_bytes: 1152
data=list(map(int,input().split()))
data.sort()
a=data[0]
b=data[1]
c=data[2]
if a == b == c:
    print(0)
elif b == c:
    count=0
    while a < c:
        a += 2
        count += 1
    if a > c:
        print(count+1)
    else:
        print(count)
else:
    count=0
    while a < c and b < c:
        a += 1
        b += 1
        count += 1
    if a == b == c:
        print(count)
    else:
        while a < c:
            a += 2
            count += 1
        if a > c:
            print(count+1)
        else:
            print(count)

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

#define INF (1 << 30)
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int n;
    cin >> n;
    // 3 -> 1
    // 4 -> 1
    // 5 -> 2
    out((n-1)/2);
    return 0;
}

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

int main()
{
    int n = 0,ans = 0;
    string s;
    cin >> n >> s;

    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'A' &&s[i + 1] == 'B' && s[i+2] == 'C')
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>
#include<iterator>
#include<regex>
#include<math.h>
#include<numeric>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007
typedef struct tree Tree;

using namespace std;

bool cmpf(pair<lli, lli> left, pair<lli, lli> right) {
	return left.first < right.first;
}
bool cmp(pair<lli, lli> left, pair<lli, lli> right) {
	if (left.first != right.first)return left.first < right.first;
	else return left.second < right.second;
}

int main() {
	string s;
	cin >> s;
	rep0(i, s.size()) {
		if (i % 2 == 0 && s[i] == 'L' || i % 2 == 1 && s[i] == 'R') {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)((x).size())
#define mp make_pair

using namespace std;

typedef unsigned long long ull;
typedef pair<int,int> ii;

template<class U,class T>ostream& operator<<(ostream& out, pair<U,T> & P){
    return out << "[" << P.first << ", " << P.second << "]";
}
template<class T>ostream& operator<<(ostream& out, vector<T> & V){
    if(!V.empty())out << "[";
    for(int i = 0; i < sz(V); i++)out << V[i] << (i+1==sz(V)?"]":", ");
    return out;
}

typedef long long ll;
vector<ll>V;
ll N, K;
ll mod = 1e9+7;

int64_t pow(int64_t a, int64_t power, int64_t mod){
    int64_t i(power), ans(1);
    for(; i; i>>=1, ((a%=mod)*=a)%=mod)if(i&1)(ans*=a)%=mod;
    return ans;
}

int64_t fact[1000000]={1};

int64_t binomial(int64_t n, int64_t m) {
    int64_t numerator(fact[n]),denominator(1);
    (denominator*=fact[m])%=mod;
    (denominator*=fact[n-m])%=mod;
    denominator = pow(denominator,mod-2,mod);
    return (numerator*denominator)%mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin >> N >> K;
    V.resize(N);
    for(int i = 0; i < N;i++){
        cin >> V[i];
    }

    for(int i = 1; i <= N; i++) fact[i] = (fact[i-1]*i)%mod;

    sort(all(V));
    ll ans = 0;
    for(int i = N-1; i >= 0; i--){
        if(N-i>=K){ // can be min
            ll res = binomial(N-1-i,K-1);
            ans -= (res*V[i])%mod;
            ans+=mod;
            ans%=mod;
        }
        if(i+1>=K){
            ll res = binomial(i,K-1);
            ans += (res*V[i])%mod;
            ans+=mod;
            ans%=mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    unsigned int y=0,m=0,d=0;
    scanf("%4d/%2d/%2d",&y,&m,&d);
    if(y<2019 ){
        printf("Heisei");
    }else  if(m<5){
        printf("Heisei");
    }else{
        printf("TBD");
    }
    return 0;
}

Measured memory_bytes: 128
n=int(input())
s=input()

#このパターンはスタックで管理していくと良い(()の整合性取れているか)
#湖の問題も整合性取れるかで判断

#"("がプラスで")"がマイナス
#全部0以上にする(最小をプラスする)
c=0
m=0
for i in s:
    if i==")":
        c-=1
    else:
        c+=1
    m=min(m,c)
s=abs(m)*"("+s
l=s.count("(")
k=s.count(")")
#print(m)
if k-l>0:
    print((k-l)*"("+s)
else:
    print(s+(l-k)*")")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> mp;
    REP(i, n) {
        cin >> a[i];
        mp[a[i]] ++;
    }

    ll ans = 0;
    for(auto t : mp) {
        ans += (t.second)*(t.second-1)/2;
    }

    for(ll i = 0; i < n; i++) {

        ll tmp = ans;
        tmp -= (mp[a[i]])*(mp[a[i]]-1)/2;
        tmp += (mp[a[i]]-1)*(mp[a[i]]-2)/2;
        cout << tmp << endl;
    }

    return 0;
}

Measured memory_bytes: 12416
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  if len(sa) > 1:
    for saj in sa[1:]:
      aj = int(saj)
      flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  int res=0;
  rep(i,n) cin >> l[i];
  for (int i=0 ; i<(n) ;++i){
    for (int j=i+1 ; j<(n) ;++j){
      for (int k=j+1 ; k<(n) ;++k){
        if (l[i]!=l[j] && l[k]!=l[j] && l[k]!=l[i]){
          int x=min({l[i],l[j],l[k]});
          int z=max({l[i],l[j],l[k]});
          int y=l[i]+l[j]+l[k]-x-z;
          if (x+y>z) res++;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}


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

int main() {
    string S;
    cin >> S;
  
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    // 後ろから解くかわりにすべての文字列を「左右反転」する
    
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true; //divideし切れるかどうか
    for (int i = 0; i < S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2) { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var N = input[0];
            var K = input[1];
            var A = ReadArrayLong();
            var keta = 0;
            for (int i = 0; Math.Pow(2, i) <= Math.Pow(10, 12); i++) keta++;
            var cnt = new int[keta];
            for (int i = 0; i < keta; i++)
            {
                var chk = 1L;
                for (int j = 0; j < i; j++) chk <<= 1;
                for (int j = 0; j < N; j++) if ((A[j] & chk) == chk) cnt[i]++;
            }
            
            var X = 0L;
            for (int i = keta - 1; i >= 0; i--)
            {
                var chk = 1L;
                for (int j = 0; j < i; j++) chk <<= 1;
                if (cnt[i] <= N / 2)
                {
                    X += chk;
                    if (X > K) X -= chk;                    
                }
            }
            
            var ans = 0L;
            for (int i = 0; i < N; i++) ans += X ^ A[i];

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 31324
/*
  This C++ Source Is
  Writen By syksykCCC
  (After July, 2019)
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for(int i = x; i < y; i++)
#define REP(i, x, y) for(int i = x; i <= y; i++)
#define per(i, x, y) for(int i = x; i > y; i--)
#define PER(i, x, y) for(int i = x; i >= y; i--)
#define LLL __int128
#define int128 __int128
#define DEBUG(x) cerr << #x << " : " << x << endl
using namespace std;
typedef unsigned int uint;
typedef long long int64;
typedef long long LL;
typedef unsigned long long uint64;
typedef long long ULL;
typedef long double LLF;
template<typename T> inline void read(T &val)
{
	val = 0; char c = getchar(); int f = 1;
	while(!isdigit(c))
	{
		if(c == '-') f = -1;
		c = getchar();
	}
	while(isdigit(c))
	{
		val = (val << 3) + (val << 1) + (c ^ 48);
		c = getchar();
	}
	val *= f;
}
template<typename T> void write_(T val)
{
	if(!val) return;
	write_(val / 10);
	putchar(val % 10 + 48);
}
template<typename T> inline void write(T val)
{
	if(val == 0) putchar(48);
	else if(val < 0)
	{
		putchar('-');
		write_(-val);
	}
	else write_(val);
}

const int N = 100005;
int n, ans;
char s[N];

int main()
{
#ifdef LOCAL
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin >> n >> s;
	REP(i, 0, n)
	{
		if(s[i] != s[i + 1]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	char ch;
	while(cin.get(ch)) {
		if('A'<=ch&&ch<='Z') cout<<(char)(ch-'A'+'a');
		else if('a'<=ch&&ch<='z') cout<<(char)(ch-'a'+'A');
		else cout<<ch;
	}
	return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define int long long
using namespace std;
unordered_map<int, int> m;
int minCost(int curr, int n, int k, vector<int> &h)
{
    if (curr == n - 1)
        return 0;

    if (m.find(curr) != m.end())
        return m[curr];

    int cost = INT_MAX;

    for (int i = 1; i <= k; i++)
    {
        if (curr + i < n)
        {
            cost = min(cost, abs(h[curr] - h[curr + i]) + minCost(curr + i, n, k, h));
        }
    }
    m[curr] = cost;
    return cost;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];

    m.clear();
    cout << minCost(0, n, k, h);
    return 0;
}

Measured memory_bytes: 12964
#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++)

int main(){
  int n,a[100010],b[100010],x=0,y;
  cin>>n;
  rep(i,n){
    scanf("%d%d",&a[i],&b[i]);
    if(a[i]==max(x,a[i])){y=i;}
    x=max(x,a[i]);
  }
  cout<<x+b[y]<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

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 A,B,C;
    cin>>A>>B>>C;
    ll res;
    if(A+B+1>=C){
        res = B+C;
    }else{
        res = A+B+1+B;
    }
    cout<<res<<endl;
    
}

Measured memory_bytes: 768
k=int(input())
a,b=map(int,input().split())
flg=0
for i in range(a,b+1):
    if i%k==0:
        flg+=1
    i+=1

if (a==b and a%k==0):
        flg+=1

if flg==0:
    print("NG")
else:
    print("OK")


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = (n/11)*2 + (n%11+7)/7;
  if (n%11 == 0) ans--;
  cout << ans << '\n';
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
Scanner s = new Scanner(System.in);
		int H = s.nextInt();
		int W = s.nextInt();
		char[][] maze = new char[H][W];
		int blacknum = 0;
		String str;
		for(int i = 0; i < H; i++) {
			str = s.next();
			blacknum += charcount(str);
			maze[i] = str.toCharArray();
		}
		
		int[] start = {0, 0, 0}; // row, col
		Queue<int[]> Q = new ArrayDeque<int[]>();
		Q.add(start);
		int[][] pass = new int[H][W];
		
		int[] vcol = {1, 0, -1,  0};
		int[] vrow = {0, 1,  0, -1};
		
		int[] tmp;
		int trow, tcol;
		while(!Q.isEmpty()) {
			tmp = Q.poll();
			for(int i = 0; i < 4; i++) {
				trow = tmp[0] + vrow[i];
				tcol = tmp[1] + vcol[i];
				if(rangecheck(trow, tcol, H, W)) {
					if(pass[trow][tcol] > 0 || maze[trow][tcol] == '#')
						continue;
					Q.add(new int[] {trow, tcol, tmp[2] + 1});
					pass[trow][tcol] = tmp[2] + 1;
				}
			}
		}
		
		if(pass[H-1][W-1] == 0) {
			System.out.println(-1);
			return;
		}
		
		System.out.println((H*W)-blacknum-pass[H-1][W-1]-1);
	}
	
	private static boolean rangecheck(int row, int col, int H, int W) {
		return (0 <= row && row < H && 0 <= col && col < W);
	}
	
	private static int charcount(String str) {
		int result = 0;
		int index = -1;
		while(index < str.length() && (index = str.indexOf('#', ++index)) > -1) {
			result++;
		}
		return result;
	}
}

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

using namespace std;

typedef unsigned long long ull;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i ++)
        cin >> arr[i];
    
    int minn = *min_element(arr, arr + n);
    int maxx = *max_element(arr, arr + n);
    int minimum = INT_MAX;
    for (int i = minn; i <= maxx; i ++) {
        int tmpSum = 0;
        for (int j : arr) {
            tmpSum += pow(j - i, 2); 
        }
        if (tmpSum < minimum)
            minimum = tmpSum;
    }

    cout << minimum;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)

int main(){
  ll n,m;
  cin>>n>>m;
  string s(n,'a');
  int b;
  char c;
  
  rep(i,m){
    cin>>b>>c;
    if(s[b-1]=='a'){
        s[b-1]=c;
    }else{
        if(s[b-1]==c){
            s[b-1]=c;
        }else{
           
            cout<<-1<<endl;
            return 0;
            
        }
    }
  }
  
  if(s[0]=='a'){
      if(n==1)s[0]='0';
      else s[0]='1';
  }
  
  if(s[0]=='0'&&n!=1){
      cout<<-1<<endl;
      return 0;
  }
 
  rep(i,n){
      if(s[i]=='a'){
          cout<<'0';
      }else{
          cout<<s[i];
      }
      if(i==n-1){
          cout<<endl;
      }
  }
       
  
}



Measured memory_bytes: 3624