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

int main() {
  int N;
  cin >> N;
  vector<int>a(N), b(N), c(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i);
  }
  vector<vector<int>>dp(N, vector<int>(3));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      dp.at(i).at(j) = 0;
    }
  }
  dp.at(0).at(0) = a.at(0);
  dp.at(0).at(1) = b.at(0);
  dp.at(0).at(2) = c.at(0);
  if (N >= 2) {
    for (int i = 1; i < N; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          if (j != k) {
            if (j == 0) {
              dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i-1).at(k) + a.at(i));
            }
            else if (j == 1) {
              dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i-1).at(k) + b.at(i));
            }
            else {
              dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i-1).at(k) + c.at(i));
            }
          }
        }
      }
    }
  }
  cout << max(dp.at(N-1).at(0), max(dp.at(N-1).at(1), dp.at(N-1).at(2)));
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}



int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    int Y = 1e9;
    for(int i=0; i<N-1; i++) {
        Y = min(Y, gcd(A[i], A[i+1]));
    }
    cout << Y << endl;
}

Measured memory_bytes: 3680
#include<cstdio>
#include<cstring> 
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=1e6+5;
int k,n,a[maxn],dmax;
int main(){
	scanf("%d %d",&k,&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		dmax=max(dmax,a[i]-a[i-1]);
	}
	dmax=max(dmax,a[1]+k-a[n]);
	//int ans=min(a[n]-a[1],k-a[2]+a[1]);
	printf("%d\n",k-dmax);
	return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n;
	while(scanf("%d", &n), n){
		unsigned s = 0, p;
		vector<unsigned> j(n - 1);
		for(int i = 0; i < n; ++i){
			scanf("%u", &p);
			s += p;
		}
		for(int i = 0; i < n - 1; ++i){
			scanf("%u", &j[i]);
		}
		sort(j.begin(), j.end());

		unsigned ans = s * n;
		for(int i = n - 2; i >= 0; --i){
			s += j[i];
			ans = max(ans, s * (i + 1));
		}
		printf("%u\n", ans);
	}
}

