akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
mint dp[105][105];
int main(){
int h,w,k;
cin>>h>>w>>k;
dp[0][0]=1;
for(int i=0;i<h;i++){
	for(int bit=0;bit<(1<<w-1);bit++){
		bool c=true;
		for(int j=0;j<w-2;j++)if((bit&(1<<j))&&(bit&(1<<j+1)))c=false;
		if(!c)continue;
		V<int> move(w);
		iota(all(move),0);
		for(int j=0;j<w-1;j++){
			if(bit&(1<<j))swap(move[j],move[j+1]);
		}
		for(int j=0;j<w;j++){
			dp[i+1][move[j]]+=dp[i][j];
		}
	}
}
cout<<dp[h][k-1]<<"\n";
}

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

bool check(string &S) {

    if (S.size() >= 5) {
        if (S.substr(S.size()-5, S.size()) == "dream") {
            S = S.substr(0, S.size()-5);
            return true;
        }
        else if (S.substr(S.size()-5, S.size()) == "erase") {
            S = S.substr(0, S.size()-5);
            return true;
        }
    }
    if (S.size() >= 6) {
        if (S.substr(S.size()-6, S.size()) == "eraser") {
            S = S.substr(0, S.size()-6);
            return true;
        }
    }
    if (S.size() >= 7) {
        if (S.substr(S.size()-7, S.size()) == "dreamer") {
            S = S.substr(0, S.size()-7);
            return true;
        }
    }
    return false;
}


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

    while (S.size() > 0) {
        bool judge = check(S);
        if (!judge) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 3740
while xs = gets
    n,x=xs.chomp.split(' ').map{|n| n.to_i}
    count=0
    if n==0 && x==0
        break
    else
        1.upto n do |a|
            (a+1).upto n do |b|
                (b+1).upto n do |c|
                    if a+b+c == x
                        count +=1
                    end
                end
            end
        end
    end
    puts count
end

Measured memory_bytes: 6108
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=4000;
const int mod=1e9+7;
int n,k;

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

int power(int a,int k)
{
    if(k<0) return 1;
    int sum=1;
    for (;k;k>>=1,a=1ll*a*a%mod)
    if (k&1)
        sum=1ll*sum*a%mod;
    return sum;
}

int fac[maxn+10],ifac[maxn+10],inv[maxn+10];

int C(int a,int b){return (a<0)||(b<0)||(a<b)?0:1ll*fac[a]*ifac[b]%mod*ifac[a-b]%mod;}

int F(int i,int j){return (C(i+j,i)-C(i+j,i+1)+mod)%mod;}

int main()
{
    fac[0]=inv[0]=inv[1]=ifac[0]=1;
    for(int i=1; i<=maxn; ++i)
    {
        fac[i]=1ll*fac[i-1]*i%mod;
    }
    for(int i=2; i<=maxn; ++i) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=1; i<=maxn; ++i) ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
    n=read(),k=read();
    printf("%lld\n",1ll*F(n-1,k-1)*power(2,n-k-1)%mod);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,n,s,f,i,ans = 0;
	
	scanf("%d %d", &a, &b);
	scanf("%d", &n);
	for(i=0;i<n;i++) {
		scanf("%d %d", &s, &f);
		if ( (s<=a) && (f>a) ) ans = 1;
		if ( (s<b) && (f>=b) ) ans = 1;
		if ( (s>=a) && (f<=b) ) ans = 1;
	}
	printf("%d\n", ans);

	return 0;
}



Measured memory_bytes: 2112
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int INF = LLONG_MAX;
constexpr Int Int_max = LLONG_MAX;
constexpr Int Int_min = LLONG_MIN;
using Container = vector<Int>;
template<typename T>
using Grid = vector<vector<T>>; // 二次元配列。[y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;


int main() {

	Int N; cin >> N;
	Grid<Int> satisfaction(N, vector<Int>{-INF, -INF, -INF});
	rep(i, N) {
		cin >> satisfaction[i][0] >> satisfaction[i][1] >> satisfaction[i][2];
	}
	Int except[3][2] = { {1, 2}, {0, 2}, {0, 1} };
	Grid<Int> dp(N + 1, vector<Int>(3));
	dp[0][0] = 0, dp[0][1] = 0, dp[0][2] = 0;
	rep(i, N) {
		rep(j, 3) {
			dp[i + 1][except[j][0]] = max(dp[i + 1][except[j][0]], dp[i][j] + satisfaction[i][except[j][0]]);
			dp[i + 1][except[j][1]] = max(dp[i + 1][except[j][1]], dp[i][j] + satisfaction[i][except[j][1]]);
		}
	}
	cout << max({ dp[N][0], dp[N][1], dp[N][2] }) << endl;

}

Measured memory_bytes: 11136
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    
    System.out.println(N*(N-1)/2 + M*(M-1)/2);
    
  }
}
 

