akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


while 1:
	w, h = MAP()
	if w == 0 and h == 0:
		exit()

	c = [LIST() for _ in range(h)]

	cnt = 0
	check = [[0]*w for _ in range(h)]

	dy = (1, 1, 0, -1, -1, -1, 0, 1)
	dx = (0, -1, -1, -1, 0, 1, 1, 1)

	for y in range(h):
		for x in range(w):
			if check[y][x] == 0 and c[y][x] == 1:
				cnt += 1
				check[y][x] = cnt
				q = deque([(y, x)])
				while q:
					ny, nx = q.popleft()
					for k in range(8):
						ky = ny + dy[k]
						kx = nx + dx[k]
						if 0 <= ky < h and 0 <= kx < w and check[ky][kx] == 0 and c[ky][kx] == 1:
							check[ky][kx] = cnt
							q.append((ky, kx))

	print(cnt)


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

const int MOD = 1e9 + 7;

void add(int &a, int b) {
	a = (1LL * a + b) % MOD;
}

int product(int a, int b) {
	return 1LL * a * b % MOD;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0, prefix = 0;
	for (int i = 0; i < n; i++) {
		add(ans, product(prefix, a[i]));
		add(prefix, a[i]);
	}
	cout << ans;
}



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


int main(){
    int P,Q,R;
    cin >> P >> Q >> R;
    int minans=301;
    minans = min(minans,P+Q);
    minans = min(minans,P+R);
    minans = min(minans,R+Q);
    cout << minans;
}



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

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;

int main()
{
    string x ;
    cin >> x ;
    ll len = x.size() ;
    for (int i = 0; i < len; i++) {
        cout << "x" ;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int x;
    cin>>x;
    cout<<10-(x/200)<<endl;

    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
void fast(){
cin.tie(0);
cin.sync_with_stdio(0);
}
int main()
{
    fast();
 int r,c;
 cin>>r>>c; int a[r][c]={};vector < pair< int ,int> > v; pair<int,int>b;int x;
 for(int i=0;i<r;i++)
 {
     for(int j=0;j<c;j++)
     {
         cin>>x;
         a[i][j]+=x;
         if(a[i][j]%2!=0)
         {
            if(j<c-1){a[i][j+1]++;b.first=i+1;b.second=j+1;v.push_back(b);b.first=i+1;b.second=j+2;v.push_back(b);}
             else if(i<r-1){a[i+1][j]++;b.first=i+1;b.second=j+1;v.push_back(b);b.first=i+2;b.second=j+1;v.push_back(b);}
         }
     }
 }
 cout<<v.size()/2<<endl;
 for(int i=0;i<v.size();i+=2)
 {
     cout<<v[i].first<<" "<<v[i].second<<" "<<v[i+1].first<<" "<<v[i+1].second<<endl;
 }
 return 0;
}


Measured memory_bytes: 5232
def main():
    N, M = map(int, input().split())
    edges = []
    
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        edges.append([a,b,c])

    d = [float('inf')] * N
    d[0] = 0

    for i in range(N-1):
        for edge in edges:
            d[edge[1]] = min(d[edge[1]], d[edge[0]] - edge[2])

    ans = d[N-1]
    for edge in edges:
        d[edge[1]] = min(d[edge[1]], d[edge[0]] - edge[2])

    if ans == d[N-1]:
        print(-ans)
    else:
        print('inf')


main()

Measured memory_bytes: 47064
n, a, b = map(int, input().split())
t, o = 0, 0
s = input()
for i in range(n):
    if s[i]=="a":
        t += 1
        if t <= a+b:
            print("Yes")
        else:
            print("No")
    elif s[i]=="b":
        o += 1
        if o <= b and t < a+b:
            t += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 52952
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,T,min=1001;
    cin>>N>>T;
    int a[N],b[N];
    for(int i=0;i<N;i++) cin>>a[i]>>b[i];
    for(int i=0;i<N;i++){
        if(b[i]<=T&&a[i]<=min) min=a[i];
    }
    if(min==1001) cout<<"TLE"<<endl;
    else cout<<min<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,j,c[6]={0};
  double t;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf",&t);
    if(t<165.0)c[0]++;
    else if(t<170.0)c[1]++;
    else if(t<175.0)c[2]++;
    else if(t<180.0)c[3]++;
    else if(t<185.0)c[4]++;
    else c[5]++;
  }
  for(i=0;i<6;i++){
    printf("%d:",i+1);
    for(j=0;j<c[i];j++){
      printf("*");
    }
    printf("\n");
  }
  return 0;
}

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

