akhauriyash/Code-Regression huggingface dataset:
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/**@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*/
/**status : */
/**url: */
/* Generate with Contest-Helper **/
/* https://github.com/goldenbijoy/Contest_Helper */
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
#define clr(arr,value) memset(arr,value,sizeof(arr))
#define MOD 1000000007
#define PI acos(-1)
#define PB push_back
#define MP make_pair
#define SP " "
#define NL "\n"
#define DE cout<<"HERE"<<endl;
#define INF 1e18
#define __FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr2V(x,sz) for(int iii=0;i<=sz;iii++) x[iii].clear();
#define NUM1(x) __builtin_popcount(x)
#define Pause system("pause");
#define MAX 100050/** can increase another 0 */

//** your code goes from here


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    ll i,j,k,arr[MAX],l,m,n,x,y,coun,sum,ans,T,check;
    vector<ll> v;
    string s;

    cin>>n;
    coun = 0;

    x = 1;
    for(i=0;i<n;i++){
        cin>>l;
        if(l==x) coun++,x++;
    }
    if(coun==0) cout<<-1<<NL;
    else cout<<n-coun<<NL;



    /// Don't forget to initialize array....
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
namespace Solve
{
	const int MAXN=105;
	int n,A[MAXN];
	void work()
	{
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
			scanf("%d",&A[i]);
		sort(A+1,A+n+1);
		int ans=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=i+1;j<=n;j++)
			{
				if(A[i]==A[j]) continue;
				for(int k=j+1;k<=n;k++)
				{
					if(A[i]==A[k] || A[j]==A[k]) continue;
					if(A[i]+A[j]>A[k]) ans++;
				}
			}
		}
		printf("%d\n",ans);
		return;
	}
}
int main()
{
	#ifdef LOCAL
	freopen("00test.in","r",stdin);
	freopen("00test.out","w",stdout);
	#endif
	Solve::work(); 
	return 0;
}

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	
}
int main(){
  
  ll N;
  cin>>N;
  vector<ll>C(N-1);
  vector<ll>S(N-1);
  vector<ll>F(N-1);
  
  rep(i,N-1){
    cin>>C[i]>>S[i]>>F[i];
  }

  ll now=0;
  rep(i,N-1){
    ll ans=0;
    for(ll j=i;j<N-1;j++){
    if(S[j]>=ans){
   
        ans+=S[j]-ans;
      ans+=C[j];
      
    }
    
    else{
      
      if(ans%F[j]==0){
ans+=C[j];
      }
      else{
      
       ans+=C[j]+F[j]-ans%F[j];
    }
    }
    }
      
      cout<<ans<<endl;
  }
  cout<<0<<endl;
  }

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

int main() {
	int e, y;

	cin >> e >> y;

	if(e == 0){
		if(y < 1912)
			cout << "M" << y - 1867;
		else if (y < 1926)
			cout << "T" << y - 1911;
		else if(y < 1989)
			cout << "S" << y - 1925;
		else
			cout << "H" << y - 1988;

		cout << endl;
	}
	else if (e == 1)
		cout << y + 1867 << endl;
	else if (e == 2)
		cout << y + 1911 << endl;
	else if (e == 3)
		cout << y + 1925 << endl;
	else if (e == 4)
		cout << y + 1988 << endl;

	return 0;
}


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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;


signed main(){

	int A, B, C;
	cin >> A >> B >> C;

	cout << min(C, (B / A)) << endl;
	

	return 0;
}

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

vector<vector<int>> ki(200002);
vector<int> ans(200002, 0);

void dfs(int v, int p=-1){
	for(int u: ki.at(v)){
		if(u == p) continue;
		ans.at(u) += ans.at(v);
		dfs(u, v);
	}
}

