akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int H, W, K; cin >> H >> W >> K;
	vector<vector<char>> s(H);
	REP(i,H) {
		string str; cin >> str;
		REP(j,W) {
			s[i].push_back(str[j]);
		}
	}
	vector<int> renzoku_arr(H, -1);
	REP(i,H) {
		bool flg = true;
		REP(j,W) {
			if (s[i][j] == '#') {
				flg = false;
				break;
			}
		}
		if (flg) {
			renzoku_arr[i] = i;
		}
	}
	// debug(renzoku_arr);
	int cnt = 1;
	vector<vector<int>> res(H, vector<int>(W));
	REP(i,H) {
		bool first_flg = false;
		REP(j,W) {
			if (renzoku_arr[i] != -1 && i == 0) {
				continue;
			}
			if (renzoku_arr[i] != -1 && i != 0) {
				res[i][j] = res[i - 1][j];
				continue;
			}
			if (!first_flg) {
				res[i][j] = cnt;
				if (s[i][j] == '#') {
					first_flg = true;
				}
			} else {
				if (s[i][j] == '#') {
					cnt++;
					res[i][j] = cnt;
				} else {
					res[i][j] = cnt;
				}
			}
		}
		if (renzoku_arr[i] == -1) {
			cnt++;
		}
	}
	for (int i = H - 2; i >= 0; --i) {
		REP(j,W) {
			// if (renzoku_arr[i] == -1) {
				if (res[i][j] == 0) {
					res[i][j] = res[i + 1][j];
				}
			// }
		}
	}
	// if (renzoku_arr[0] != -1) {
	// 	REP(j,W) {
	// 		res[0][j] = res[1][j];
	// 	}
	// }
	REP(i,H) {
		REP(j,W) {
			if (j == W - 1) {
				cout << res[i][j] << endl;
			} else {
				cout << res[i][j] << " ";
			}
		}
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
//#define attrib +h /s /d
using namespace std;
int main(){

   long long int n,a,b,c,d,e,f=0,g=0,i,j,k,l,t,u,ar[1000];
   double res,arr[100][100];
   string x,y;
   char ch,ch1;
   vector<int> v;
   vector<int> v1;
   set<char> s;
   cin>>x;
   if(x=="ABC"){
     cout<<"ARC"<<endl;
   }
   else cout<<"ABC"<<endl;



   return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<map>
using namespace std;

map<long long, long long>key;

int main()
{
	key[0] = 1;
	long long sum = 0;
	int n, tmp;
	long long num = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &tmp);
		sum += tmp;
		if (key[sum]) {
			num += key[sum];
			key[sum]++;
		}
		else {
			key[sum] = 1;
		}
	}
	printf("%lld\n", num);
    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
using namespace std;
int main()
{
    int a, n, d, x, w=0;
    cin >> n;
    cin >> d >> x;
    for(int s=0; s<n; s++)
    {
        cin >> a;
        for(int i=0; (i*a+1)<=d; i++)
        {
            w++;
        }
    }
    cout << w+x << '\n';
}

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

int main(){
 string s;
 cin >> s;
 if(s == "Sunny"){
   cout << "Cloudy";
 }else if(s == "Cloudy"){
   cout << "Rainy";
 }else if(s == "Rainy"){
   cout << "Sunny";
 }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    long k;
    cin >> k;
    if (k%2==0 or k%5==0)
    {
        cout << -1 << endl;
        return 0;
    }
    long M[k];
    M[0] = 7%k;
    if (M[0]==0)
    {
        cout << 1 << endl;
        return 0;
    }
    
    for (int i = 1; i < k; i++)
    {
        M[i] = (( (M[i-1]%k)*(10%k) )%k + 7%k)%k;
        if (M[i]==0)
        {
            cout << i+1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 11348
//   PIGMEISTER™   //

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

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    ll n, k;
    cin >> n >> k;
    ll h[n];
    sidha (i, 0, n) cin >> h[i];

    ll dp[n] = {0};
    sidha (i, 1, n) {
        dp[i] = 1e18;
        sidha (j, max(i-k, 0ll), i) {
            dp[i] = min(dp[i], dp[j]+abs(h[j]-h[i]));
        }
    }

    cout << dp[n-1] << '\n';
    
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int	main()
{
	int	N, K, Q;
	int	A;
	int	*player;

	scanf("%d %d %d\n", &N, &K, &Q);
	player = (int *)malloc(sizeof(int) * (N + 1));
	for (int i = 1; i <= N; i++)
		player[i] = K - Q;
	for (int i = 0; i < Q; i++)
	{
		scanf("%d\n", &A);
		player[A]++;
	}
	for (int i = 1; i <= N; i++)
	{
		if (player[i] > 0)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return (0);
}

Measured memory_bytes: 896
fun main(args: Array<String>) {
    val (n, x) = readLine()!!.split(' ').map { it.toInt() }
    var min = Int.MAX_VALUE
    val sum = (0 until n).map {
        val m = readLine()!!.toInt()
        min = Math.min(min, m)
        m
    }.sum()
    println(n + (x - sum) / min)
}


Measured memory_bytes: 38264
n, a, b= map(int,input().split())
if (b-a) % 2 == 0:
    print((b-a)//2)
elif (b-a) % 2 == 1:
    print(min(a-1+1+(b-a-1)//2,n-b+1+(b-a-1)//2))

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


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

	int buf = 0;
	int l = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int h; cin >> h;
		if (buf < h) {
			buf = h;
			l = 0;
		}
		else {
			buf = h;
			l++;
		}
		ans = max(ans, l);
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new java.util.Scanner(System.in);

	public static void main(String[] args) {

		while (sc.hasNext()){
			String str = sc.next();
			String[] st =str.split("");
			int[] num=new int[9];
			String ans="d";

			 //o,x,d?????°??????
			 for(int i=0;i<9;i++){
				 if(st[i].equals("o")){
					 num[i]=1;
				 }else if(st[i].equals("x")){
					 num[i]=4;
				 }else{
					 num[i]=0;
				 }
			 }
			 //?¨??????????
			 for(int i=0;i<9;i+=3){
				 if(num[i]+num[i+1]+num[i+2]==3){
					 ans="o";
				 }else if(num[i]+num[i+1]+num[i+2]==12){
					 ans="x";
				 }
			 }
			 //????????????
			 for(int i=0;i<3;i++){
				 if(num[i]+num[i+3]+num[i+6]==3){
					 ans="o";
				 }else if(num[i]+num[i+3]+num[i+6]==12){
					 ans="x";
				 }
			 }
			 //??????????????????
			 if(num[0]+num[4]+num[8]==3||num[2]+num[4]+num[6]==3){
				 ans="o";
			 }else if(num[0]+num[4]+num[8]==12||num[2]+num[4]+num[6]==12){
				 ans="x";
			 }
			 System.out.println(ans);

		}

	}

}

Measured memory_bytes: 25960
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
#define N 100015
int a,b,s[N],tot,ans[N];
char ch[N];
int main()
{
	scanf("%d%d",&a,&b);
	if(a<=b){puts("Impossible");return 0;}
	for(int i=0;i<a+b;i++)
	{
		if(!tot){s[++tot]=i;continue;}
		printf("? %d %d\n",s[tot],i);fflush(stdout);scanf("%s",ch);
		if(ch[0]=='Y')s[++tot]=i;
		else tot--;
	}
	for(int i=0;i<a+b;i++)
	{
		printf("? %d %d\n",s[tot],i);fflush(stdout);scanf("%s",ch);
		if(ch[0]=='Y')ans[i]=1;
		else ans[i]=0;
	}
	printf("! ");
	for(int i=0;i<a+b;i++)printf("%d",ans[i]);puts("");
}


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

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

  ll A; cin >> A;
  ll B; cin >> B;
  ll K; cin >> K;
  if (A >= K) {
    cout << (A - K) << ' ' << B << '\n';
  } else {
    cout << 0 << ' ' << max(B - (K - A), 0ll) << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>l(n);
  for(int i=0;i<n;i++)cin>>l[i];
  sort(l.begin(),l.end());
  int sum=0;
  
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
        for(int k=j+1;k<n;k++){
          if(l[i]+l[j]<=l[k])break;
          else sum++;
        }
    }
  }
  
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {

	int i;
	char s[11], t[12];
	
	scanf("%s %s", s, t);

	for(i = 0; ; i++){
		if(t[i] == s[i]){
			continue;
		}
		else if(t[i] != s[i] && s[i] == '\0'){
			printf("Yes");
			break;
		}else{
			printf("No");
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1732
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int du[100100];
int main()
{
	int n,k,q,q1;
	read(n);read(k);read(q);
	q1=q;
	while (q--)
	{
		int x;
		read(x);
		du[x]++;
	}
	for (int i=1;i<=n;i++) puts(q1-du[i]>=k?"No":"Yes");
	return 0;
}









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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define bits(n) __builtin_popcount(n)

void solve()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int c=0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if((a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])&&((a[i]+a[j]>a[k])&&(a[j]+a[k]>a[i])&&(a[i]+a[k]>a[j]))){
                c++;
                }
            }
        }
    }
    cout<<c;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

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

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
struct node{
    int l,r;ll v;
}t[800040];
struct inv{
    int l,r;ll val;
}g[200005];
ll n,m,flag[800040];
void build(int x,int l,int r){
    t[x].l=l;t[x].r=r;
    if(l==r) return;
    int mid=(l+r)>>1;
    build((x<<1),l,mid);
    build((x<<1)|1,mid+1,r);
}
void pushdown(int x) {
    if(flag[x]) {
        flag[x<<1]+=flag[x];
        t[x<<1].v+=flag[x];
        flag[(x<<1)|1]+=flag[x];
        t[(x<<1)|1].v+=flag[x];
        flag[x]=0;
    }
}
ll query(int x,int y) {
    int l=t[x].l,r=t[x].r,mid=(l+r)>>1;
    if(r==y) return t[x].v;
    pushdown(x);
    if(y<=mid) return query(x<<1,y);
    else return max(t[x<<1].v,query((x<<1)|1,y));
}
void change(int x,int l,int r,ll val) {
    int lc=t[x].l,rc=t[x].r,mid=(lc+rc)>>1;
    if(l<=lc&&r>=rc) {
        flag[x]+=val;
        t[x].v+=val;
        return;
    }
    pushdown(x);
    if(l<=mid) change(x<<1,l,r,val);
    if(r>mid) change((x<<1)|1,l,r,val);
    t[x].v=max(t[(x<<1)].v,t[(x<<1)|1].v);
}
bool cmp(inv x,inv y){return x.r<y.r;}
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=m;i++) scanf("%d%d%lld",&g[i].l,&g[i].r,&g[i].val);
    sort(g+1,g+m+1,cmp);
    build(1,1,n);
    int tmp=1;
    for(int i=1;i<=n;i++){
        change(1,i,i,query(1,i));
        while(g[tmp].r==i){
            change(1,g[tmp].l,g[tmp].r,g[tmp].val);
            tmp++;
        }
    }
    printf("%lld",max(t[1].v,0ll));
    return 0;
}

Measured memory_bytes: 18560
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    vector<int> X(M);
    for (int i = 0; i < M; ++i) {
        cin >> X[i];
    }

    if (N >= M) {
        cout << 0 << endl;
        return 0;
    }

    sort(begin(X), end(X));

    using P = pair<int, int>;
    vector<P> d(M);
    d[0].first = 0;
    d[0].second = 0;

    for (int i = 1; i < M; ++i) {
        d[i].second = i;
        d[i].first = X[i] - X[i-1];
    }

    vector<P> top(N-1);
    partial_sort_copy(begin(d), end(d), begin(top), end(top), greater<P>());

    for (int i = 0; i < N-1; ++i) {
        d[top[i].second].first = 0;
    }

    int ans = 0;
    for (int i = 0; i < M; ++i) {
        ans += d[i].first;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <numeric>

using namespace std;


vector<long> z_algorithm(const std::string& s, const long n){
  std::vector<long> z(n, 0);
  long L=0, R=0;
  for (long i=1; i<n; i++){
    if(i>R) {
      L = R = i;
      while(R<n && s[R-L]==s[R]) R++;
      z[i] = R-L;
      R--;
    } else {
      long k = i-L;
      if(z[k] < R-i+1){
        z[i] = z[k];
      } else {
        L = i;
        while(R<n && s[R-L]==s[R]) R++;
        z[i] = R-L; R--;
      }
    }
  }
  return z;
}

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

  vector<long> z;
  for (int i=0; i<n-1; i++) {
    z = z_algorithm( s.substr(i, n-i), n-i);
    for (long j=1; j<n-i; j++) {
      ans = max(ans, min(z[j],j));
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int dp[3003][3003];
pii from[3003][3003];
signed main() {
    REP(i, 3003) REP(j, 3003) from[i][j] = {-1, -1};
    string s, t;
    cin >> s >> t;
    dp[0][0] = 0;
    REP(i, SZ(s)) {
        REP(j, SZ(t)) {
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
                from[i + 1][j + 1] = {i, j};
            } else {
                if (dp[i + 1][j] < dp[i][j + 1]) {
                    dp[i + 1][j + 1] = dp[i][j + 1];
                    from[i + 1][j + 1] = {i, j + 1};
                } else {
                    dp[i + 1][j + 1] = dp[i + 1][j];
                    from[i + 1][j + 1] = {i + 1, j};
                }
            }
        }
    }
    string ans = "";
    int i = SZ(s), j = SZ(t);
    while (1) {
        int ni, nj;
        tie(ni, nj) = from[i][j];
        if (ni == -1) break;
        if (dp[i][j] == dp[ni][nj] + 1) {
            ans += s[ni];
        }
        i = ni, j = nj;
    }
    reverse(ALL(ans));
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 211584
// ※※※ 解答不能 ※※※
// KrK氏.
// https://atcoder.jp/contests/abc150/submissions/9398690
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const int Maxn = 600015;
int n, slen;
int a[Maxn], S[Maxn], Z[Maxn];

int main(){
    scanf("%d", &n);
    rep(i, n) scanf("%d", &a[i]);
    rep(i, n) scanf("%d", &S[i]);
    slen = n;
    rep(i, n) S[slen++] = a[i];
    rep(i, n - 1) S[slen++] = a[i];
    int l = -1, r = -1;
    repx(i, 1, slen){
        if(i <= r) Z[i] = min(r - i, Z[i - l]);
        int mask = (S[0] ^ S[i]);
        while(i + Z[i] < slen && (S[Z[i]] ^ S[i + Z[i]]) == mask) Z[i]++;
        if(i >= n && Z[i] >= n) printf("%d %d\n", i - n, mask);
        if(i + Z[i] - 1 > r) l = i; r = i + Z[i] - 1;
    }
    return 0;
}

Measured memory_bytes: 9600
X = int(input())

num_list = [0]*(100001 + 105)
num_list[0] = 1

for i in range(100001 + 105):
    if i == X:
        print(num_list[X])
        exit()

    for j in [100, 101, 102, 103, 104, 105]:
        if num_list[i]:
            num_list[i+j] = 1

print(0)

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

int main(){
    set<int> a, b, c;
    int n, m, x;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x;
        a.insert(x);
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> x;
        b.insert(x);
    }

    set_symmetric_difference(a.begin(), a.end(), b.begin(), b.end(), inserter(c, c.end()));

    for(int x : c)  printf("%d\n", x);

    return 0;
}


Measured memory_bytes: 40656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main(){
  int a,b;
  cin>>a>>b;
  int ans=0;
  int cnt=1;
  while(cnt<b){
    cnt--;
    cnt+=a;
    ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> x(m);
	rep(i,m) cin >> x.at(i);
	sort(x.begin(),x.end());
	vector<int> a(m-1);
	rep(i,m-1) a.at(i)=x.at(i+1)-x.at(i);
	sort(a.begin(),a.end());
	ll ans=0;
	rep(i,m-n) ans+=a.at(i);
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
inline int read() {
    int x=0;
    char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}

const int N=1e5+10;

int main() {
    int n;
    cin>>n;
    cout<<(n-1)/2;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	
	scanf("%d",&n);
	
	int a[100],i,j;
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(j=0;j<n;j++){
		if(!(j==0))printf(" ");
		printf("%d",a[n-1-j]);
	}
	
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <numeric>

using namespace std;

int main()
{
    int ctime[5];
    int ttime, min, idx;
    int digit[5];

    ttime = 0;
    min = 10;
    for (int i = 0; i < 5; i++) {
        cin >> ctime[i];
        digit[i] = ctime[i] % 10;
        if (digit[i] != 0 && min > digit[i]) {
            min = digit[i];
            idx = i;
        }
    }

    for (int i = 0; i < 5; i++) {
        if (i == idx)
            ttime += ctime[i];
        else
            ttime += (int)((ctime[i] + 9) / 10) * 10;
    }

    cout << ttime << endl;

    return 0;
}

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

int main() {
   int x;
   string s;
   int sum;

   while (cin >> s) {
       if (s[0] == '0') return 0;

       sum = 0;
       for (int i = 0; i < s.size(); i++) {
           sum += s[i] - '0';
       }
       cout << sum << endl;
   }
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int N;
	cin >> N;
	int NUM[4] = {N/1000, (N % 1000) / 100, (N % 100) / 10, N % 10};
	int bit = 1;

	for (int i = 0; i < (1<<3); i++){
		int ans = 0;
		ans += NUM[0];
		string s;
		for (int j = 0; j < 3; j++){
			if (bit << j & i){
				ans -= NUM[j+1];
				s += "-";
			}
			else {
				ans += NUM[j+1];
				s += "+";
			}
		}
		if (ans == 7){
			cout << NUM[0] << s[0] << NUM[1] << s[1] << NUM[2] << s[2] << NUM[3];
			break;
		}
	}

	cout << "=7" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.out;
 
public class Main{
   public static Scanner sc = new Scanner(System.in);
   public static void main(String args[]){
    int A = sc.nextInt();
    int B = sc.nextInt();
 
    if (A > 8 || B > 8) {
      System.out.println(":(");
    } else {
      System.out.println("Yay!");
    }
 
   }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;
struct dr{
  int y,x,d,t;
  dr(){}
  dr(int y,int x,int d,int t):y(y),x(x),d(d),t(t){}
};
int ans=6;
int h=4,w=4;

void dfs(int d,mat v){
  if(ans<=d+1) return;
  if(d>=5) return;
  /*
    cout<<d<<":"<<endl;
    for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
    cout<<v[i][j]<<" \n"[j==w-1];
  */
  int ax[]={1,0,-1,0};
  int ay[]={0,1,0,-1};
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(!v[i][j]) continue;
      mat u(v);
      u[i][j]++;
      queue<dr> qd;
      int tmp=-1;
      while(1){
	if(!qd.empty()){
	  dr t=qd.front();qd.pop();
	  if(tmp<t.t){
	    for(int a=0;a<h;a++)
	      for(int b=0;b<w;b++)
		if(u[a][b]>=5)
		  for(int k=0;k<4;k++){
		    qd.push(dr(a,b,k,t.t));
		    u[a][b]=0;
		  }
	    tmp=t.t;
	  }
	  t.y+=ay[t.d];t.x+=ax[t.d];t.t++;
	  if(t.y<0||h<=t.y||t.x<0||w<=t.x) continue;
	  if(u[t.y][t.x]) u[t.y][t.x]++;
	  else qd.push(t);
	}else{
	  tmp++;
	  bool fl=0;
	  for(int a=0;a<h;a++)
	    for(int b=0;b<w;b++)
	      if(u[a][b]>=5)
		for(int k=0;k<4;k++){
		  qd.push(dr(a,b,k,tmp));
		  u[a][b]=0;
		  fl=1;
		}
	  if(!fl) break;
	}
      }
      bool f=0;
      for(int a=0;a<h;a++)
	for(int b=0;b<w;b++)
	  f|=u[a][b];
      if(!f){
	ans=d+1;
	return;
      }
      dfs(d+1,u);
    }
  }
}

signed main(){
  mat v(h,vector<int>(w));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin>>v[i][j];
  bool f=0;
  for(int a=0;a<h;a++)
    for(int b=0;b<w;b++)
      f|=v[a][b];
  if(!f){
    cout<<0<<endl;
    return 0;
  }
  dfs(0,v);
  cout<<(ans>5?-1:ans)<<endl;
  return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i< (int)(n); i++)
int main(){
    int X,N;
    int min=1000,ans=1000;
    cin >> X >> N;
    if(N==0) cout << X << endl;
    else{
        vector<int> p(N);
        vector<int> existp(102,0);//0から101までの箱
        rep(i,N){
            cin >> p.at(i);
            existp.at(p.at(i))++;
        }
        rep(i,102){
            if(existp.at(i)==0){
                if(abs(X-i)<min){
                    ans=i;
                    min=abs(X-i);
                }
            }
        }
        cout << ans << endl;

    }
}

Measured memory_bytes: 3628
//created by missever

#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;

map<LL,LL> p;

LL ff(LL x)
{
    if(x < 2) return x;
    if(p.find(x) != p.end()) return p[x];
    LL y;
    if(x & 1) y = (ff(x / 2) * 2 + ff(x / 2 + 1)) % MAX;
    else y = (ff(x / 2) * 2 + ff(x / 2 - 1)) % MAX;
    p[x] = y;
    return y;
}

int main(){
    LL n;
    cin>>n;
    printf("%lld\n",ff(n + 1));
    return 0;
}


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

class UnionFind{
private:
  vector<ll> data;
public:
  UnionFind(ll x){
    data.resize(x,-1);
  }
  //data[x]はxの根の値
  //xが根の場合data[x]は根がxの集合の要素の個数
  ll root(ll x){
    return (data[x]<0) ? x : data[x] = root(data[x]);
  }
  void unite(ll x, ll y){
    x = root(x);
    y = root(y);
    if(x == y) return;
    //xにyを結合
    data[x] += data[y];
    data[y] = x;
  }
  bool same(ll x, ll y){
    return (root(x) == root(y));
  }
  ll size(ll x){
    return -data[root(x)];
  }
};

int main(){
  ll n,q;
  cin >> n >> q;
  UnionFind uf(n);
  for(int i=0;i<q;i++){
    ll com,x,y;
    cin >> com >> x >> y;

    if(com == 0){
      uf.unite(x,y);
    }else{
      if(uf.same(x,y)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
}


Measured memory_bytes: 3160
A,B,K = map(int,input().split())

if K >= B:
  print(*sorted(range(A,B+1)), sep = "\n")

else:
  a = [i for i in range(A,min(B+1,A+K))]
  b = [i for i in range(B,max(A-1,B-K),-1)]
  print(*sorted(set(a+b)), sep = "\n")

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <string.h>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;

ll pw(ll a, ll p) {
	ll ans = 1;
	while (p > 0) {
		if (p & 1) {
			ans = (ans * a) % MOD;
		}
		a = (a * a) % MOD;
		p /= 2;
	}
	return ans;
}

ll inv(ll a) {
	return pw(a, MOD - 2);
}

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	vector<ll> fact(200001, 1);
	for (ll i = 1; i <= 200000; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
	}
	for (int i = 0; i < min(k + 1, n); i++) {
		ll cur = ((fact[n] * inv(fact[i])) % MOD) * inv(fact[n - i]) % MOD;
		cur *= (fact[n - 1] * inv(fact[n - i - 1])) % MOD * inv(fact[i]) % MOD;
		ans += cur;
		ans %= MOD;
	}
	cout << ((ans % MOD) + MOD) % MOD;
}



Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=1e7+1;
int f[N];
int32_t main()
{
	IOS;
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j*i<=n;j++)
		{
			f[i*j]+=1;
		}	
	}
	for(int i=1;i<=n;i++)
		sum+=f[i]*i;
	cout<<sum<<endl;

	
}

Measured memory_bytes: 81724
#import<bits/stdc++.h>
#define LL long long
using namespace std;
int a,b,c,i,j,k,m,n,s,t,x,y,z[20];
int dgs(int x){int s=0;for(;x;x/=10)s+=x%10;return s;}
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int max2(int x,int y){return x>y?x:y;}
int max3(int x,int y,int z){return x>y?x>z?x:z:y>z?y:z;}
int min2(int x,int y){return x<y?x:y;}
int min3(int x,int y,int z){return x<y?x<z?x:z:y<z?y:z;}
int prime(int x){if(x<2||x%6^1&&x%6^5)return x==2|x==3;for(int i=5;i*i<=x;i+=6)if(x%i<1||x%(i+2)<1)return 0;return 1;}
char e[5];
main()
{
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",z+i);
for(i=0;++i<n-1;)s+=z[i]>z[i-1]&&z[i]<z[i+1]||z[i]<z[i-1]&&z[i]>z[i+1];
printf("%d",s);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A, B) << ' ' << max(A+B-N, 0) << endl;
  return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int p = 1;
  for (int i = 0 ; i < N; i++) {
    if( p * 2 < p + K ){
      p *= 2;
      }
    else {
      p += K;
      }//if
    }// for
  cout << p << endl; 
  }//main


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int  n, a, i, f=0;
  int  b4=0, ev=0, od=0;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &a);
    if(a%4 == 0){
      b4++;
    }else if(a%2 == 0){
      ev++;
    }else{
      od++;
    }
  }

  if( ev > 0 ) {
    if( od > b4) f=1;
  }else{
    if( od > b4+1) f=1;
  }

  if( f==0 ) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
from collections import deque
from collections import defaultdict
# input = sys.stdin.buffer.readline
H, W = map(int, input().split())
ch, cw = map(int, input().split())
ch, cw = ch - 1, cw - 1  # 0-indexed
dh, dw = map(int, input().split())
dh, dw = dh - 1, dw - 1  # 0-indexed
# print(f'{ch=}, {cw=}')
S = []
for _ in range(H):
    S.append(list(input()))
# S = np.array(S)
# print(f'{S=}')

# G = np.full_like(S, -1, dtype='int')
G = []
for _ in range(H):
    G.append([-1] * W)
# print(f'{G=}')

current_G = 0
group_dic = defaultdict(list)
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            continue
        if G[h][w] != -1:
            continue
        G[h][w] = current_G
        group_dic[current_G].append((h, w))
        q = deque([(h, w)])
        while q:
            # print(f'{q=}')
            _h, _w = q.popleft()
            # print(f'{_h=}, {_w=}')
            for dx, dy in ((-1, 0), (1, 0), (0, -1), (0, 1)):
                nx = _w + dx
                ny = _h + dy
                # print(f'{nx=}, {ny=}')
                if nx < 0 or ny < 0 or nx >= W or ny >= H:
                    # print(f'fuga {nx=}, {ny=}')
                    continue
                if S[ny][nx] == '#':
                    continue
                if G[ny][nx] != -1:
                    # print(f'hoge')
                    continue
                G[ny][nx] = current_G
                q.append((ny, nx))
                group_dic[current_G].append((ny, nx))
        current_G += 1
#         print(f'')
# print(f'{G=}')
# print(f'{current_G=}')
# print(f'{group_dic=}')

if current_G == 1:
    print(0)
    exit()

# print(f'start group = {G[ch][cw]=}')
start_group = G[ch][cw]

P = [-1] * (current_G)
P[start_group] = 0
# print(f'{P=}')

g = start_group
GG = deque([start_group])
while GG:
    g = GG.popleft()
    for h, w in group_dic[g]:
        for dx, dy in ((-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -2),
                       (-1, -1), (-1, 1), (-1, 2), (0, -2), (0, 2), (1, -2),
                       (1, -1), (1, 1), (1, 2), (2, -2), (2, -1), (2, 0),
                       (2, 1), (2, 2)):
            nx = w + dx
            ny = h + dy
            if nx < 0 or ny < 0 or nx >= W or ny >= H:
                continue
            if S[ny][nx] == '#':
                continue
            _g = G[ny][nx]
            if P[_g] != -1:
                continue
            P[_g] = P[g] + 1
            GG.append(_g)

# print(f'{P=}')
# print(f'goal group = {G[dh][dw]=}')
ans = P[G[dh][dw]]
print(ans)


Measured memory_bytes: 158444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            //入力読取。
            string strDateLength = Console.ReadLine();
            int intDateLength = int.Parse(strDateLength);
            int[,] addPeapleArray = new int[intDateLength, 4];
            for (int dateIndex = 0; dateIndex < intDateLength; dateIndex++)
            {
                string strAddPeaple = Console.ReadLine();
                string[] strAddPeapleArray = strAddPeaple.Split(' ');
                for(int addPeapleArrayIndex = 0; addPeapleArrayIndex < 4; addPeapleArrayIndex++)
                {
                    int intNum = int.Parse(strAddPeapleArray[addPeapleArrayIndex]);
                    addPeapleArray[dateIndex, addPeapleArrayIndex] = intNum;
                }
            }

            //入居処理。
            int[,,] apartArray = new int[4, 3, 10];
            for (int dateIndex = 0; dateIndex < intDateLength; dateIndex++)
            {
                int buildingPlace = addPeapleArray[dateIndex, 0] - 1;
                int floorPlace = addPeapleArray[dateIndex, 1] - 1;
                int roomPlace = addPeapleArray[dateIndex, 2] - 1;
                int addPeaple = addPeapleArray[dateIndex, 3];
                apartArray[buildingPlace, floorPlace, roomPlace] += addPeaple;
            }

            //出力
            for (int buildingIndex = 0; buildingIndex < 4; buildingIndex++)
            {
                for (int floorIndex = 0; floorIndex < 3; floorIndex++)
                {
                    for (int roomIndex = 0; roomIndex < 10; roomIndex++)
                    {
                        Console.Write(" {0}",apartArray[buildingIndex, floorIndex, roomIndex]);
                    }
                    Console.WriteLine();

                }
                if (buildingIndex < 3)
                {
                    Console.WriteLine("####################");
                }
                
            }
            
            Console.ReadKey();
        }
    }
}



Measured memory_bytes: 18028
import Control.Applicative
import Control.Monad.ST
import Control.Monad.State
import Control.Monad
import Data.Array.IO
import Data.List
import Data.Array
import Data.Int
import Data.Maybe
import Debug.Trace
import qualified Data.ByteString.Char8 as BS
import Data.IORef

type Node = Int
type Cost = Int64
type Edge = (Node, Cost)
type Graph = Array Node [Edge]

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)
readIntBS = fst . fromJust . BS.readInt

inf = maxBound `div` 2 :: Cost

infixr 1 ?
(?) :: Bool -> (a,a) -> a
(?) b t = (if b then fst else snd) t

main = do
  n <- readLn :: IO Int
  graph <- newArray ((1,1),(n,n)) 0 :: IO (IOUArray (Int,Int) Cost)
  mn <- newArray ((1,1),(n,n)) 0 :: IO (IOUArray (Int,Int) Cost)

  forM_ [1..n] $ \i -> do
    as <- map (fromIntegral . readIntBS) . BS.words <$> BS.getLine :: IO [Cost]
    forM_ (zip [1..n] as) $ \(j,a) -> do
      writeArray graph (i,j) a
      writeArray mn (i,j) a

  failed <- newIORef False :: IO (IORef Bool)

  forM_ [1..n] $ \i -> do
    forM [i+1..n] $ \j -> do
      forM [k | k<-[1..n], k/=i, k/=j] $ \k -> do
        ij <- readArray mn (i,j)
        ikj <- (+) <$> readArray mn (i,k) <*> readArray mn (k,j)
        when (ij==ikj) $ writeArray graph (i,j) inf >> writeArray graph (j,i) inf
        when (ikj<ij) $ writeIORef failed True
               
  readIORef failed >>= \a -> 
    if a then
      print $ -1
    else
      print =<< sum . filter (/=inf) . concat <$> (forM [1..n] $ \i -> forM [i+1..n] $ \j -> readArray graph (i,j))
    


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

using namespace std;

int v[51], k;
struct myc {int x, y;} ans[103];

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

    int p = 0;
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
        if (abs(v[i]) >= abs(v[p]))
            p = i;
    }

    if (v[p] > 0) {
        ans[k++] = {p, n};
        ans[k++] = {p, n};
        for (int i = 2; i < n; i++) {
            ans[k++] = {n, n};
            ans[k++] = {n, i};
        }
        ans[k++] = {n, n};
    } else if (v[p] < 0) {
        ans[k++] = {p, 1};
        ans[k++] = {p, 1};
        for (int i = n - 1; i > 1; i--) {
            ans[k++] = {1, 1};
            ans[k++] = {1, i};
        }
        ans[k++] = {1, 1};
    }

    cout << k << '\n';
    for (int i = 0; i < k; i++)
        cout << ans[i].x << ' ' << ans[i].y << '\n';

    return 0;
}


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

