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

using ll = long long;

const ll INF = 1001001001001;

int main() {
	string s, t;
	cin >> s >> t;
	int sn = s.size();
	int tn = t.size();
	vector<vector<int>> dp(sn + 1, vector<int>(tn + 1, 0));
	for (int i = 1; i <= sn; ++i) {
		for (int j = 1; j <= tn; ++j) {
			dp[i][j] = max({
				dp[i - 1][j],
				dp[i][j - 1],
				dp[i - 1][j - 1] + (s[i - 1] == t[j - 1] ? 1 : 0)
			});
		}
	}
	int i = sn;
	int j = tn;
	string ans;
	while (i > 0 && j > 0) {
		if (s[i - 1] == t[j - 1]) {
			ans += s[i - 1];
			i--; j--;
		} else {
			if (dp[i][j] == dp[i - 1][j]) --i;
			else --j;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 35584
/*****************************************************

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 2e5+7;
const ll inf = 1e17;

int pwr(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r % MOD;
}

int inv(int x)
{
    return pow(x, MOD-2);
}

void solve()
{
    int n; cin>>n;
    int ans = (n-2)*180;
    cout<<ans;   
}

signed main()
{
    fast;

    int t=1;
    // cin >>t;
    while(t--){
        solve();
    }
    return 0;
}

/*****************************


****************************/

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

int main(){
  int K, X;
  cin >> K >> X;
  
  for(int i=X-K+1; i<=X+K-1; i++){
    cout << i;

    if (i == K+X-1){
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

Measured memory_bytes: 256
var input= require("fs").readFileSync("/dev/stdin", "utf8");
input = input.split(" ");
var a=parseInt(input[0]);
var b=parseInt(input[1]);
var c=parseInt(input[2]);

if(a<b&&b<c&&a<c){
    console.log("Yes");
}
else{
    console.log("No");
}


Measured memory_bytes: 15088
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static System.Console;

namespace C_ABC128
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            var kslist = new List<int[]>();
            for (int i = 0; i < s[1]; i++)
            {
                int[] ks = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
                kslist.Add(ks);
            }
            int[] p = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int n = s[0];
            int m = s[1];

            var blst = new List<int>();
            for (int bit1 = 0; bit1 < (1 << n); ++bit1)
            {
                blst.Add(bit1);
            }


            for (int i = 0; i < m; i++)
            {
                for (int bit = 0; bit < (1 << n); ++bit)
                {
                    int ans = 0;
                    for (int j = 1; j <= kslist[i][0]; j++)
                    {
                        
                        if ((bit & (1 << kslist[i][j]-1)) >= 1)
                        {
                            ans++;
                        }
                    }
                    if (ans % 2 != p[i])
                    {
                        int idx = blst.IndexOf(bit);
                        if (idx >= 0)
                        {
                            blst.RemoveAt(idx);
                        }
                    }

                }


            }

            WriteLine(blst.Count);
        }
    }
}


Measured memory_bytes: 13396
from math import gcd

# def GCD(a,N):
#     gcd = a[0]
#     for i in range(1, N):
#         gcd = math.gcd(gcd, a[i])
#     return gcd


k = int(input())

ans = 0
L = []
G = [0] * k**3

for i in range(1, k+1):
    for j in range(1, k+1):
        for l in range(1, k+1):
            # _l = sorted([i,j,l])
            # if i==1 or j == 1 or l == 1:
            #     ans += 1
            # elif not _l in L:
            #     L.append(_l)
            #     g = GCD(_l, 3)
            #     G[L.index(_l)] = g
            #     ans += g
            # else:
            #     ans += G[L.index(_l)]
            ans += gcd(i,gcd(j,l))

print(ans)

Measured memory_bytes: 129844
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);

    int sum = 0;

    for(int i = 0; i < N; i++) {
        cin >> a[i];
        sum = sum ^ a[i];
    }

    for(int i = 0; i < N; i++) {
        cout << (sum ^ a[i]) << endl;
    }

    return 0;
}


Measured memory_bytes: 4020
import sys
input = sys.stdin.readline
k,q=map(int, input().split())
d=list(map(int, input().split()))

for _ in range(q):
    n,x,m=map(int, input().split())
    dm=[di%m if di%m>0 else m for di in d]
    oa=on=0
    for i,a in enumerate(dm):
        oa+=a
        if i+1==(n-1)%k: on=oa
    first = x
    last = x + (oa * ((n-1)//k)) + on
    print(n-1 - (last//m - first//m))


Measured memory_bytes: 66012
#include <stdio.h>

int main()
{
	int x, i;
	i = 0;
	while(1){
		scanf ("%d", &x);
		if( x == 0 ){
			break;
		}
		i++;
		printf("Case %d: %d\n", i, x);
	}





	return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll i,o,t,j,l,s,z;
  cin >> i >> o >> t >> j >> l >> s >> z;
  ll ans = 0;
  ans += o * 2;
  int cnt = 0;
  if (i % 2 == 1) cnt++;
  if (j % 2 == 1) cnt++;
  if (l % 2 == 1) cnt++;
  if (j % 2 == i % 2 && i % 2 == l % 2 && l % 2 == j % 2) {
    ans += (i + j + l) * 2;
  } else {
    ans += (i + j + l - 1) * 2;
  }
  if (cnt == 2 && min({j,l,i}) == 0) {
    ans -= 2;
  } 
  cout << ans / 2<< endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);


int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int W[N+1], E[N+1];
  W[0] = 0; E[N] = 0;
  for(int i=1; i<=N; i++){
    W[i] = W[i-1];
    if(S[i-1] == 'W')
      W[i]++;
  }
  for(int i=N; i>=1; i--){
   E[i-1] = E[i];
    if(S[i-1] == 'E')
      E[i-1]++;
  }
  int tmp, ans=N;
  for(int i=1; i<=N; i++){
    ans = min(W[i-1] + E[i], ans);
  }
 
  cout << ans << endl;
}
  

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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;
}

ll M = 1000000007;

void solve()
{
	int n;
	cin>>n;
	set<string>ans;
	rep(i,n){
		string s;
		cin>>s;
		ans.insert(s);
	}
	cout<<size(ans)<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 19244
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a int
    fmt.Scan(&a)
    ans := "Christmas"
    for i:=0; i<25-a; i++{
        ans += " Eve"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

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

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

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <math.h>
#include <numeric>
#include <vector>
#include <iomanip>

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    int N,K;
    cin >> N >> K;

    vector<double> p;
    double temp;
    for(int i=0;i<N;i++){
        cin >> temp;
        p.push_back((temp+1)/2);
    }

    double max_val = 0,val=0;
    val = accumulate(next(p.begin(),0),next(p.begin(),K),0.0);
    for(int j=0;(j+K)<N+1;j++){
        //std::cout << p[j] << " " << p[j+K] << " " << val << std::endl;
        if(max_val < val){
            max_val = val;
        }
        val -= p[j];
        val += p[j+K];
    }

    cout << fixed << setprecision(3) << max_val << "\n";

    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n)
    cin >> a[i];

  map<ll, ll> x_sum;
  REP(i, n)
    x_sum[a[i]]++;

  sort(a.begin(), a.end());
  decltype(a)::iterator result = unique(a.begin(), a.end());
  a.erase(result, a.end());
  ll sum = 0;
  REP(i, a.size()){
    if(x_sum[a[i]] - a[i] >= 0)
      sum += x_sum[a[i]] - a[i];
    else
      sum += x_sum[a[i]];
  }

  cout << sum << endl;
}






Measured memory_bytes: 7040
#include <stdio.h>

int main()
{
	int a, b, d = 0, r = 0;
	double f = 0.0;
	scanf("%d%d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %f\n", d, r, f);
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int s,i,j;
  int a[1000005];
  int min = 10000001;
  cin >> s;
  a[0] = s;
  for(i=1; i<=1000000; i++){
    if(s % 2 == 0){
      s = s / 2;
      a[i] = s;
    } else {
      s = (3 * s) + 1;
      a[i] = s;
    }
  }
  for(i=0; i<=1000000; i++){
    j = i;
    do{
      j++;
      if(a[i] == a[j]){
	if(j < min){
	  min = j;
	}
	break;
      }
      if(1000001 < j) break;
    }while(a[i] != a[j]);
  }
  cout << min + 1 << endl;
  return 0;
}


Measured memory_bytes: 4224
def knap(N,W,weight,value):
    inf=float("inf")
    dp=[[-inf for i in range(W+1)] for j in range(N+1)]
    #各nについて初期化　以下で各ｗについて0この時０とする
    for i in range(W+1):#w+1とは0~w
        dp[0][i]=0
    for i in range(N):#each n 0~N-1
        for w in range(W+1):#w 0~w
            if weight[i]<=w:#=を入れないとぎりぎりの時が困る
                dp[i+1][w]=max(dp[i][w-weight[i]]+value[i],dp[i][w])
            else:
                dp[i+1][w]=dp[i][w]
   # print(dp)
    return dp[N][W]


n,W=map(int,input().split())
w=[]
v=[]
for i in range(n):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
print(knap(n,W,w,v))

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

int main()
{
    double a,b,c,d,e,f,t,u,v;
    vector<double> x(0),y(0);
    while (cin>>a>>b>>c>>d>>e>>f)
    {
        x.push_back(0);
        y.push_back(0);
        t=a; u=b; v=c;
        a*=d;  b*=d; c*=d;
        d*=t; e*=t; f*=t;
        y[y.size()-1]=(c-f)/(b-e);
        x[x.size()-1]=(v-u*y[y.size()-1])/t;
    }
    for (int i=0; i<x.size(); i++)
    {
        printf("%.3f %.3f\n", x[i], y[i]);
        //cout<<x[i]<<".000 "<<y[i]<<".000\n";
    }
    return 0;
}



Measured memory_bytes: 3196
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=0;
  string s;
  cin>>s;
  n=s.size();
  vector<vector<ll> >dp(n+1,vector<ll>(13,0));
  dp[0][0]=1;
  for(ll i=0;i<n;i++){
    if(s[i]=='?'){
      for(ll k=0;k<10;k++){
        for(ll j=0;j<13;j++){
          dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%MOD;
        }
      }
    }
    else{
      ll x=s[i]-'0';
      for(ll j=0;j<13;j++){
        dp[i+1][(j*10+x)%13]=(dp[i+1][(j*10+x)%13]+dp[i][j])%MOD;
      }
    }
  }
  cout<<dp[n][5]<<endl;
}


Measured memory_bytes: 13632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define ifl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i++)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


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

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

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

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

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

// int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];    
// for(int i=0;i<n;i++)cout<<a[i];
// int a,b;cin>>a>>b;   

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

// vector< tuple < int ,int ,int > > tv;
// vector< int ,int > pv;


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


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	    int n;
	    cin>>n;
	    bool ok=0;
	    for(ll i=0;i<10000;i++)
	    {
	        for(ll j=-10000;j<100000;j++)
	        {
	            if((pow(i,5)-pow(j,5))==n)
	            {
	                cout<<i<<" "<<j<<bn;
	                ok=1;
	                break;
	            }
	        }
	        if(ok)
	        break;
	    }
	    
	}
	
	return 0;
}