int main() {
	
	int n, q;
	cin >> n >> q;
	
	rep(i, n-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		ki.at(a).push_back(b);
		ki.at(b).push_back(a);
	}
	rep(i, q){
		int p, x;
		cin >> p >> x;
		p--;
		ans.at(p) += x;
	}
	
	dfs(0);
	
	rep(i, n){
		cout << ans.at(i) << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 26624
n = input()

v = map(int, raw_input().split(' '))

dict = {}

sum = 0

for i in range(n):
	sum += v[i]
	if sum not in dict:
		dict[sum] = 0

	dict[sum] += 1

res = 0

sum = 0

if sum in dict:
	res += dict[sum]

sum += v[0]

for i in range(1, n):
	sum += v[i]
	dict[sum] -= 1
	res += dict[sum]

print res


Measured memory_bytes: 38024
#include <bits/stdc++.h>
using namespace std;
int N, A, B, C;
vector<int> l(9);

int dfs(int a, int b, int c, int d, bool s, bool t, bool u){
  if(d == N){
    if(s && t && u){
    return abs(a-A)+abs(b-B)+abs(c-C)-30;
    }
    else return 1e9;
  }
  int x=dfs(a+l.at(d),b,c,d+1,true,t,u)+10;
  int y=dfs(a,b+l.at(d),c,d+1,s,true,u)+10;
  int z=dfs(a,b,c+l.at(d),d+1,s,t,true)+10;
  int w=dfs(a,b,c,d+1,s,t,u);
  return min({x,y,z,w});
}
int main(){
  cin >> N >> A >> B >> C;
  for(int i=0;i<N;i++){
    cin >> l.at(i);
  }
  int ans=dfs(0,0,0,0,false,false,false);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int;


int main(void){
  
  int n, m;
  cin>>n;
  
  map<string, int> blue;
  map<string, int> red;

  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    blue[s]++;
  }

  cin>>m;
  for(int i=0;i<m;i++){
    string s;
    cin>>s;
    red[s]++;
  }

  int ans;
  int max = 0;

  for(auto i=blue.begin();i!=blue.end();i++){
    ans = i->second - red[i->first];
    if(ans>max) max = ans;
  }

  cout<<max<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long
#define ULL unsigned long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int main() {
	ULL h, w;
	cin >> h >> w;
	if ((h == (ULL)(1)) || (w == (ULL)(1))) {
		cout << (1) << endl;
		return 0;
	}
	ULL ans = (h * w + (ULL)(1)) / (ULL)(2);
	cout << ans << endl;
	return 0;
}

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

int getGCD(int x, int y);

int main(void) {
  int x, y;
  cin >> x >> y;
  printf("%d\n", getGCD(x, y));
  
  return 0;
}

int getGCD(int x, int y) {
  int rem;
  if(x < y) swap(x, y);
  rem = x%y;
  while(rem != 0) {
    x = rem;
    if(x < y) swap(x, y);
    rem = x%y;
  }

  return x > y ? y : x;
}

Measured memory_bytes: 3228
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int H;
		int W;
		for (int i = 0; i < 10000; i ++) {
			H = scan.nextInt();
			W = scan.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int h = 0; h < H; h++) {
				for (int w = 0; w < W; w++) {
					if (h == 0 || w == 0 || h == H-1 || w == W-1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 34372
## input list ##
n1 = list(map(int,input().split()))
n2 = list(map(int,input().split()))
n3 = list(map(int,input().split()))

nall  = n1 + n2 + n3
#print(nall)

## input iterate num ##
N = int(input())

## input number ##
num = []
for i in range(N):
  add = int(input())
  num.append(add)

#print(num)

## check same number ##
out = []
for i in range(len(nall)):
  if nall[i] in num:
    out.append(i)

##print(out)

## check bingo ##
out_set = set(out)
#print(out_set)

bingo1 = [0,1,2]
bingo2 = [3,4,5]
bingo3 = [6,7,8]
bingo4 = [0,3,6]
bingo5 = [1,4,7]
bingo6 = [2,5,8]
bingo7 = [0,4,8]
bingo8 = [6,4,2]

if (set(bingo1) <= set(out_set)) or (set(bingo2) <= set(out_set)) or (set(bingo3) <= set(out_set)) or (set(bingo4) <= set(out_set)) or (set(bingo5) <= set(out_set)) or (set(bingo6) <= set(out_set)) or (set(bingo7) <= set(out_set)) or (set(bingo8) <= set(out_set)):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int a, b, c;
        int min, mid, max;
        Scanner s = new Scanner(System.in);
        a = s.nextInt();
        b = s.nextInt();
        c = s.nextInt();
        if (a < b){
            if (b < c){
                System.out.println(a+" "+b+" "+c);
            }else if (a < c){
                System.out.println(a+" "+c+" "+b);
            }else{
                System.out.println(c+" "+a+" "+b);
            }
        }else{
            if (c < b){
                System.out.println(c+" "+b+" "+a);
            }else if (a < c){
                System.out.println(b+" "+a+" "+c);
            }else{
                System.out.println(b+" "+c+" "+a);
            }
        }
    }
}


Measured memory_bytes: 26116
try:
     (n)  =  int(input())
except:
    exit
try:
    l =  list(map(int,input().split()))
except:
    exit

l.reverse()
for i in l:
    print(i,end="")
    if ( n != 1 ):
        print (" ",end="")
    n = n -1
print ("")



Measured memory_bytes: 5624
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

#define ll long long
using vt = int; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

int main() {
	int r;
	cin >> r;
	cout << r * r;
	return 0;
}

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

using namespace std;
typedef long long ll;

const int MAX_E = 100005, MAX_V = 205, MAX_R = 1001;
const int INF = 1e+7+1;

int GL[MAX_V][MAX_V];
int GS[MAX_V][MAX_V];

int V,E;

void init(){
    for(int i = 0;i < V;i++){
        for(int j = 0;j < V;j++){
            GL[i][j] = GS[i][j] = INF;
            if(i == j) GL[i][j] = GS[i][j] = 0;
        }
    }
}

void floyd(){
    for(int k = 0;k < V;k++)
        for(int i = 0;i < V;i++)
            for(int j = 0;j < V;j++){
                GL[i][j] = min(GL[i][j], GL[i][k]+GL[k][j]);
                GS[i][j] = min(GS[i][j], GS[i][k]+GS[k][j]);
            }
}

int R;
int z[MAX_R];
int dp[MAX_R][MAX_V];//此时船在j点的情况下,完成前i个任务的最小时间

void solve(){
    floyd();

    for(int i = 0;i < R;i++){
        for(int j = 0;j < V;j++){
            dp[i][j] = INF;
        }
    }

//    cout<<"______________________________________"<<endl;
//    for(int i = 0;i < V;i++){
//        for(int j = 0;j < V;j++){
//            cout<<setw(9)<<GS[i][j]<<' ';
//        }
//        cout<<endl;
//    }
//
//    cout<<"______________________________________"<<endl;
//    for(int i = 0;i < V;i++){
//        for(int j = 0;j < V;j++){
//            cout<<setw(9)<<GL[i][j]<<' ';
//        }
//        cout<<endl;
//    }

    dp[0][z[0]] = 0;//默认第一个点ok了,且更第二个点的时候没法用dp[0][z[0]以外]的更,因为刚开始船只在z[0]

    for(int i = 1;i < R;i++){
        for(int j = 0;j < V;j++){//上次船停到哪
            dp[i][j] = min(dp[i][j], dp[i-1][j]+GL[z[i-1]][z[i]]);//只走陆路
            for(int k = 0;k < V;k++){//这次船要停哪
                if(j != k)
                    dp[i][k] = min(dp[i][k], dp[i-1][j]+GL[z[i-1]][j]+GS[j][k]+GL[k][z[i]]);//走陆路到船,走水路到停船,走陆路
            }

        }
    }
    int mint = INF;
    for(int i = 0;i < V;i++){
        mint = min(mint, dp[R-1][i]);
    }
//    cout<<"______________________________________"<<endl;
//    for(int i = 0;i < V;i++){
//        for(int j = 0;j < V;j++){
//            cout<<setw(9)<<dp[i][j]<<' ';
//        }
//        cout<<endl;
//    }
    printf("%d\n", mint);
}

int main() {
    while(~scanf("%d%d", &V, &E)){
        if(V==0&&E==0) break;

        init();

        for(int i = 0;i < E;i++){
            int s,t,d;
            char w;
            scanf("%d %d %d %c", &s,&t,&d,&w);
            s--;t--;
            if(w == 'L') GL[s][t] = GL[t][s] = min(d,GL[s][t]);
            else GS[s][t] = GS[t][s] = min(d,GS[s][t]);
        }


        scanf("%d", &R);
        for(int i = 0;i < R;i++){
            scanf("%d", &z[i]);
            z[i]--;
        }
        solve();
    }
    return 0;
}



/*
3 3
1 2 5 L
1 2 7 S
2 3 11 S
3
1 2 3
5 5
1 2 15 L
2 3 10 L
4 5 7 L
1 3 30 S
3 4 100 S
5
1 3 5 4 1
0 0
 */


Measured memory_bytes: 4324
#include<stdio.h>

int main()
{  
   int i,k,count=0;
   char a[200001],b[200001];
    
   scanf("%s %s",&a,&b);

   k=strlen(a);

    for(i=0;i<k;i++)
    {
       if(b[i]!=a[i])
       {
          count++;
       }
    
    }
   
    printf("%d",count);
    
   
    return 0;

}

Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int n, m, q;
int query[110000][4];
vector<int> v;
vector<int> vs[10000000];
int ind = 0;

void dfs(vector<int> ret, int sz, int las) {
    if (sz < n) {
        for (int i = las; i <= m; i++) {
            ret[sz] = i;
            dfs(ret, sz+1, i);
        }
    }
    if (sz == n) {
        vs[ind] = ret;
        ind++;
    }
} 

int main() {
    cin >> n >> m >> q;
    rep(i,q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--;
        query[i][0] = a;
        query[i][1] = b;
        query[i][2] = c;
        query[i][3] = d;
    }
    rep(i,10) v.push_back(0);
    dfs(v, 0, 1);
    Int max_ans = 0;
    for(vector<int> arr : vs) {
        Int ans = 0;
        if (arr.size()) {
            rep(i,q) {
                int a = query[i][0];
                int b = query[i][1];
                int c = query[i][2];
                int d = query[i][3];
                if (arr[b] - arr[a] == c) ans += d;
            }
            max_ans = max(max_ans, ans);
        }
    }
    cout << max_ans << endl;
}

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

using namespace std;

typedef long long LL;

const int MAX_N = 1e5 + 10;
const LL MAX_A = 1e12 + 10;
const int MAX_D = __lg(MAX_A) + 10;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int N, used[MAX_D] = {};
	LL K, t, A[MAX_N];
	
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i], t = A[i];
		
		for (int j = 0; t; j++, t >>= 1)
		{
			if (t & 1)
				used[j]++;
		}//for i
	}//for i
	
	LL X = 0;
	for (int i = MAX_D - 1; i >= 0; i--)
	{
		if (used[i] >= (N >> 1) + 1 || (1LL << i) > K || (1LL << i | X) > K)
			continue;
			
		X |= 1LL << i;
	}//for i
	
	LL ans = 0;
	for (int i = 0; i < N; i++)
		ans += X ^ A[i];
	
	cout << ans << '\n';
	
	return 0;
}//main


