akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define bit(x) (1LL << x)
#define PI acos(-1.0)
#define EPS 1e-9

#define mod 1000000007
#define maxn 200005

using namespace std;

using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///All indexing is 0-based
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

typedef long long ll;
typedef double ld;
typedef pair<ll, ll> par;

ll N;

string s, s1;

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> s >> s1;

    s1.pop_back();

    if(s == s1)
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto& e:c)
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); ++it)

ll const inf = 1<<28;
double const pi = acos(-1);

int a[1024];
int d[1024*1024];

// 整数二分探索,
// int res=l;
// for(int d=(inf); d; d>>=1) if(res+d <= r && ok(res+d)) res += d;
// すると間違えない. (n回目)
int solve(int n, int k){
    int c=0;
    rep(i,n)loop(j,i,n){
        int s=a[i]+a[j];
        if(s<=k){
            d[c++]=s;
        }
    }

    sort(d,d+c);
    int ans=0;
    rep(i,c){
        int s1=d[i];
        int l=0, r=c;
        int res=l;
        for(int w=r-l;w;w>>=1){
            bool ok;
            if(res+w>=r) ok=false;
            else{
                int s2=d[res+w];
                ok=(s1+s2<=k);
            }
            if(res+w<r && ok) res+=w;
        }
        ans=max(ans, s1+d[res]);

        // int s1=d[i];
        // int l=0, r=c;
        // while(l+1<r){
        //     int mid=(l+r)>>1;
        //     int s2=d[mid];
        //     if(s1+s2>k){
        //         r=mid;
        //     }else{
        //         l=mid;
        //     }
        // }
        // int s2=d[l];
        // ans=max(ans, s1+s2);
    }
    return ans;
}

int main(){
    int n,k;
    while(cin>>n>>k && n|k){
        a[0]=0;
        rep(i,n)cin>>a[i+1];
        n++;
        cout << solve(n,k) << endl;
    }
}

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


	int a=0;
    int b=0;
  	int c=0;
  	int d=0;
  	int e=0;
	int ans=0;
	int er=0;
	
		scanf("%d%d%d%d%d", &a,&b,&c,&d,&e);

		if (a == 0&&b==2&&c==3&&d==4&&e==5) {
			ans = 1;
          er=1;
		}
  		if (a == 1&&b==0&&c==3&&d==4&&e==5) {
			ans = 2;
          er=1;
		}
  		if (a == 1&&b==2&&c==0&&d==4&&e==5) {
			ans = 3;
          er=1;
		}
  		if (a == 1&&b==2&&c==3&&d==0&&e==5) {
			ans = 4;
          er=1;
		}
  		if (a == 1&&b==2&&c==3&&d==4&&e==0) {
			ans = 5;
          er=1;
		}

  
  if(ans>0){
	printf("%d",ans);
  }
	if(er==0){
      printf("error");
    }
  
	return 0;
}

Measured memory_bytes: 1680
abcde = [int(input()) for i in range(5)]
k = int(input())
flag = False
for i in range(5):
    for j in range(5):
        if abcde[i] - abcde[j] > k:
            flag = True
            break
if flag:
    print(':(')
else:
    print('Yay!')


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

using namespace std;

typedef long long int64;
const int mod = 1e9 + 7;


int N, C, A[400], B[400];
int64 mat[401][401];

int main()
{

  cin >> N >> C;
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i < N; i++) cin >> B[i];

  for(int i = 0; i < N; i++) {
    for(int k = A[i]; k <= B[i]; k++) {
      int64 ret = 1;
      for(int j = 0; j <= C; j++) {
        (mat[i][j] += ret) %= mod;
        (ret = ret * k) %= mod;
      }
    }
  }

  vector< int64 > curr(C + 1, 0);
  curr[0] = 1;
  for(int i = 0; i < N; i++) {
    vector< int64 > next(C + 1, 0);
    for(int j = 0; j <= C; j++) {
      for(int k = 0; k <= j; k++) {
        (next[j] += curr[j - k] * mat[i][k]) %= mod;
      }
    }
    curr.swap(next);
  }

  cout << curr[C] << endl;
}


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

int main(void)
{
	char S[27];
	int i, j;
	int flag = 0;

	scanf("%s", &S);

	for(i = 0; i < strlen(S) - 1; i++) {
		for(j = i + 1; j < strlen(S); j++) {
			if(S[i] == S[j]) {
				printf("no");

				return 0;
			}
		}
	}
	printf("yes");

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int main(){
	double x1,x2,x3,y1,y2,y3,xp,yp;
	double g1,g2,g3,g4;
	double p,q;
	
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
		g1 = ((xp-x1)*(y3-y1))-((yp-y1)*(x3-x1));
		g2 = ((x2-x1)*(yp-y1))-((y2-y1)*(xp-x1));
		g3 = ((x2-x1)*(y3-y1))-((x3-x1)*(y2-y1));
		p = g1/g3;
		q = g2/g3;
		if(p>0&&q>0&&p+q<1)
		printf("YES\n");
		else
		printf("NO\n");
	}
}

Measured memory_bytes: 3104
#include <stdio.h>
int main(void){
    
    double r;
    double x, y, p = 3.14159265359;
    scanf("%lf\n", &r);
    
    x = p * r * r;
    y = 2 * p * r;
    
    printf("%.6lf %.6lf\n", x, y);
    
    return 0;
}


Measured memory_bytes: 2044
#include <stdio.h>
#include <math.h>