Measured memory_bytes: 4172
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

//小数出力
double print_double(double d){printf("%.8f", d);}

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

//約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main() {
  ll H,N,t;
  cin >> H >> N;
  vector<pair<int,int>> v(N);
  rep(i,N){
    cin >> v[i].first >> v[i].second;
  }
  
  Vl dp(10000*2+1,0);//効用にかかるコストの最小
  FOR(i,1,10000*2+1){
    
    dp[i] = 100000000000;
    rep(j,N){
      if (i>=v[j].first){
        t = v[j].second + dp[i-v[j].first];
        if (dp[i] > t) {
          dp[i] = t;
          }
      }
    }
  }
  for (int i=2*10000;i>=H;i--) {
    
    if (dp[i-1]>dp[i]) dp[i-1] = dp[i];
  }
  
  cout << dp[H] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,p;
  while(cin >> n >> p, n!=0 && p!=0){
    int s[n];
    int index = 0;
    int stone = p;
    for(int i=0;i<n;i++){
      s[i] = 0;
    }
    while(true){
      if(stone > 0){
    s[index]++;
    stone--;
      }else if(stone == 0){
    stone = s[index];
    s[index] = 0;
      }
     
      if(s[index] == p) break;
      if(index == n-1){
    index = 0;
      }else{
    index++;
      }
    }
    cout << index << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  int N, K, Q; cin >> N >> K >> Q;
  vector<int> a(Q);
  rep(i, Q){
    cin >> a[i];
    a[i]--;
  }
  vector<int> point(N, K - Q);
  rep(i, Q){
    point[a[i]]++;
  }
  rep(i, N){
    if (point[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

int main() {
  int64_t A,B,K;
  cin >> A >> B >>K;

//cout << (B-A+1)-(2*K) << endl;
  if((B-A+1)>=(2*K)){
    for(int i=A;i<=A+K-1;i++){
      cout << i << endl;
    }
    for(int j=B-K+1;j<=B;j++){
      cout << j << endl;
    }
  }

else{
  for(int i=A;i<=B;i++){
    cout << i <<endl;
  }
}


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n;
  cin>>n;
  
  
  //divisor n
  std::vector<int64_t> div;
  for (int64_t i = 1; i*i < n; ++i)
  {
    if(n%i==0){
      div.push_back(n/i);
    }
  }

  cout<<accumulate(div.begin(), div.end(),0LL,[&](int64_t acc,int64_t i){
    i-=1;
    if(n%i==(n-n%i)/i) return acc+=i;
    else return acc+=0;
  });
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<queue>

#define INF 20

int field_x, field_y;
int res = INF;

bool check(int field[10][10]){

	int r = 0, g = 0, b = 0;

	for (int i = 0; i < field_y; i++){
		for (int j = 0; j < field_x; j++){
			field[i][j] == 0 ? r++ : field[i][j] == 1 ? g++ : b++;
		}
	}

	int a = field_x*field_y;
	if (r == a || g == a || b == a)return true;
	return false;
}

void bfs(int(&field)[10][10], int color){

	bool used[10][10];
	memset(used, false, sizeof(used));

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

	typedef std::pair<int, int> P;
	std::queue<P>q;
	q.push(P(0, 0));
	used[0][0] = true;

	while (!q.empty()){

		P p = q.front();
		q.pop();

		for (int i = 0; i < 4; i++){
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (0 <= nx&&nx < field_x && 0 <= ny&&ny < field_y&&!used[ny][nx] && field[ny][nx] == field[0][0]){
				field[ny][nx] = color;
				q.push(P(nx, ny));
				used[ny][nx] = true;
			}
		}
	}

	field[0][0] = color;
}

void calc(int field[10][10], int count){

	if (check(field)){
		res = count;
		return;
	}

	if (count >= res)return;

	for (int i = 0; i < 3; i++){
		if (field[0][0] == i)continue;

		int copy_field[10][10];
		memcpy(copy_field, field, sizeof(copy_field));

		bfs(copy_field, i);

		calc(copy_field, count + 1);
	}
}

int main(){

	while (std::cin >> field_x >> field_y, field_x || field_y){

		int field[10][10];

		for (int i = 0; i < field_y; i++){
			for (int j = 0; j < field_x; j++){
				char c;
				std::cin >> c;
				c == 'R' ? field[i][j] = 0 : c == 'G' ? field[i][j] = 1 : field[i][j] = 2;
			}
		}

		calc(field, 0);

		std::cout << res << std::endl;

		res = INF;
	}

	return 0;
}

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

#define last vec.size() - 1

int main() {
	int n; long long int sum = 0;
	cin >> n; vector<int> vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec[i]; sum += vec[i];
	}
	stable_sort(vec.begin(), vec.end());
	cout << vec[0] << " " << vec[last] << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3224
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

bool IsKaibun(const string &S)
{
    int N = S.length();
    for (int i = 0; i < N; ++i)
    {
        if (S[i] != S[N - 1 - i]) return false;
    }
    return true;
}

int main()
{
    string S; cin >> S;
    int N = S.length();
    string S1, S2;
    for (int i = 1; i <= (N - 1) / 2; ++i)
    {
        S1.push_back(S[i - 1]);
    }
    for (int i = (N + 3) / 2; i <= N; ++i)
    {
        S2.push_back(S[i - 1]);
    }
    if (IsKaibun(S) && IsKaibun(S1) && IsKaibun(S2))
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   int n=0;
   for(int i=0;i<3;i++)
   {
       if(s[i]=='R')
        n++;
   }
   if(n==3)
    printf("3\n");
   else if(n==2)
   {
       if(s[1]=='S')
        printf("1\n");
       else
        printf("2\n");
   }
   else
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 3684
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        m: usize,
        k: usize,
        a: [u64; n],
    }
    let mut dp = a.clone();
    for k in 1..k {
        let mut d = std::collections::VecDeque::new();
        d.push_back((k - 1, dp[k - 1]));
        for i in k..n {
            if d.front().unwrap().0 + m + 1 == i {
                d.pop_front();
            }
            let next = d.front().unwrap().1 + ((k + 1) as u64) * a[i];
            while let Some((j, v)) = d.pop_back() {
                if v > dp[i] {
                    d.push_back((j, v));
                    break;
                }
            }
            d.push_back((i, dp[i]));
            dp[i] = next;
        }
    }
    let ans = dp[(k - 1)..].iter().max().unwrap();
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 6396
N, M = map(int, input().split())

t = [-1] * N
for _ in range(M):
    s, c = map(int, input().split())
    s -= 1
    if t[s] != -1 and t[s] != c:
        print(-1)
        exit()
    t[s] = c

if N != 1:
    if t[0] == 0:
        print(-1)
        exit()

    if t[0] == -1:
        t[0] = 1

    for i in range(1, N):
        if t[i] == -1:
            t[i] = 0
else:
    if t[0] == -1:
        t[0] = 0

print(''.join(map(str, t)))

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

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while(k){
		if(b <= a) b *= 2, k--;
		else break;
	}
	while(k){
		if(c <= b) c *= 2, k--;
		else break;
	}
	//cout << a << ' ' << b << ' ' << c;

	if(a < b && b < c) cout << "Yes";
	else cout << "No";

    return 0;
}


Measured memory_bytes: 3644
# 常にi < jを考える
from collections import Counter

N = int(input())
H = [0]
H.extend(list(map(int, input().split())))

plus = [H[i] + i for i in range(1,N+1)]
minus = [i - H[i] for i in range(1, N+1)]
ans = 0

# 独立というのがよくわからなかったが，
# i > jで成り立つと仮定すると，
# aj -ai = Ai + Aj > 0　で，
# j > i となり，矛盾する。
# 連想配列で調べれば良い

cnt = Counter(minus)

for i in plus:
    ans += cnt.get(i, 0)

print(ans)

Measured memory_bytes: 136496
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod (ll)(1e9+7)
ll vec[(ll)1e5+1][2];

ll dfs(ll s,ll e,vector<ll>*adj,ll flag){
    if(vec[s][flag]!=-1) return vec[s][flag];
    vec[s][flag] = 1;
    for(auto u : adj[s]){
        if(u==e) continue;
        if(flag) vec[s][flag] = vec[s][flag] * dfs(u,s,adj,0) % mod;
        else vec[s][flag] = vec[s][flag] * (dfs(u,s,adj,0)%mod + dfs(u,s,adj,1)%mod) % mod;
    }
    return vec[s][flag];
}

int main(){
    memset(vec,-1,sizeof vec);
    ll n;
    cin >> n;
    vector<ll>adj[n];
    ll x,y;
    for(ll i = 0;i < n-1;i++){
        cin >> x >> y;
        x--,y--;
        adj[x].emplace_back(y),adj[y].emplace_back(x);
    }
    vec[0][0] = dfs(0,-1,adj,0);
    vec[0][1] = dfs(0,-1,adj,1);
    cout<<(vec[0][0] + vec[0][1])%mod;
}

Measured memory_bytes: 20372
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define int long long
using namespace std;

int n;
int a;
map<int, int> cnt;

signed main() {
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (cnt.find(a) == cnt.end()) cnt[a] = 0;
		cnt[a]++;
	}
	
	vector<pair<int, int>> b;
	for (map<int, int>::iterator it = cnt.begin(); it != cnt.end(); it++) {
		if ((*it).second >= 2) {
			b.push_back(pair<int, int>((*it).first, (*it).second));
		}
	}
	sort(b.begin(), b.end(), greater<pair<int, int>>());
	
	if (b.size() == 0) { cout << 0 << endl; }
	else if (b[0].second >= 4) { cout << b[0].first * b[0].first << endl; }
	else if (b.size() >= 2) { cout << b[0].first * b[1].first << endl; }
	else { cout << 0 << endl; }
	
	return 0;
}

Measured memory_bytes: 6528
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    for(string s; (s=readln().chomp()).length; )
    {
        immutable N=4;
        auto a = s.split().map!(to!int).array();
        auto b = readln().split().map!(to!int).array();
        int h=0,m=0;
        foreach(i;0..N)
            if(a[i]==b[i]) ++h;
            else
                foreach(j;0..N)
                    if(a[i]==b[j]) ++m;
        writeln(h," ",m);
    }
}

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

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

#define sd(mark) scanf("%d",&mark)
#define s2d(mark,marx) scanf("%d%d",&mark,&marx)
#define s3d(mark,marx,marz) scanf("%d%d%d",&mark,&marx,&marz)
#define sf(mark) scanf("%f",&mark)
#define slf(mark) scanf("%lf",&mark)
#define sst(mark) scanf("%s",&mark)
#define sld(mark) scanf("%lld",&mark)
#define s2ld(mark,marx) scanf("%lld%lld",&mark,&marx)
#define s3ld(mark,marx,marz) scanf("%lld%lld%lld",&mark,&marx,&marz)
#define sline(mline) scanf("%[^\n]%*c",&mline)

#define pi(n) printf("%d\n",n)
#define pf(n) printf("%f\n",n)
#define plf(n) printf("%lf\n",n)
#define pst(n) printf("%s\n",n)
#define pl(n) printf("%lld\n",n)

#define pis(n) printf("%d ",n)
#define pfs(n) printf("%f ",n)
#define plfs(n) printf("%lf ",n)
#define pss(n) printf("%s ",n)
#define pls(n) printf("%lld ",n)

#define sff fflush(stdout)
#define decimal(n) cout.precision(n)
#define fix cout<<fixed
#define debug(mark) printf("check%d\n",mark)
#define in(a) cin>>a
#define out(a) cout<<a<<'\n'
#define clr(mark) memset(mark,0,sizeof(mark))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ll long long int
#define mod 1000000007ll
#define llu unsigned long long int
#define endl '\n'
#define INF 1123456789
#define eps 1e-9
#define fo(i,a,b) for(int i=a;i<b;++i)
#define foll(i,a,b) for(ll i=a;i<b;++i)
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)

#define UL 100000		//5
#define MAXN 1000000	//6
#define MAXL 10000000	//7

typedef vector< vector<int> > vvi;
typedef vector< vector<ll> > vvl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< pair<ll,ll> > vll;
typedef pair<char,char> pcc;
typedef vector< pair<int, int> > vii;


// bool mark[MAXN+5];

// int sieve()
// {
// 	int ULL = MAXN;
// 	for(int i=0;i<=ULL;i++) mark[i]=true;
// 	for(int i=2;i*i<=ULL;i++) if(mark[i]) for(int j=i*i;j<=ULL;j+=i) mark[j]=false;
// 	for(int i=2;i<=ULL;i++) if(mark[i]) p.pb(i);
// 	return p.size();
// }


ll gcd(ll a, ll b) {if(!b) return a; return gcd(b,a%b);}

ll modexp(ll a,ll b)
{
	if(b==0) return 1;
	if(b==1) return a;
	ll temp = modexp(a,(b>>1));
	temp = (temp*temp);
	return (temp*modexp(a,b&1));
}

ll modexp(ll a,ll b, ll m)
{
	if(b==0) return 1;
	if(b==1) return a%m;
	ll temp = modexp(a,(b>>1),m);
	temp = (temp*temp)%m;
	return (temp*modexp(a,b&1,m))%m;
}

ll modinv(ll a, ll p)
{
	return modexp(a,p-2,p);
}

int A[3*UL+5],B[3*UL+5];
ll sA[3*UL+5],sB[3*UL+5];

int solve(int l1,int l2,int r1,int r2)
{
	if(l1>r1||l2>r2) return 0;
	int x = l1, y = l2;
	while((sA[x]-sA[l1-1])!=(sB[y]-sB[l2-1]))
	{
		if((sA[x]-sA[l1-1])<(sB[y]-sB[l2-1])) x++;
		else if((sA[x]-sA[l1-1])>(sB[y]-sB[l2-1])) y++;
	}
	return (1+solve(x+1,y+1,r1,r2));
}

map<string, bool> dic;

int main()
{
	int n; sd(n);
	bool flag = true;
	string y = "";
	fo(i,0,n)
	{
		string x; cin>>x;
		if(dic[x]) flag = false;
		else 
		{
			dic[x] = true;
			if(i>0&&x[0]!=y[y.size()-1]) flag = false;
		}
		y = x;
	}
	if(flag) cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 256
from sys import stdin
input = stdin.readline
from collections import deque

N,M = [int(x) for x in input().split()]
next =[set() for _ in range(N+1)]

for i in range(M):
    A,B = [int(x) for x in input().split()]
    next[A].add(B)
    next[B].add(A)

opened = deque()
opened.append(1)

closed = [False] * (N+1)
prev = [-1] * (N+1)
prevlen = [float('inf')] * (N+1)
prevlen[1] = 0

while len(opened) != 0:
    target = opened.popleft()
    closed[target] = True
    for n in next[target]:
        if closed[n] == False:
            opened.append(n)
            closed[n] = True
        if prevlen[n] > prevlen[target]+1:
            prev[n] = target
            prevlen[n] = prevlen[target]+1


print('Yes')
# for i in range(2,N+1):
#     print(prev[i])
print(" ".join([str(x) for x in prev[2:]]))


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

/*
#include <boost/functional/hash.hpp>
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mlint;
*/

#define debug 0
#define fcout(d) cout << fixed << setprecision(d)
#define urep(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define drep(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) urep(i,0,(n) - 1)
#define rep1(i,n) urep(i,1,(n))
#define rrep(i,n) drep(i,(n) - 1,0)
#define all(v) begin(v),end(v)
#define rall(v) rbegin(v),rend(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define rsz resize
#define era erase
#define emp emplace
#define emf emplace_front
#define emb emplace_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define odd(x) ((x) & 1)
#define even(x) (~(x) & 1)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef vct<vct<ll>> mat;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef map<int,int> mpii;
typedef unordered_map<int,int> umpii;

const int dir[8][2] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const ll inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;
const ll mod = 1e9 + 7;
const db eps = 1e-9;

template <class T, class U> T qceil(T x, U y) { return x > 0 ? (x - 1) / y + 1 : x / y; }
template <class T, class U> bool parity(T x, U y) { return odd(x) ^ even(y); }
template <class T, class U> bool chmax(T &m, U x) { if(m < x) { m = x; return 1; } return 0; }
template <class T, class U> bool chmin(T &m, U x) { if(m > x) { m = x; return 1; } return 0; }
template <class T> bool cmprs(T &v) {
    T tmp = v;
    sort(all(tmp));
    tmp.erase(unique(all(tmp)),end(tmp));
    for(auto it = begin(v); it != end(v); ++it) *it = l_bnd(all(tmp),*it) - begin(tmp) + 1;
    return v.size() > tmp.size();
}

template <class T> void esc(T ret) {
    cout << ret << endl;
    exit(0);
}

int n,x[101],y[101],h[101];

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

    int tt;
    cin>>n>>tt;
    int c[101],t[101];
    rep(i,n) cin>>c[i]>>t[i];
    ll cost=inf64;
    rep(i,n){
        if(tt>=t[i]) chmin(cost,c[i]);
    }
    if(cost<inf64) esc(cost);
    else esc("TLE");
}


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

const ll INF = 1E18+5;
const ll mod = 1E9+7;
int main(){
    int h,w;
    cin>>h>>w;
    char a[h+1][w+1];
    int i, j;
    for(i=1;i<=h;i++)
        for(j=1;j<=w;j++)
            cin>>a[i][j];
    ll dp[h+1][w+1];
    memset(dp,0,sizeof(dp));
    dp[1][1] = 1;
    for(i=1;i<=h;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(a[i][j]!='#')
            {
                    if(a[i][j-1]=='.')
                    {
                        dp[i][j] = (dp[i][j]+dp[i][j-1])%mod;
                       
                    }
                    if(a[i-1][j]=='.')
                    {
                        dp[i][j] = (dp[i][j]+dp[i-1][j])%mod;
                       // cout<<"i=="<<i<<"j=="<<j<<" "<<dp[i][j]<<" ";
                    }
            }
        }//cout<<endl;
    }
    cout<<dp[h][w];

   

}