long long min(long long a, long long b)
{
    if(a>b)
        return b;
    else
        return a;
}

int main() {
    // insert code here...


    int n;
    long long A[100003];
    long long B[100003];
      long long C[200003];
    long long  s[200010];
    long long ans,s1,s2;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>A[i]>>B[i];
        s1+=A[i];
        s2+=B[i];
        C[i]=A[i];
        C[i+n]=B[i];
       
    }
    ans=min(s1,s2);
    sort(C+1,C+1+n+n);
    for(int i=1;i<=n+n;++i) s[i]=s[i-1]+C[i];
    for(int i=1;i<=n;++i){
        int nw=n;
        long long cnt=0;
        if(A[i]>=C[nw]) --nw,cnt+=A[i];
        if(B[i]>=C[nw]) --nw,cnt+=B[i];
        ans=min(ans,cnt+s[nw]);
    }
    cout<<ans<<endl;
   
    return 0;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        //入力準備
        Scanner sc = new Scanner(System.in);
        
        int x;
        int i = 1;
        
        while(true){
            x  = sc.nextInt();
            if(x == 0)break;
            System.out.println("Case " + (i++) + ": " + x);
        }
    }
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>p(N);
  for(int i=1;i<=N;i++){
    int a;
    cin>>a;
    p[a]=i;
  }
  ll ans=0;
  set<ll>used={0,N+1};
  for(int i=1;i<=N;i++){
    auto itr=used.lower_bound(p[i]);
    ll r=*itr;
    ll l=*(--itr);
    ans+=i*(p[i]-l)*(r-p[i]);
    used.insert(p[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 10368
package main

import (
	"fmt"
	"sort"
	"strconv"
)

func main() {
	var num int64
	num = 1000000000000001
	arr := make([]int64, 14)
	eval := make([]int64, 14)
	arr[1] = 26
	for i := 2; i < 13; i++ {
		arr[i] = arr[i-1] * 26
	}
	for i := 1; i < 13; i++ {
		eval[i] = eval[i-1] + arr[i]
	}
	fmt.Scan(&num)
	var test string
	pos := 0
	for i := 0; i < 13; i++ {
		if eval[i+1] >= num {
			pos = i
			break
		}
	}
	num = num - eval[pos]
	test = strconv.FormatInt(num-1, 26)
	str := ""
	for _, c := range test {
		var neko int64
		neko, _ = strconv.ParseInt(string(c), 36, 64)
		neko += 10
		str = str + strconv.FormatInt(neko, 36)
	}
	passNum := pos + 1 - len(str)
	for i := 0; i < passNum; i++ {
		str = "a" + str
	}
	fmt.Print(str)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 1772
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

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

    cout << S.substr(0, 3) << endl;
}


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

using namespace std;

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

  int dp[1001][1001] = {{}};
  dp[0][0] = 1;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j <= K; j++) {
      for(int k = 1; k <= K; k++) {
        if(j == k) continue;
        dp[i + 1][k] += dp[i][j];
      }
    }
  }
  int ret = 0;
  for(int i = 1; i <= K; i++) ret += dp[N][i];
  cout << ret << endl;
}