int gcd(int x, int y) {
  int tmp, r;
  if(x < y) {
    tmp = x;
    x = y;
    y = tmp;
  }

  while(y) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

int main(void) {
  int W, H, C, S = 0;

  scanf("%d %d %d", &W, &H, &C);

  S = (W*H) / pow(gcd(W, H), 2);

  printf("%d\n", C*S);
  
  return 0;
}



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

typedef long long ll;
const int MOD = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());

  bool flag = false;
  int res = 0;
  for(int i = 1; i < N; i++){
    if(a[i] == a[i-1]){
      if(flag){
	res += 2;
	flag = false;
      }else{
	flag = true;
      }
    }
  }
  if(flag){
    res += 2;
  }
  cout << N - res << endl;
}


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

int main()
{
  int N;
  cin >> N;
  long long ans = 0;
  for (int i = 1; i <= N; i++)
  {
    if (i % 3 == 0 || i % 5 == 0)
    {
      continue;
    }
    ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
n=(input())
if n[-1] == '2' or n[-1]== '4' or n[-1]== '5' or n[-1]== '7' or n[-1]=='9':
    print('hon')
elif n[-1] == '0' or n[-1]=='1' or n[-1]=='6' or n[-1]=='8':
    print('pon')
elif n[-1]=='3':
    print('bon')

Measured memory_bytes: 9124
n = int(input())
a = list(map(int, input().split()))

sums = 0
for x in a:
    sums ^= x

blu = set()
remain = set(range(n))

for i in range(61)[::-1]:
    if (sums >> i) & 1 == 0:
        di = -1
        for j in remain:
            if (a[j] >> i) & 1 == 1:
                di = j
                break
        if di != -1:
            blu.add(di)
            remain.remove(di)
            for j in range(n):
                if j != di and (a[j] >> i) & 1 == 1:
                    a[j] = a[j] ^ a[di]
bsum = 0
for i in blu:
    bsum = bsum ^ a[i]
print(bsum + (sums ^ bsum))


Measured memory_bytes: 84384
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int a, b;
	cin >> a >> b;
	if (a <= b) cout << a << endl;
	else cout << a - 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
set<pii>sts,ps;
ll h,w,n,cnt[11];
int main()
{ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    cin>>h>>w>>n;
    for(int i=1;i<=n;i++){
        int x,y;cin>>x>>y;ps.insert({x,y});
        for(int xa=0;xa<3;xa++){
            for(int ya=0;ya<3;ya++){
                int nx=x-xa,ny=y-ya;
                if(nx<=0||ny<=0||nx+2>h||ny+2>w)continue;
                sts.insert({nx,ny});
            }
        }
    }
    ll lef=(h-2)*(w-2);
    for(auto el:sts){
        int c=0;
        int x=el.first,y=el.second;
        for(int xa=0;xa<3;xa++){
            for(int ya=0;ya<3;ya++){
                c+=ps.count({x+xa,y+ya});
            }
        }
        cnt[c]++;
        lef--;
    }
    cnt[0]=lef;
    for(int i=0;i<10;i++)cout<<cnt[i]<<'\n';
    return 0;
}


Measured memory_bytes: 50492
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



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

    string n;
    cin>>n;
    int sum=0;
    rep(i,n.size()){
        sum+=(n[i]-'0');
    }
    if(sum%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3768
program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n,ans
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) n,m
    if(n>=m/2)then
        ans=m/2
    else
        b=m-2*n
        ans=n+b/4
    end if
    write(*,*)ans

    stop
end program sample
  



Measured memory_bytes: 2856
N,Q = map(int, input().split())
s = input()
cnt_ac = [0]*N

for i in range(N-1):
    if s[i]=="A" and s[i+1]=="C":
        cnt_ac[i+1] = 1
for i in range(1, N):
    cnt_ac[i] += cnt_ac[i-1]
# print(cnt_ac)

for _ in range(Q):
    l,r = map(lambda x:int(x)-1, input().split())
    print(cnt_ac[r] - cnt_ac[l])

Measured memory_bytes: 7668
#include <stdio.h>
#include <string.h>
#include <vector>

int main()
{
	long long int X;
	scanf("%lld", &X);

	std::vector<long long int> list;
	for (long long int i = 0; i <= 1000; i++) {
		long long int t = (i * i);
		t = t * t * i;
		list.push_back(t);
	}

	auto pow5 = [](long long int x) {
		return x * x * x * x * x;
	};
	for (int a = 0; a < list.size(); a++) {
		for (int b = 0; b < list.size(); b++) {
			if (list[a] - list[b] == X) {
				printf("%d %d\n", a, b);
				return 0;
			}
			else if (list[a] + list[b] == X) {
				printf("%d %d\n", a, -b);
				return 0;
			}
		}
	}

	return 0;
}


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

int main()
{

	long long int a, b, c, d;
	cin >> a >> b >> c >> d;

	vector<long long int> gari(4);
	gari[0] = max(a, b) * max(c, d);
	gari[1] = min(a, b) * min(c, d);
	gari[2] = max(a, b) * min(c, d);
	gari[3] = min(a, b) * max(c, d);

	cout << *max_element(gari.begin(), gari.end());
	return 0;
}


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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	ll n,sum=0;map<ll,int> m;cin>>n; ll a; repi(i,n) {cin>>a;m[a]++;sum+=a;}
		
	
	ll b,c;
	int test1;cin>>test1;while(test1--){ 
		cin>>b>>c;
		if(m[b]) {sum+=(c-b)*m[b];m[c]=m[c]+m[b];m[b]=0;}
		db(sum);
	 }
	 //*/
return 0;
}



Measured memory_bytes: 9328
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = long.Parse(spl[0]);
        var b = long.Parse(spl[1]);
        var n = long.Parse(spl[2]);

        if(n >= b - 1) {
            var x = b - 1;
            return (a * x) / b;
        } else {
            var x = n;
            return (a * x) / b - a * (x / b);
        }
    }

}