Measured memory_bytes: 1308
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string s, t; cin >> s >> t;
    int sum = 0;
    rep(i,s.size()) {
        sum += (s.at(i) == t.at(i));
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

int n,s;
int saiki(int n1,int u,int m){
    if(n1 > s) return 0;
    else if(m==1){
	int d = s-n1;
	if(d <= 9 && (u & (1<<d))==0) return 1;
	else return 0;
    }else if(m==2){
	if(s-n1>26) return 0;
    }
    int ans;
    for(int i=9;i>=0;i--){
	if((u & (1<<i))==0){
	    ans += saiki(n1+m*i,u|(1<<i),m-1);
	}
    }
    return ans;
}

void main(){
    while(true){
	auto ss = readln();
	if(stdin.eof()) break;
	int[] s1 = ss.split().to!(int[]);
	n = s1[0];
	s = s1[1];
	if(n <= 330)
	    writeln(saiki(0,0,n));
	else writeln(0);
    }
}

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

int main()
{
    int a, b, cost;  
    cin >> a >> b;
    if(a<6)
        cost = 0;
    else if(a<13)
        cost = b / 2;
    else
        cost = b;

    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
typedef long long goo;
using namespace std;
goo read(){
    char ch;
    goo input = 0, num = 1;
    do{
        ch = getchar();
        if(ch == '-') num=-1;
    }
    while(ch < '0' or ch > '9');
    while(ch >= '0' and ch <= '9'){
        input = input * 10 + ch - '0';
        ch = getchar();
    }
    return input * num;
}
goo gcd(goo x,goo y)
{
	if(x%y==0) return y;
	else return (gcd(y,x%y));
}
int main()
{
    goo n=read(),T=1,A=1;
    for(int i=1;i<=n;i++){
        goo t=read(),a=read();
        goo num=max((T+t-1)/t,(A+a-1)/a);
        T=t*num,A=a*num;
    }
    goo res=T+A;
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  vector<vector<int>> ans(h, vector<int>(w));
  int num = 1;
  rep(i, h) rep(j, w) {
    if (s[i][j] == '#') {
      for (int l = j; l >= 0; l--) {
        if (ans[i][l])
          break;
        ans[i][l] = num;
      }
      for (int l = j+1; l < w; l++) {
        if (s[i][l] == '#')
          break;
        ans[i][l] = num;
      }
      num++;
    }
  }
  for (int i = 1; i < h; i++) rep(j, w) {
    if (!ans[i][j])
      ans[i][j] = ans[i-1][j];
  }
  for (int i = h-2; i >= 0; i--) rep(j, w) {
    if (!ans[i][j])
      ans[i][j] = ans[i+1][j];
  }
  rep(i, h) rep(j, w)
    cout << ans[i][j] << (j+1<w?' ':'\n');
  return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

double dst(double x1, double y1, double x2, double y2)
{
   return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

ll gcd(ll a, ll b)
{
   return b == 0 ? a : gcd(b, a % b);
}
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, x[8] = {}, y[8] = {};
   double d[8][8] = {};
   double ans = 0;
   cin >> n;
   FOR(i, 0, n)
   cin >> x[i] >> y[i];

   FOR(i, 0, n)
   FOR(j, 0, n)
   {
      ans += dst(x[i], y[i], x[j], y[j]);
   }
   ans /= n;
   printf("%.6lf\n", ans);

   return 0;
}


Measured memory_bytes: 384
n =int(input())
a = list(map(int,input().split()))
b = []
x = {}
def fx(x) :
    ans = 0
    for i in range(1,x):
        ans += i
    return ans
for i in a :
    if i in x :
        x[i] += 1
        if x[i] == 2:
            b.append(i)
    else :
        x[i] = 1
anskari = 0
for i in b :
    anskari += fx(x[i])
for i in a :
    if x[i] == 1:
        print(anskari)
    else :
        print(anskari - x[i] +1)

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

struct mint {
    long long x;
    mint(long long 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;
    }
    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;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    ll n,k; cin >> n >> k;

    vector<mint> dp(k+1);
    mint ans = 0;
    RREP(d,1,k+1){
        mint x = mint(k/d).pow(n);
        for(int di=d; di<k+1; di+=d){
            x -= dp[di];
        }
        dp[d] = x;
        ans += mint(d) * x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4060
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		
		int[] A = new int[n];
		for(int i = 0; i < n; i++){
			A[i] = scan.nextInt();
		}
		Print(A, n);
		Sort(A, n);
		
	}
	
	public static void Print(int A[], int n){
		for(int i = 0; i < n; i++){
			if(i > 0){
				System.out.print(" ");
				
			}
			System.out.print(A[i]);
		}
		System.out.println();
	}
	
	public static void Sort(int A[], int n){
		int v = 0;
		int j = 0;
		for(int i = 1; i < n; i++){
			v = A[i];
			j = i -1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			Print(A,n);
		}
	}

}

Measured memory_bytes: 34024
N,K=map(int,input().split())
p=list(map(int,input().split()))
ans=0
temp=0
for i in range(K):
    temp+=(1+p[i])/2
ans=temp
for j in range(N-K):
    temp=temp-(1+p[j])/2+(1+p[j+K])/2
    if temp>ans:
        ans=temp
print(ans)

Measured memory_bytes: 24812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 3050;
int r,c,k,x,y,val;
ll dp[MAX][MAX][4];
ll room[MAX][MAX];
int main() {
    cin>>r>>c>>k;
    while(k--){
        cin>>x>>y>>val;
        room[x][y]=val;
    }
    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            for(int k=1;k<=3;k++){
                dp[i][j][k]=max(max(room[i][j]+dp[i-1][j][3],dp[i][j-1][k]),room[i][j]+dp[i][j-1][k-1]);
            }
        }
    }
    cout<<dp[r][c][3];
    return 0;
}


Measured memory_bytes: 360956
#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
int main(){
  int n; cin>>n;
  vector<vector<P>> num(n);
  
  for(int i=0;i<n;i++){
    int a; cin>>a;
    for(int j=0;j<a;j++){
      int x,y; cin>>x>>y;
      num[i].push_back(P(x-1,y));
    }
  }
  
  int ans=0;
  for(int bit=0;bit<(1<<n);bit++){
    bool flag=true;
    int c=0;
    
    for(int i=0;i<n;i++){
      if(bit & (1<<i)){
        c++;
        
        for(int j=0;j<num[i].size();j++){
          if(bit & (1<<num[i][j].first)){
            if(num[i][j].second==0){
              flag=false;
              break;
            }
          }else{
            if(num[i][j].second==1){
              flag=false;
              break;
            }
          }
        }
      }
      
    }
    
    if(flag){
       ans=max(c,ans);
    }
    
  }
  
  cout<<ans<<endl;
}       

Measured memory_bytes: 256
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    int N,K;
    cin >> N >> K;
    ll res=K;
    rep(i,1,N){
        res*=(K-1);
    }
    COUT(res);
}

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