Measured memory_bytes: 1024
n = int(input())
a_ls = list(map(int, input().split()))
sum_a_ls = sum(a_ls)

i = 0
short_bou = 0
half = sum_a_ls / 2#小数なるかも
while True:
    if short_bou + a_ls[i] > half:
        break
    else:
        short_bou += a_ls[i]
        i+=1

if half == short_bou:
    print(0)
else:
    sub_diff = min(half - short_bou, short_bou + a_ls[i] - half)
    print(int(sub_diff * 2))


Measured memory_bytes: 26224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class Program
{
	public static void Main(string[] args)
	{
		while (true)
		{
			int[] NMP = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int N = NMP[0], M = NMP[1], P = NMP[2];
			var X = new int[N];
			if (NMP.Sum() == 0)
			{
				return;
			}
			for (int i = 0; i < N; i++)
			{
				X[i] = int.Parse(Console.ReadLine());
			}
			int sum = X.Sum();
			if (X[M - 1] == 0)
			{
				Console.WriteLine(0);
			}
			else
			{
				Console.WriteLine(sum * (100 - P) / X[M - 1]);
			}
		}
	}
}

Measured memory_bytes: 9728
import java.util.Scanner; 
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn =new Scanner (System.in);
		String a=stdIn.next();
		String b=stdIn.next();
		int alen=a.length();
		int blen=b.length();
		String c="";
		for(int i=0;i<alen+blen;i++){
			if(i%2==0)
				c+=a.charAt(i/2);
			else
				c+=b.charAt(i/2);
			
		}
		System.out.println(c);
		}
}