Measured memory_bytes: 27448
#include <bits/stdc++.h>
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;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll n; cin >> n;
    n--;
    vector<int> v;
    while (n >= 0) {
        v.push_back(n % 26);
        n /= 26;
        n--;
    }
    reverse(all(v));
    for (int x: v) cout << (char)('a' + x);
    cout << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 N;
  cin >> N;
  dynarr<i64> H(N);
  rep(i,0,N) cin >> H[i];
  reverse(all(H));
  i64 ans = 0;
  i64 cnt = 0;
  i64 now = 1e18;
  rep(i,0,N) {
    if(now > H[i]) {
      now = H[i];
      ans = max(ans, cnt);
      cnt = 0;
    }
    else {
      now = H[i];
      cnt++;
    }
  }
  cout << max(ans , cnt) << endl;
}


Measured memory_bytes: 1024
MOD=10**9+7
def gcd(x,y):
  if(x<y) :
    z=y
    y=x
    x=z
  if(y==0):
    return x
  return gcd(x%y,y)

def lcm(x,y):
  return x//gcd(x,y)*y

n=int(input())
a=list(map(int,input().split()))
l=1
for x in a:
  l=lcm(l,x)

ans=0
for x in a:
  ans += l//x
print(ans%MOD)


  

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	string s;
	cin >> s;
	
	for (char& c : s) {
		if (c == '?') {
			c = 'D';
		}
	}

	cout << s << endl;

	return 0;
}


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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, m, x;
    cin >> n >> m >> x;
    int a[n][m];
    int c[n];
    for(int i = 0; i < n; i++) {
        cin >> c[i];
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 1e18;
    for(int i = 0; i < (1<<n); i++) {
        vi b(m);
        int cost = 0;
        for(int j = 0; j < n; j++) {
            if((1<<j)&i) {
                for(int k = 0; k < m; k++) {
                    b[k] += a[j][k];
                }
                cost += c[j];
            }
        }
        bool cantake = 1;
        for(int k = 0; k < m; k++) {
            cantake &= (b[k] >= x);
        }
        if(cantake) {
            ans = min(ans, cost);
        }
    }
    if(ans == 1e18) {
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    int T; int P; int R;
    int t; int p; int ti; String m;
    int[] rank;

    void run(){
	while(sc.hasNext()){
	    T = sc.nextInt();
	    P = sc.nextInt();
	    R = sc.nextInt();
	    if(T!=0) solve();
	}
    }

    void solve(){
	Team[] team = new Team[T];
	rank = new int[T];
	for(int i=0; i<T; i++){
	    team[i] = new Team(i+1, P);
	    rank[i] = i;
	}

	while(R>0){
	    R--;
	    t = sc.nextInt();
	    p = sc.nextInt();
	    ti = sc.nextInt();
	    m = sc.next();
	    team[t-1].doLog(p, ti, m);
	}

	sort(team);

	for(int i=0; i<team.length; i++){
	    System.out.println(team[rank[i]].getID()+" "+team[rank[i]].getCorrect()
			       +" "+team[rank[i]].getTime());
	}
    }

    void sort(Team[] team){
	for(int i=0; i<rank.length-1; i++){
	    for(int j=i+1; j<rank.length; j++){
		int a = team[ rank[i] ].getCorrect();
		int b = team[ rank[j] ].getCorrect();
		if(a < b){
		    int temp = rank[i];
		    rank[i] = rank[j];
		    rank[j] = temp;
		}
		else if(a == b){
		    int t1 = team[rank[i]].getTime();
		    int t2 = team[rank[j]].getTime();
		    if(t1 > t2){
			int temp = rank[i];
			rank[i] = rank[j];
			rank[j] = temp;
		    }
		    else if(t1 == t2){
			int i1 = team[rank[i]].getID();
			int i2 = team[rank[j]].getID();
			if(i1 > i2){
			    int temp = rank[i];
			    rank[i] = rank[j];
			    rank[j] = temp;
			}
		    }
		}
	    }
	}
    }

    class Team{
	int id;
	int correct;
	int time;
	int[] pena;
	boolean[] pro;

	Team(int i, int p){
	    id = i;
	    correct = 0;
	    time = 0;
	    pena = new int[p+1];
	    pro = new boolean[p+1];
	}

	void doLog(int p, int t, String m){
	    if(m.equals("WRONG")){
		pena[p]++;
	    }
	    else {
		pro[p] = true;
		correct++;
		time += t+(pena[p]*1200);
	    }
	}
	int getID(){ return id; }
	int getCorrect(){ return correct; }
	int getTime(){ return time; }
    }
}

Measured memory_bytes: 62508
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;

vector <ll> s;
vector <ll> a;
ll n;

void build(int id = 1,int l = 0,int r = n){
	if(r - l < 2){	//	l + 1 == r
		s[id] = a[l];
		return ;
	}
	int mid = (l+r)/2;
	build(id * 2, l, mid);
	build(id * 2 + 1, mid, r);
	s[id] = max(s[id * 2],s[id * 2 + 1]);
}

int sum(int x,int y,int id = 1,int l = 0,int r = n){
	if(x >= r or l >= y)	return 0;
	if(x <= l && r <= y)	return s[id];
	int mid = (l+r)/2;
	return max(sum(x, y, id * 2, l, mid),
	       sum(x, y, id * 2 + 1, mid, r));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	a.resize(n);
	s.resize(n*4,0);
	for (int z=0;z<n;z++){
		cin >> a[z];
	}
	build();
	for (int z=0;z<n;z++){
		cout << max(sum(0,z),sum(z+1,n)) << endl;
	}
}

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

int main()
{
    int n,ans=0;
    char s[101];
    int i;

  	cin >> n;
    for(i=0;i<n;i++){
        cin >> s[i]; 
       // cout << s[i] << endl;
        if(s[i]=='Y'){
            ans++;
            break;
        }
    }

    if(ans>0){
        cout << "Four" << endl;
    }else{
        cout << "Three" << endl;
    }

}

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

int A,B,C,D,E,F;
double cur;
int sugar,sugar_water;

void calc(int a,int b, int c, int d){
    int sw = 100*A*a+100*B*b+C*c+D*d;    
    int w = 100*A*a+100*B*b;
    int s = C*c+D*d;
    if(w == 0) return;
    if(sw > F) return;

    if((w/100)*E >= s){
          if(cur < (double)(100*s)/(sw)){
            cur =  (double)(100*s)/(sw);
            sugar = s;
            sugar_water = sw;
        }
    }
}

int main(){
    cin>>A>>B>>C>>D>>E>>F;
    cur = 0;
    sugar = sugar_water = 0;

    for(int a=0; a<=30; a++){
        for(int b=0; b<=30; b++){
            for(int c=0; c<=100; c++){
                for(int d=0; d<=100; d++){
                    calc(a,b,c,d);
                }
            }
        }
    }

    if(cur == 0) sugar_water = 100*A;

    cout<<sugar_water<<" "<<sugar<<endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

template<class T>inline bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }


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

	const lint k = 'A' - 'a';

	string in[3]; cin >> in[0] >> in[1] >> in[2];
	char out[4] = { in[0][0] + k,in[1][0] + k ,in[2][0] + k, 0 };
	co(out);
	gc();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cassert>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
using namespace std;


#define N 100

int n;
int fa[N], fa2[N], deg[N];
vector <int> ve[N], ve2[N];
bool ok[N];

void dfs2(int k, int f) {
	fa2[k] = f;
	for (int i = 0; i < (int) ve2[k].size(); i++)
		if (ve2[k][i] != f) {
			dfs2(ve2[k][i], k);
		}
}

void dfs(int k, int f) {
	fa[k] = f;
	for (int i = 0; i < (int) ve[k].size(); i++)
		if (ve[k][i] != f) {
			dfs(ve[k][i], k);
		}
}

int calc(int r) {
	for (int i = 1; i <= n; i++)
		ok[i] = false;
	dfs2(r, 0);
	dfs(r, 0);

	ok[r] = true;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++)
			if (ok[fa[j]] && fa[j] == fa2[j])
				ok[j] = true;
	}	
	for (int i = 1; i <= n; i++)
		deg[i] = 0;
	for (int i = 1; i <= n; i++)
		deg[fa[i]]++;
	int op = 0;
	for (int i = 1; i <= n; i++) {
		int k = -1;
		for (int j = 1; j <= n; j++)
			if (!ok[j] && !deg[j] && ok[fa2[j]]) {
				k = j;
				break;
			}
		if (k == -1) {
			break;
		}
		op++;
		ok[k] = true;
		deg[fa[k]]--;
	}
	for (int i = 1; i <= n; i++)
	if (!ok[i])
		return 1e9;
	return op;
}