Measured memory_bytes: 12428
#include<iostream>
#include<stdio.h>
using namespace std;
int mat[100][100];
int vec[100];
int n,m,ans;
int main(){
    cin >> n >> m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> mat[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin >> vec[i];
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            ans += mat[i][j]*vec[j];
        }
        cout << ans << endl;
        ans = 0;
    }


}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 3007 , mo = 1000000007;

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a)
{
	return powa(a,mo-2);
}

const int inv2 = inva(2);

int n,qn,val[_],px[_],py[_];
lint gai[_][_];

int main()
{
	n=ty(),qn=ty();
	for(int i=1;i<=n;i++)val[i]=ty();
	for(int i=1;i<=qn;i++)px[i]=ty(),py[i]=ty();

	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)gai[i][j]=val[i]<val[j];
	for(int i=1;i<=qn;i++)
	{
		int a=px[i],b=py[i];
		gai[a][b]=gai[b][a]=(gai[a][b]+gai[b][a])%mo*inv2%mo;
		for(int j=1;j<=n;j++)
		{
			if(a==j || b==j)continue;
			gai[a][j]=gai[b][j]=(gai[a][j]+gai[b][j])%mo*inv2%mo;
			gai[j][a]=gai[j][b]=(gai[j][a]+gai[j][b])%mo*inv2%mo;
		}
	}

	lint ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<i;j++)
			ans=(ans+gai[i][j])%mo;
	printf("%lld\n",ans*powa(2,qn)%mo);
	
	return 0;
}