Measured memory_bytes: 22868
package main

import (
	"fmt"
	"sort"
)

type Edge struct {
	I int
	J int
	A int
}

func main() {
	var n int
	fmt.Scan(&n)

	g := make([][]int, n)
	edges := make([]Edge, 0, n*(n-1)/2)
	parents := make([]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Scan(&g[i][j])
			if g[i][j] >= 0 {
				edges = append(edges, Edge{i, j, g[i][j]})
			}
		}
		parents[i] = i
	}
	sort.SliceStable(edges, func(i, j int) bool { return edges[i].A >= edges[j].A })

	sum := 0
	num := 0
	for len(edges) > 0 && num < n-1 {
		edge := edges[len(edges)-1]
		edges = edges[:len(edges)-1]

		if same(edge.I, edge.J, &parents) {
			continue
		}
		union(edge.I, edge.J, &parents)
		sum += edge.A
		num += 1
	}
	fmt.Println(sum)
}



func root(id int, parents *[]int) int {
	if id == (*parents)[id] {
		return id
	}
	return root((*parents)[id], parents)
}

func union(i, j int, parents *[]int) {
	(*parents)[root(j, parents)] = (*parents)[root(i, parents)]
}

func same(i, j int, parents *[]int) bool {
	return root(i, parents) == root(j, parents)
}



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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	vector<ll> v;
	for(int i=1;i<=n;++i){
		ll x;
		cin>>x;
		v.push_back(x-i);
	}
	sort(v.begin(),v.end());
	ll median=v[n/2],sum=0;
	for(ll x:v)
		sum+=abs(x-median);
	cout<<sum<<'\n';
}



Measured memory_bytes: 5332
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <set>
#include <utility>

using namespace std;