int calc2(int r1, int r2) {
	for (int i = 1; i <= n; i++)
		ok[i] = false;
	dfs2(r2, 0);
	dfs(r1, 0);

	for (int i = 1; i <= n; i++)
		deg[i] = 0;
	for (int i = 1; i <= n; i++)
		deg[fa[i]]++;
	int op = 0;
	ok[0] = true;
	for (int i = 1; i <= n; i++) {
		int k = -1;
		for (int j = 1; j <= n; j++)
			if (!ok[j] && !deg[j] && ok[fa2[j]]) {
				k = j;
				break;
			}
		if (k == -1) {
			break;
		}
		op++;
		ok[k] = true;
		deg[fa[k]]--;
	}
	for (int i = 1; i <= n; i++)
	if (!ok[i])
		return 1e9;
	return op;
}

int main() {
	int T;
	scanf("%d", &T);
	while (T--) {
		scanf("%d", &n);
		for (int i = 1; i <= n; i++)
			ve[i].clear(), ve2[i].clear();
		for (int i = 1; i < n; i++) {
			int a, b;
			scanf("%d%d", &a, &b);
			ve[a].push_back(b);
			ve[b].push_back(a);
		}
		for (int i = 1; i < n; i++) {
			int a, b;
			scanf("%d%d", &a, &b);
			ve2[a].push_back(b);
			ve2[b].push_back(a);
		}
		int ans = 1e9;
		for (int root = 1; root <= n; root++) {
			ans = min(ans, calc(root));
		}
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				ans = min(ans, calc2(i, j));

		printf("%d\n", ans == 1000000000 ? -1 : ans);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Node{
    int key;
    Node *prev,*next;
} *nil;

void insert(int key){
	Node *x = new Node;
	x->key = key;
	x->prev = nil;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
}
Node *listSearch(int key){
	Node *cur = nil->next;
	while(cur!=nil && cur->key!=key)
		cur = cur->next;
	return cur;
}
void deleteNode(Node *t){
	if(t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	delete t;
}
void deleteFirst(){
	deleteNode(nil->next);
}
void deleteLast(){
	deleteNode(nil->prev);
}
void deleteKey(int key){
	deleteNode(listSearch(key));
}
void pp(){
	Node *cur = nil->next;
	while(cur!=nil){
		printf("%d",cur->key);
		cur = cur->next;
		if(cur==nil) putchar('\n');
		else putchar(' ');
	}
}
int main(){
    nil = new Node;
	nil->next = nil;
	nil->prev = nil;
	
	int t,key;
	char cmd[15];
	scanf("%d",&t);
	while(t--){
		scanf("%s",cmd);
		if(!strcmp(cmd,"delete")){
			scanf("%d",&key);
			deleteKey(key);
		}
		else if(!strcmp(cmd,"insert")){
			scanf("%d",&key);
			insert(key);
		}
		else if(cmd[6]=='F') deleteFirst();
		else deleteLast();
	}
	pp();
    return 0;
}


Measured memory_bytes: 34468
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

const int N = 1e6;


int32_t main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n , k;
    cin >> n >> k;
    int a[n];
    int s = 0;
    for(int i = 0 ; i < n ; i++) cin >> a[i];
    sort(a, a + n);
    for(int i = 0 ; i < k ; i++) s += a[i];
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 3660
import heapq

H,W=map(int,input().split())

mat=[]
for i in range(H):
  array=[x=='.' for x in input()]
  mat.append(array)
#print(mat)

#convert mat to graph
#(i0,j0)->(i1,j1,dist)
graph={}
if mat[0][0]:
  graph[(0,0)]=[(1,1,0)]
else:
  graph[(0,0)]=[(1,1,1)]
  
for i in range(H):
  for j in range(W):
    graph[(i+1,j+1)]=[]
    if mat[i][j]:
      if i<H-1:
        if mat[i+1][j]:
          graph[(i+1,j+1)].append((i+2,j+1,0))
        else:
          graph[(i+1,j+1)].append((i+2,j+1,1))
      if j<W-1:
        if mat[i][j+1]:
          graph[(i+1,j+1)].append((i+1,j+2,0))
        else:
          graph[(i+1,j+1)].append((i+1,j+2,1))
    else:
      if i<H-1:
        graph[(i+1,j+1)].append((i+2,j+1,0))
      if j<W-1:
        graph[(i+1,j+1)].append((i+1,j+2,0))
#print(graph)

# init used,queue,dist
dist={}
hq=[]
dist[(0,0)]=0
heapq.heappush(hq,(0,0,0))
for i in range(1,H+1):
  for j in range(1,W+1):
    dist[(i,j)]=10**9
    heapq.heappush(hq,(i+j,i,j))
#print(queue)

#dkjstra
while(True):
  if len(hq)==0:
    break

  ij,ii,jj=heapq.heappop(hq)
  
  candlist=graph[(ii,jj)]
  for cand in candlist:
    xx,yy,dd=cand
    dist[(xx,yy)]=min(dist[(xx,yy)],dist[(ii,jj)]+dd)
  
print(dist[(H,W)])

Measured memory_bytes: 54492
#include<iostream>
using namespace std;
int main(){
string a;
  cin>>a;
  int f=1;
  for(int i=0;i<3;i++)
  {
    if(a[i]==a[i+1]){
    f=0;
      break;
    }
  }
  if(f==0)
    cout<<"Bad";
  else
    cout<<"Good";
}

Measured memory_bytes: 3596
f [] = True
f ('A':[])    = True
f ('A':'B':s) = f ('B':s)
f ('A':'D':s) = f ('D':s)
f ('A':_)     = False

f ('B':[])    = True
f ('B':'A':s) = f ('A':s)
f ('B':'C':s) = f ('C':s)
f ('B':'E':s) = f ('E':s)
f ('B':_)     = False

f ('C':[])    = True
f ('C':'B':s) = f ('B':s)
f ('C':'F':s) = f ('F':s)
f ('C':_)     = False

f ('D':[])    = True
f ('D':'A':s) = f ('A':s)
f ('D':'E':s) = f ('E':s)
f ('D':'G':s) = f ('G':s)
f ('D':_)     = False

f ('E':[])    = True
f ('E':'B':s) = f ('B':s)
f ('E':'D':s) = f ('D':s)
f ('E':'F':s) = f ('F':s)
f ('E':'H':s) = f ('H':s)
f ('E':_)     = False

f ('F':[])    = True
f ('F':'C':s) = f ('C':s)
f ('F':'E':s) = f ('E':s)
f ('F':'I':s) = f ('I':s)
f ('F':_)     = False

f ('G':[])    = True
f ('G':'D':s) = f ('D':s)
f ('G':'H':s) = f ('H':s)
f ('G':_)     = False

f ('H':[])    = True
f ('H':'G':s) = f ('G':s)
f ('H':'E':s) = f ('E':s)
f ('H':'I':s) = f ('I':s)
f ('H':_)     = False

f ('I':[])    = True
f ('I':'F':s) = f ('F':s)
f ('I':'H':s) = f ('H':s)
f ('I':_)     = False

main = do
  c <- getContents
  let i = lines c
      o = filter f i
  mapM_ putStrLn o

Measured memory_bytes: 4104
from sys import stdin
input = stdin.readline

n = int(input().rstrip())
a = list(map(int, input().rstrip().split()))

MOD = 1000000007
ans = 0

k = 0
s = [0] * n
for i in range(n-1, 0, -1):
    k += a[i] % MOD
    s[i] = k

for i in range(n-1):
    ans += a[i] * s[i+1]

ans = ans % MOD

print(ans)

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

from collections import defaultdict

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    s = [0]
    for x in a:
        s.append((s[-1] + x) % m)
    cnt = defaultdict(int)
    for i, v in enumerate(s):
        cnt[v] += 1
    res = 0
    for k, v in cnt.items():
        res += v * (v - 1) // 2
    print(res)

if __name__ == "__main__":
    main()


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

using namespace std;

int n;
long long xs[105], ys[105];
long long h[105];
int nonZeroIndex;
int main()
{
    while(cin >> n)
    {
        for(int i = 0; i < n; i++)
        {
            cin >> xs[i] >> ys[i] >> h[i];
            if(h[i])
                nonZeroIndex = i;
        }

        long long hi;
        bool found = 0;
        long long xRes, yRes, hiRes;
        for(long long curX = 0; curX <= 100 && !found; curX++)
        {
            for(long long curY = 0; curY <= 100 && !found; curY++)
            {
                hi = h[nonZeroIndex] + abs(xs[nonZeroIndex] - curX) + abs(ys[nonZeroIndex] - curY);
                if(hi < 1)
                    continue;
                for(int i = 0; i < n; i++)
                {
                    if(h[i] != max(hi - abs(xs[i] - curX) - abs(ys[i] - curY), 0LL))
                        break;

                    if(i + 1 == n)
                    {
                       xRes = curX, yRes = curY;
                       hiRes = hi;
                       found = 1;
                    }
                }

                if(found)
                    break;
                hi = h[nonZeroIndex] - abs(xs[nonZeroIndex] - curX) - abs(ys[nonZeroIndex] - curY);
                if(hi < 1)
                    continue;
                for(int i = 0; i < n; i++)
                {
                    if(h[i] != max(hi - abs(xs[i] - curX) - abs(ys[i] - curY), 0LL))
                        break;

                    if(i + 1 == n)
                    {
                       xRes = curX, yRes = curY;
                       hiRes = hi;
                       found = 1;
                    }
                }
            }
        }

        cout << xRes << " " << yRes << " " << hiRes << endl;
    }
    return 0;
}


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

int main() {
	int n;
	cin>>n;
	int x[n];
	int n4=0,n2=0,nx=0;
	for(int i=0;i<n;i++){
		cin>>x[i];
		if(x[i]%4==0)n4++;
		else if(x[i]%2==0)n2++;
		else nx++;
	}
	bool q;
	if(n2%2==1){
		nx++;
		n2--;
	}
	if(nx>n4+1)q=false;
	else q=true;
	if(q==false){
		cout<<"No";
	}else cout<<"Yes";
	return 0;
}

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


int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  ll cnt=0;
  rep(i,0,n) cin >> a[i];
  rep(i,0,n){
    rep(j,i,n){
      rep(k,j,n){
        if((a[i]!=a[j])&&(a[j]!=a[k])&&(a[k]!=a[i])){
          if((a[i]<a[j]+a[k])&(a[j]<a[i]+a[k])&(a[k]<a[j]+a[i])){
            cnt++;
//            cout << a[i] << ' ' << a[j] << ' ' << a[k] << endl;
            }
        }

      }
    }
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3572
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] cmd=br.readLine().split(" ");
		int n=Integer.valueOf(cmd[0]);
		int m=Integer.valueOf(cmd[1]);
		int[] h=new int[n+1];
		cmd=br.readLine().split(" ");
		HashMap<String,Integer> map=new HashMap<>();
		for(int i=0;i<n;i++)
		{
			h[i+1]=Integer.valueOf(cmd[i]);
		}
		ArrayList<Integer>[] g=new ArrayList[n+1];
		for(int i=0;i<n+1;i++)
		{
			g[i]=new ArrayList<>();
		}
		for(int i=0;i<m;i++)
		{
			cmd=br.readLine().split(" ");
			int x=Integer.valueOf(cmd[0]);
			int y=Integer.valueOf(cmd[1]);
			if(map.containsKey(x+" "+y) || map.containsKey(y+" "+x))
				continue;
			g[x].add(y);
			g[y].add(x);
			map.put(x+" "+y,1);
			map.put(y+" "+x,1);
		}
		int ans=0;
		int[] status=new int[n+1];
		Arrays.fill(status,1);
		for(int i=1;i<=n;i++)
		{
			if(status[i]==0)
				continue;
			for(int j=0;j<g[i].size();j++)
			{
				if(h[i]>=h[g[i].get(j)])
					status[g[i].get(j)]=0;
				if(h[i]<=h[g[i].get(j)])
				{
					status[i]=0;
					break;
				}
			}
		}
		for(int i=1;i<=n;i++)
		{
			if(status[i]==1)
			{
				ans++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 98944
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion

#pragma region Combination
const int MAX = 2002002;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
#pragma endregion

int main()
{
	COMinit();
	int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
	ll res = COM(r2 + c2 + 2, r2 + 1) - 1 + MOD;
	res -= (COM(r1 + c2 + 1, r1) - 1);
	res -= (COM(r2 + c1 + 1, c1) - 1);
	res += (COM(r1 + c1, r1) - 1);
	res %= MOD;
	cout << res << endl;
}

Measured memory_bytes: 47104
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
int mypow(int b, int n) {
    if (n <= 0) return 1;
    if (n == 1) return b;
    if (n % 2 == 0) {
        return mypow(b * b, n / 2);
    } else {
        return mypow(b, n - 1) * b;
    }
}

int main()
{
ll ans,h,w,k,aa;
ll mo=1000000007;
cin >> h>>w>>k;
ll dp[h+1][w]={};
dp[0][0]=1;
ll id[w][3]={};
ll idd[8]={1,2,3,5,8,13,21,34};

if(w==1){
    ans=1;
}
else{

//0から2^d乗まで
for (int bit = 0; bit < (1<<w-1); ++bit) {
    bool ng=1;
    
//各ビットを下から見ていく
     rep(j,w-1){

//jビット目が1なら処理を行う
        if(bit>>j&1){
            if(j!=w-2&&bit>>(j+1)&1){ng=0;}
        }
    }
    rep(j,w-1){

//jビット目が1なら処理を行う
        if(bit>>j&1&&ng){
            id[j][2]++;
            id[j+1][1]++;
        }
    }
}
rep(i,w){
    id[i][0]=idd[w-1]-id[i][2]-id[i][1];
}

rep(i,h)rep(j,w){
    if(j==0){
        dp[i+1][j]=(dp[i+1][j]+dp[i][j]*id[j][0])%mo;
        dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j]*id[j][2])%mo;
    }
    else if(j==w-1){
        dp[i+1][j]=(dp[i+1][j]+dp[i][j]*id[j][0])%mo;
        dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j]*id[j][1])%mo;
    }
    else{
        dp[i+1][j]=(dp[i+1][j]+dp[i][j]*id[j][0])%mo;
        dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j]*id[j][2])%mo;
        dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j]*id[j][1])%mo;
    }
}
ans=dp[h][k-1];
}
/* 
for (int i = 0; i < w; ++i) {
    cout << id[i][0] << " ";
}cout  << endl;
for (int i = 0; i < w; ++i) {
    cout << id[i][1] << " ";
}cout  << endl;
for (int i = 0; i < w; ++i) {
    cout << id[i][2] << " ";
}cout  << endl; */