Measured memory_bytes: 22612
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <deque>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i) = 0; (i) <= (n); (i)++)
using namespace std;

int N, L;

int pool[2000010][2];

int ans = 0;

int g(int depth)
{
	int n = 1;
	int max = n;
	while (true)
	{
		if (depth % n == 0)
		{
			max = n;
		}
		n *= 2;
		if (n > depth) break;
	}
	return max;
}

void dfs(int a, int d)
{
	if (pool[a][0] < 0 && pool[a][1] < 0)
	{
		return;
	}

	if (pool[a][0] >= 0)
	{
		if (pool[a][1] < 0)
		{
			ans ^= g(L - d);
		}
		dfs(pool[a][0], d + 1);
	}

	if (pool[a][1] >= 0)
	{
		if (pool[a][0] < 0)
		{
			ans ^= g(L - d);
		}
		dfs(pool[a][1], d + 1);
	}
}

signed main()
{
	memset(pool, -1, sizeof(pool));

	cin >> N >> L;
	int m = 1;
	REP(i, N)
	{
		int v = 0;
		char s[100010];
		cin >> s;
		int len = strlen(s);
		REP(c, len)
		{
			int a = s[c] - '0';
			if (pool[v][a] == -1)
			{
				pool[v][a] = m++;
			}
			v = pool[v][a];
		}
	}

	dfs(0, 0);

	if (ans == 0)
	{
		cout << "Bob" << endl;
	}
	else
	{
		cout << "Alice" << endl;
	}
}