int main()
{
    int n, m, b, c, pcut=-1, ans=0;
    pair<int, int> a[100010]; //(b,c) b is end, c is start
    cin>>n>>m;
    for (int i=0; i<m; i++)
    {
        cin>>b>>c;
        a[i].first=c;
        a[i].second=b;
    }
    sort(a, a+m);
    //pretend start, end
    for (int i=0; i<m; i++)
    {
        if (a[i].second<pcut) continue;
        pcut=a[i].first;
        ans++;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
int main (int argc, char * argv[])
{
    int n;//生徒の人数
    int s[1000];//点数

    while (1){
        n=0;
        double a=0;//分散
        double b=0;
        double sum=0;
        double sum2=0;
//        printf("生徒の人数");
        scanf("%d",&n);
        if(n==0){
            break;
        }
//        printf("生徒の得点");
        for(int i=0;i<n;i++){
            scanf("%d",&s[i]);
            sum+=s[i];
        }
//        printf("合計:%d\n",sum);

        sum = sum/n;
//        printf("平均:%d\n",sum);
        for(int i=0;i<n;i++){
            b = pow(s[i] - sum,2);
            sum2 +=b;
            
        }
        a = sum2/n;
        a = sqrt(a);
//        printf("分散");
//        printf("\n");
        printf("%f\n",a);

    }
    return 0;
}



Measured memory_bytes: 2112
#include <stdio.h>
int main(void)
{
	//答えを格納する変数
	int ans=0;
	
	//華氏で表された温度を入力する変数
	int f=0;
	
	//華氏で表された温度を入力
	scanf("%d",&f);
	
	//華氏→摂氏
	ans=(f-30)/2;
	
	//答えの表示
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2112
#include<stdio.h>
int main()
{
	int n,a,x=0,x2=0,y,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(x<a){
			x2=x;
			x=a;
			y=i;
		}
		else if(x2<a) x2=a;
	}
	for(i=0;i<n;i++){
		if(y==i) printf("%d\n",x2);
		else printf("%d\n",x);
	}
	return 0;
}


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

min_H = 0
f = True
for i in range(N):
    if min_H > H[i]:
        f = False
        break
    else:
        if min_H < H[i]:
            min_H = H[i]-1
if f:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 63984
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int a, b, k;

int solve() {
  set<int> v;
  v.insert(1);
  for (int i = 1; i <= a * b - 1; ++i) {
    if (a % i == 0 && b % i == 0) {
      v.insert(i);
    }
  }
  vector<int> vv;
  for (auto e : v) {
    vv.push_back(e);
    // cout << e << endl;
  }
  sort(vv.begin(), vv.end(), greater<int>());
  if (vv.size() >= 2)
    return vv[k - 1];
  return vv.front();
}

int main() {
  cin >> a >> b >> k;
  cout << solve() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#define EPS (1.0e-8)
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;


int S, A, C;
int M;
int N;
int R[256], I[256], O[256];

double m_log[300];

void calcR() {
  for(int i = 0; i < N; ++i) {
    if(i == 0) R[i] = (A*S+C)%M;
    else       R[i] = (A*R[i-1]+C)%M;
  }
}

void calcO() {
  calcR();
  for(int i = 0; i < N; ++i) {
    O[i] = (I[i]+R[i]) % M;
  }
}

double H() {
  double ans = 0;
  int buf[256];
  fill(buf, buf+256, 0);

  calcO();

  for(int i = 0; i < N; ++i) {
    ++buf[O[i]];
  }

  for(int i = 0; i < 256; ++i) {
    if(buf[i] == 0) continue;
    ans += -buf[i] * (m_log[buf[i]] - m_log[N]);
  }
  return ans;
}

void solve() {
  int aS, aA, aC;
  double minH = 99999999;
  for(S = 0; S <= 15; ++S) {
    for(A = 0; A <= 15; ++A) {
      for(C = 0; C <= 15; ++C) {
	double tmp = H();
	if(S == 8 || A == 7 || C == 14) {
	  // for(int i = 0; i < N; ++i) cout << O[i] << " ";
	  //cout << endl;
	}
	//if(tmp == 0) printf("%d %d %d %.20f\n", S, A, C, tmp);
	if(equals(tmp, minH)) {
	  if(aS > S || aS == S && aA > A || aS == S && aA == A && aC > C) {
	    aS = S;
	    aA = A;
	    aC = C;
	  }
	} else if(tmp < minH) {
	  minH = tmp;
	  aS = S;
	  aA = A;
	  aC = C;
	}
      }
    }
  }
  cout << aS << " " << aA << " " << aC << endl;
}

main() {
  M = 256;
  for(int i = 1; i <= 300; ++i) m_log[i] = log(i);
  while((cin >> N) && N) {
    for(int i = 0; i < N; ++i) cin >> I[i];
    solve();
  }
}

Measured memory_bytes: 888
using System;

namespace AC_5
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            if (A < 10)
            {
                Console.WriteLine(A);
            }
            else if (10 <= A && A < 100)
            {
                Console.WriteLine(9);
            }
            else if (100 <= A && A < 1000)
            {
                Console.WriteLine((A - 100) + 10);
            }
            else if (1000 <= A && A < 10000)
            {
                Console.WriteLine(909);
            }
            else if (10000 <= A && A < 100000)
            {
                Console.WriteLine((A - 10000) + 910);
            }
            else if (A == 100000)
            {
                Console.WriteLine(90909);
            }
         
        }
    }
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (a, b) = (ab[0], ab[1]);

        Console.WriteLine(a * b);
    }
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    ll x = 0,y,z = 0;
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 2;i < n;++i) x ^= a[i];
    y = a[0]+a[1];
    bool ans = true;
    if (x > y) ans = false;
    y -= x;
    for (int i = 0;i < 40;++i) {
        if (!((x>>i)&1)) z ^= (1LL<<(i+1));
    }
    if ((y&z) != y) ans = false;
    ll a1 = y/2;
    if (a[1] > a1+x) ans = false;
    while (ans && a[1] > a1) {
        ll sum = 0;
        for (int i = 0;i < 40;++i) if ((x>>i)&1) {
            sum += (1LL<<i);
            if (a[1] <= a1+sum) {
                a1 += (1LL<<i);
                break;
            }
            if (i == 39) {
                ans = false;
            }
        }
    }
    if (a1 == a[0]+a[1]) ans = false;
    cout << (ans ? a1-a[1] : -1) << endl;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    b = input()
    table = str.maketrans({'A':'T', 'T':'A', 'C':'G', 'G':'C'})
    print(b.translate(table))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long arr[100001];