Measured memory_bytes: 4220
a,b=map(int,input().split())
if b<2 or b>2*a-2:print("No")
else:
    print("Yes")
    d=[i for i in range(1,b-1)]+[i for i in range(b+1,a+1)]+[b-1,b]+[i for i in range(a+1,2*a)]if 1<=b<a+1else[i for i in range(1,a)]+[b,b+1]+[i for i in range(a,b)]+[i for i in range(b+2,2*a)]
    for i in d:print(i)

Measured memory_bytes: 13176
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

ll a,b,x;

ll f(ll n){
    if(n == -1) return 0;
    else return n/x + 1;
}
int main() {
    cin >> a >> b >> x;

    cout << f(b) - f(a-1);

    return 0;
}


Measured memory_bytes: 3620
//g++  5.4.0
// Time-complexity : ( 3^n * n + 2^n * n * n )
#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;


signed main()
{
    fast;
    int n;
    cin >> n;
    int a[n][n];
    for(int i=0 ; i<n ; i++ )
    {
        for(int j=0 ; j<n ; j++ )
        {
            cin >> a[i][j];
        }
    }
    int sum[(1<<n)];
    memset( sum,0,sizeof(sum) );
    for(int mask=0 ; mask<(1<<n) ; mask++ )
    {
        for(int i=0 ; i<n ; i++ )
                    {
                        for(int j=i+1 ; j<n ; j++ )
                        {
                            if( (1<<i)&mask && (1<<j)&mask )
                                sum[mask] += a[i][j];
                        }
                    }
    }
    
    int dp[(1<<n)];
    memset( dp,0,sizeof(dp) );
    
    for(int mask=0 ; mask<(1<<n) ; mask++ )
    {
                int dummy_mask = mask;
                while( dummy_mask )
                {
                    dp[mask] = max( dp[mask] ,  sum[dummy_mask] + dp[ mask^dummy_mask ] );
                    dummy_mask = ( mask&(dummy_mask-1) );
                }
           
    }
    
    
    cout << dp[(1<<n)-1];
}





Measured memory_bytes: 1280