Measured memory_bytes: 33152
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    set<int> s;
    rep(i,n) {
        s.insert(a[i]);
    }
    if(s.size()==1) {
        for(auto m:s) {
            if(m==0) {
                cout << "Yes" << endl;
                return 0;
            }else {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    if(s.size()==2) {
        bool f = false;
        for(auto m:s) {
            if(m==0) f = true;
        }
        if(!f) cout << "No" << endl;
        else {
            int cnt = 0;
            rep(i,n) {
                if(a[i]==0) cnt++;
            }
            if(n%3==0 && cnt==n/3) {
                cout << "Yes" << endl;
            }else cout << "No" << endl;
        }
        return 0;
    }
    if(n%3==0 && s.size()==3) {
        vector<int> b;
        for(auto m:s){
            b.push_back(m);
        }
        vector<int> c(3,0);
        rep(i,n) {
            if(b[0]==a[i]) c[0]++;
            if(b[1]==a[i]) c[1]++;
            if(b[2]==a[i]) c[2]++;
        }
        if((b[0]^b[1]^b[2])==0 && c[0]==n/3&& c[1]==n/3&& c[2]==n/3) {
            cout << "Yes" << endl;
            return 0;
        } 
    } 
    cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 7440
#include <bits/stdc++.h>
using namespace std;
// 写経
int main() {
    int x, y;
    cin >> x >> y;
    string board[110];
    bool goodx[110]={false}, goody[110]={false};
    for(int i=0; i<x; i++) {
        cin >> board[i];
    }
    for(int i=0; i<x; i++) {
        for(int j=0; j<y; j++) {
            if(board[i][j]=='#') {
                goodx[i]=true;
                goody[j]=true;
            }
        }
    }

    for(int i=0; i<x; i++) {
        if(goodx[i]) {
            for(int j=0; j<y; j++) {
                if(goody[j]) {
                    cout << board[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
int num,tmp;
int S[20000000];


int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}



void heapIncreaseKey(int i,int key){
  if(S[i]>key){
    return ;
  }


  S[i]=key;
  while(i>1 && S[parent(i)]<S[i]){
    tmp=S[i];
    S[i]=S[parent(i)];
    S[parent(i)]=tmp;
    i=parent(i);
  }
}



void maxHeapInsert(int key){
  num=num+1;
  S[num]=-1000;
  heapIncreaseKey(num,key);
}



void maxHeapify(int i){
  int l,r,largest,tmp;
  l= left(i);
  r =right(i);
  if(l<=num && S[l]>S[i])largest =l;
  else largest =i;
  if(r<=num &&S[r]>S[largest])largest=r;
  if(largest != i){
    tmp=S[i];
    S[i]=S[largest];
    S[largest]=tmp;
    maxHeapify(largest);
  }
}

//?????§?????????????????? S ???????´???? S ????????????????????????????????????                                                                                                                                                                                    

int heapExtractMax(){
  int Max;

  if(num<1){
    return 0;
  }

  Max=S[1];
  S[1]=S[num];
  num=num-1;
  maxHeapify(1);
  return Max;
}


int main(){
 char b[100];
 int j;
  while(1){
    scanf("%s",b);
    if(b[0] =='i') {
      scanf("%d",&j);
      maxHeapInsert(j);
              }

    else if(b[1]=='x'){
      printf("%d\n",heapExtractMax());
      }
 else break;
    }

      return 0;
}

Measured memory_bytes: 4692
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

const int MAX_N = 207;

int edge[MAX_N][MAX_N], dist[MAX_N], n;
int q[MAX_N], head;

void solve() {
	cin >> n;
	int answ = 0;

	for(int i = 0; i < n; ++i) {
		string line;
		cin >> line;

		for(int j = 0; j < n; ++j) 
			edge[i][j] = (line[j] == '1');
	}

	for(int src = 0; src < n; ++src) {
		for(int v = 0; v < n; ++v) {
			dist[v] = INF;
		}	

		head = 0;
		int max_dist = 0;

		dist[src] = 0;
		q[head++] = src;

		for(int j = 0; j < head; ++j) {
			int v = q[j];

			for(int u = 0; u < n; ++u) {
				if(edge[v][u] == 0)
					continue;

				if(dist[u] > dist[v] + 1) {
					dist[u] = dist[v] + 1;
					q[head++] = u;

					if(dist[u] > max_dist)
						max_dist = dist[u];
				}
			}		
		}

		int ok = 1;

		for(int v = 0; v < n; ++v) {
			for(int u = 0; u < n; ++u) {
				if(edge[v][u] == 0)
					continue;

				if(dist[v] == dist[u]) {
					ok = 0;
					break;
				}
			}

			if(ok == 0)
				break;
		}

		if(max_dist + 1 > answ && ok)
			answ = max_dist + 1;
	}

	cout << (answ == 0 ? NIL : answ) << '\n';
}

int main() {
	init_IO();
	solve();

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,x;  //ｎは1~ｎの範囲、ｘは組み合わせの数値
    int c = 0;
    
    while(1){
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        
        for(int i = 1; i <= n; i++){
            
            for(int j = i + 1; j <= n; j++){
                
                for(int k = j + 1; k <= n; k++){
                    if((i + j + k) == x) c += 1;
                }
            }
        }
        cout << c << endl;
        c = 0;
    }
    
    
}



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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    int all = 1;
    int bad = 1;
    for(int i = 0;i < n;i++){
          cin >> a[i];
          all *= 3;
          if(a[i] % 2 == 0){
                bad *= 2;
          }
    }
    cout << all - bad << endl;
}


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

import numpy as np

A = [0]*(10**5+1)

for _ in range(N):
  a,b = map(int,input().split())
  A[a] += b

A = np.array(A,dtype=np.int64)
A = A.cumsum()
answer = (A >= K).nonzero()[0].min()
print(answer)

Measured memory_bytes: 15560
#include <bits/stdc++.h>
#include <set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define mod 1000000007
using namespace std;
int main()
{ 
	 #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ll int n;
    cin>>n;
    ll int a[n],i,s=0;
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
    	s+=a[i];
    }
    ll int ss[n+1];
    ss[0]=s;
    for(i=1;i<=n;i++)
    {
    	s-=a[i-1];
    	ss[i]=s;
    }
    ll int ans=0;
    for(i=1;i<=n;i++)
    {
    	ans=ans%mod+((a[i-1]%mod)*((ss[i])%mod)%mod);

    }
    ans=ans%mod;
    cout<<ans<<endl;


    





    	

}

	
		
	
	
	
	





Measured memory_bytes: 6704
#include<bits/stdc++.h>
#pragma GCC optimize(3)
namespace ZDY{
	#define res register
	#define ri res int
	#define ll long long
	#define db double
	#define il inline
	#define MB template <class T>
	#define Fur(i,x,y) for(ri i=x;i<=y;i++)
	#define fur(i,x,y) for(i=x;i<=y;i++)
	#define Fdr(i,x,y) for(ri i=x;i>=y;i--)
	#define in2(x,y) in(x),in(y)
	#define in3(x,y,z) in2(x,y),in(z)
	#define in4(a,b,c,d) in2(a,b);in2(c,d)
	#define outn(x) out(x),pc('\n')
	#define clr(x,y) memset(x,y,sizeof(x))
	#define cpy(x,y) memcpy(x,y,sizeof(x))
	#define fl(i,x) for(ri i=head[x],to;to=e[i].to,i;i=e[i].nxt)
	#define inf 2147483647
	#define fin(s) freopen(s".in","r",stdin)
	#define fout(s) freopen(s".out","w",stdin)
}using namespace ZDY;using namespace std;
namespace FAST{
	#define SIZ 10000000
	#define gc ibuf[bi++]
	#define pc(x) obuf[bo++]=x
	char ibuf[SIZ],obuf[SIZ];int bi=0,bo=0;il void clin(){fread(ibuf,1,SIZ,stdin);}il void clout(){fwrite(obuf,1,bo,stdout);}MB il void in(T &x){x=0;int f=1;while(ibuf[bi]<'0'||'9'<ibuf[bi])if(ibuf[bi++]=='-')f=-f;while('0'<=ibuf[bi]&&ibuf[bi]<='9')x=(x<<3)+(x<<1)+ibuf[bi++]-48;x*=f;}MB il void out(T x){if(x<0)x=-x,pc('-');if(x>9)out(x/10);pc(x%10+48);}
	MB il T ABS(T x){return x>0?x:-x;}
	MB il T MAX(T x,T y){return x>y?x:y;}
	MB il T MIN(T x,T y){return x<y?x:y;}
	MB il T GCD(T x,T y){return y?GCD(y,x%y):x;}
	MB il void SWAP(T x,T y){T t=x;y=t;x=y;}
}using namespace FAST;
#define N 100010
int n,k,a[N],ans=inf;
int main(){
	clin();
	in2(n,k);
	Fur(i,1,n)in(a[i]);
	if(n==1)return cout<<ABS(a[1]),0;
	if(a[1]>=0)return cout<<a[k],0;
	if(a[n]<=0)return cout<<-a[n-k+1],0;
	Fur(l,1,n-k+1){
		int r=l+k-1,x=ABS(a[l])+ABS(a[r])*2,y=ABS(a[l])*2+ABS(a[r]);
		ans=MIN(ans,MIN(x,y));
	}
	cout<<ans;
}

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

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

Measured memory_bytes: 1172
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int,int> P1;
typedef pair<P1,P1> P2;
typedef pair<int,P2> P3;
int d[50][51];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
bool used[50][50][50][50];
int main() {
	int X,Y;
	while(scanf("%d %d",&X,&Y),X) {
		memset(used,0,sizeof(used));
		int tx,ty,kx,ky;
		scanf("%d %d",&tx,&ty); tx--;ty--;
		scanf("%d %d",&kx,&ky); kx--;ky--;
		for(int i=0;i<Y;i++) {
			for(int j=0;j<X;j++) scanf("%d",&d[i][j]);
		}
		queue<P3> Q;
		Q.push(P3(0,P2(P1(tx,ty),P1(kx,ky))));
		used[tx][ty][kx][ky]=1;
		bool NA=1;
		while(!Q.empty()) {
			P3 p3=Q.front();Q.pop();
			int tx=p3.second.first.first;
			int ty=p3.second.first.second;
			int kx=p3.second.second.first;
			int ky=p3.second.second.second;
			if(p3.first>=100) break;
			if(tx==kx&&ty==ky) {
				printf("%d\n",p3.first);
				NA=0;
				break;
			}
			for(int i=0;i<4;i++) {
				int ntx=tx+dx[i],nty=ty+dy[i];
				int nkx=kx-dx[i],nky=ky-dy[i];
				if(0>ntx||ntx>=X||0>nty||nty>=Y||d[nty][ntx]) {
					ntx=tx,nty=ty;
				}
				if(0>nkx||nkx>=X||0>nky||nky>=Y||d[nky][nkx]) {
					nkx=kx,nky=ky;
				}
				if(!used[ntx][nty][nkx][nky]) {
					used[ntx][nty][nkx][nky]=1;
					Q.push(P3(p3.first+1,P2(P1(ntx,nty),P1(nkx,nky))));
				}
			}
		}
		if(NA) printf("NA\n");
	}
}

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

#define pb push_back
#define ss second
#define ff first
#define N 10000007
#define inf 1000000009
#define ll long long
#define pii pair<int,int>
#define sz(a) int(a.size())

using namespace std;

int n,dis[N],vis[N],pos,now,a[N],ans;
ll k;

void dfs(int nd){
	vis[nd] = 1;
	if(vis[a[nd]] == 1){
		pos = a[nd];
		ans = dis[nd] + 1 - dis[a[nd]];
		return;
	}
	dis[a[nd]] = dis[nd] + 1;
	dfs(a[nd]);
}

int main()
{
	scanf("%d%lld",&n,&k);
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	dfs(1);
	now = 1;
	while(k > 0 && now != pos){
		k--;
		now = a[now];
	
	}
	if(k == 0) printf("%d",now);
	else {
		k %= ans;
		while(k > 0){
			pos = a[pos];
			k--;
		} 
		printf("%d",pos);
	}
}


Measured memory_bytes: 6176
import copy

N = int(input())
SP = []
ss = set()
for i in range(N):
    s, p = input().split()
    ss.add(s)
    SP.append([i+1, s, int(p)])

calSP = copy.deepcopy(SP)
calSP = sorted(calSP, key=lambda x:(x[2]), reverse=True)
ss = sorted(ss)
num = 1
for sss in ss:
    for cal in calSP:
        if cal[1] == sss:
            cal.append(num)
            num += 1
calSP = sorted(calSP, key=lambda x:(x[3]))
for cal in calSP:
    print(cal[0])

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

using namespace std;

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

    bool isOK = true;

    for(int i = 0; i < s.length(); i++){
        if(s[i] != s[s.length() - i - 1]) isOK = false;
        if(!isOK) break;
    }

    for(int i = 0; i < (s.length() - 1) / 2; i++){
        if(s[i] != s[(s.length() - 1) / 2 - i - 1]) isOK = false;
        if(s[s.length() - 1 - i] != s[(s.length() + 3) / 2 - 1 + i]) isOK = false;
        if(!isOK) break;
    }

    if(isOK) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <queue>
#include <iostream>
#include <vector>
#include <map>
int main(){
  int a, b;
  std::cin>>a>>b;
  int ans=a+b;
  ans=std::max(ans, a-b);
  ans=std::max(ans, a*b);
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		cout<< (n+1)/2 <<endl;
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,c,d,e,f,i,j,k,l;
  cin>>a>>b;
  c=a%b;
  d=b-c;
  e=min(c,d);
  cout<<e<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,c;
    int x,y;
    x=0,y=0;
    while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
        if((a*a)+(b*b) == (c*c))x++;
        if(a == b)y++;
    }
    printf("%d\n%d\n",x,y);
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	ll N, M;
	cin >> N >> M;
	vector<ll> imos(N + 1);
	REP(i, M) {
		ll L, R;
		cin >> L >> R;
		L--; R--;
		imos[L]++;
		imos[R + 1]--;
	}
	REP(i, N)imos[i + 1] += imos[i];

	ll res = 0;
	REP(i, N) {
		if (imos[i] == M)res++;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;
using namespace atcoder;

int main(){
  int n, q;
  cin >> n >> q;
  fenwick_tree<ll> ft(n);
  rep(i, n){
    ll in;
    cin >> in;
    ft.add(i, in);
  }
  rep(_q, q){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == 0) ft.add(b, c);
    else cout << ft.sum(b, c) << endl;
  }
  return 0;
}

Measured memory_bytes: 8224
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;

int main() {
    ll n,T;
    cin >> n >> T;
    vector<ll> t(n); 
    for(ll i=0;i<n;i++) cin >> t[i];
    ll minu=0,temp=0;
    for(ll i=0;i<n;i++){
        if(minu<t[i])   temp+=(t[i]-minu);
        minu = t[i]+T;
    }
    cout << t[n-1]+T-temp << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,c) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n)	for(int i=0;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;
int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
bool comp(int a, int b) 
{ 
    return (a < b); 
} 

void solve()
{
	int n,k;
	cin>>n>>k;
	vi v(n);
	fr(i,n)cin>>v[i];
	sort(all(v));
	ll sum=0;
	fr(i,k)
		sum=sum+v[i];
	cout<<sum;

}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	// int t;
	// cin>>t;
	// while(t--)
	// {
	// 	solve();
	// 	cout<<endl;
	// }
	solve();
	return 0;
	
}



Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;

long long N, H;
vector<pair<long long, long long> > x;

bool pairGreater(const pair<int, int> &a,
               const pair<int, int> &b)
{
    return (a.first > b.first);
}

int main()
{
    cin >> N >> H;
    for (int i = 0;i < N;i++)
    {
        long long a, b;
        cin >> a >> b;
        x.push_back(make_pair(a, 0));
        x.push_back(make_pair(b, 1));
    }

    sort(x.begin(), x.end(), pairGreater);

    long long ans = 0;
    long long rh = H;
    long long cnt = 0;
    while (rh > 0)
    {
        pair<long long, long long> t = x[cnt];
        if(t.second == 0)
        {
            if(rh % t.first == 0)
            {
                ans += rh / t.first;
            }
            else
            {
                ans += rh / t.first + 1;
            }
            break;
        }
        else
        {
            cnt++;
            ans++;
            rh -= t.first;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6128
import numpy as np 

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

w_all = np.zeros(W + 1, dtype=int)

for i in range(N):
  w, v = map(int, input().split())
  w_all[w:] = np.maximum(w_all[w:], w_all[:-w] + v)

print(w_all[W])


Measured memory_bytes: 15424
from math import factorial as fact
N, K = map(int, input().split())
def cnt_pairs(num1, num2):
    return fact(num1 + num2) // (fact(num1) * fact(num2))

for i in range(1, K + 1):
    if (i - 1 >=  0) and (K - i >= 0) and (N - K - i + 1 >= 0):
        blue_pairs = cnt_pairs(K - i, i - 1)
        print(cnt_pairs(N - K - i + 1, i) * blue_pairs % 1000000007)
    else:
        print(0)

Measured memory_bytes: 66520
// https://www.youtube.com/watch?v=prx1psByp7U

#include <bits/stdc++.h>
using namespace std;

#define N 101

int dp[N+1][N+1], p[N+1];

// dp[i][j] := [Mi, Mj]におけるminimum number of scalar multiplications 

int main(){
    
    int n;
    cin >> n;
    
    for (int i = 1; i < n+1; i++) cin >> p[i-1] >> p[i];
    
    
    // l はchain lengthを表す変数である.
    // l == 1のとき計算回数は0である.
    for (int l = 2; l <= n; l++){
        
        // 変数iは区間の左端を表す
        // 左端が動ける範囲の上限は, n - l + 1である
        // 具体例を考えてみよ
        for (int i = 1; i <= n-l+1; i++){
            
            // jは右端の上限値を表す
            int j = i + l - 1;
            
            dp[i][j] = (1<<20);
            
            // 今回調べる区間は, [i, j-1]
            for (int k = i; k < j; k++){
                
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i-1] * p[k] * p[j]);
            }
        }
    }
    
    cout << dp[1][n] << endl;
}


Measured memory_bytes: 3144
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

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

    for(int i=0;i<s.length();i++){
        if(s[i] == 'a') continue;
        if( ( 'z' - s[i] +1 ) <= k ){
            k = k - ('z'-s[i]+1);
            s[i] = 'a';
        }
        if(k == 0) break;
    }

    if(k>0){
        s[s.length()-1] = s[s.length()-1] + (k%26);
    }

    cout<<s<<endl;

}

Measured memory_bytes: 512
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

X,Y=get_i
puts X+Y/2

Measured memory_bytes: 1788
N = int(input())
S = [input() for _ in range(N)]

M = int(input())
T = [input() for _ in range(M)]

SD = {}
for s in S:
    SD[s] = SD.get(s, 0) + 1

TD = {}
for t in T:
    TD[t] = TD.get(t, 0) + 1

# print(SD)
# print(TD)

ans = 0
for k, v in SD.items():
    # print(k,v)
    ans = max(ans, v - TD.get(k, 0))

print(ans)


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

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for (int i = 0; i < N; ++i) cin >> P[i];
    for (int i = 0; i < N; ++i) cin >> Q[i];

    vector<vector<int>> vs;
    vector<int> v(N);
    iota(v.begin(), v.end(), 1);
    do {
        vs.push_back(v);
    } while (next_permutation(v.begin(), v.end()));

    int a, b;
    for (int t = 0; t < vs.size(); ++t) {
        bool ok1 = true, ok2 = true;
        for (int i = 0; i < N; ++i) {
            ok1 &= (vs[t][i] == P[i]);
            ok2 &= (vs[t][i] == Q[i]);
        }
        if (ok1) a = t;
        if (ok2) b = t;
    }
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 3256
package main

import (
  "bufio"
  "fmt"
  "strings"
  "os"
  "strconv"
  "sort"
)

var sc = bufio.NewScanner(os.Stdin)

func newLine() string {
  sc.Scan()
  return sc.Text()
}

func main()  {
  fst := newLine()
  fstArray := strings.Split(fst, " ")
  N, _ := strconv.Atoi(fstArray[0])
  C, _ := strconv.Atoi(fstArray[1])
  K, _ := strconv.Atoi(fstArray[2])
  T := make([]int, N)
  for i:=0; i<N; i++ {
    T[i], _ = strconv.Atoi(newLine())
  }
  sort.Ints(T)
  init := -10000000000
  cap := 0
  n := 0
  for i:=0; i<N; i++ {
    if  T[i] > init+K || cap > C {
      n += 1
      cap = 1
      init = T[i]
    }
    cap += 1
  }
  fmt.Println(n)
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int cnt = 1;
    rep(i,n){
        int a;
        cin >> a;
        if(a == cnt)cnt++;
    }

    int ans = n - cnt + 1;

    if(ans == n)ans = -1;

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


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
	if (a > b) swap(a, b);
	while (a != 0) tie(a, b) = make_pair(b%a, a);
	return b;
}
int main() {
	int N;
	vector<int> can; can.clear();
	unordered_map<int, int> m; m.clear();
	cin >> N;
	for(int i = 0, ai; i < N; i++) {
		cin >> ai;
		m[ai]++;
	}
	int pre = 0;
	for (const auto &it: m) {
		if (it.second >= 2) pre = gcd(pre, it.first);
		else can.push_back(it.first);
	}
	int ans = 1, tmp;
	sort(can.begin(), can.end());
	for (const int &t: can) {
		tmp = pre;
		for (const int &i: can) {
			if (i == t) continue;
			tmp = gcd(tmp, i);
			if (tmp <= ans) break;
		}
		ans = max(ans, tmp);
	}
	if (can.empty()) ans = pre;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
   int a[3][3];
   int ans[3][3];
   int tmp;
   int flag = 0;

   for(int i = 0;i < 3 ; i++){
       for(int j = 0 ; j < 3;j++){
           cin >> a[i][j];
       }
   }
   int n;
   cin >> n;

   for(int k = 0;k < n;k++){
       cin >> tmp;
       for(int i = 0;i < 3; i++){
           for(int j = 0; j < 3 ;j++){
               if(a[i][j] == tmp){
                   ans[i][j] = 1;
               }
               
           }
       }
      
   }
   for(int i = 0;i < 3;i++){
       if(ans[i][0] == 1&&ans[i][1] == 1&&ans[i][2] == 1)flag=1;
       if(ans[0][i] == 1&&ans[1][i] == 1&&ans[2][i] == 1)flag=1;
       
   }
   if(ans[0][0] == 1&&ans[1][1] == 1&&ans[2][2] == 1)flag=1;
   if(ans[0][2] == 1&&ans[1][1] == 1&&ans[2][0] == 1)flag=1;

   if(flag !=0){
       cout << "Yes";
   }else{
       cout << "No";
   }
}
   



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#define ull unsigned long long
using namespace std;
ull x,yer;
void dp() {
        for (ull i = 100,j=1; i < x;j++) {
        i += i / 100;
        yer = j;
    }
}
int main() {
    scanf("%lld", &x);
    dp();
    printf("%lld\n", yer);
    return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int a,a1,b,b1,c,c1;
int main()
{
    string s,s1="abc";
    cin>>s;
    sort(s.begin(),s.end());
    if(s==s1) cout<<"Yes\n";
    else cout<<"No";
    return 0;
}


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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;
ll N, M, Q;

struct Number{
    int a;
    int b;
    int c;
    int d;
};
vector<Number> v;
ll ans = 0;

/*
bool cmp(const Number &a, const Number &b){
    return a.a < b.a;
}

void dfs( vector<bool> &used, int depth){

    if(depth == Q){
        int point = 0;
        bool valid = true;
        for(int i = 0; i < Q; i++){
            vector<int> vp(N, 1);
            int mini = 1;
            if(used[i]){
                if( vp[ v[i].a ] == -1 ){
                    vp[ v[i].a ] = mini;
                }
                else{
                    mini = vp[ v[i].a ] ; 
                }

                if(  vp[ v[i].b ] != -1){
                    if( vp[ v[i].b ]  - vp[ v[i].a ] != v[i].c ) valid = false;
                }
                else{
                    vp[ v[i].b ] = vp[ v[i].a ] + v[i].c; 
                    //if( vp[ v[i].b ] > M ) valid = false;
                }
                point += v[i].d;
            }
        }
        if(valid) ans = max(ans, point);
        return ;
    }

    for(int i = 0; i < 2; i++){
        used[depth] = i;
        dfs( used, depth + 1); 
    }
}
*/

void rekkyo(vector<int> &test, int depth ){
    /*
    for(int i = 0; i < N; i++) cout << test[i] << " ";
    cout << endl;
    */
    //cout << "depth = " << depth << endl;

    if(depth == N){
        ll point = 0;
        for(int i = 0; i < Q; i++){
            if(test[ v[i].b ] - test[ v[i].a ] == v[i].c){
                point += v[i].d;
            }
        }
        ans = max(ans, point);
        return;
    }

    if(depth == 0){
        //cout << "a" << endl;
        for(int i = 1; i <= M; i++){
            test[depth] = i;
            rekkyo(test, depth + 1);
        }
    }
    for(int i = 1; i <= M; i++){
        //cout << "b" << endl;

        if( i >= test[depth - 1] ){
            test[depth] = i;
            rekkyo(test, depth + 1);
        } 
    }
}

int main(){
    
    cin >> N >> M >> Q;
    v.resize(Q);
    for(int i = 0; i < Q; i++){
        cin >> v[i].a >> v[i].b >> v[i].c >> v[i].d;
        v[i].a --;
        v[i].b --;
    }

    vector<int> test(N);
    rekkyo( test, 0 );
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *
from heapq import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N, M = reads()
edges = set()
for _ in range(M):
  a, b = reads()
  a, b = a-1, b-1
  edges.add((a, b))
  edges.add((b, a))

for k in range(N):
  if (0, k) in edges and (k, N-1) in edges:
    print("POSSIBLE")
    exit()

print("IMPOSSIBLE")


Measured memory_bytes: 88152
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: chars,
    }
    let num = n
        .iter()
        .clone()
        .map(|c| c.to_string())
        .collect::<String>()
        .parse::<usize>()
        .unwrap();
    let mut s_num = 0;
    for ch in n {
        s_num += ch.to_string().parse::<usize>().unwrap();
    }
    println!("{}", if num % s_num == 0 { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

struct Point {
    long long x, y;
    int ind;

    Point(long long int x, long long int y, int ind) : x(x), y(y), ind(ind) {}

    Point() {}

    Point operator+(Point p) {
        return {x + p.x, y + p.y, ind};
    }

    Point operator-(Point p) {
        return {x - p.x, y - p.y, ind};
    }
};

long long cross(Point a, Point b) {
    return a.x * b.y - a.y * b.x;
}

long long dot(Point a, Point b) {
    return a.x * b.x + a.y * b.y;
}

long long len2(Point a) {
    return a.x * a.x + a.y * a.y;
}

bool cmp(Point a, Point b) {
    if (cross(a, b) != 0) {
        return cross(a, b) > 0;
    } else {
        return len2(a) < len2(b);
    }
}

long double angle(Point a, Point b) {
    return atan2(cross(a, b), dot(a, b));
}

int main() {
    int n;
    cin >> n;
    vector<Point> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].x >> a[i].y;
        a[i].ind = i;
    }

    Point mn = a[0];
    for (int i = 0; i < n; i++) {
        if (a[i].y < mn.y || (a[i].y == mn.y && a[i].x < mn.x)) {
            mn = a[i];
        }
    }
    for (int i = 0; i < n; i++) {
        a[i] = a[i] - mn;
    }

    sort(a.begin(), a.end(), cmp);

    vector<Point> st;
    for (auto p : a) {
        while (st.size() >= 2 && cross(st.back() - st[st.size() - 2], p - st.back()) <= 0) {
            st.pop_back();
        }
        st.push_back(p);
    }

    vector<long double> ans(n);

    if (st.size() == 2) {
        ans[st[0].ind] = ans[st[1].ind] = 0.5;
    } else {
        for (int i = 0; i < st.size(); i++) {
            Point p1 = st[(i + st.size() - 1) % st.size()];
            Point p = st[i];
            Point p2 = st[(i + 1) % st.size()];

            Point v1 = p - p1;
            Point v2 = p2 - p;
            ans[p.ind] = angle(v1, v2) / 2 / M_PI;
        }
    }

    cout.precision(20);
    for (int i = 0; i < n; i++) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize(2)

#include "bits/stdc++.h"

using namespace std;

//#define _DEBUG
#define all(a) begin(a), end(a)
#define MOD 1000000007
#define PII pair<int, int>
#define complete_unique(a) a.erase(unique(begin(a), end(a)), end(a))
#define mst(x, a) memset(x, a, sizeof(x))
typedef vector<int> VI;
typedef long long ll;

ll quick_pow(ll a, ll b) {
    long long res = 1;
    while (b) {
        if (b & 1)
            res = a * res;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll gcd(ll a, ll b) {
    a = abs(a), b = abs(b);
    while (b != 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

bool is_prime(int n) {
    if (n == 0) return false;
    if (n == 1) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    int j = sqrt(n);
    for (int i = 2; i <= j; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}

ll reverse_num(ll n) {
    ll x = 0, t = n;
    while (t != 0) {
        x = x * 10 + t % 10;
        t /= 10;
    }
    return x;
}

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

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
    // 加速输入和输出
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



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

int main(){
    int K;
    //入力
    cin >> K;
    int ans = -1;
  	int seven = 0;
    for(int i=1;i<=1000001;i++){
      seven = 10*seven%K + 7;
        if(seven % K == 0){
          ans = i;
          break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3680
N, T = map(int, input().split())
c_min = 1001

for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        c_min = min(c, c_min)

if c_min > 1000:
    print("TLE")
else:
    print(c_min)


Measured memory_bytes: 3060
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll n; cin >> n;
  vector<ll> B(n-1), A;
  loop(i,0,n-1) cin >> B[i];
  A.push_back(B[0]);
  loop(i,0,n-2) {
    A.push_back(min(B[i], B[i+1]));
  }
  A.push_back(B[B.size()-1]);
  assert(A.size()==n);
  ll sum = 0;
  loop(i,0,n) sum += A[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int N,K;
int S[105],B[105][105];
int main()
{
	while(1)
	{
		cin >> N >> K;
		if(N==0&&K==0)break;
		memset(S,0,sizeof(S));
		memset(B,0,sizeof(B));
		for(int i=0;i<K;i++)cin >> S[i];
		for(int i=0;i<N;i++)
		{
			for(int j=0;j<K;j++)
			{
				cin >> B[i][j];
			}
		}
		bool ans=true;
		for(int i=1;i<N;i++)
		{
			for(int j=0;j<K;j++)
			{
				B[i][j]+=B[i-1][j];
			}
		}
		for(int i=0;i<K;i++)ans&=(B[N-1][i]<=S[i]);
		printf("%s\n",(ans?"Yes":"No"));
	}
	return 0;
}

Measured memory_bytes: 1168