long long N,M;
vector<vector<long long>> v(100001);
int main(){
	cin>>N>>M;
	for(long long i=1; i<=N; i++){
		cin>>arr[i];
	}
	for(long long i=1; i<=M; i++){
		long long a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	long long total=0;
	for(long long i=1; i<=N; i++){
		total++;
		for(long long j=0; j<v[i].size(); j++){
			if(arr[i]<=arr[v[i][j]]){
				total--;
				break;
			}
		}
	}
	cout<<total<<'\n';
}

Measured memory_bytes: 9832
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cassert>
#include<utility>
#include<algorithm>
#include<complex>
using namespace std;
int a,b;
int main(){
  cin>>a>>b;
  cout<<(a+b+1)/2<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = 10000000;
const long long INFL = (1LL<<50);
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int h,w;cin>>h>>w;
    int n;cin>>n;
    vector<int> a(n);cin>>a;
    vector<int> col;
    rep(i,n){
        while(a[i]!=0){
            col.push_back(i+1);a[i]--;
        }
    }
    
    vector<vector<int>> ans(h,vector<int>(w));
    rep(i,h*w){
        if(i/h %2==0){
            ans[i%h][i/h] = col[i];
        }else{
            ans[h-1 - i%h][i/h] = col[i];
        }
    }
    rep(i,h){
        cout<<ans[i]<<endl;
    }
    
    return 0;
}










Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int A, B, C;
	cin >> A >> B >> C;

	if (A == B && B == C) co(1);
	else if (A != B && B != C && C != A) co(3);
	else co(2);

	Would you please return 0;
}

Measured memory_bytes: 256
/*
  Contest 068
  C - Cat Snuke and a Voyage
  Rakesh Kumar --> 01/09/2020
*/

#include <bits/stdc++.h>

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

    int n = 0, m = 0;
    std::cin >> n >> m;
    std::string r = "IMPOSSIBLE";
    std::unordered_map<int, bool> stop_overs;
    std::vector<int> stops;
    while (m--) {
        int s = 0, e = 0;
        std::cin >> s >> e;
        if (s == 1 && e == n)
            r = "POSSIBLE";
        else if (s == 1)
            stop_overs[e] = true;
        else if (e == n)
            stops.emplace_back(s);
    }
    if (r == "IMPOSSIBLE") {
        for (int s : stops) {
            if (stop_overs.find(s) != stop_overs.end()) {
                r = "POSSIBLE";
                break;
            }
        }
    }
    std::cout << r << std::endl;

    return 0;
}


Measured memory_bytes: 7672
import java.util.ArrayList;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		Al t=new Al();
		 int n=sc.nextInt();
		for(int i=0; i<n; i++){
			int c=sc.nextInt();

			if(c==0){
				int b=sc.nextInt();
				t.pushback(b);
			}else if(c==1){
				int b=sc.nextInt();
				System.out.println(t.randomAccess(b));

			}else{
				t.popback();
			}

		}


	}
}
 class Al{
	 ArrayList<Integer> a=new ArrayList<Integer>();
	 void print(){
		 for(int i=0; i<a.size(); i++){
			 System.out.print(a.get(i));
		 }
		 System.out.println();
	 }
	 void pushback(int b){
			a.add(b);

		}
	void popback(){
			a.remove(a.size()-1);
		}
	int randomAccess(int b){
			return a.get(b);

		}
 }