cout <<ans<< endl;
return 0;
}





Measured memory_bytes: 256
#include <string>
#include <iostream>

using namespace std;

int main()
{
    string S;
    
    while(true)
    {
        S = "";
        
        while(S == "")
        {
            getline(cin, S);
        }
        
        if(S == "END OF INPUT") { break; }
        
        int count_ = 0;
        
        for(int i = 0; i < S.size(); i++)
        {
            if(S[i] == ' ')
            {
                cout << count_;
                
                count_ = 0;
            }
            else
            {
                count_++;
            }
        }
        
        cout << count_ << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3180
import bisect
import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

n=input()
s=input()

l,r=0,0
for c in s:
    if c == '(':
        r += 1
    else:
        if r:
            r -= 1
        else:
            l += 1
res = "(" * l + s + ")" * r
print(res)

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

string S;

int main(){
	
	cin >> S;
	int num = count( S.begin(), S.end(), 'o' );
	cout<<700+num*100<<endl;
}




Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)998244353;
//}}}

ll nums[100001];
int main(){
  int N;
  cin >> N;
  rep(i, N){
    int D;
    cin >> D;
    if(i == 0){
      if(D != 0){
        cout << 0 << endl;
        return 0;
      }
    }
    nums[D]++;
  }

  if(nums[0] != 1){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  int num = 1;
  int i = 1;
  while(1){
    if(nums[i] == 0) {
      if(N == 1){
        ans = 1;
      }else{
        ans = 0;
      }
      break;
    }
    rep(j, nums[i]){
      ans *= nums[i - 1];
      ans %= mod;
    }
    num += nums[i];
    if(num == N) {
      break;
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}


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

    using namespace std;

    const int Nmax = 1e5+5;

    int x, y, i, n, cnt = 0, iset[Nmax];
    queue< pair<int,int> > q;
    multiset<int> edge[Nmax];
    bool active[Nmax];

    int main()
    {
       // freopen("input", "r", stdin);
        cin.sync_with_stdio(false);

        cin >> n;
        for(i=1; i<=2*(n-1); ++i)
        {
            cin >> x >> y;
            edge[x].insert(y);
            edge[y].insert(x);

            if(edge[x].count(y) == 2)
            {
                q.push({x,y});
              //  edge[x].erase(y);
                //edge[y].erase(x);
            }
        }

        for(i=1; i<=n; ++i) iset[i] = 1, active[i] = 1;

        while(!q.empty())
        {
            x = q.front().first;
            y = q.front().second;
            q.pop();
            if(!active[x] || !active[y] || edge[x].count(y) != 2) continue;

            edge[x].erase(y);
            edge[y].erase(x);

            ++cnt;
            if(edge[x].size() > edge[y].size()) swap(x, y);
            active[x] = 0;

            for(auto it : edge[x])
                {
                    edge[y].insert(it);
                    edge[it].insert(y);
                    edge[it].erase(x);

                    if(edge[y].count(it) == 2)
                    {
                        q.push({y, it});
                   //     edge[y].erase(it);
                      //  edge[it].erase(y);
                    }
                }
        }

        cout << (cnt == n-1 ? "YES\n" : "NO\n");

        return 0;
    }


Measured memory_bytes: 26496
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;

constexpr int IMAX = ((1<<30)-1)*2+1 ;
constexpr int INF = 100000000;
double EPS = 1e-10 ;

const int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31} ;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m,d,date = 3;
  while(1){
    date = 3 ;
    cin >> m >> d ;
    if(m == 0){
      break ;
    }
    for(int i = 0;i < m-1;++i){
      date += month[i] % 7 ;
    }
    date += d % 7 - 1 ;
    switch(date%7){
      case 0:
        cout << "Monday" << endl ;
        break;
      case 1:
        cout << "Tuesday" << endl ;
        break;
      case 2:
        cout << "Wednesday" << endl ;
        break;
      case 3:
        cout << "Thursday" << endl ;
        break;
      case 4:
        cout << "Friday" << endl ;
        break;
      case 5:
        cout << "Saturday" << endl ;
        break;
      case 6:
        cout << "Sunday" << endl ;
        break;
      default:
        break;
    }
  }
  return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    
    int index=0,cnt=0;
    vector<int>zero,one;
    if(s[0]=='0')one.push_back(0);
    rep(i,n){
        cnt=1;
        while(i<n-1){
            if(s[i]!=s[i+1])break;
            cnt++;
            i++;
        }
        if(s[i]=='0')zero.push_back(cnt);
        else one.push_back(cnt);
    }
    if(s[n-1]=='0')one.push_back(0);

    if(zero.size()==0){
        cout<<s.size()<<endl;
        return 0;
    }
    if(zero.size()<=k){
        cout<<s.size()<<endl;
        return 0;
    }


    int ref=one[0];
    rep(i,k)ref+=(one[i+1]+zero[i]);

    int ans=ref;
    for(int i=k;i<(int)zero.size();i++){
        ref-=(one[i-k]+zero[i-k]);
        ref+=(one[i+1]+zero[i]);
        ans=max(ans,ref);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1020
#個数が無制限のナップザックの問題(ただし、上限に注意)です(どの魔法を順番に選べば良いなどの制約がないのでナップザックDPを選択しました。)。
#dpの配列にはi番目の要素にモンスターの体力をi減らすために必要な最小の魔力を保存します。
#この配列は個数制限がないことに注意してinfではない要素のみを順に更新していけば良いです。
#また、最終的にモンスターの体力を最小の魔力で0以下にすれば良いので、モンスターの体力をh以上減らせる最小の魔力を求めれば良いです。

h,n=map(int,input().split())
a,b=[],[]
for i in range(n):
    a_sub,b_sub=map(int,input().split())
    a.append(a_sub)
    b.append(b_sub)
inf=10000000000000
ma=max(a)#ダメージの最大値

dp=[inf]*(h+1+ma)#与えるダメージの最大値を考慮したDP
dp[0]=0#初期値

for i in range(h+1+ma):# 与えるダメージ合計：0ーH+1+maまで
    if dp[i] == inf:#更新してきて、ダメージiになる組み合わせが存在しない場合は飛ばす
        continue
    for j in range(n):    #N個の魔法を試す
        ni = i + a[j] #今の状態から新しく与えた場合のダメージ合計
        if ni<h+ma:#オーバーキルの範囲を超えるなら、無視
            dp[ni] = min(dp[ni], dp[i] + b[j])        #ダメージniを与えるのにより小さい魔力で実現できる場合は更新
print(min(dp[h:]))


Measured memory_bytes: 41836
#072_b
s = input()
a = []
if s.islower() and 1 <= len(s) and len(s) <= 10 ** 5:
    b=""
    for n in range(len(s)):
        if n % 2 == 0:
            a.append(s[n])
    for m in range(len(a)):
        b=b+a[m]
    print(b)


Measured memory_bytes: 9388
#include <stdio.h>

int Area(int x, int y);
int Length4(int x, int y);

int main(void) {
    
    int a;
    int b;
    
    do {
        scanf("%d %d", &a, &b);
    } while ((a < 1 || a > 100) || (b < 1 || b > 100));
    
    printf("%d %d\n", Area(a, b), Length4(a, b));
}

int Area(int x, int y) {
    return x * y;
}

int Length4(int x, int y) {
    return x * 2 + y * 2;
}


Measured memory_bytes: 2052
#AtCorder Begginer Contest 161 Christmas Eve
import numpy as np
N,K= map(int, input().split())
Tree_List= [int(input()) for i in range(N)]
Tree_List=np.array(sorted(Tree_List))
Answer=min(Tree_List[K-1:]-Tree_List[:-(K-1)])
print(Answer)

Measured memory_bytes: 17904
import math
"nの約数列挙"
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass

"nの素因数分解"
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


import collections
N = int(input())
A = prime_factor(N)
A.sort()
c = collections.Counter(A)
ans = 0
for x in c.values():
  count = 1
  while x > 0:
    x -= count
    if x >= 0:
      count +=1
      ans += 1

print(ans)



Measured memory_bytes: 9744