Measured memory_bytes: 70912
#include<bits/stdc++.h>
int main(){
   int a[3];for(int i=0;i<3;i++)std::cin>>a[i];
   std::sort(a,a+3);
   int l=2*a[2]-(a[1]+a[0]);
   std::cout<<(l%2?(l+3)/2:l/2);
}

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

int main(int argc, char *argv[])
{
    int H, W;
    int i, j;
    while(1) {
        scanf("%d %d", &H, &W);
        if(H==0&&W==0) break;
        for(i=0;i<H;i++){
            for(j=0;j<W;j++) {
                if((i+j)%2==0) printf("#");
                else printf(".");
            }printf("\n");
        }
        printf("\n");

    }
    return 0;
}


Measured memory_bytes: 3096
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var abc=(Arr.shift()).split(" ").map(Number);
   if(abc[0]==0 & abc[1]==0 & abc[2]==0)break;
   var sum=abc[0]+abc[1]+abc[2];
   var obj={};
   for(var i=1;i<=sum;i++)obj[i]=2;
   var N=Arr.shift()-0;
   var arr=[];
   for(var i=0;i<N;i++){
      var ABCK=(Arr.shift()).split(" ").map(Number);
      arr.push(ABCK);
   }
   arr=arr.filter(function(v){
      if(v[3]===1){
         for(var i=0;i<3;i++)obj[v[i]]=1;
      }
      return v[3]!=1;
   });
   var bad=0;
   while(true){
      arr.forEach(function(v){
         var cnt=0;
         var memo="";
         for(var i=0;i<3;i++){
            if(obj[v[i]]===1)cnt++;
            if(obj[v[i]]===2)memo=i;
         }
         if(cnt===2 && memo!=="")obj[v[memo]]=0;
      });
      var cnt=0;
      for(var i=1;i<=sum;i++){
         if(obj[i]===0)cnt++;
      }
      if(bad===cnt)break;
      else bad=cnt;
   }
   for(var i=1;i<=sum;i++)console.log(obj[i]);
}

