akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader rd = new MyReader();        
        int N = rd.i();
        int[] P = rd.ii();
        int[] q = new int[N+1];
        for(int i = 0; i < N; i++)
            q[P[i]] = i + 1;

        long ans = 0;
        int[] l = new int[N+2];
        int[] r = new int[N+2];
        for(int i = 0; i < N+1; i++){
            l[i+1] = i;
            r[i] = i+1;
        }
        r[N+1] = N+1;

        for(int i = 1; i < N+1; i++){
            int v = q[i];
            int l1 = l[v];
            int r1 = r[v];
            long l2 = l[l1];
            long r2 = r[r1];
            ans += i*((v-l1)*(r2-r1) + (r1-v)*(l1-l2));
            l[r1] = l1;
            r[l1] = r1;
        }
        println(ans);
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 37460
import java.util.*;
import java.io.*;

public class Main {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer stok;

    String nextToken() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            stok = new StringTokenizer(s);
        }
        return stok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    char nextChar() throws IOException {
        return (char) (br.read());
    }

    String nextLine() throws IOException {
        return br.readLine();
    }

    void solve() throws IOException {
        String s = nextToken();
        if (s.startsWith("YAKI"))
        {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }

    void run() throws IOException {
        // br = new BufferedReader(new FileReader("dragons.in"));
        //out = new PrintWriter("dragons.out");
        // br = new BufferedReader(new FileReader("input.txt"));
        // out = new PrintWriter("output.txt");
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        br.close();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        // Locale.setDefault(Locale.US);
        new Main().run();
    }
}

Measured memory_bytes: 23124
def comb(n, k, p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n) % p
    b = factorial(k) % p
    c = factorial(n - k) % p
    return (a * power_func(b, p - 2, p) * power_func(c, p - 2, p)) % p


def power_func(a, b, p):
    """a^b mod p を求める"""
    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, p)
        return d * d % p
    if b % 2 == 1:
        return (a * power_func(a, b - 1, p)) % p


N, M, K = map(int, input().split())
mod = 10 ** 9 + 7
c = comb(N * M - 2, K - 2, mod)

sumx = 0
for d in range(1, M + 1):
    sumx += d * (M - d)
    sumx %= mod
sumx *= N
sumx %= mod
sumx *= N
sumx %= mod

sumy = 0
for d in range(1, N + 1):
    sumy += d * (N - d)
    sumy %= mod
sumy *= M
sumy %= mod
sumy *= M
sumy %= mod

ans = (((sumx + sumy) % mod) * c) % mod
print(ans)




Measured memory_bytes: 72924
# -*- coding:utf-8 -*-

N = int(input())
s = [int(input()) for i in range(N)]
s.sort()

sum = 0
for i in range(N):
	sum = sum + s[i]

check = 0
if sum % 10 != 0:
	print(sum)
else:
	for i in range(N):
		if s[i] % 10 != 0:
			print(sum - s[i])
			break
		else:
			check = check + 1

if check == N:
	print(0)



Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;


int main()
{
    int H, W;
    char a[1000][1000];
    int dp[1000][1000];
    cin >> H >> W;
    rep(i,H) rep(j,W) cin >> a[i][j];

    dp[0][0] = 1;
    for (int i = 1; i < H; ++i) {
        dp[i][0] = (dp[i-1][0] && a[i][0] == '.') ? 1 : 0;
    }
    for (int j = 1; j < W; ++j) {
        dp[0][j] = (dp[0][j-1] && a[0][j] == '.') ? 1 : 0;
    }

    for (int i = 1; i < H; ++i) {
        for (int j = 1; j < W; ++j) {
            if (a[i][j] == '.') {
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
            } else {
                dp[i][j] = 0;
            }
        }
    }

    cout << dp[H-1][W-1] << endl;

    return 0;
}


Measured memory_bytes: 5120
import heapq # 優先度付きキュー(最小値取り出し)
n,m = map(int, input().split())
a = [list(map(int,input().split())) for i in range(n)]
a.sort(reverse = True)
b = []
heapq.heapify(b)   # ヒープ化
ans = 0

for i in range(1,m+1):
    while a and a[-1][0] == i:
        val = a.pop()[1]
        heapq.heappush(b, (-1)*(val))           # 今考えてる日にちの価値をpush
    if b:
        val = heapq.heappop(b)*(-1)             # 最大値の取り出し
        ans += val