int int_sort(const void *a, const void *b) {
  if( *(int *)a > *(int *)b ) {
    return -1;
  }else if( *(int *)a == *(int *)b ) {
    return 0;
  }
  return 1;
}

int main(){
  int n;
  scanf("%d", &n);
  int i;
  int a[n];
  int used[n];
  for(i=0;i<n;i++){
    used[i] = 0;
    scanf("%d", &a[i]);
  }
  qsort(a, n, sizeof(int), int_sort);
  int ans = 0;
  long long int max = 1;
  while(max <= a[0]){
    max = max * 2;
  }
  int j = n - 1;
  for(i=0;i<n;i++){
    if(used[i] == 1){
      continue;
    }
    while(a[i] < max / 2){
      max = max / 2;
      j = n - 1;
    }
    while(a[j]<=max-a[i] && i<j){
      if(a[j] == max-a[i] && used[j] == 0){
        ans++;
        //used[i] = 1;
        used[j] = 1;
        j--;
        break;
      }
      j--;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2556
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include <string>
using namespace std;

void split(string s, vector<string> &v){
    v.clear();
    s +='"';
    string str="";
    for(int i=0;i<s.size();i++){
        if(s[i]=='"'){
            v.push_back(str);
            str="";
        }
        else{
            str+=s[i];
        }
    }
}
int main(){
    while(1){
        string s1,s2; cin >>s1;
        if(s1==".")break;
        cin >> s2;
        if(s1==s2){
            cout << "IDENTICAL"<< endl;
        }
        else{
            vector<string> v1,v2;
            split(s1,v1);
            split(s2,v2);
            if(v1.size()!=v2.size()){
                cout << "DIFFERENT" << endl;
            }
            else{
                bool a=false;
                int cnt=0;
                for(int i=0;i<v1.size();i++){
                    if(i%2==0){
                        if(v1[i]!=v2[i])a=true;
                    }
                    else{
                        if(v1[i]!=v2[i])cnt++;
                    }
                }
                if(a){
                    cout << "DIFFERENT" << endl;
                }
                else if(cnt>1){
                    cout << "DIFFERENT" << endl;
                }
                else{
                    cout << "CLOSE" << endl;
                }
            }
        }
    }
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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; }

typedef pair<int, int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S, T;
	cin >> S >> T;
	int N = SZ(S) + 1; 
	int M = SZ(T) + 1;
	auto dp = make_v<int>(N, M);
	auto pre = make_v<P>(N, M);
	fill_v<P>(pre,P(-1,-1));
	FOR(i, 1, N) {
		FOR(j, 1, M) {
			if (S[i - 1] == T[j - 1]) {
				if (dp[i][j] < dp[i - 1][j - 1] + 1) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
					pre[i][j] = P(i - 1, j - 1);
				}
				if (dp[i][j] < dp[i][j - 1]) {
					dp[i][j] = dp[i][j - 1];
					pre[i][j] = P(i, j - 1);
				}
				if (dp[i][j] < dp[i - 1][j]) {
					dp[i][j] = dp[i - 1][j];
					pre[i][j] = P(i - 1, j);
				}
			}
			else {
				if (dp[i][j] < dp[i][j - 1]) {
					dp[i][j] = dp[i][j - 1];
					pre[i][j] = P(i, j - 1);
				}
				if (dp[i][j] < dp[i - 1][j]) {
					dp[i][j] = dp[i - 1][j];
					pre[i][j] = P(i - 1, j);
				}
			}
		}
	}
	P p = pre[N - 1][M - 1];
	P cur = P(N - 1, M - 1);
	vector<char> V;
	while (p != P(-1, -1)) {
		int pf = p.first;
		int ps = p.second;
		int cf = cur.first;
		int cs = cur.second;
		if (dp[cf][cs] > dp[pf][ps]) {
			V.push_back(S[pf]);
		}
		cur = p;
		p = pre[pf][ps];
	}
	rev(V);
	REP(i, SZ(V)) {
		cout << V[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 106112
(declaim (optimize (debug 0) (safety 0) (speed 3)))
(defun blacken (grid queue1 queue2 cnt)
  (loop while (< 0 (length queue1)) do
        (loop
          with j = (vector-pop queue1)
          with i = (vector-pop queue1)
          for (a b) in '((0 1) (0 -1) (1 0) (-1 0)) do
            (if (< (1+ cnt) (aref grid (+ i a) (+ j b)))
              (progn
                (setf (aref grid (+ i a) (+ j b)) (1+ cnt))
                (vector-push-extend (+ i a) queue2)
                (vector-push-extend (+ j b) queue2)))))
  (if (= 0 (length queue2))
    cnt
    (blacken grid queue2 queue1 (1+ cnt))))

(defun main ()
  (let* ((h (read))
         (w (read))
         (grid (make-array (list (+ h 2) (+ w 2))
                           :initial-element 0))
         (queue (make-array 0 :fill-pointer 0 :adjustable t)))
    (loop for i from 1 to h do
          (loop for j from 1 to w
                for c in (concatenate 'list (read-line)) do
                (if (equal c #\.)
                  (setf (aref grid i j) 9999999)
                  (progn
                    (setf (aref grid i j) 0)
                    (vector-push-extend i queue)
                    (vector-push-extend j queue)))))
    (format t "~a~%" 
      (blacken grid
               queue
               (make-array 0 :fill-pointer 0 :adjustable t)
               0))))
(main)

Measured memory_bytes: 66020
#include<stdio.h>
int main(){
  int a,b,c,d,e,k,ans;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  scanf("%d",&e);
  scanf("%d",&k);
  
  ans = a + e;
               	
  if((b - a) <= k && (c - a) <= k &&(d - a)<=k && (e - a) <= k && (c - b) <= k && (d - b) <= k && (e - b) <= k && (d - c) <=k && (e - c) <= k && (e - d) <= k){
    printf("Yay!");
  }else{
    printf(":(");
  }
  return 0;
  
}



Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=60;
//↑templete
vint node[SIZE];
vpint pathes;
int used[SIZE][SIZE]={};
vpint edges;
int bitcount32(int dw32){
	dw32 = ((dw32 & 0xAAAAAAAA) >>  1) + (dw32 & 0x55555555);
	dw32 = ((dw32 & 0xCCCCCCCC) >>  2) + (dw32 & 0x33333333);
	dw32 = ((dw32 & 0xF0F0F0F0) >>  4) + (dw32 & 0x0F0F0F0F);
	dw32 = ((dw32 & 0xFF00FF00) >>  8) + (dw32 & 0x00FF00FF);
	dw32 = ((dw32 & 0xFFFF0000) >> 16) + (dw32 & 0x0000FFFF);
	return dw32;
}
bool DFS(int now, int to, int par, int num){	//各エッジがどの制約に使われているか？
	if(now==to)
		return 1;
	for(int next:node[now]){
		if(par==next)
			continue;
		if(DFS(next, to, now, num)){
			used[now][next]|=(1<<num);
			used[next][now]|=(1<<num);
			return 1;
		}
	}

	return 0;

}
signed main(){
	ll bi[SIZE]={1, 0};
	for(int i=1;i<SIZE;i++)
		bi[i]=2*bi[i-1];

	int N;
	cin>>N;

	for(int i=0;i<N-1;i++){
		int a, b;
		cin>>a>>b;
		a--, b--;
		node[a].eb(b);
		node[b].eb(a);
		edges.eb(a, b);
	}
	int M;
	cin>>M;
	for(int i=0;i<M;i++){
		int u, v;
		cin>>u>>v;
		u--, v--;
		pathes.eb(u, v);
		DFS(u, v, -1, i);
	}

	//制約の組み合わせを全探索
	ll ans=0;
	for(int state=0;state<(1<<M);state++){
		ll cnt=0;
		for(pint p:edges){
			int a, b;
			tie(a, b)=p;
			if(used[a][b]&state)	//選んだ制約のうち一つでも関係ある辺だったら
				cnt++;
		}
		if(bitcount32(state)%2)
			ans-=bi[N-1-cnt];
		else
			ans+=bi[N-1-cnt];
	}

	cout<<ans<<endl;

	return 0;
}

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

using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define PB(x, v) x.push_back(v);
#define M_P(a, b) make_pair(a, b)
#define pll pair<ll, ll>
#define ll long long
#define mll map<ll, ll>
#define vl vector<ll>
#define fa(x, v) for(auto x: v)
#define fr(i, a, b) for(int i= a;i <=b; i++)
#define TEST  ll Test; cin >> Test; while(Test--)

#define B_ begin()
#define E_ end()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define NL_ "\n"
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second

#define mod(a) a%1000000007
#define MAX 2000000000
#define  ull unsigned long long

void solve()
{
   ll a, b;
   cin>> a >> b;
   if(a< b) swap(a, b);
   ll r= a - b;
   if(!r) {cout << 0<<NL_; return ;}
   ll i =1;
   while(true)
   {
       ll t = i*(i+1)/2;
       if((t-r)%2==0 and t-r>=0)
       {
           cout << i <<NL_;
           return ;
       }
       i++;
   }
}

bool check(ll n)
{
    if(n==2)
        return 1;
    for(ll i = 2; i*i<=n; i++)
    {
        if(n%i==0)
            return 0;
    }
    return 1;

}

int main()
{

    FAST;
    string s;
    cin >> s;
    ll sum= 0;
    for(ll i=0; i< s.length(); i++) sum += s[i] - '0';
    if(sum%9) cout << "No";
    else cout <<"Yes";




    return 0;
}


Measured memory_bytes: 3784
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int N, K;
  cin >> N >> K;
  bool sunuke[N] = {};
  for(int i = 0; i < K; i++){
    int d;
    cin >> d;
    for(int j = 0; j < d; j++){
      int tmp;
      cin >> tmp;
      sunuke[tmp - 1] += 1;
    }
  }
  int count = 0;
  for(int i = 0; i < N; i++){
    if(!sunuke[i])  count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      String α = scan.next();
      
      if(Character.isUpperCase(α.charAt(0)))
        System.out.println("A");
      else
        System.out.println("a");
    }
}

Measured memory_bytes: 35588
using System;
using System.Linq;
using System.Collections.Generic;
    
class Program
{
    static void Main(string[] args)
    {
        string[] NMX = Console.ReadLine().Split(' ');
        int N = int.Parse(NMX[0]);
        int M = int.Parse(NMX[1]);
        int X = int.Parse(NMX[2]);

        int[] C = new int[N];
        int[,] A = new int[N,M];

        for(int i=0; i<N; i++) {
            string[] input = Console.ReadLine().Split(' ');
            C[i] = int.Parse(input[0]);
            for(int j=0; j<M; j++) {
                A[i,j] = int.Parse(input[j+1]);
            }
        }

        bool can = true;
        int Asum;
        for(int i=0; i<M; i++) {
            Asum = 0;
            for(int j=0; j<N; j++) {
                Asum += A[j,i];
            }
            if(Asum < X) {
                can = false;
                Console.WriteLine(-1);
                break;
            }
        }

        int Csum;
        int CsumMin = C.Sum();
        if(can) {
            for(int i=0; i<Math.Pow(2,N); i++) {
                can = true;

                string buyStr = Convert.ToString(i, 2).PadLeft(N, '0');
                
                for(int j=0; j<M; j++) {
                    Asum = 0;
                    for(int k=0; k<N; k++) {
                        Asum += A[k,j] * int.Parse(buyStr[k].ToString());
                    }
                    if(Asum < X) {
                        can = false;
                        break;
                    }
                }
                if(can) {
                    Csum = 0;
                    for(int j=0; j<N; j++) {
                        Csum += C[j] * int.Parse(buyStr[j].ToString());
                    }
                    if(Csum < CsumMin) {
                        CsumMin = Csum;
                    }
                }

            }
            Console.WriteLine(CsumMin);
        }        
    }
}

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

int main(){
    string input;
    cin >> input;
    bool ret = false;
    if (input[0] == 'A') {
        bool contains_one_C = false;
        int idx = -1;
        for(size_t i = 2; i < input.length()-1; i++)
        {
            if (input[i] == 'C') {
                if (!contains_one_C){
                    contains_one_C = true;
                    idx = i;
                }
                else {
                    contains_one_C = false;
                    break;
                }
            }
        }
        if (contains_one_C) {
            ret = true;
            for(size_t j = 0; j < input.length(); j++)
            {
                if (j != 0 && j != idx && input[j] >= 'A' && input[j] <= 'Z'){
                    ret = false;
                }
            }
        }
    }
    string ret_str = ret ? "AC" : "WA";
    cout << ret_str << endl;
        
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n;
    cin>>n;
    vector<int> a(n,0);
    rep(i,n) cin>>a.at(i);
    vector<int> b(n,0);
    rep(i,n) cin>>b.at(i);
    vector<int> c(n,0);
    rep(i,n) cin>>c.at(i);
    const in zero=0ll;
    sort(all(a));sort(all(b));sort(all(c));
    in ans=0ll;
    rep(i,n){
        in x=n-(in)(upper_bound(all(c),b[i])-c.begin());
        in y=(in)(lower_bound(all(a),b[i])-a.begin());
        if(x>0ll &&y>0ll) ans +=(x*y);
    }
    cout<<ans<<endl;
}

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

int main(){

    int n;
    int a,b;//bが桁の合計値
    cin>>n;
    a=n;
    while(a){
        b+=a%10;
        a/=10;
    }

    if(n%b==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;








    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[1000],b[1000],i=0,j=0,t,n;
  while(scanf("%d",&t)!=EOF){
    if(t!=0){
      a[i]=t;
      i++;
    }
    else if(t==0){
      i--;
      b[j]=a[i];
      j++;
    }
  }
  for(n=0;n<j;n++){
    printf("%d\n",b[n]);
  }
  return (0);
}

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

#define MAX_N 100000

#define pb push_back

#define xx first
#define yy second

using namespace std;

int n;

vector <pair<int, int>> g[MAX_N + 1];
vector <pair<int, int>> tata[MAX_N + 1];

int poz[MAX_N + 1];

bool viz[MAX_N + 1];
bool luat[MAX_N + 1];

void out()
{
    cout << "No\n";

    exit(0);
}

void add(int a, int b, int c)
{
    luat[b] = 1;

    g[a].pb({b, c});
}

void rev(int a, int b, int c)
{
    tata[a].pb({b, c});
}

void dfs(int a)
{
    viz[a] = 1;
    for(auto u : g[a])
    {
        if(viz[u.xx] == 0)
        {
            poz[u.xx] = poz[a] + u.yy;
            dfs(u.xx);
        }

        else
            if(poz[u.xx] != poz[a] + u.yy)
                out();
    }

    for(auto u : tata[a])
    {
        if(viz[u.xx] == 0)
        {
            poz[u.xx] = poz[a] - u.yy;
            dfs(u.xx);
        }

        else
            if(poz[u.xx] != poz[a] - u.yy)
                out();
    }
}

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

    int i;
    int a, b, c;
    for(i = 1; i <= m; i ++)
    {
        cin >> a >> b >> c;

        add(a, b, c);
        rev(b, a, c);
    }

    for(i = 1; i <= n; i ++)
        poz[i] = -1;

    for(i = 1; i <= n; i ++)
    {
        if(viz[i] == 0)
        {
            poz[i] = 0;
            dfs(i);
        }
    }


    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 14720
#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> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 pb push_back
#define pp 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;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout <<mp.size()<<endl;

    return 0;
}


Measured memory_bytes: 19236
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int Y = cin.nextInt();
        for (int a = 0; a <= N; a++)
        {
            for (int b = 0; a + b <= N; b++)
            {
                int c = N - a - b;
                if(a * 10000 + b * 5000 + c * 1000 == Y)
                {
                    Console.WriteLine($"{a} {b} {c}");
                    return;
                }
            }
        }
        Console.WriteLine("-1 -1 -1");
    }
    
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



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

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<int> A(N + 1), count(N + 1, 0);

    for(int i = 1; i <= N; i ++){
        cin >> A[i];

        if(0 <= i - A[i] && i - A[i] <= N){
            count[i - A[i]] ++;
        }
    }
    llint ans = 0;

    for(int i = 1; i <= N; i ++){
        if(0 <= i + A[i] && i + A[i] <= N){
            ans += count[i + A[i]];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
	
	public static void main(String[] args) throws IOException {
		new Main().input().solve().output();
	}
	
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//	InputUtil in = new InputUtil();
	PrintWriter out = new PrintWriter(System.out);
//	int n = 0;
	String s = null;
	boolean ans = false;
	public Main input() throws IOException {
		//n = Integer.parseInt(br.readLine());
//		n = in.nextInt();
		s = br.readLine();
		return this;
	}

	public Main solve() throws IOException {
		ans = s.startsWith("YAKI");
		return this;
	}
	
	public Main output() {
		out.println(ans ? "Yes" : "No");
		out.flush();
		return this;
	}
}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}


Measured memory_bytes: 22484
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define pai 3.141592653589793238462643383279

int main(){
  int k, n; cin >> k >> n;
  if(k%2==0){
    cout << k/2 << " ";
    rep(i, n-1){
      cout << k << " ";
    }
    cout << endl; return 0;
  }
  vector<int> ans;
  int modosi = n/2; int med = (k+1)/2;
  rep(i, n){
    ans.push_back(med);
  }
  while(modosi--){
    if(ans[ans.size()-1]==1){
      ans.pop_back(); continue;
    }
    ans[ans.size()-1]--;
    while(ans.size()<n){
      ans.push_back(k);
    }
  }
  rep(i, ans.size()){
    cout << ans[i]; cout << " ";
  }
  cout << endl;
}

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

int main() {
	ll n, k; cin >> n >> k;
	vector<ll>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	vector<ll>inans(n);
	for (int i = 0; i < n; i++) {
		if (i == n - 1) {
			inans.at(i) = 0;
			break;
		}
		else {
			ll x = a.at(i);
			ll ct = 0;
			for (int j = i + 1; j < n; j++) {
				if (x > a.at(j))ct++;
			}
			inans.at(i) = ct;
		}
	}
	vector<ll>loopans(n);
	for (int i = 0; i < n; i++) {
		ll ct = 0;
		for (int j = 0; j < n; j++) {
			if (i == j)continue;
			if (a.at(i) > a.at(j))ct++;
		}
		loopans.at(i) = ct;
	}
	ll ans = 0;
	for (int i = 0; i <= n - 1; i++) {
		ans += (ll) k * inans.at(i);
		ans %= 1000000007;
		ans += (ll)((k * (k - 1) / 2) % 1000000007) * (loopans.at(i));
		ans %= 1000000007;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
S = input()

N = len(S)

ans = True
for i in range(N//2):
    ans = ans and S[i]==S[N-1-i]

S1 = S[:N//2]
S2 = S[N//2+1:]
N2 = len(S1)

for i in range(N2//2):
    ans = ans and S1[i] == S1[N2-1-i]
    ans = ans and S2[i] == S2[N2-1-i]

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static final int MAX = 1000000;
	static int[][] dp = new int[2][MAX];
	
	// nを表す必要な正四面体の最小個数を返す
	static int Search(int k, int n){
		// 計算されている
		if(dp[k][n]!=-1){
			return dp[k][n];
		}
		// 再帰によりnを減らすので0の終了条件
		else if(n==0){
			return 0;
		}
		// 最大値で初期化
		int min = Integer.MAX_VALUE;
		// 1番目の正四面体から順にひたすら
		for(int i=1;;i++){
			// i 番目の正四面体における粒の数は j
			int j = i*(i+1)*(i+2)/6;
			// 求めたい整数より粒が多い
			if(j>n){
				break;
			}
			// 奇数判定時、正四面体の数が偶数
			else if(k==1&&j%2==0){
				continue;
			}
			// 再帰呼び出し
			// 　整数nからj個引いた整数において
			// 　　必要な正四面体の最小の個数を
			// 　　　Search(k,n-j)で呼び出す
			// 　　　　+1はその結果に対してj個足した
			// 　　　　　正四面体1個を意味する
			min = Math.min(min, Search(k,n-j)+1);
		}
		// 整数nの最小個数が求まったので登録
		dp[k][n] = min;
		// 最小値を返す
		return min;
	}
	
	static void dp(){
		// 整数 i を小さいのから順に
		// 　必要な正四面体の最小個数を調べる
		for(int i=0;i<MAX;i++){
			Search(0,i);
			Search(1,i);		// 奇数
		}
	}
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		for(int i=0;i<2;i++){
			Arrays.fill(dp[i], -1);
		}
		dp();
		while(true){
			int n = stdIn.nextInt();
			if(n==0){
				return;
			}
			System.out.println(dp[0][n]+" "+dp[1][n]);
		}
	}
}

Measured memory_bytes: 19000
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
//upper_bound is maximum index of an array element not greater than the given one
//lower bound is minimum index of an array element not less than the given one

#define N (int)1e6+10
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
#define endl "\n";
using namespace std;


void solve()
{	
	int n;
	cin>>n;
	int a[n];
	int b[n];
	for(int i=0;i<n;i++)
	{
	cin>>a[i];
	b[i]=a[i];
	}
	
	for(int i=n-2;i>=1;i--)
	{
		a[i]=a[i]+a[i+1];
	}
	
	int ans=0;
	
	for(int i=1;i<n;i++)
	{
		int q=mul(a[i],b[i-1]);
		ans=(q%mod+ans%mod)%mod;
	}
	cout<<ans<<endl;
}


signed main()
{
    
	nuenxfiu
	int t;
	//cin>>t;
	t=1;
	for(int i=1;i<=t;i++)
	{
	//cout<<"Case #"<<i<<": ";
	solve();
	}
     return 0;
}

Measured memory_bytes: 6684
import sys
input = sys.stdin.readline

n = int(input())
b = list(map(int,input().split()))

res = [-1]*n
#今考えている数列のindex、ないなら-1
ind = [i for i in range(1,n+1)]
#決定した数
cnt = 0
while cnt != n:
    #judge:変化があるか
    judge = False
    for i in range(n-1,-1,-1):
        if ind[i] == b[i]:
            ind[i] = -1
            res[n-1-cnt] = b[i]
            cnt += 1
            judge = True
            break
        else:
            ind[i] -= 1
    if not judge:
        print(-1)
        exit()
for e in res:
    print(e)

Measured memory_bytes: 3064
s = input()

s = s.replace('BC', 'X')
# print("#", s)

seqs = []
seq = ''
for si in s:
    if si in ('A', 'X'):
        seq += si
    else:
        seqs.append(seq)
        seq = ''
else:
    if len(seq) > 0:
        seqs.append(seq)
        seq = ''
        
ans = 0
for seq in seqs:
    Ni = len(seq)
    cnttab = [None] * Ni
    cnt = seq.count('X')
    for i, ci in enumerate(seq):
        if ci == 'X':
            cnt -= 1
        cnttab[i] = cnt
    # print("##", seq, cnttab)
    #
    for i, ci in enumerate(seq):
        if ci == 'A':
            ans += cnttab[i]

print(ans)

Measured memory_bytes: 6436
dx = [1,0,0,1, 1,1, 1,0, 0,1,-1, 1, 1]
dy = [0,1,0,1,-1,0, 0,1, 1,1, 1,-1, 1]
dz = [0,0,1,0, 0,1,-1,1,-1,1, 1, 1,-1]

def judge(B,x,y,z,color):
    for i in range(13):
        seq = B[z][y][x]
        nx,ny,nz = x+dx[i],y+dy[i],z+dz[i]
        while 0 <= min(nx,ny,nz) and max(nx,ny,nz) < n:
            seq += B[nz][ny][nx]
            nx += dx[i]; ny += dy[i]; nz += dz[i]
        nx,ny,nz = x-dx[i],y-dy[i],z-dz[i]
        while 0 <= min(nx,ny,nz) and max(nx,ny,nz) < n:
            seq = B[nz][ny][nx] + seq
            nx -= dx[i]; ny -= dy[i]; nz -= dz[i]
        if str(color)*m in seq: return True
    return False
    
while 1:
    n,m,p = map(int,raw_input().split())
    if n == 0: break
    B = [[["-"]*n for i in range(n)] for j in range(n)]
    isWin = False
    for move in xrange(p):
        x,y = map(int,raw_input().split())
        if isWin: continue

        x -= 1; y -= 1
        color = move%2
        for z in range(n):
            if B[z][y][x] == "-":
                B[z][y][x] = str(color)
                isWin = judge(B,x,y,z,color)
                break
        
        if isWin: print ["Black","White"][color],move+1
    if not isWin:
        print "Draw"

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

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    const ll size = s.size();
    const ll maximum = 1 << (size - 1);
    ll sumation = 0;
    for (ll i = 0; i < maximum; i++) {
        vector<string> vs(1);
        vs[0].push_back(s[0]);
        ll num = i;
        ll pos = 0;
        for (int j = 1; j < size; j++) {
            if (num % 2 == 1) {
                pos++;
                vs.push_back("");
            }
            vs[pos].push_back(s[j]);
            num /= 2;
        }
        ll sum = 0;
        for (const string& ss : vs) {
            sum += stoll(ss);
        }
        sumation += sum;
    }
    cout << sumation << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,Q = map(int,input().split())
graph = [[] for i in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

#print(graph)
v = [0]*N
for i in range(Q):
    p,x = map(int,input().split())
    v[p-1] += x

notv = [True]*N
notv[0] = False
stack = [0]

while stack:
    now = stack.pop()
    for i in graph[now]:
        if notv[i]:
            notv[i] = False
            stack.append(i)
            v[i] += v[now]

print(*v)

Measured memory_bytes: 92876
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <stdio.h>
using namespace std;

int main()
{
    stack<int> S1;
    stack<pair<int,int> > S2;
    int i=0,sum=0;
    char c;
    while((c=cin.get())!='\n'){
        if(c=='\\')S1.push(i);
        else if(c=='/' && S1.size()>0){
            int j=S1.top();
            S1.pop();
            sum+=i-j;
            int a=i-j;
            while(S2.size()>0&&S2.top().first>j){
                a+=S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,a));
        }
        i++;
    }

    cout<<sum<<endl;
    vector<int> ans;
    while(S2.size()>0){
        ans.push_back(S2.top().second);
        S2.pop();
    }
    cout<<ans.size();
    reverse(ans.begin(),ans.end());
    for(i=0;i<ans.size();i++){
        cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3200