Measured memory_bytes: 10820
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>
//by Skeef79

typedef long long ll;
typedef long double ld;

typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define what_is(x) cout<<#x<<" is "<<x<<en;

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];

}

void solve()
{
	int n, k;
	cin >> n >> k;
	vector<ll>a(n);
	input(a);
	sort(all(a));
	ll ans = 0;
	for (int i = 0; i < k; i++)
		ans += a[i];
	cout << ans;
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	//freopen("luigi.in", "r", stdin);
	//freopen("luigi.out", "w", stdout);

	int tst = 1;
	//cin >> tst;

	while (tst--)
		solve();
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

int main(void) {
	int n, i, j, k;
	cin >> n;
	vector<string> s(n);
	vector<string> ans(51);
	cin >> s[0];
	ans[0] = s[0];
	for (i = 1; i < n; i++) {
		cin >> s[i];
		for (j = 0; j < ans[i - 1].size(); j++) {
			for (k = 0; k < s[i].size(); k++) {
				if (ans[i - 1][j] == s[i][k]) {
					ans[i] += s[i][k];
					ans[i - 1].erase(ans[i - 1].begin() + j);
					s[i].erase(s[i].begin() + k);
					k = -1; j = 0;
				}
			}
		}
	}
	sort(ans[n - 1].begin(), ans[n - 1].end());
	cout << ans[n - 1] << endl;
	return 0;
}

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

int dx[8] = {1,  1,  0, -1, -1, -1, 0, 1};
int dy[8] = {0, -1, -1, -1,  0,  1, 1, 1};
 
int main(){
    int H, W;
    cin >> H >> W;
    char S[H][W];
    for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)
            cin >> S[i][j];
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j] == '#'){
                cout << '#';
            }else{
                int x, y, num = 0;
                for(int k=0;k<8;k++){
                    x = j + dx[k];
                    y = i + dy[k];
                    if(x >= 0 && x < W && y >= 0 && y < H){
                        if(S[y][x] == '#')
                            num++;
                    }
                }
                cout << num;
            }
        }
        cout << endl;
    }

}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

void read() {
	int n;
	cin >> n;
	int ans = n / 500 * 1000;
	n %= 500;
	ans += n / 5 * 5;
	cout << ans;
}

void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

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

using namespace std;

using ll = long long;

int main(void) {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(auto &e: a) cin >> e;

    ll g = 0;
    for(auto &e: a) g = __gcd(g, e);
    
    cout << (any_of(a.begin(), a.end(),
                [&](ll x){return x>=k && (x-k)%g==0;}) ?
            "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin>>d.at(i);
  }

  int s=0;
  
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      s+=d.at(i)*d.at(j);
    }  
  }

  cout<<s<<endl;
  return 0;
}



Measured memory_bytes: 256