akhauriyash/Code-Regression huggingface dataset:
import math

while True:
    s = int(input())
    if s == 0:
        break

    r = list(map(float, input().split()))
    x = sum(r) / s
    sigtwo = sum(list(map(lambda y: (y-x)**2, r))) / s
    sig = math.sqrt(sigtwo)
    print("{:.8f}".format(sig))



Measured memory_bytes: 5772
def combination(n,r,mod=10**9+7):
    r=min(r,n-r)
    up,down=1,1
    for i in range(r):
        up=up*(n-i)%mod
        down=down*(i+1)%mod
    return up*pow(down,mod-2,mod)%mod


x,y=map(int,input().split())
n,m=(2*y-x)//3,(2*x-y)//3
if (x+y)%3!=0 or n<0 or m<0:print(0);exit()
print(combination(n+m,m))

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

int main()
{
  int a, b;
  cin >> a >> b;

  if(a>8 || b>8)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;

  return 0;
}


Measured memory_bytes: 3572
N = gets.to_i
V = gets.to_i

if N == 1
	if V == 2
		puts 3
	else
		puts 2
	end

elsif N == 2
	if V == 1
		puts 3
	else
		puts 1
	end
else
	if V == 1
		puts 2
	else
		puts 1
	end
end

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M,X;
int A[111111];

signed main(){
    cin>>N>>M>>X;
    rep(i,M){
        cin>>A[i];
    }

    int tmp=lower_bound(A,A+M,X)-A;
    cout<<min(tmp,M-tmp)<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i64 = read();
    let x: i64 = read();
    let y: i64 = read();
    let mut ans: Vec<i64> = (0..n).map(|_| 0).collect();
    for i in 1..n+1 {
        for j in i..n+1 {
            let mut min = j - i;
            let mut tmp = (x-i).abs() + 1 + (j-y).abs();
            if tmp < min {
                min = tmp;
            }
            tmp = (y-i).abs() + 1 + (j-x).abs();
            if tmp < min {
                min = tmp;
            }
            //println!("{} {} {}", i, j, min);
            ans[min as usize] += 1;
        }
    }

    for a in &ans[1..] {
        println!("{}", a);
    }
}



Measured memory_bytes: 4352
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    string x , y;
    cin >> x >> y;
    if (x > y)cout << '>' << endl;
    else if (x < y)cout << '<' << endl;
    else cout << "=" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    
    int a, b; cin >> a >> b;
    if(a == b) {
        cout << "a == b" << endl;
    }
    else if( a > b) {
        cout << "a > b" << endl;
    }
    else cout << "a < b" << endl;
}


Measured memory_bytes: 3072
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();		
		int a[] = new int[N];//N個の配列をつくる
		Set<Integer> set = new HashSet<Integer>();//HashSetで空の箱を作る
		for(int  i=0; i<N; i++) {
			a[i]= sc.nextInt();
			set.add(Integer.valueOf(a[i]));//set.addで空の箱に重複を除いたaを追加する
		}
		//元の配列の要素数と異なればNO、変化していなければYES
		if(set.size()!=N){
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}
	}		
}

Measured memory_bytes: 104820
#define F(a,t) for(a=2*t;a<=n;a+=t)
main(){int i,j,n,s,p[1000000];while(~scanf("%d",&n)){s=n;F(i,1)p[i]=1;F(i,1)F(j,i){s-=p[j];p[j]=0;};printf("%d\n",--s);}}