int main(){

    int q;
    cin >> q;
    multiset<int> st;
    for(int i = 0; i < q; ++i){
        int com, x;
        cin >> com;
        if(com != 3){
            cin >> x;
        }
        if(com == 0){
            st.insert(x);
            cout << st.size() << endl;
        }
        else if(com == 1){
            cout << st.count(x) << endl;
        }
        else if(com == 2){
            st.erase(x);
        }
        else{
            int L, R;
            cin >> L >> R;
            auto l = st.lower_bound(L);
            auto r = st.upper_bound(R);
            for(auto it = l; it != r; ++it){
                cout << *it << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 12344
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const s = input[0][0];

  const head = s.indexOf("A");
  const tail = s.lastIndexOf("Z");

  return tail - head + 1;
};

console.log(main(read()));


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

int main() {
    ll n, m, x;
	cin >> n >> m;
    
    ll sm = 0;
    for(int i=0; i<m; i++) {
        cin >> x;
        sm += x;
    }
    
    ll res = max(-1ll, n-sm);
    cout << res << endl;

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 200200;
vector<int> g[maxn];
bool used[maxn];

int Q;
int col[2][maxn];
map<pair<int, int>, int> ans;

void dfs(int u, int c) {
    col[Q][u] = c;
    used[u] = true;
    for (int v: g[u]) {
        if (!used[v])
            dfs(v, c);
    }
}

int main() {
    #ifdef LOCAL
    assert(freopen("d.in", "r", stdin));
    #else
    #endif
    int n, m1, m2;
    cin >> n >> m1 >> m2;
    forn (i, m1) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int COL = 0;
    forn (i, n)
        if (!used[i])
            dfs(i, COL++);
    forn (i, n)
        g[i].clear();
    forn (i, m2) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    fill(used, used + n, false);
    Q = 1;
    COL = 0;
    forn (i, n) {
        if (!used[i])
            dfs(i, COL++);
    }
    forn (i, n)
        ans[{col[0][i], col[1][i]}]++;
    forn (i, n)
        cout << ans[{col[0][i], col[1][i]}] << ' ';
    cout << '\n';
}


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

struct dat {
  int d;
  vector<int> c;
  vector<vector<int>> s;
};

int calc(const dat &a, const vector<int> &last, int day, int t) {
  int v = 0;
  v += a.s.at(day - 1).at(t);
  for (int i = 0; i < 26; i++) {
    if (i == t) continue;
    v -= a.c.at(i) * (day - last.at(i));
  }
  return v;
}

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  dat a = {d, c, s};
  
  int w = 10;
  vector<vector<int>> last(w, vector<int>(26)), ans(w);
  vector<int> score(w);
  for (int i = 0; i < d; i++) {
    vector<tuple<int, int, int>> idx;
    for (int j = 0; j < w; j++) {
      vector<int> best(w, -4e4), best_t(w);
      for (int t = 0; t < 26; t++) {
        int v = calc(a, last.at(j), i + 1, t);
        if (v > best.at(w - 1)) {
          best.at(w - 1) = v;
          best_t.at(w - 1) = t;
        }
        for (int k = w - 1; k > 0; k--) {
          if (best.at(k - 1) < best.at(k)) {
            swap(best.at(k - 1), best.at(k));
            swap(best_t.at(k - 1), best_t.at(k));
          }
        }
      }
      for (int k = 0; k < w; k++) {
        if (best.at(k) == -4e4) continue;
        idx.emplace_back(score.at(j) + best.at(k), j, best_t.at(k));
      }
    }
    sort(idx.rbegin(), idx.rend());
    vector<vector<int>> newlast(w, vector<int>(26)), newans(w);
    for (int j = 0; j < w; j++) {
      if (j >= idx.size()) break;
      int k = get<1>(idx.at(j)), t = get<2>(idx.at(j));
      score.at(j) = get<0>(idx.at(j));
      newans.at(j) = ans.at(k);
      newlast.at(j) = last.at(k);
      newans.at(j).push_back(t);
      newlast.at(j).at(t) = i + 1;
    }
    ans = newans;
    last = newlast;
  }
  for (int i = 0; i < d; i++) {
    cout << ans.at(0).at(i) + 1 << endl;
  }
}


Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
3 2
acp
ae
)");
#define cin input
#endif

bool bfs(int rGraph[202][202], int s, int t, int parent[])
{
    using namespace std;
    bool visited[202] = {};
    queue <int> q;
    q.push(s);
    visited[s] = true;
    parent[s] = -1;
 
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        for (int v = 0; v < 202; v++)
        {
            if (visited[v] == false && rGraph[u][v] > 0)
            {
                q.push(v);
                parent[v] = u;
                visited[v] = true;
            }
        }
    }
    return (visited[t] == true);
}
 
int fordFulkerson(int graph[202][202], int s, int t)
{
    int u, v;
    int rGraph[202][202];  
    for (u = 0; u < 202; u++)
    {
        for (v = 0; v < 202; v++)
        {
            rGraph[u][v] = graph[u][v];
        }
    }
    int parent[202];
    int max_flow = 0;
    while (bfs(rGraph, s, t, parent))
    {
        int path_flow = 1 << 30;
        for (v = t; v != s; v = parent[v])
        {
            u = parent[v];
            path_flow = min(path_flow, rGraph[u][v]);
        }
        for (v = t; v != s; v = parent[v])
        {
            u = parent[v];
            rGraph[u][v] -= path_flow;
            rGraph[v][u] += path_flow;
        }
        max_flow += path_flow;
    }
    return max_flow;
}

int main()
{
    int graph[202][202] = {}; 
	int h, w;
	cin >> h >> w;
    int xs, ys, xt, yt;
    REP (i, h)
    {
        string s;
        cin >> s;
        REP (j, w)
        {
            switch (s[j])
            {
            case 'o':
                graph[i][j + 100] = 1;
                graph[j + 100][i] = 1;
                break;
            case 'S':
                graph[200][j + 100] = 1 << 30;
                graph[200][i] = 1 << 30;
                xs = j;
                ys = i;
                break;
            case 'T':
                graph[i][201] = 1 << 30;
                graph[j + 100][201] = 1 << 30;
                xt = j;
                yt = i;
                break;
            }
        }
    }

    if (xs == xt || ys == yt)
        cout << -1 << endl;
    else
        cout << fordFulkerson(graph, 200, 201) << endl;

	return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,n;
    ULL mx,ans=1,a[100005],b[100005];
    cin >> n;
    for(i=0;i<=n;i++)cin >> a[i];
    if(a[0] > 1  ||  (a[0] == 1  &&  n > 0))
    {
        cout << "-1";
        return 0;
    }
    b[0]=1;
    for(i=1;i<=n;i++)
    {
        mx=min(2ULL*b[i-1],(ULL)1e18);
        if(a[i] > mx)
        {
            cout << "-1";
            return 0;
        }
        if(i < n)b[i]=mx-a[i],ans+=mx;
        else ans+=a[i],b[i]=0;
    }
    for(i=n-1;i>0;i--)
    {
        if(b[i] > a[i+1]+b[i+1])
        {
            ans-=b[i]-a[i+1]-b[i+1];
            b[i]=a[i+1]+b[i+1];
        }
        else break;
    }
    cout << ans;
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll n = 1;
    while (n * (n + 1) <= 2 * N) {
        if (n * (n + 1) != 2 * N) {
            n++;
            continue;
        }
        cout << "Yes" << endl;
        vector<vector<ll>> v(n + 1);
        ll index = 0;
        ll m = 1;
        REP(i, N) {
            v[index].push_back(i + 1);
            v[index + m++].push_back(i + 1);

            if (v[index].size() == n) {
                index++;
                m = 1;
            }
        }

        cout << v.size() << endl;
        REP(i, v.size()) {
            cout << v[i].size();
            REP(j, v[i].size()) {
                cout << " " << v[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <math.h>
int main()
{
    int n,jvli,i,time,cnt=1;
    scanf("%d",&n);
    int x[n+1],y[n+1],t[n+1];
    t[0]=0;x[0]=0;y[0]=0;
    for(i=1;i<n+1;i++)
    {
        scanf("%d%d%d",&t[i],&x[i],&y[i]);
    }
    for(i=1;i<n+1;i++)
    {
        jvli=x[i]+y[i]-x[i-1]-y[i-1];
        jvli=abs(jvli);
         time=t[i]-t[i-1];
         if(time<jvli)
            {
                cnt=0;
                break;
            }
         else
         {
             if((time-jvli)%2)
                {
                    cnt=0;
                    break;
                }
         }
    }
    if(cnt)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 1280
using System;
using static System.Console;
using System.Collections.Generic;

namespace abc168
{
    class Program
    {
        static void Main()
        {
            var nm = ReadLine().Split(' ');
            var n = int.Parse(nm[0]);
            var m = int.Parse(nm[1]);
            var table = new Dictionary<int, List<int>>();
            for (var i = 0; i < m; ++i)
            {
                var ab = ReadLine().Split(' ');
                var a = int.Parse(ab[0]);
                var b = int.Parse(ab[1]);
                if (!table.ContainsKey(a))
                {
                    table.Add(a, new List<int>());
                }
                table[a].Add(b);
                if (!table.ContainsKey(b))
                {
                    table.Add(b, new List<int>());
                }
                table[b].Add(a);
            }

            var sign = new int[n + 1];
            Scan(sign, table);

            WriteLine("Yes");
            for (var i = 2; i < sign.Length; ++i)
            {
                WriteLine(sign[i]);
            }
        }
        static void Scan(int[] sign, Dictionary<int, List<int>> table)
        {
            var q = new Queue<int>();
            q.Enqueue(1);
            while (q.Count > 0)
            {
                var current = q.Dequeue();
                if (table.ContainsKey(current))
                {
                    foreach (var dest in table[current])
                    {
                        if (sign[dest] == 0)
                        {
                            sign[dest] = current;
                            q.Enqueue(dest);
                        }
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 58036
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X=sc.nextInt();
        int Y=sc.nextInt();
        int Z=sc.nextInt();

        System.out.print(Z);
        System.out.print(" "+X);
        System.out.print(" "+Y);
        
        sc.close();
    }
}

Measured memory_bytes: 38400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
vector<vector<int>> to(200005,vector<int>(0));
vector<int> ans;
void dfs(int v,int p =-1){
  for(int u:to.at(v)){
    if(u==p) continue;
    ans.at(u) += ans.at(v);
    dfs(u,v);
  }
}
int main() {
  int n,q;
  cin >> n >> q;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    --a;--b;
    to.at(a).push_back(b);
    to.at(b).push_back(a);    
  }
  ans.resize(n);
  rep(i,q){
    int p,x;
    cin >> p >> x;
    --p;
    ans.at(p) += x;
  }
  dfs(0);
  rep(i,n){
    cout << ans.at(i) <<endl;
  }
}
    

Measured memory_bytes: 26624
#include<bits/stdc++.h>
using namespace std;
int main() {
int i,j,l,t,a[200000],s,k,p,x,n;
 cin>>n;
 for(i=0;i<n;i++){
    cin>>a[i];
 }
 s=0;p=0;
 sort(a,a+n,greater<int>());
  for(i=0;i<n;i+=2){
    s+=a[i];
  }
  for(i=1;i<n;i+=2){
    p+=a[i];
  }
  cout<<s-p<<endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 105
using namespace std;
string s[maxn];
int dp[maxn][maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	for(int i=0;i<n;i++)
		cin >> s[i];
	dp[0][0] = 1;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(i != 0 || j != 0) {
				dp[i][j] = -1;
				if(i > 0)	dp[i][j] = dp[i-1][j] + (s[i][j] != s[i-1][j] ? 1 : 0);
				if(j > 0) {
					int now = dp[i][j-1] + (s[i][j] != s[i][j-1] ? 1 : 0);
					if(dp[i][j] == -1 || dp[i][j] > now)
						dp[i][j] = now;
				}
			}
	cout << (s[0][0] == '#' || s[n-1][m-1] == '#' ? 1 : 0) + (dp[n-1][m-1] - 1) / 2 << endl;
	return 0;
}


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

int main(){
    int m1,m2,d1;
    cin >> m1 >> d1 >> m2;
    if(m1 == m2) cout << 0 << endl;
    else cout << 1 << endl;
    
    return 0;
}


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;

int main(){
    ll N,ans = 0;
    ll A[6];
    //double ans = 0.0;
    cin >> N;
    rep(i,5) cin >> A[i];
    sort(A,A+5);

    ans += (N+A[0]-1)/(A[0])+4;

    cout << ans ;
    //printf("%.15lf",ans);
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
K = int(input())
g = [[] for i in range(K+1)]
for i in range(1, K+1):
    for j in range(i, K+1, i):
        g[j].append(i)
sigma = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            for d in reversed(range(len(g[i]))):
                if g[i][d] in g[j] and g[i][d] in g[k]:
                    sigma += g[i][d]
                    break
print(sigma)

Measured memory_bytes: 74664
#!/usr/bin/env python3
import sys


def get_num_of_paty(n):
    return 2**(n+1)-1

def get_num_of_lay(n):
    return 2**(n+2)-3

def solve(N: int, X: int):

    ans = 0
    now_level = N + 1
    for i in range(N+1):
        now_level -= 1
        pivot = (get_num_of_lay(now_level)+1)/2
        if X > pivot:#get a half party
            ans += get_num_of_paty(now_level-1)+1
            X -= pivot
        elif X == pivot:
            ans += get_num_of_paty(now_level-1)+1
            break
        else:
            X -= 1

    print(ans)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(N, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import math
while True:
    arr = input().split()
    a,b,c = int(arr[0]),arr[1],int(arr[2])
    if b == "?":
        break
    elif b == "+":
        print(a+c)
    elif b == "-":
        print(a-c)
    elif b == "*":
        print(a*c)
    elif b == "/":
        print(math.floor((a/c)))


Measured memory_bytes: 5664
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#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 PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int h,w,a,b;
  cin>>h>>w>>a>>b;

  rep(i,h){
    rep(j,w){
      if(i<b&&j<a||i>=b&&j>=a){
        cout<<'0';
      }else{
        cout<<'1';
      }
    }
    cout<<endl;
  }



}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdlib>
#include <math.h>
using namespace std;
 
int main() {
	int w,h,n;
	cin>>w>>h>>n;
	int ans=0;
	int a[2][2];
	for(int i= 0;i<n;i++){
		cin>>a[1][0]>>a[1][1];
		if(i!=0){
			int u=a[0][0]-a[1][0];
			int y=a[0][1]-a[1][1];
if(u<=0 and y<=0){ans=ans+max(abs(u),abs(y));}
else if(u>=0 and y>=0){ans=ans+max(abs(u),abs(y));}
else{ans=ans+abs(y)+abs(u);}
		}
		a[0][0]=a[1][0];
		a[0][1]=a[1][1];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#define maxn 105
int main()
{
    int n,m,cnt=1;
    int a[maxn];
    long long b[maxn];
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    memset(b,0,sizeof(b));
    for (int i=2;i<=n+1;i++)
    {
        b[i] = (long long)b[i-1]+a[i-1];
        if (b[i]<=(long long)m) cnt++;
    }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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 n;cin>>n;
    vector<string> s(n);
    rep(i,n) cin>>s[i];
    vector<ll> num(4,0);

    rep(i,n){
        if(s[i]=="AC") num[0]++;
        if(s[i]=="WA") num[1]++;
        if(s[i]=="TLE") num[2]++;
        if(s[i]=="RE") num[3]++;
    }

    printf("AC x %lld\n",num[0]);
    printf("WA x %lld\n",num[1]);
    printf("TLE x %lld\n",num[2]);
    printf("RE x %lld\n",num[3]);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  vector<int> b(n);
  for(int i=0; i<n; i++) {
    cin >> b[i];
  }
  vector<int> c(n);
  for(int i=0; i<n-1; i++) {
    cin >> c[i];
  }
  
  int sum = 0;
  for(int i=0; i<n; i++) {
    sum += b[a[i]-1];
    if (i>0 && a[i-1]+1 == a[i]) {
      sum += c[a[i]-2];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <queue>

using namespace std;

class node {
public:
    int size;
public:
    int number;
public:
    int child1, child2;
};

int main() {
    string s;
    cin >> s;
    map<char, int> m;
    for (int i = 0; i < s.size(); i++)m[s[i]]++;

    vector<node> tree;
    priority_queue<vector<int>, vector<vector<int>>, greater<>> que;

    vector<pair<char, int>> v(m.begin(), m.end());
    for (int i = 0; i < v.size(); i++) {
        node n;
        n.size = v[i].second;
        n.number = i;
        n.child1 = -1;
        n.child2 = -1;
        tree.push_back(n);

        vector<int> a(2);
        a[0] = n.size;
        a[1] = n.number;
        que.push(a);
    }

    int nextnum = v.size();
    while (true) {
        vector<int> a = que.top();
        que.pop();
        if (que.empty())break;
        vector<int> b = que.top();
        que.pop();

        node n;
        n.size = a[0] + b[0];
        n.number = nextnum;
        nextnum++;
        n.child1 = a[1];
        n.child2 = b[1];
        tree.push_back(n);

        vector<int> c(2);
        c[0] = n.size;
        c[1] = n.number;
        que.push(c);
    }

    long long ret = 0;
    queue<int> nodequeue;
    nodequeue.push(nextnum - 1);
    nodequeue.push(-1);
    int depth = 0;
    while (true) {
        int nextnode = nodequeue.front();
        nodequeue.pop();
        if (nextnode == -1) {
            if (nodequeue.empty())break;
            depth++;
            nodequeue.push(-1);
        } else {
            if (nextnode < v.size())
                ret += depth * v[nextnode].second;
            if (tree[nextnode].child1 >= 0)
                nodequeue.push(tree[nextnode].child1);
            if (tree[nextnode].child2 >= 0)
                nodequeue.push(tree[nextnode].child2);
        }
    }

    if (ret == 0)ret += s.size();
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3372
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    int N,K; string S;
    cin >> N >> K >> S;
    S[K-1] = tolower(S[K-1]);
    cout << S;
    rn 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var n [][]int
	var h, w int

	for {
		fmt.Scan(&h)
		fmt.Scan(&w)

		if h == 0 && w == 0 {
			break
		}

		n = append(n, []int{h, w})

	}

	for i := 0; i < len(n); i++ {

		for j := 0; j < n[i][0]; j++ {
			for k := 0; k < n[i][1]; k++ {
				fmt.Print("#")
			}
			fmt.Print("\n")
		}

		fmt.Print("\n")
	}

}

//a, _ := strconv.ParseFloat(tmp[0], 64)



Measured memory_bytes: 1120
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            for (; ; )
            {
                var firstLine = Console.In.ReadLine();
                var count = int.Parse(firstLine);
                if (count == 0)
                {
                    break;
                }

                var secondLine = Console.In.ReadLine();
                var secondSplitStrings = secondLine.Split(' ');

                if (count != secondSplitStrings.Length)
                {
                    break;
                }

                var values = new List<double>();
                foreach (var s in secondSplitStrings)
                {
                    values.Add(double.Parse(s));
                }

                // なんかこんな展開の仕方があった気がする
                double squaredSum = 0;
                double sum = 0;
                foreach (var v in values)
                {
                    squaredSum += v * v;
                    sum += v;
                }

                var average = sum / count;
                var verb = squaredSum / count - average * average;
                var deviation = Math.Sqrt(verb);

                Console.Out.WriteLine("{0:0.########}", deviation);
            }
        }
    }
}



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

int A, B;
char field[100][100];

int main(void) {

    cin >> A >> B;

    for (int h = 0; h < 50; h++) {
        for (int w = 0; w < 100; w++) {
            field[h][w] = '.';
        }
    }
    for (int h = 50; h < 100; h++) {
        for (int w = 0; w < 100; w++) {
            field[h][w] = '#';
        }
    }

    A--;
    B--;

    for (int h = 0; h < 50; h+=2) {
        for (int w = 0; w < 100; w+=2) {
            if (B) {
                field[h][w] = '#';
                B--;
            } 
        }
    }
    for (int h = 51; h < 100; h+=2) {
        for (int w = 0; w < 100; w+=2) {
            if (A) {
                field[h][w] = '.';
                A--;
            }
        }
    }


    cout << 100 << ' ' << 100 << endl;
    for (int h = 0; h < 100; h++) {
        for (int w = 0; w < 100; w++) {
            cout << field[h][w];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $s);
$q = ['NA', 'YYMM', 'MMYY', 'AMBIGUOUS'];
$n = floor($s / 100);
$m = $s % 100;
$x = 0;
if ($n >= 1 && $n <= 12) $x += 2;
if ($m >= 1 && $m <= 12) $x++;
echo $q[$x];

Measured memory_bytes: 4856
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
	"strings"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	memo := make([]map[string]int, N+1)
	done := make([]map[string]bool, N+1)
	for i := 0; i <= N; i++ {
		memo[i] = make(map[string]int)
		done[i] = make(map[string]bool)
	}
	var dfs func(cur int, before string) int
	dfs = func(cur int, before string) int {
		if done[cur][before] {
			return memo[cur][before]
		}
		if cur == N {
			return 1
		}
		res := 0
		next := []string{"A", "G", "C", "T"}
		for i := 0; i < 4; i++ {
			if isOk([]rune(before + next[i])) {
				res += dfs(cur+1, before[1:]+next[i])
				res %= MOD
			}
		}
		done[cur][before] = true
		memo[cur][before] = res
		return res
	}
	fmt.Fprintln(wtr, dfs(0, "TTT"))
}

func isOk(before4 []rune) bool {
	for i := 0; i < 4; i++ {
		runes := make([]rune, len(before4))
		copy(runes, before4)
		if i != 0 {
			runes[i], runes[i-1] = runes[i-1], runes[i]
		}
		if strings.Contains(string(runes), "AGC") {
			return false
		}
	}
	return true
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
#define loop(i,n) for(int i=0; i<n; i++)
int main(){
  int n,m,k=0;
  int h[200],m1[200];
  cin >> n;
  loop(i,n){
    cin >> h[i] >> m1[i];
    k++;
  }
  cin >> m;
  loop(i,m){
    cin >> h[i+k] >> m1[i+k];
  }
  vector<pair<int, int> > p(n+m);
  loop(i,n+m){
    p[i] = make_pair(h[i],m1[i]);
  }
  sort(p.begin(),p.end());
  loop(i,n+m){

  }
  loop(i,n+m){
    if(p[i] == p[i-1] && i>0) continue;
    if(p[i].second>=10){
      if(i==0) cout << p[i].first << ":" << p[i].second;
      else cout << " " << p[i].first << ":" << p[i].second;
    }
    else{
      if(i==0) cout << p[i].first << ":" << "0" << p[i].second;
      else cout << " " << p[i].first << ":" << "0" << p[i].second;
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    map<char, int> cnt;
    for (int i = 0; i < s.size(); ++i) {
        cnt[s[i]]++;
    }
    for (char i = 'a'; i <= 'z'; ++i) {
        if (cnt[i] == 0) {
            cout << i << "\n";
            return 0;
        }
    }
    cout << "None"
         << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

int main(void){
    int n, k;
    std::string s;

    std::cin >> n >> k >> s;
    k--;
    if(s[k] == 'A')     s[k] = 'a';
    else if(s[k] == 'B')    s[k] = 'b';
    else if(s[k] == 'C')    s[k] = 'c';

    std::cout << s << std::endl;

    return 0;
}

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

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int N = sc.nextInt();
    	int R = sc.nextInt();

    	if(N>9) {
    		System.out.println(R);
    	} else {
    		System.out.println(R+100*(10-N));
    	}


    }

}

Measured memory_bytes: 23252
/*  ex5_3
    potter0723sw  */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int height, width, i, j, rowblack[100], colblack[100];
    char cell[100][100];
    scanf("%d %d", &height, &width);

    for(i=0;i<100;i++){
      rowblack[i]=0;
      colblack[i]=0;
    }

    for(i=0; i < height; i++){//マスの入力を受け取る
        for(j=0; j < width; j++){
            scanf(" %c", &cell[i][j]);
        }
    }

    for(i=0; i < height; i++){
        for(j=0; j < width; j++){
            if(cell[i][j] == '#'){
                rowblack[i] = 1;
                colblack[j] = 1;
            }
        }
    }
    
    for(i=0; i < height; i++){
        if(rowblack[i]==1){
            for(j=0; j < width; j++){
                if(colblack[j] == 1){
                    printf("%c", cell[i][j]);
                }
            }
        printf("\n");
        }
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n+2],b=0;
    a[0]=a[n+1]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b+=abs(a[i]-a[i-1]);
    }
    b+=abs(a[n]);
    for(int i=1;i<=n;i++){
        cout << b-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1])<<endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define GET_BIT(n, i) (((n) & (1LL << ((i)-1))) >> ((i)-1)) // i start from 1
#define SET_BIT(n, i) ((n) | (1LL << ((i)-1)))
#define CLR_BIT(n, i) ((n) & ~(1LL << ((i)-1)))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
void myInit();
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int MOD = 1000000007;
const int N = 3e5, M = N;
//=========TQR==============
vi g[N];

int main() {
	myInit();
	FIO;
	int t, sn = 0;
	cin >> t;
	cout << abs(t - 1) << endl;
	return 0;
}

void myInit() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int mpow(int base, int exp) {
	base %= MOD;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % MOD;
		base = ((ll)base * base) % MOD;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		g[u - 1].pb(v - 1);
		g[v - 1].pb(u - 1);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}

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

#define ll long long
#define vi vector<int>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>

using namespace std;

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

	char la=s[0];
	int m=1;
	for(int i=1;i<n;i++){
		if(s[i]!=la){
			la=s[i];
			m++;
		}
	}
	cout<<m<<endl;
}

Measured memory_bytes: 512
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T>
void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C>
void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion


int main()
{
    int n;
    cin >> n;
    int ans = 0;
    REPI(i,1,n) {
        ans += i;

    }
    P(ans);
    return 0;
}



Measured memory_bytes: 256
// include
#include <array>
#include <algorithm>
#include <set>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <unordered_map>


// pow(10, 15) 10の15乗

//  多倍長整数
#include <boost/multiprecision/cpp_int.hpp>
using big_int = boost::multiprecision::cpp_int;


std::uint64_t f(std::uint64_t x, std::uint64_t y, std::uint64_t z) {
  return (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
}

// ============================================
int main() {
    int N;
    std::cin >> N;
    std::vector<int> v(N);

    int limit = std::numeric_limits<int>::max();;
    for (int x = 1; x <= N; x++) {
      for (int y = 1; y <= N; y++) {
        for (int z = 1; z <= N; z++) {
          if (x+y+z > limit) {
            break;
          }
          std::uint64_t a = f(x, y, z);
//std::cout << "x:" << x << " y:" << y << "z:" << z << " n=" << a << std::endl;          
          if (a > N) {
//            std::cout << "b" << std::endl;
            limit = x + y + z + 1;
            break;
          }
          a = a-1;
          v[a] += 1;
        }
      }
    }
   for (int i = 0; i < N; ++i) {
     std::cout << v[i] << std::endl;
   }
  
    return 0;
}


Measured memory_bytes: 3052
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h, a;
    cin >> h >> a;

    cout << (h + a - 1) / a << "\n";

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef complex<ld> PT;
#define F first
#define S second

inline int in(){int x, y; y = scanf("%d", &x); return x; }

const int N = -1;

istream& operator>> (istream& is, complex<ld>& p){
	ld val;
	is >> val;
	p.real(val);
	is >> val;
	p.imag(val);
	return is;
}

PT proj(PT a, PT b, PT c){
	b -= a, c -= a;
	return a + b*real(c/b);
}

PT reflect(PT a, PT b, PT c){
	b -= a, c -= a;
	return a + conj(c/b)*b;
}

void Projection(){
	PT a, b;
	cin >> a >> b;
	cout << setprecision(10) << fixed;
	for (int i = in(); i; i--){
		PT p;
		cin >> p;
		PT img = proj(a, b, p);
		cout << img.real() << ' ' << img.imag() << '\n';
	}
}

void Reflection(){
	PT a, b;
	cin >> a >> b;
	for (int i = in(); i; i--){
		PT p;
		cin >> p;
		PT ref = reflect(a, b, p);
		cout << ref.real() << ' ' << ref.imag() << '\n';
	}
}

int main(){
	cout << setprecision(10) << fixed;
//	Projection();
	Reflection();
	return 0;
}


Measured memory_bytes: 3348
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> vec(n);
  for (auto &v : vec)
    cin >> v;

  if (n <= k) {
    cout << 0 << endl;
    return EXIT_SUCCESS;
  }
  sort(vec.begin(), vec.end());
  cout << fixed << setprecision(0) << accumulate(vec.begin(), vec.begin() + n - k, 0.) << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
 
int main(void)
{
    int i = 0, a, b, c, n;
    while(scanf("%d %d", &a, &b) != -1){
        c = a + b;
        for(n = 0; c != 0; n++){
            c = c / 10;
        }
        printf("%d\n", n);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define INF 1e+9
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void){
    int N;
    int a;
    map<int, int> mp;

    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a;
        mp[a]++; mp[a-1]++; mp[a+1]++;
    }

    int res = -1;
    for(auto x: mp){
        res = max(res, x.second);
    }

    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 4736
n,w=map(int, input().split())
m=10**5+1
x=[list(map(int, input().split())) for i in range(n)]
dp=[[float('inf')]*m for i in range(n+1)]
dp[0][0]=0
for i in range(n):
    for j in range(m):
        if j>=x[i][1]:
            dp[i+1][j]=min(dp[i][j],dp[i][j-x[i][1]]+x[i][0])
        else:
            dp[i+1][j]=dp[i][j]
ans=0
for i in range(m):
    if dp[-1][i]<=w:ans=max(ans,i)
print(ans)

Measured memory_bytes: 311404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

int main()
{
    ll n,k,ans=0;
    cin>>n>>k;
    ll h[n];
    rep(i,n)cin>>h[i];
    sort(h,h+n);
    rep(i,n-k) ans+=h[i];
    cout<<ans<<endl;
}


Measured memory_bytes: 1792