Measured memory_bytes: 140196
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int cc,tt;ll pw=1,a[10005],b[10005];
int S(ll a){int r=0;while(a)r+=a%10,a/=10;return r;}
int main()
{
	for(int i=1;i<=15;i++,pw*=10)for(int j=1;j<140;j++)if(j*pw!=1)a[++cc]=j*pw-1;
	sort(a+1,a+cc+1);cc=unique(a+1,a+cc+1)-a-1;
	for(int i=1;i<=cc;i++)if(a[i]<=1e15)
	{
		int ff=1;
		for(int j=i+1;j<=cc;j++)if(a[j]<=1e15)if(a[i]*S(a[j])>a[j]*S(a[i])){ff=0;break;}
		if(ff)b[++tt]=a[i];
	}
	int k;scanf("%d",&k);
	for(int i=1;i<=k;i++)printf("%lld\n",b[i]);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define ll long long
using namespace std;


int main(){
  ll n;
  ll sum =0;
  cin>>n;
  ll A[n] ;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  for(int i=0;i<n-1;i++){
    if(A[i+1]<A[i]){
      sum+= (A[i]-A[i+1]);
      A[i+1] = A[i];
    }
  }
  cout<<sum;
  return 0;
}





Measured memory_bytes: 5112
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn=100005;
int n,q;
int a[maxn];
int flag[maxn];
int find1(int x)
{
    if(flag[x])
        return x;
    else
        return find1(a[x]);
}
int main()
{
    while (scanf("%d%d",&n,&q)!=EOF&&(n||q))
    {
        memset (flag,0,sizeof(flag));
        for (int i=1;i<=n;i++)
                a[i]=i;
        for (int i=2;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        long long int sum=0;
        flag[1]=1;
        for (int i=0;i<q;i++)
        {
            char s[3];
            int xx;
            scanf("%s",s);
            scanf("%d",&xx);
            if(s[0]=='Q')
            {
                sum+=find1(xx);
            }
            else
            {
                flag[xx]=1;
            }
        }
        printf("%lld\n",sum);
    }
    return 0;
}



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

int main() {
  int A, B, K, c;
  cin >> A >> B >> K;
  for (int i = 1; i < K+1; i++) {
    if( i % 2 == 1) {
      if( A % 2 == 1) A--;
      c = A / 2;
      A = A - c;
      B = B + c;
    }else{
      if( B % 2 == 1) B--;
      c = B / 2;
      B = B - c;
      A = A + c;
    }
  }
  cout << A << " " << B;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
using namespace std;    
const int N = 510, mod = int(1e9)  + 7; 
int n,m,h, w;
int a[N][N];

ll d[N][N];

bool isp(int x){
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) return 0;
	}
	return 1;
}

int main () {
	scanf("%d%d%d%d",&n,&m,&h,&w);
	int x = 500 * 500;
	while(!isp(x)){
		x++;
	}
	x = 2011;

	int cur = - x * w * h  + x - 1;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			a[i][j] = x;
		}
	}
	ll sum = 0;
	for(int i = h; i <= n; i += h){
		for(int j = w; j <= m; j += w){
			a[i][j] = cur;
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			sum += a[i][j];
		}
	}
	if(sum <= 0) puts("No");
	else{
		puts("Yes");
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= m; j++){
				printf("%d ", a[i][j]);
			}
			printf("\n");
		}
	}

return 0;
}

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

using namespace std;
using ll = long long;
const ll INF = 1e18;

int main()
{
    int n, W; cin >> n >> W;
    vector<vector<ll>> dp(n + 1, vector<ll>(10001, INF)); //dp[i][j] := i個目まで見た時に価値jのものの最小重さ
    vector<ll> v(n), w(n);
    for(int i = 0; i < n; i++)cin >> v[i] >> w[i];
    dp[0][0] = 0;

    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= 10000; j++) {
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
            dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
        }
    }


    ll ans = 0;
    for(int i = 0; i <= 10000; i++) {
        if(dp[n][i] <= W)ans = i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10804
// Oh boi here we go again
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

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

#define all(s) s.begin(), s.end()
#define ok puts("ok")
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >
#define pii pair < int, pi >
#define next next123
#define left left123

const int N = 1e5 + 7;
const int INF = 1e9 + 7;

int a[N];
int n, m, v, p;

bool solve (int k){
    ll s = 0;
    if (a[p] > a[k] + m)
        return false;
    for (int i = p; i < k; i++)
        s += min(m, (a[k] + m) - a[i]);
    int r = v - p - n + k;
    if (s / m >= r)
        return true;
    return false;
}

main(){
    cin >> n >> m >> v >> p;
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    sort(a + 1, a + n + 1, greater<int>());
    int l = p, r = n + 1;
    while (l + 1 < r){
        int mid = (l + r) >> 1;
        if (solve(mid))
            l = mid;
        else
            r = mid;
    }
    cout << l;
}


Measured memory_bytes: 640
import numpy as np

def resolve():
  n, l = map(int, input().split())
  arr = []
  for i in range(n):
    arr.append(i + l)

  yotei = sum(arr)
  ans = abs(yotei - arr[0])
  sa = abs(yotei - (yotei - arr[0]))

  for i in range(n):
    if (sa > abs(yotei - (yotei - arr[i]))):
      sa = abs(yotei - (yotei - arr[i]))
      ans = yotei - arr[i]

  print(ans)

  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 12504
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    double a, b, x, aa, bb, theta, po;
    scanf("%lf %lf %lf", &a, &b, &x);
    if(x >= a*a*b/2){
        po = a*a*b - x;
        bb = po*2/a/a;
        theta = atanl(bb/a);
//        printf("%lf %lf %lf\n", po, bb, theta);
    }else{
        aa = x*2/a/b;
        po = atanl(aa/b);
        theta = M_PI/2 - po;
//        printf("%lf %lf %lf\n", aa, po, theta);
    }
    printf("%lf", theta*180/M_PI);
    
}