print(ans)

Measured memory_bytes: 74200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll n; cin >> n;
  printf("%d", n/3);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;



int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	ll n,m;
	cin >> n >> m;
	ll a = min(n,m/2);
	n -= a;
	m -= a*2;
	if(n == 0) {
		a += m/4;
	}
	cout << a << "\n";
}

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

int main() {
	int s1s2s3 , s1 , s2 , s3;
	cin >> s1s2s3 >> s1 >> s2 >> s3;
		s1 = s1s2s3 / 100;
		s2 = ( s1s2s3 - s1 * 100 ) /10;
		s3 = s1s2s3 - s1 * 100 - s2 * 10;
  		cout << s1 + s2 + s3 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	string s;
	ll ans{};
	cin>>s;
	while(!s.empty())
	{
		ans+=(s.back()-'0');
		s.pop_back();
	}
	(!(ans%9))?cout<<"Yes\n":cout<<"No\n";
	//system("pause");
	return 0;	
}

Measured memory_bytes: 3708
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

sum_dist = 0
cnt = 0
from itertools import permutations

for seq in permutations(a):
    cnt += 1
    for i in range(len(seq)-1):
        sum_dist += ((seq[i][0] - seq[i+1][0]) ** 2 + (seq[i][1] - seq[i+1][1]) ** 2)**0.5