Measured memory_bytes: 4312
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
source:
    ll a, b, c;
    cin >> a >> b >> c;
    double n = a, m = b, d = c;

    double ans = 0;
    if (d == 0) {
        ans = (m - 1) / n;
    } else {
        ans = (m - 1) * 2 * (n - d) / (n * n);
    }

    printf("%.10lf\n", ans);

    return 0;
}



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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int64_t a){if(a<=1)return false;for(int64_t i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }



int main()
{
	int64_t a, b, n, x;

	cin >> a >> b >> n;
	x = min(n, b - 1);
	cout << (a * x) / b - a * (x / b) << endl;
}


Measured memory_bytes: 3688
K = int(input())
X, Y = map(int, input().split())

P = []
x, y = 0, 0

while (x, y) != (X, Y):
    dx = abs(X - x)
    dy = abs(Y - y)
    D = dx + dy
    if D == K:
        x, y = X, Y
    elif D % 2 != 0 and K % 2 == 0:
        print(-1)
        exit()
    elif D % 2 == 0 and D <= 2 * K:
        pos   = D // 2
        shift = (2 * K - D) // 2
        if pos <= dx:
            x += pos   if X > x else -pos
            y -= shift if Y > y else -shift
        else:
            x = X + (shift if X > x else -shift)
            y += pos - dx if Y > y else -(pos - dx)
    elif D < K:
        x -= K if X > x else -K
    elif dx >= K:
        x += K if X > x else -K
    else:
        x = X
        y += K - dx if Y > y else -(K - dx)
    P.append((x, y))

print(len(P))
for x, y in P:
    print(x, y)


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int m;
  cin >> m;
  int64 count = 0;
  int64 d_sum = 0;
  for (int i = 0; i < m; i++) {
    int64 d, c;
    cin >> d >> c;
    count += c;
    d_sum += d * c;
  }
  cout << count - 1 + (d_sum - 1) / 9 << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "string.h"

using namespace std;

int main( void ) {
    
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    int array[H][W];

    for ( int i = 0; i < H; i++ ) {

        for ( int j = 0; j < W; j++ ) {
            
            if ( i < B ) {
                
                array[i][j] = ( j < A ) ? 0 : 1;

            } else {
                
                array[i][j] = ( j < A ) ? 1 : 0;
            }       
        }
    }

    for ( int i = 0; i < H; i++ ) {
        for ( int j = 0; j < W; j++ ) {
            cout << array[i][j];
        }
        cout << endl;
    }

    return 0;   
}

Measured memory_bytes: 5120
#include <stdio.h>

int main()
{ int a,b,c,x,y;y=0;
	scanf("%d %d %d",&a,&b,&c);
	for(x=a;x<=b;x++){
	if(c%x==0){y++;};
	};
	printf("%d\n",y);
	
	return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
typedef  long long LL;
using namespace std;
int main()
{
    LL a;
    cin>>a;
    LL b=sqrt(a);
    if(b*b==a)
        cout<<b*b<<endl;
    else
        cout<<b*b<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int par[100010];
int depth[100010];
void init(int n){
  for(int i=0;i<=n;i++){
      par[i]=i;
      depth[i]=0;
  }
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return root(x)==root(y);
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y)return;
  if(depth[x]<depth[y]){
      par[x]=y;
  }else{
      par[y]=x;
      if(depth[x]==depth[y])depth[x]++;
  }
}
int main(){
    ll n,m;cin>>n>>m;
    init(n);
    vector<vector<ll> >lang(m+1);
    REP(i,1,n+1){
        ll k;cin>>k;
        rep(j,k){
            ll l;cin>>l;
            lang[l].pb(i);
        }
    }
    rep(i,m+1){
        rep(j,lang[i].size()){
            if(j!=lang[i].size()-1){
                unite(lang[i][j],lang[i][j+1]);
            }
        }
    }
    bool f=1;
    REP(i,1,n){
        f&=same(i,i+1);
    }
    cout<<(f?"YES":"NO")<<endl;
}

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

int main(void) {
  int n; cin >> n;
  vector<int> l(n);
  for (int i=0; i<n; i++) {
    cin >> l.at(i);
  }
  
  sort(l.begin(), l.end());
  
  int ans = 0;
  for (int i=0; i<(n-1); i++) {
    ans += l[i];
  }

  if (l[n-1] < ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000001
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<pll,ll>
#define vplll vector<plll>
#define vpll vector<pll>
using namespace std;
using namespace std::chrono; 
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);

ll graph[210][210];
ll color[210];
ll vertice;

bool isbipartite(ll start,ll col)
{
    bool res=true;
    bool store;
    color[start]=col;
    for(ll i=0;i<vertice;i++)
    {
        if(graph[start][i]==1 && !color[i])    
        {
            store=isbipartite(i,3-col);
            res=res&store;
        }
        else if(graph[start][i]==1 && color[i]==col)
        {
            return false;
        }
    }
    return res;
}

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

    memset(color,0,sizeof(color));
    cin>>vertice;
    string store[vertice];
    for(ll i=0;i<vertice;i++)
    {
        cin>>store[i];
    }
    for(ll i=0;i<vertice;i++)
    {
        for(ll j=0;j<vertice;j++)
        {
            graph[i][j]=store[i][j]-'0';
        }
    }
    bool res=true;
    for(ll i=0;i<vertice;i++)
    {
        if(color[i]==0)
        {
            res=res&isbipartite(i,1);
        }
    }
    if(!res)
    {
        cout<<"-1";
        exit(0);
    }
    for(ll i=0;i<vertice;i++)
    {
        for(ll j=0;j<vertice;j++)
        {
            if(graph[i][j]==0)
            {
                graph[i][j]=INF;
            }
            graph[i][i]=0;
        }
    }
    for(ll k=0;k<vertice;k++)
    {
        for(ll i=0;i<vertice;i++)
        {
            for(ll j=0;j<vertice;j++)
            {
                graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
            }
        }
    }
    ll ans=NEGINF;
    for(ll i=0;i<vertice;i++)
    {
        for(ll j=0;j<vertice;j++)
        {
            if(graph[i][j]==INF)
            {
                graph[i][j]=0;
            }
            ans=max(ans,graph[i][j]);
        }
    }  
    ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
 
using namespace std;
 
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int INF = 1e10;
const int max_N = 3000 + 6;
int a[max_N];

int main(){
	IOS;
	int n;
	while(cin>>n){
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		int sum =0 ;
		for(int i=0;i<n;i++){
			sum += a[i];
		}
		sum = sum - n;
		cout<<sum<<endl;
	}
	return 0;
}

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

int main() {
  map<int, int> or_num;
  int n;
  cin >>n;
  rep(i, n) {
    int a;
    cin >> a;
    or_num[a] = i + 1;
  }
  for (auto p : or_num)
    cout << p.second << " ";
}


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

int main() {
    ll A, P;
    cin >> A >> P;
    cout << (A * 3 + P) / 2 << endl;
    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

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

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);


    int n, m;
    cin >> n >> m;
    int a[2000], b[2000];
    ll c[2000];

    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        c[i] = -c[i];
    }

    ll dist[1000];
    fill_n(dist, 1000, LLONG_MAX);
    dist[0] = 0;


    rep(i, n-1){
        rep(j, m){
            if(dist[a[j] - 1] == LLONG_MAX) continue;
            if(dist[b[j]-1] > dist[a[j]-1] + c[j])
                dist[b[j]-1] = dist[a[j]-1] + c[j];
        }
    }

    ll ans = dist[n-1];

    bool neg[1000];
    fill_n(neg, 1000, false);

    rep(i, n){
        rep(j, m){
            if(dist[a[j]-1] == LLONG_MAX) continue;
            if(dist[b[j]-1] > dist[a[j]-1] + c[j]){
                dist[b[j]-1] = dist[a[j]-1] + c[j];
                neg[b[j] - 1] = true;
            }
            if(neg[a[j]-1])
                neg[b[j]-1] = true;
        }
    }


    if(neg[n-1])
        ppp("inf");
    else
        ppp(-ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;




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

	set<string> s;

	rep(i, n) {
		string t;
		cin >> t;

		s.insert(t);
	}
	cout << s.size() << endl;

	return 0;
}


Measured memory_bytes: 15640
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2

#define INF ((1<<30)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
int n,x,a[105],ans;
int main(){
	scanf("%d%d",&n,&x);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (;ans<n&&x>=a[ans+1];) x-=a[++ans];
	if (x&&ans==n) ans--;
	printf("%d",ans);
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = read!(usize);
    let mut a: Vec<Vec<usize>> = Vec::new();
    for i in 0..2 {
        a.push(read![[usize]]);
    }
    let mut ans = 0;
    for i in 0..n {
        let s: usize =
            a[0].iter().take(i + 1).sum::<usize>() + a[1].iter().skip(i).take(n - i).sum::<usize>();
        if s > ans {
            ans = s;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1e9;

int main(){
  int D, N;
  cin >> D >> N;
  vector<int> T(D);
  for(int i = 0; i < D; ++i){
    cin >> T[i];
  }
  vector<int> A(N), B(N), C(N);
  for(int i = 0; i < N; ++i){
    cin >> A[i] >> B[i] >> C[i];
  }
  int M = *max_element(C.begin(), C.end())+1;
  vector<int> dp(M,-INF);
  for(int i = 0; i < M; ++i){
    for(int j = 0; j < N; ++j){
      if(T[0] < A[j] or T[0] > B[j]) continue;
      dp[C[j]] = 0;
    }
  }
  for(int i = 1; i < D; ++i){
    vector<int> dp_(M,-INF);
    for(int j = 0; j < N; ++j){
      if(T[i] < A[j] or T[i] > B[j]) continue;
      for(int k = 0; k < M; ++k){
        dp_[C[j]] = max(dp_[C[j]],dp[k]+abs(k-C[j]));
      }
    }
    dp = dp_;
  }
  cout << *max_element(dp.begin(), dp.end()) << endl;
}



Measured memory_bytes: 3136
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
ostream &operator<<(ostream &os, const pint &a) { os << "(" << a.fi << "," << a.se << ")"; return os; }
ostream &operator<<(ostream &os, const vector<int> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
vector<vector<int> > mat;
int ma[334][334];
lint mo=998244353;
lint zyo(lint x,lint y){
    lint ret=1,a=x;
    while(y>0){
    	if(y%2==1) ret=(ret*a)%mo;
    	a=(a*a)%mo;y/=2;
    }
    return ret;
}
int main()
{
	memset(ma,0,sizeof(ma));
	int n,m;
	cin>>n>>m;
	rep(i,n) rep(j,m) cin>>ma[i][j];
	if(n<m){
		rep(i,m) REP(j,i+1,m) swap(ma[i][j],ma[j][i]);
		swap(n,m);
	}
	rep(i,n){
		vector<int> cl(m,0);
		mat.pb(cl);
		rep(j,m) mat[i][j]=ma[i][j]%2;
	}
	//rep(i,n) cout<<mat[i]<<endl;
	//rep(i,n) rep(j,m) mat[i][j]%=2;
	int rank=0;
	rep(i,m){
		//if(rank>=m) continue;
		REP(j,rank,n){
			if(mat[j][i]>0) swap(mat[j],mat[rank]);
		}
		if(mat[rank][i]<1){
			continue;
		}
		rep(j,n){
			if(j==rank || mat[j][i]==0) continue;
			REP(k,i,m){
				//if(k<i) assert(mat[rank][k]==0);
				mat[j][k]+=mat[rank][k];mat[j][k]%=2;
			}
		}
		rank++;
	}
	//rep(i,n) cout<<mat[i]<<endl;
	//cout<<n<<m<<rank<<endl;
	//lint zyo=1;rep(i,rank) zyo=(zyo*2)%mo;zyo--;
	lint out=zyo(2,rank);out--;
	out*=zyo(2,m-1);out%=mo;
	out*=zyo(2,n-rank);out%=mo;
	cout<<out<<endl;
}


Measured memory_bytes: 1024
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl

using namespace std;
typedef long long int ll;
typedef string::const_iterator State;
typedef pair<int,int> P;
class ParseError {};
const ll INF=1LL<<50;
char fi[101][101];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
double EPS = 1e-14;
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003



int bow[353][353]={0};
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))
	return 0;
	return a+b;
}

/*struct P{
	double x,y;
	P(){}
		P(double x,double y):x(x),y(y){
		}
		P operator + (P p){
			return P(add(x,p.x),add(y,p.y));
		}
		P operator - (P p){
			return P(add(x,-p.x),add(y,-p.y));
		}
		P operator *(double d){
			return P(x*d,y*d);
		}
		double dot(P p){
			return add(x*p.x,y*p.y);
		}
		double det(P p){
			return add(x*p.y,-y*p.x);
		}
};

bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}

vector<P> convex_hull(P* ps, int n){
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> 	qs(n*2);
	
	rep(i,n){
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
			k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--){
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
		k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int n,m;
vector<double> p;
P ps[101];
*/
//char c[520][520];
long long mod=1000000007;
long long pow(ll i,ll j){
	ll tmp=1;
	while(j){
		if(j%2) tmp=tmp*i%mod;
		i=i*i%mod;
		j/=2;
	}
	return tmp;
}

int expression(State&);
int term(State&);
int factor(State&);
int number(State&);
int expression(State &begin){
	int ret = term(begin);
	
	for(;;){
		if(*begin == '+'){
			begin++;
			ret += term(begin);
		}
		else if(*begin == '-'){
			begin++;
			ret -= term(begin);
		}
		else
			break;
	}
	return ret;
}

int term(State &begin){
	int ret = factor(begin);
	
	for(;;){
		if(*begin=='*'){
			begin++;
			ret *= factor(begin);
		}
		else if(*begin=='/'){
			begin++;
			ret /= factor(begin);
		}
		else
			break;
	}
	return ret;
}

int factor(State &begin){
	int ret;
	if(*begin == '('){
		begin++;
		ret = expression(begin);
		begin++;
	}
	else
	ret = number(begin);
	
	return ret;

}

int number(State &begin){
	int ret =0;
	
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin - '0';
		begin++;
	}
	return ret;
}






int main(void){
	
	string s;
	
	cin>>s;
	set<char> st;
	bool f=false;
	for(int i=0;i<s.size();i++){
		if(st.count(s[i])==0){
		st.insert(s[i]);
		}
		else{
			f=true;
			break;
		}
	}
	
	if(!f)
		cout<<"yes"<<endl;
	else
		cout<<"no"<<endl;



	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  while (true) {
    int n; cin >> n;
    if (n == 0) break;
    int ans = 0;
    rep(i,n/4) {
      int a; cin >> a;
      ans += a;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3100
#Weather Prediction 141
#一日ごとにSunny、Cloudy、Rainy
#Sは Sunny, Cloudy, Rainy のいずれかである

S = input('')
print()

if S =="Sunny":
    print('Cloudy')
elif S =="Cloudy":
    print('Rainy')
elif S =="Rainy":
    print('Sunny')

Measured memory_bytes: 8908
import java.io.*;
import java.util.*;
public class Main{
	static void main() throws Exception{
		int n=sc.nextInt()
				;
		pw.println((1000-(n%1000))%1000);
	}
	public static void main(String[] args) throws Exception{
		sc=new MScanner(System.in);
		pw = new PrintWriter(System.out);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

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

//各桁の和を出す関数
int wa(int n){
    int sum = 0;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int total = 0;
    for(int i = 1; i <= N; i++){
        int sum = wa(i);
        if(sum >= A && sum <= B){
            total += i;
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<memory>
#include<vector>
#include<algorithm>

class UnionFind{
private:
	int n;
	std::unique_ptr<int[]> par, rank;
public:
	UnionFind(int n);
	int find(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};

UnionFind::UnionFind(int _n)
	:n(_n)
{
	this->par.reset(new int[n]);
	this->rank.reset(new int[n]);
	for(int i=0;i<n;i++){
		this->par[i] = i;
		this->rank[i] = 0;
	}
}

int UnionFind::find(int x){
	if(x == this->par[x]){
		return x;
	}
	return this->par[x] = find(par[x]);
}

void UnionFind::unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y){//すでに同じ
		return;
	}

	if(rank[x] < rank[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(rank[x] == rank[y]){
			rank[x]++;
		}
	}
}

bool UnionFind::same(int x, int y){
	return find(x) == find(y);
}

struct Edge{
	int from, to, cost;
};

bool comp(const Edge& l_edge, const Edge& r_edge){
	return l_edge.cost < r_edge.cost;
}

const int MAX_N = 100, MAX_M = 100;
const int INF = 1 << 24;

int kruskal(int V, std::vector<Edge> &ev){
		std::sort(ev.begin(), ev.end(), comp);
		UnionFind uf(V);
		int res = 0, ev_size = ev.size();
		for(int i=0;i<ev_size;i++){
			Edge e = ev[i];
			if(!uf.same(e.from, e.to)){
				uf.unite(e.from, e.to);
				res += e.cost;
			}
		}
		return res;
}

int main(){
	int n, m;
	int cost[MAX_N][MAX_N];
	while(std::cin >> n >> m, n){
		std::vector<Edge> ev;

		for(int i=0;i<MAX_N;i++){
			std::fill(cost[i], cost[i]+MAX_N, INF);
		}

		for(int i=0;i<m;i++){
			int a, b, c;
			std::cin >> a >> b >> c;
			Edge e = {a, b, c};
			ev.push_back(e);
		}

		std::cout << kruskal(n, ev) << std::endl;
	}
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int n;
vector<ll> a;

ll cnt1 = 0;
ll ans = 0;
ll super = 1;

int main(){
    cin >> n;
    a.resize(n);

    rep(i,n) cin >> a[i];



    rep(i,61){
        cnt1 = 0;


        rep(j,n){
            if(a[j] & (1ll << i)) cnt1++;
        }

        ans += ((cnt1 * (n - cnt1)) % 1000000007) * ((1ll << i) % 1000000007);
        ans %= 1000000007;

    }

    dunk(ans);
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int N;
	cin >> N;
	int x, y, b, p;
	int moneya;
	int moneyb;
	for (int i = 0; i < N; i++){
		cin >> x >> y >> b >> p;
		moneya = x*b + y * p;
		if (b >= 5 && p >= 2){
			moneya *= 0.8;
		}
		if (b <= 5){
			b = 5;
		}
		if (p <= 2){
			p = 2;
		}
		moneyb = x*b + y*p;
		moneyb *= 0.8;
		cout << min(moneya, moneyb) << endl;
	}
	return 0;
}

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

int main(){
	int n,k,p;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> k >> p;
		int a = k % p;
		if(!a)cout << p << endl;
		else cout << a << endl;
	}
	return 0;
}


Measured memory_bytes: 3112
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			if 500*i + 100*j + 50*k == x:
				count += 1
print(count)

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;
#define MAXN 202020
using namespace std;
vector<pair<int , pii>> tot;

vi pos;

vector<vi> t(2 , vi(2 * MAXN , INF));
int n;

void build(int par){
    for(int i = n - 1 ; i > 0 ; --i){
        t[par][i] = min(t[par][2 * i] , t[par][2 * i + 1]);
    }
}
 
void modify(int par , int p , int val){
    for(t[par][p += n] = val ; p > 1 ; p /= 2){
        t[par][p / 2] = min(t[par][p] , t[par][p ^ 1]);
    }
}
 
int query(int par , int l , int r){//[l , r)
    int res = INF;
    for(l += n , r += n ; l < r ; l /= 2 , r /= 2){
        if(l % 2){
            res = min(res, t[par][l]);
            ++l;
        }
        if(r % 2){
            --r;
            res = min(res , t[par][r]);
        }
    }
    return res;
}


map<int , vector<pii>> ans;

int last = 0;
map<int , pii> code;
map<pii , int> rcode;

vi g[MAXN];

void solve(vi & p , int l , int r , int k , int prev = -1){
	if(r - l < 1)return;
	if(r >= sz(p) || l < 0)return;
	if(r - l == 1){
		code[last] = {p[l] , p[r]};
		rcode[{p[l] , p[r]}] = last;
		if(prev != -1){
			g[prev].pb(last);
		}
		prev = last;
		++last;
	}else{
		pii o = {0 , 0};
		
		int par = l % 2;
		o.fi = query(par , l , r + 1);
		if(sz(tot) * 2 == sz(p))exit(0);
		int pos1 = pos[o.fi];
		o.se = query((pos1 + 1) % 2 , pos1 + 1 , r + 1);
		code[last] = o;
		rcode[o] = last;
		if(prev != -1){
			g[prev].pb(last);
		}
		prev = last;
		++last;
		

		int pos2 = pos[o.se];
		
		rep(q , 2){
			modify(q , pos1 , INF);
			modify(q , pos2 , INF);

		}

		solve(p , pos1 + 1 , pos2 - 1 , k - 1 , prev);
		solve(p , l , pos1 - 1 , k - 1 , prev);
		solve(p , pos2 + 1 , r , k - 1 , prev);
		
	}
}

vi restore(){
	vi res;
	priority_queue<pii , vector<pii> , greater<pii>> q; 
	q.push(code[0]);
	while(!q.empty()){
		pii u = q.top();
		q.pop();
		res.pb(u.fi);
		res.pb(u.se);
		
		for(int c : g[rcode[u]]){
			q.push(code[c]);
		}
	}
	return res;
}

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


	cin >> n;
	
	pos.resize(n + 1);
	
	vi p(n);
	rep(i , n){
		cin >> p[i];
		pos[p[i]] = i;
		int par = i % 2;
		t[par][n + i] = p[i];
		t[par ^ 1][n + i] = INF;
	}

	
	build(0);
	build(1);
	
	solve(p , 0 , n - 1 , INF);
	
	for(int e : restore()){
		cout << e << " ";
	}
	
	return 0;
}

Measured memory_bytes: 40916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
 
 
int main() {
 
    int n;
    cn n;
 
    while(n){
 
    	int d=n%10;
    	n/=10;
    	if(d==7){
    		ct "Yes",nl;
    		return 0;
    	}
    }
 
 
    ct "No",nl;
    
 
 
 
 
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
#define sync ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 35001;
const int inf = 1e9 + 7;
const int MOD = 1e9 + 7;
const int P = 1e5 + 3;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
signed main() {
    sync;
#ifdef varex
    freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
#endif
    int n, k;
    cin >> n >> k;
    if (n >= 10) return cout << k, 0;
    cout << k + (10 - n) * 100 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
using namespace std;
ll maxi(ll a,ll b)
{
	if(a>=b)
	return a;
	else
	return b;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin>>x;
    if(x>=30)
    {
    	cout<<"Yes"<<endl;
    }
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3640
n = int(input())
flg = True
t, x, y = 0, 0, 0
for i in range(n):
    nt, nx, ny = map(int, input().split()) 
    dist = abs(x - nx) + abs(y - ny)
    dt = nt - t
    if dist > dt or (dist - dt) % 2 == 1:
        print("No")
        flg = False
        break
    t, x, y = nt, nx, ny
if flg == True:
    print("Yes")

Measured memory_bytes: 3064
def main():
  from sys import stdin
  import itertools
  N, M, Q = map(int, input().split())
  scores = [list(map(int, stdin.readline().split())) for _ in range(Q)]
  best = 0
  x = list(range(1, M+1))
  for y in itertools.combinations_with_replacement(x, N):
    target = sorted(list(y))
    sco = 0
    for score in scores:
      if target[score[1]-1] - target[score[0]-1] == score[2]:
      	sco += score[3]
    if sco > best:
      best = sco
      
  print(best)
main()

Measured memory_bytes: 68452
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int dp[101010];
int main() {
	int n, m;
	cin >> n >> m;
	vector<int>in(n);
	vector<int>e[101010];
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		e[x].pb(y);
		in[y]++;
	}

	stack<int>st;
	for (int i = 0; i < n; i++)if (!in[i])st.push(i);

	vector<int>ans;
	while (st.size()) {
		int i = st.top();
		st.pop();
		ans.pb(i);
		fore(x, e[i]) {
			in[x]--;
			if (!in[x])st.push(x);
		}
	}

	for (int i = 0; i < n-1; i++) {
		int cur = ans[i];
		fore(to,e[cur])dp[to] = max(dp[to], dp[cur] + 1);
	}
	
	int res = -1;
	for (int i = 0; i < n; i++) {
		res = max(res,dp[i]);
	}
	puts(res);

	return 0;
}

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

using namespace std;

int main() {
  int N; cin >> N;
  int a[101] = {};

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

  int ans=0;
  for (int i = 0; i < 101; i++) {
    if(a[i]) ans++;
  }

  cout << ans << endl;

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        String input = scanner.nextLine();

        String[] values = input.split(" ");
        int A = Integer.parseInt(values[0]);
        int B = Integer.parseInt(values[1]);
        int C = Integer.parseInt(values[2]);

        int x = A - B;
        int answer;
        if (x <= C) {
            answer = C - x;
        } else {
            answer = 0;
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 22996
fn run_length_encoding<T: Clone + Eq>(a: &[T]) -> Vec<(T, usize)> {
    if a.len() == 0 {
        return vec![];
    }
    let mut x = a[0].clone();
    let mut cnt = 1;
    let mut ans = vec![];
    for y in &a[1..] {
        if x == *y {
            cnt += 1;
        } else {
            ans.push((x, cnt));
            x = y.clone();
            cnt = 1;
        }
    }
    ans.push((x, cnt));
    ans
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let s: Vec<char> = s.trim().chars().collect();
    let a = run_length_encoding(&s);
    let mut ans = a.iter().fold(0, |s, a| s + a.1 * (a.1 + 1) / 2);
    for i in 1..a.len() {
        if a[i - 1].0 == '<' && a[i].0 == '>' {
            ans -= std::cmp::min(a[i - 1].1, a[i].1);
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 12528
#include<stdio.h>

int gcd(int x,int y){
    int tmp;
    
    while( x%y != 0){
        tmp = y;
        y = x%y;
        x = tmp;
    }
    return y;
}

void swap(int *a, int *b){
    int tmp;
    
    tmp = *b;
    *b = *a;
    *a = tmp;
}

int main(void){
    int a, b;
    scanf("%d %d", &a, &b);
    
    if(a < b) swap(&a, &b);
    
    printf("%d\n", gcd(a,b));
    
    return 0;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

void update(vector<vector<mint>> &dp, int index, int now){
  rep(i, 13){
    int nx = (i*10 + now) % 13;
    dp.at(index+1).at(nx) += dp.at(index).at(i);
  }
}

int main(){
  string s;
  cin >> s;
  vector<vector<mint>> dp(s.size()+1, vector<mint>(13, 0));
  dp.at(0).at(0) = 1;
  rep(i, s.size()){
    if(s.at(i) == '?'){
      rep(j, 10){
        update(dp, i, j);
      }
    }else{
      int now = s.at(i) - '0';
      update(dp, i, now);
    }
  }
  cout << dp.at(s.size()).at(5).x << endl;
  return 0;
}

Measured memory_bytes: 16616
#!/usr/bin/env python
# coding: utf-8

# In[67]:


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


# In[68]:


taste = list(range(L, N+L))


# In[69]:


choice_index = list(map(abs, taste)).index(min(list(map(abs, taste))))
del taste[choice_index]
print(sum(taste))


# In[ ]:






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

typedef long long ll;
typedef long double lxd;
typedef vector<ll> vll ;
 
#define INF 1e10 ;
#define mem(dp,a) memset(dp,a,sizeof dp)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) ;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define fo(i,n,x) for (ll i=x;i<=n  ;i++)
#define mp(a,b) push_back(make_pair(a,b))
#define pb(x) push_back(x)
#define make_graph(a,b) adj[a].pb(b) ; adj[b].pb(a);
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t; cin>>t; label: while(t--)
#define fls fflush(stdout)
#define F first
#define S second

main(){
    ll k ;
    cin>>k  ;
    ll s = 0 ;
    fo(i,k,1){
        fo(j,k,1){
            ll x = __gcd(i,j) ;
            fo(z,k,1){
                s += __gcd(x, z) ;
            }
        }
    }
    cout<<s ;
}

Measured memory_bytes: 3592
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 1e8;
    int n = s.size(), m = t.size();
    for(int i = 0; i <= n-m; i++) {
        string a = s.substr(i, m);
        int cou = 0;
        rep(i, m) if(a[i] != t[i]) cou++;
        ans = min(cou, ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;

namespace ABC052 {
    class Program {
        const int N=1000000000;
        static Dictionary<int, int> dic;
        static void Main(string[] args) {
            dic = new Dictionary<int, int>();

            int n = int.Parse(Console.ReadLine());
            ulong num = 1;
            for(int i = 1; i <= n; i++) {
                divNum(i);
            }
            foreach(KeyValuePair<int,int> item in dic) {
               // Console.WriteLine(item.Key + " " + item.Value);
                num *= (ulong)(item.Value+1);
                num = num % (N + 7);
            }
            Console.WriteLine(num%(N+7));
        }
        static void divNum(int n) {
            int div = 2;
            while (true) {
                if (n == 1) {
                    break;
                }
                if (n % div == 0) {
                    if (!dic.ContainsKey(div)) {
                        dic[div] = 0;
                    }
                    dic[div]++;
                    n /= div;
                } else {
                    div++;
                }
            }
        }
    }
}


Measured memory_bytes: 3160
#include<stdio.h>
#include<string.h>

int main(void)
{
	int n;
	char s[101];
	int i;
	int ans=0;
	
	scanf("%d%s",&n,s);
	
	if(n%2==1)
		ans=1;
	
	for(i=0;i<n/2;i++){
		if(s[i]!=s[i+n/2])
			ans=1;
	}
	
	if(ans==0)
		printf("Yes");
	else
		printf("No");
	
	return 0;
}

Measured memory_bytes: 128