Measured memory_bytes: 128
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int F[1001]; F[0]=2,F[1]=3;
	rep(i,999)F[i+2]=(F[i+1]+F[i])%1001;
	
	int v,d;
	while(cin>>v>>d){
		int f[1001]; copy(F,F+v,f);
		sort(f,f+v);
		int ans=0;
		rep(i,v)if(i==0||f[i]>=f[i-1]+d)ans++;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3990970#1

import sys
input=sys.stdin.readline

class MIN_SEGMENTTREE:
    def __init__(self,lis):
        length=len(lis)
        self.n=2**length.bit_length()
        self.node=[float("inf")]*(2*self.n-1)
        
        for i in range(length):
            self.node[i+self.n-1]=lis[i]
        for i in range(self.n-2,-1,-1):
            if self.node[2*i+1]>self.node[2*i+2]:
                self.node[i]=self.node[2*i+2]
            else:
                self.node[i]=self.node[2*i+1]

    def update(self,point,value):
        point+=self.n-1
        self.node[point]=value
        while point>0:
            point=(point-1)//2
            if self.node[2*point+1]>self.node[2*point+2]:
                self.node[point]=self.node[2*point+2]
            else:
                self.node[point]=self.node[2*point+1]
    
    def getmin(self,a,b):
        l,r = a+self.n,b+self.n
        ret = float("inf")
        while l<r:
            if r&1:
                r-=1
                if ret>self.node[r-1]:
                    ret=self.node[r-1]

            if l&1:
                if ret>self.node[l-1]:
                    ret=self.node[l-1]
                l+=1

            l>>=1
            r>>=1
        return ret

n,q=map(int,input().split())
s=MIN_SEGMENTTREE([2**31-1]*n)
for i in range(q):
    f,a,b=map(int,input().split())
    if f:
        print(s.getmin(a,b+1))
    else:
        s.update(a,b)

#print(s.node)


Measured memory_bytes: 9444
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

using LONG = long long;
using LVEC = vector<long long>;

#define FOR(_i, s, e) for(_i = s; _i < e; ++_i)
#define FOR_INV(_i, s, e) for(_i = e - 1; _i >= s; --_i)

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


using pos = std::pair<LONG, LONG>;


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

    LONG i, j, k;
    LONG n = S.size();

    LVEC table[13];
    FOR(i, 0, 13){
        table[i].resize(n, 0);
    }

    if(S[n-1] == '?'){
        FOR(j, 0, 10){
            table[j][n-1] = 1;
        }
    }
    else{
        int num = S[n-1] - '0';
        table[num][n-1] = 1;
    }

    LONG mod_keta = 1;

    FOR_INV(i, 0, n-1){
        mod_keta *= 10;
        mod_keta %= 13;

        if(S[i] == '?'){
            FOR(j, 0, 10){
                int mod = (mod_keta * j) % 13;
                FOR(k, 0, 13){
                    int index = (k + mod) % 13;
                    table[index][i] += table[k][i + 1];
                    table[index][i] %= PRIME;
                }
            }
        }
        else{
            int num = S[i] - '0';
            int mod = (mod_keta * num) % 13;
            FOR(k, 0, 13){
                int index = (k + mod) % 13;
                table[index][i] += table[k][i + 1];
                table[index][i] %= PRIME;
            }
        }
    }

    cout << table[5][0] << endl;

}



Measured memory_bytes: 10624
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let x: u32 = sc.read();
    let a: u32 = sc.read();
    if x < a {
        println!("0");
    } else {
        println!("10");
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
n = int(input())
a_input = list(map(int,input().split()))

#左から単調非増加、単調非減少を試して行って長いほうを採用すればよいO(N)
#値の増減の反転するポイントを探索する
ans=1
tmp=0
for i in range(1,n):
    if (a_input[i]-a_input[i-1])*tmp<0:
        ans+=1
        tmp=0
    elif a_input[i]-a_input[i-1]!=0:
        tmp=a_input[i]-a_input[i-1]

print(ans)


Measured memory_bytes: 14228