print('{:.8f}'.format(sum_dist / cnt))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int n,m,dis[200005],l,r,d;
bool Error,f[200005];
struct edge {
	int to,cost;
	edge(int a=0,int b=0) {
		to=a;
		cost=b;
	}
};
vector<edge> path[200005];
void spfa(int x) {
	for(int i=0; i<path[x].size(); i++) {
		edge e=path[x][i];
		if(f[e.to])
			if(e.cost+dis[x]!=dis[e.to]) {
				Error=true;
				return;
			} else continue;
		f[e.to]=true;
		dis[e.to]=dis[x]+e.cost;
		spfa(e.to);
		if(Error) return;
	}
}
int main() {
	cin>>n>>m;
	for(int i=0; i<m; i++) {
		scanf("%d%d%d",&l,&r,&d);
		path[l].push_back(edge(r,d));
		path[r].push_back(edge(l,-d));
	}
	for(int i=0; i<n; i++) {
		dis[i]=0;
		if(!f[i]) {
			spfa(i);
			if(Error) break;
		}
	}
	if(!Error) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 13440
#include<iostream>

using namespace std;

int main(void)
{
  string w; cin>>w;
  int a[26]={0};
  int num;
  
  for(int i=0;i<w.size();i++){
    num=w[i]-'a';
    a[num]++;
  }
  
  for(int i=0;i<26;i++){
    if(a[i]%2!=0){puts("No"); return 0;}
  }
  
  puts("Yes");
  return 0;
}

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

int N;
string s;

int main() {
    cin >> N;
    int a = 0, un = 0;
    bool ng = false;
    rep(i,0,N) {
        cin >> s;
        if(s == "A") a++;
        else un++;

        if(a - un < 0) ng = true;
        // printf("a = %lld, un = %lld\n", a, un);
    }
    if(a != un) ng = true;
    cout << (ng ? "NO" : "YES") << endl;
    return 0;
}

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

ll modpow(ll x, ll n, ll mod) {
    ll r = 1;
    while (n > 0) {
        if (n & 1)
            r = r * x % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return r;
}

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

    ll n;
    cin >> n;
    vector<ll> d(n);
    rep(i, 0, n) cin >> d[i];
    if (d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<ll> e(n);
    rep(i, 0, n) e[d[i]]++;
    if (e[0] > 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    ll mod = 998244353;
    rep(i, 1, n) {
        if (e[i] > 0) {
            if (e[i - 1] != 0) {
                ans *= modpow(e[i - 1], e[i], mod);
                ans %= mod;
            } else {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)



int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int x = ((n - 1)*(n - 2)) / 2;
	if (k > x) {
		printf("-1\n");
		return 0;
	}
	vector<PII> ans;
	REP(i, n - 1) {
		ans.PB(MP(i, n - 1));
	}
	REP(i, n - 1) {
		if (x == k)break;
		FOR(j, i + 1, n - 1) {
			if (x == k)break;
			ans.PB(MP(i, j));
			x--;
		}
	}
	printf("%d\n", ans.size());
	for (auto e : ans) {
		printf("%d %d\n", e.first + 1, e.second + 1);
	}
	return 0;
}

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

const int inf = (int)1e9;

int main()
{
	int n, m, k;
	int ans = 0;
	vector<int> dist;
	vector<vector<pair<int, int> > > graph;
	vector<pair<pair<int, int>, int> > edge;
	
	scanf("%d%d%d", &n, &m, &k);
	dist.resize(n, inf);
	graph.resize(n);
	for(int i = 0; i < m; ++i) {
		int a, b, l;
		scanf("%d%d%d", &a, &b, &l);
		a -= 1, b -= 1;
		edge.push_back(make_pair(make_pair(a, b), l));
		graph[a].push_back(make_pair(b, l));
		graph[b].push_back(make_pair(a, l));
	}
	
	for(int i = 0; i < k; ++i) {
		
		int s;
		scanf("%d", &s);
		s -= 1;
		
		priority_queue<pair<int, int> > q;
		
		q.push(make_pair(0, s));
		
		while(!q.empty()) {
			
			int v = q.top().second;
			int c = -q.top().first;
			q.pop();
			
			if(dist[v] < c)
				continue;
			dist[v] = c;
			
			for(int i = 0; i < graph[v].size(); ++i) {
				int w = graph[v][i].first;
				int d = graph[v][i].second + c;
				q.push(make_pair(-d, w));
			}
		}
	}
	
	//for(int i = 0; i < n; ++i)
	//	printf("[debug] %d -> %d\n", i, dist[i]);
	
	for(int i = 0; i < m; ++i) {
		
		int a = edge[i].first.first;
		int b = edge[i].first.second;
		int l = edge[i].second;
		int cost;
		
		if(dist[a] > dist[b])
			swap(a, b);
		
		if(dist[a] + l == dist[b])
			cost = dist[b];
		else
			cost = (l - (dist[b] - dist[a]) + 1) / 2 + dist[b];
		ans = max(ans, cost);
		//printf("[debug] (%d, %d) -> (%d, %d) -> %d -> %d\n", a, dist[a], b, dist[b], l, cost);
	}
	
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 8016
fn main() {
    proconio::input! {
        n: usize,
        a: [usize; n]
    }

    let maxn: usize = 1000000;
    let mut dp: Vec<usize> = vec![0; maxn + 1];

    for i in (2..).take_while(|&x| x * x <= maxn) {
        if dp[i] != 0 { continue; }
        for j in (i..maxn).step_by(i) {
            if dp[j] == 0 { dp[j] = i; }
        }
    }
 
    let mut used: Vec<bool> = vec![false; maxn + 1];

    let paircoprime = a.iter()
        .find(|&&a| {
            let mut x = a;
            while x != 1 {
                let y = if dp[x] != 0 { dp[x] } else { x };
                // if x != 1 && used[x] { return true; }
                if y != 1 && used[y] { return true; }
                // used[x] = true;
                used[y] = true;
                while x % y == 0 { x /= y; }
            }

            return false;
        });

    if paircoprime.is_none() {
        println!("pairwise coprime");
        return;
    }

    let setwise = a.iter()
        .fold(a[0], |x , &y| num::integer::gcd(x, y));

    if setwise == 1 {
        println!("setwise coprime");
        return;
    }

    println!("not coprime");
    return;
}


Measured memory_bytes: 25528
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
using namespace std;
 
int n;
vector <int> G[101];
queue <int> Q;
int  d[100];
int  dis[101];
 
 
int visit(int x){
  int t,i;
   
  Q.push(x);
  dis[x] = 0;
  d[x] = 1;
 
  while(Q.empty() == false) {
     
    // cout << "start Q" <<endl;
 
    t = Q.front();
    Q.pop();
 
    for(i=0; i<G[t].size();i++) {
      if(d[G[t][i]] == 0 ) {
    d[G[t][i]] = 1;
    dis[G[t][i]] = dis[t] + 1;
 
    Q.push(G[t][i]);
      }
 
    }
  }
}
     
int main() {
   
  int i,j,k,l,u,a,t;
   
   
  scanf("%d",&n);
 
   
   
  for(i=0;i<n;i++){
    d[i] = 0;
    dis[i] = -1;
    scanf("%d %d ",&k,&u);
     
    for(j=0;j<u;j++) {
      scanf("%d",&a);
      G[k-1].push_back(a-1);
      // printf("G[%d][%d] = 1\n",i,k-1);
    }
  }
   
   
  visit(0);
 
   
 
  for(i=0;i<n;i++) cout << i+1<<" " << dis[i] <<endl;
 
 
 
  return 0;
 
     
     
}

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

int main(){
	int n, m, l;
	long long A[100][100], B[100][100], C[100][100];
	cin >> n >> m >>l;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < l; j++){
			cin >> B[i][j];
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			C[i][j] = 0;
			for(int k = 0; k < m; k++){
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			if(j != 0) cout << " " ;
			cout << C[i][j] ;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1396
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define int long long int 
#define fi first
#define se second
#define FIO {ios::sycnt2_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;
 
int32_t main()
{
int n;
cin>>n;
string s;
while(n>0)
{
  n--;
  s+=('a'+n%26);
  n/=26;
}
reverse(s.begin(),s.end());
cout<<s;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <list>
using namespace std;


bool hoge(string S)
{
    if (S[0] != 'A') {
        return false;
    }
    
    int C = 0;
    for (int i = 2; i < S.size()-1; i++) {
        if (S[i] == 'C') {
            C++;
        }
    }
    if (C != 1){
        return false;
    }
    
    int upper = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] >= 'A' && S[i] <= 'Z') {
            upper++;
        }
    }
    if (upper != 2) {
        return false;
    }
    
    return true;
}


int main()
{
    string S;
    cin >> S;
    
    if (hoge(S)) {
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split(" ")))

    for i in a:
        if i % 2 == 0:
            if i % 3 == 0 or i % 5 == 0:
                continue
            else:
                print("DENIED")
                exit()
    print("APPROVED")


Measured memory_bytes: 2940
#coding: utf-8
N = int(input())
A = [0] + list(map(int, input().split()))
B = [0 for _ in range(N+1)]
ans = []
for i in range(N, 0, -1):
    v = 0
    j = i
    while j <= N:
        v += B[j]
        j += i
    if A[i] != v % 2:
        ans.append(i)
        B[i] = 1

ans.sort()
print(len(ans))
if len(ans) != 0:
    print(*ans)

Measured memory_bytes: 14152
n,m=map(int,input().split())
a=[[0]*m for i in range(n)]
b=[0]*m

for i in range(n):
	a[i]=list(map(int,input().split()))

for i in range(m):
	b[i]=int(input())

for i in range(n):
	suma=0
	for j in range(m):
		c=a[i][j]*b[j]
		suma=suma+c
	print(suma)
		


Measured memory_bytes: 5976
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	vector<ll>sum[4];
	ll n,w;
	cin>>n>>w;
	ll w1,v;
	cin>>w1>>v;
	
	sum[0].push_back(v);
	for(int i=1;i<n;i++)
	{
		ll w,va;
		cin>>w>>va;
		sum[w-w1].push_back(va);

	}
	for(int i=0;i<4;i++)
		sort(sum[i].begin(),sum[i].end(),greater<ll>());
	for(int i=0;i<4;i++)
	{
		for(int j=1;j<sum[i].size();j++)
		{
			sum[i][j] +=sum[i][j-1];
		}
	}
	ll val=0;
	for(int i=0;i<=sum[0].size();i++)
	{
		for(int j=0;j<=sum[1].size();j++)
		{
			for(int k=0;k<=sum[2].size();k++)
			{
				for(int l=0;l<=sum[3].size();l++)
				{
					if(i*w1+j*(w1+1)+k*(w1+2)+l*(w1+3)<=w)
					{
						ll v=0;
						if(i>0)
							v += sum[0][i-1];
						if(j>0)
							v += sum[1][j-1];
						if(k>0)
							v += sum[2][k-1];
						if(l>0)
							v += sum[3][l-1];
						if(v>val)
							val=v;
					}
				}
			}
		}
	}
	cout<<val<<"\n";
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
#define w(x) int x; cin>>x; while(x--)
int visited[100001];
vector<int> adj[100001];
void dfs(int src)
{
  visited[src]=1;
  for(auto i:adj[src])
  {
    if(visited[i]==0)
      dfs(i);
  }
}
int main()
{
      #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output3.txt","w",stdout);
   #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    memset(visited , 0 , sizeof(visited));
    for (int i = 0; i < m; ++i)
    {
      int u,v;  cin>>u>>v;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    int cnt=0;
    for (int i = 1; i <=n; ++i)
    {
        if(visited[i]==0)
        {
          dfs(i);
          cnt++;
        }
    }
    cout<<cnt-1;
  }

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1<<29;

template<class G>
class Fenwick_tree{
	vector<G> a;
public:
	Fenwick_tree(int n):a(n){}
	void add(int i,G val){
		for(;i<a.size();i|=i+1) a[i]+=val;
	}
	G sum(int l,int r){
		if(l==0){
			G res{};
			for(r--;r>=0;r=(r&(r+1))-1) res+=a[r];
			return res;
		}
		return sum(0,r)-sum(0,l);
	}
};

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

	int pos[2][2000];
	rep(i,2*n){
		char c;
		int a; cin>>c>>a; a--;
		if(c=='W') pos[0][a]=i;
		else       pos[1][a]=i;
	}

	static int dp[2001][2001];
	rep(i,n+1) rep(j,n+1) dp[i][j]=INF;
	dp[0][0]=0;

	Fenwick_tree<int> F0(2*n);
	rep(i,n+1){
		Fenwick_tree<int> F1(2*n);
		rep(j,n+1){
			if(i<n){ // append (white, i)
				int x=pos[0][i];
				int cost=x-F0.sum(0,x)-F1.sum(0,x);
				dp[i+1][j]=min(dp[i+1][j],dp[i][j]+cost);
			}
			if(j<n){ // append (black, j)
				int x=pos[1][j];
				int cost=x-F0.sum(0,x)-F1.sum(0,x);
				dp[i][j+1]=min(dp[i][j+1],dp[i][j]+cost);
			}
			F1.add(pos[1][j],1);
		}
		F0.add(pos[0][i],1);
	}

	cout<<dp[n][n]<<endl;

	return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
ll N,M;
ll k[20];
vector<ll> s[20];
ll p[20],ans;

int main()
{
    //N個のスイッチ、M個の電球
    cin >> N >> M;
    REP(i,M){
        cin >> k[i];
        REP(j,k[i]){
            ll x;
            cin >> x;
            --x; //indexにしている
            s[i].push_back(x); //vectorに追加
            
        }
    }
    REP(i,M){
        cin >> p[i];//各電球の指定数
    }
    REP(i,1<<N){
        bool fl = true; //初期はtrue
        REP(j,M){
            ll sum = 0;
            for(auto v: s[j])
                sum += i >> v&1;
            fl &= sum%2 == p[j];
        }
        if(fl) ans++;
    }
    fin(ans);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

const int MAXL = 100000;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> V(N+1),W(N+1);
    rep(i,N) cin >> V[i+1] >> W[i+1];
    int Q; cin >> Q;
    vector<vector<pii>> L(N+1);
    rep(i,Q) {
        int v,l; cin >> v >> l;
        L[v].emplace_back(l,i);
    }
    
    vector<vector<ll>> dp(512, vector<ll>(MAXL+1));
    vector<ll> ans(Q);
    auto dfs=[&](auto&& self, int v, int a, vector<pll> arr)->void {
        if (v > N) return;
        int pv = v/2;
        if (v < 512) {
            rep(i,MAXL+1) {
                chmax(dp[v][i],dp[pv][i]);
                if (i+W[v]<=MAXL) chmax(dp[v][i+W[v]],dp[pv][i]+V[v]);
            }
            for (auto i : L[v]) {
                ans[i.second] = dp[v][i.first];
            }
            self(self,v*2,v,arr);
            self(self,v*2+1,v,arr);
        } else {
            auto B = arr;
            for (auto val : arr) {
                B.emplace_back(val.first+V[v],val.second+W[v]);
            }
            for (auto i : L[v]) {
                for (auto val : B) {
                    if (val.second > i.first) continue;
                    chmax(ans[i.second],dp[a][i.first-val.second]+val.first);
                }
            }
            self(self,v*2,a, B);
            self(self,v*2+1,a, B);
        }
    };
    vector<pll> arr;
    arr.emplace_back(0,0);
    dfs(dfs,1,0,arr);
    rep(i,Q) cout << ans[i] << ln;
}

Measured memory_bytes: 418936
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
 
using namespace std;
 
int main() {
    int K, S;
    int count = 0;
    cin >> K >> S;
    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
                if (S - i - j >= 0 && S - i - j <= K)
                {
                    count++;
                }
        }
    }
    cout << count << 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 repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;

int main(){
int N,m;
string s;
cin>>N>>m;
cout<<max(N-2*m,0);
}

Measured memory_bytes: 256
//与えられた整数xの立方体を計算するプログラムを書いてください。
#include <stdio.h>

int main(void)
{
    //変数定義
    int iSide;
    int iCube;

    //変数初期化
    iSide = 0;
    iCube = 0;

    scanf("%d",&iSide);
    iCube = iSide*iSide*iSide;
    printf("%d\n",iCube);

    return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

using graph = vector<vector<int>>;

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

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

        graph g(n);
        rep (i, n - 1) {
                int u, v;
                cin >> u >> v;
                --u;
                --v;

                g[u].push_back(v);
                g[v].push_back(u);
        }
        
        constexpr int inf = 1e9 + 1;
        vector<int> dp(n, inf), ans(n, -1);
        stack<int> st;

        function<void(int, int)> rec = [&](int bv, int v) {
                auto itr = lower_bound(dp.begin(), dp.end(), a[v]);
                st.push(*itr);
                *itr = a[v];
                ans[v] = lower_bound(dp.begin(), dp.end(), inf) - dp.begin();

                for (int u : g[v]) {
                        if (u == bv) continue;
                        rec(v, u);
                }

                *itr = st.top();
                st.pop();
        };

        rec(-1, 0);
        rep (i, n) cout << ans[i] << endl;

        return 0;
}


Measured memory_bytes: 37320
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int k=sc.nextInt();
    Deque<Long> dq=new ArrayDeque<>();
    if(k<10){
      System.out.println(k);
      return;
    }
    for(long i=1;i<10;i++){
      dq.addLast(i);
    }
    long last;
    int cnt=9;
    while(true){
      long x=dq.pollFirst();
      long bi=x%10;
      if(bi!=0){
        last=x*10+bi-1;
        dq.add(last);
        cnt++;
        if(cnt==k){break;}
      }
      last=x*10+bi;
      dq.add(last);
      cnt++;
      if(cnt==k){break;}
      if(bi!=9){
        last=x*10+bi+1;
        dq.add(last);
        cnt++;
        if(cnt==k){break;}
      }
    }
    System.out.println(last);
  }
}

Measured memory_bytes: 23892
# Recursion / Divide and Conquer - The Number of Inversions
def conq(A,left,mid,right):
    global c
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid] + [10**9+1]
    R = A[mid:right] + [10**9+1]
    i,j = 0,0
    for k in range(left,right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            c += n1 - i

def num_inv(A,left,right):
    if left + 1 < right:
        mid = (left + right) // 2
        num_inv(A,left,mid)
        num_inv(A,mid,right)
        conq(A,left,mid,right)

n = int(input())
A = list(map(int, input().split()))
c = 0
num_inv(A,0,n)
print(c)


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

int main() {
  int N;
  char Si;
  
  cin >> N;
  
  for(int i =0; i < N; i++){
  	 cin >> Si;
    
    if(Si == 'Y'){
      cout << "Four" << endl;
      
      return 0;
    }
  }
  
  cout << "Three" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static int insertionSort(int[] array, int n, int g){
		int cnt=0;

		for(int i=g;i<n;i++){
			int j;
			int tmp=array[i];
			for(j=i-g;j>=0&&array[j]>tmp;j-=g){
				array[j+g]=array[j];
			    cnt++;}
			array[j+g]=tmp;
		}
		return cnt;
	}

	public static void shellSort(int[] array, int n){
		int cnt=0;
		int[] G=new int[15];
		int g, i, m;
		m=0;

		for(g=1;g<=n;g=g*3+1){G[m]=g;m++;}

		//???????????°???i?????\?????????????????????
		System.out.println(m);//???????????°
		for(int j=m-1;j>0;j--){
		System.out.print(G[j]+" ");
		}System.out.println(G[0]);

		for(i=m-1;i>=0;i--){
			cnt+=insertionSort(array, n, G[i]);
		}

		//??\?????????
		System.out.println(cnt);
		for(i=0;i<n;i++){
			System.out.println(array[i]);
		}

	}

	public static void main(String[] args){

		int n;
		int[] array;
		Scanner scan=new Scanner(System.in);
		n=scan.nextInt();
		array=new int[n];

		for(int i=0;i<n;i++){
			array[i]=scan.nextInt();
			}


		shellSort(array, n);

		scan.close();
	}

}

Measured memory_bytes: 299392
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*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 unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

vector<int> minprime;

void CalculateMinPrime(int n)
{
    minprime.resize(n+2,0);
    for(int i = 2; i * i <= n; i++)
    {
        if(minprime[i] == 0)
        {
            for(int j = i * i; j <= n; j += i)
            {
                if(minprime[j] == 0)
                    minprime[j] = i;
            }
        }
    }
    rep(i,2,n)
    {
        if(minprime[i] == 0)
            minprime[i] = i;
    }
}

unordered_map<int, int> pf(int n)
{
    unordered_map<int, int> ret;
    while(n != 1)
    {
        ret[minprime[n]]++;
        n /= minprime[n];
    }
    return ret;
}


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n;
    cin>>n;
    int a[n];
    f(i, n) cin>>a[i];
    CalculateMinPrime((int)1e6 + 2);
    unordered_map<int, int> lcm;
    f(i, n) {
        unordered_map<int, int> mp = pf(a[i]);
        for(auto &it: mp) {
            lcm[it.first] = max(lcm[it.first], it.second);
        }
    }
    int ans = 0;
    f(i, n) {
        unordered_map<int, int> mp = pf(a[i]);
        int tt = 1;
        for(auto &it: lcm) {
            if(mp.find(it.first) == mp.end()) {
                tt = mul(tt, power(it.first, it.second));
            }
            else {
                int to = it.second - mp[it.first];
                tt = mul(tt, power(it.first, to));
            }
        }
        ans = add(ans, tt);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8576
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };*/

//Union Find
/*class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};*/

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
/*long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}*/

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI A, B;
	cin >> A >> B;
	if (A != 1 && B != 1) {
		cout << 1 << endl;
	}
	else if (A != 2 && B != 2){
		cout << 2 << endl;
	}
	else {
		cout << 3 << endl;
	}
}

Measured memory_bytes: 256
#import numpy as np
def main():
    S=input()
    #dp=np.zeros((len(S)+1,13),dtype=int)
    dp=[[0]*13 for _ in range(len(S)+1)]
    dp[0][0]=1
    mod=10**9+7
    """
    for i in range(1,len(S)+1):
        for a in range(13):
            if S[i-1]=="?":
                if a*10%13<(a*10+10)%13:
                    dp[i][a*10%13:(a*10+10)%13]+=dp[i-1][a]
                    dp[i][a*10%13:(a*10+10)%13]%=mod
                else:
                    dp[i][a*10%13:]+=dp[i-1][a]
                    dp[i][a*10%13:]%=mod
                    dp[i][:(a*10+10)%13]+=dp[i-1][a]
                    dp[i][:(a*10+10)%13]%=mod
            else:
                dp[i][(a*10+int(S[i-1]))%13]+=dp[i-1][a]
                dp[i][(a*10+int(S[i-1]))%13]%=mod
    print(dp[len(S)][5])
"""
    for i in range(1,len(S)+1):
        for a in range(13):
            if S[i-1]=="?":
                for n in range(10):
                    dp[i][(a*10+n)%13]+=dp[i-1][a]
                    dp[i][(a*10+n)%13]%=mod
            else:
                dp[i][(a*10+int(S[i-1]))%13]+=dp[i-1][a]
                dp[i][(a*10+int(S[i-1]))%13]%=mod
    print(dp[len(S)][5])
if __name__=="__main__":
    main()

Measured memory_bytes: 62048
#include<stdio.h>
#include<string.h>
int main(){
char c[10]="Sunny";
char d[10]="Cloudy";
 char e[10]="Rainy";
char f[7];
gets(f);
if(strcmp(f,c)==0){
  printf("Cloudy");
}
else if(strcmp(f,d)==0){
  printf("Rainy");
}
else if(strcmp(f,e)==0){
  printf("Sunny");
}


return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define MOD 1000000007
#define MAX (int)10e6+1

int main(){
  int n,t=0,
      i;
  long long res=1;
  char c[MAX];
  
  scanf("%d",&n);
  scanf("%s",&c);
  
  for(i=0;i<2*n;i++){
    if((i%2==0 && c[i]=='B') || (i%2==1 && c[i]=='W')){
      if(2*n-i == t){
        printf("0\n");
        return 0;
      }
      t++;
    }else{
      if(t==0){
        printf("0\n");
        return 0;
      }
      res *= t;
      res %= MOD;
      t--;
    }
  }
  if(t!=0)res = 0;
//  printf("%lld\n",res);
  
  for(i=1;i<=n;i++){
    res *= i;
    res %= MOD;
  }
  
  printf("%lld\n",res);
  return 0;
}

Measured memory_bytes: 2304
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)



int main(){
	int N; cin >> N;
	vector<int> a(N);
	int sum = 0;
	rep(i,N) cin >> a[i];
	rep(i,N) sum += a[i];
	cout << sum - N << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		HashMap<String, Integer> S = new HashMap<String, Integer>();
		for (int i = 0; i < N; i++) {
			String SS = sc.next();
			if (S.containsKey(SS)) {
				S.put(SS, S.get(SS) + 1);
			} else {
				S.put(SS, 1);
			}
		}
		int max = 0;
		for (Entry<String, Integer> entry : S.entrySet()) {
			if (entry.getValue() > max)
				max = entry.getValue();
		}
		List<String> maxList = new ArrayList<String>();
		for (Entry<String, Integer> entry : S.entrySet()) {
			if (entry.getValue() == max) {
				maxList.add(entry.getKey());
			}
		}
		Collections.sort(maxList);
		for (String string : maxList) {
			System.out.println(string);
		}
	}
}

Measured memory_bytes: 85140
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a;scanf("%d",&a);
	while(a--){
		int r,t;
		scanf("%d%d",&r,&t);
		if(r%100==0){
			if(t%30==0){
				printf("%d\n",t/30*5+r/100);
			}else{
				printf("%d %d\n",r/100+t/30*5,r/100+t/30*5+5);
			}
		}else{
			if(t%30==0){
				printf("%d %d\n",r/100+t/30*5,r/100+1+t/30*5);
			}else{
				printf("%d %d %d %d\n",r/100+t/30*5,r/100+1+t/30*5,r/100+t/30*5+5,r/100+1+t/30*5+5);
			}
		}
	}
}

Measured memory_bytes: 1028
H, W = map(int, input().split())
m = [list(input()) for _ in range(H)]
inf = 10**3

V = H*W
maze = [[inf]*V for _ in range(V)]

for i in range(V):
    maze[i][i] = 0

for py in range(H):
    for px in range(W):
        if m[py][px] == "#":
            continue
        candidate = [(px+1, py), (px-1, py), (px, py+1), (px, py-1)]
        for x, y in candidate:
            if not (0<=x<W and 0<=y<H):continue
            if m[y][x] == "#":
                continue
            maze[W*py+px][W*y+x] = 1

for k in range(V):
    for i in range(V):
        for j in range(V):
            maze[i][j] = min(maze[i][j], maze[i][k]+maze[k][j])

print(max([j for i in maze for j in i if j!=inf]))

Measured memory_bytes: 51036
list1=[1]
for i in range(2,100001):
    list1.append((list1[len(list1)-1]*i)%(10**9+7))
N,M=map(int,input().split())
if abs(N-M)>=2:
    print(0)
elif abs(N-M)==1:
    print((list1[N-1]*list1[M-1])%(10**9+7))
elif N==M:
    print((list1[N-1]*list1[M-1]*2)%(10**9+7))

Measured memory_bytes: 7060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 1; i <= 9; i++) {
			if(111*i/n == 1) {
				System.out.println(111*i);
				break;
			}
		}
	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll y,fi=100,ye=0;
	cin>>y;
	while(1){
		ye++;
		fi+=fi/100;
		if(fi>=y){
			break;
		}
	}
	cout<<ye<<endl;
} 

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define llin(a) cin >> a
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define DEBUG(x) cout << #x << " : " << x << endl;
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define M 1000000007
//check the limits, man
// read the constraint properly (ll vs int)
const int N = 1e5+5;
typedef long long int ll;
int main()
{
    int i,n,x;
    in(n);
    vii vp(n);
    rep(i,n)
        in(x),vp[i]={x,i+1};
    sort(all(vp));
    rep(i,n)
        pr(vp[i].S);
}





Measured memory_bytes: 1536
from collections import deque
import sys
sys.setrecursionlimit(1000000)

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


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

ans = 0
for i in range(n-k+1):
    ans += (-a[i] + a[-1-i]) * cmb(n-1-i, k-1,mod)
    ans %= mod
print(ans)

Measured memory_bytes: 133144