akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
    int n;cin >> n;
    int S[n];
    for(int i=0;i<n;i++){
        cin >> S[i];
    }
    int q;cin >> q;
    int T[q];
    for(int i=0;i<q;i++){
        cin >> T[i];
    }

    int count = 0;
    for(int i=0;i<q;i++){
        int left = 0;
        int right = n;
        while(left<right){
            int mid = (left+right)/2;
            if(S[mid] == T[i]){
                count ++;
                break;
            }
            else if(S[mid] < T[i])
                left = mid+1;
            else
                right = mid;
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 1740
// {{{ Headers
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <cassert>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <fstream>
#include <iostream>
#include <sstream>

using namespace std;
// }}}

typedef long long int64;
const int INF = 0x3f3f3f3f;
template <class T> inline int len (const T &a) { return a.size (); }
#define ALL(x) (x).begin(), (x).end()

const int MX = 100 * 1000 + 5;
int a [MX], b [MX], c [MX], dp [MX][3];

int
main () {
    int N;
    scanf ("%d", &N);
    for (int i = 0; i < N; i++) scanf ("%d %d %d", a + i, b + i, c + i);

    for (int i = 0; i < N; i++)
        for (int j = 0; j < 3; j++) {
            if (j == 0) {
                dp [i][j] = max (dp [i][j], a [i] + (i > 0 ? dp [i - 1][1] : 0));
                dp [i][j] = max (dp [i][j], a [i] + (i > 0 ? dp [i - 1][2] : 0));
            } else if (j == 1) {
                dp [i][j] = max (dp [i][j], b [i] + (i > 0 ? dp [i - 1][0] : 0));
                dp [i][j] = max (dp [i][j], b [i] + (i > 0 ? dp [i - 1][2] : 0));
            } else if (j == 2) {
                dp [i][j] = max (dp [i][j], c [i] + (i > 0 ? dp [i - 1][0] : 0));
                dp [i][j] = max (dp [i][j], c [i] + (i > 0 ? dp [i - 1][1] : 0));
            }
        }
    int ret = max ({ dp [N - 1][0], dp [N - 1][1], dp [N - 1][2] });
    printf ("%d\n", ret);

#ifdef LOCALHOST
	cerr << "time: " << (int64) clock () * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
    return 0;
}



Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	class Island {

		int[][] map = new int[14][14];
		int num = 2;

		public Island(int[][] map) {
			this.map = map;
		}

		private void label(int row, int column) {
			map[row][column] = num;
			for(int i=0; i<4; i++) {
				if(i==0) {
					if(map[row][column-1] == 1) label(row, column-1);
				} else if(i == 1) {
					if(map[row-1][column] == 1) label(row-1, column);
				} else if(i == 2) {
					if(map[row][column+1] == 1) label(row, column+1);
				} else if(i == 3) {
					if(map[row+1][column] == 1) label(row+1, column);
				}
			}
		}

		public int count() {
			for(int i=1; i<14; i++) {
				for(int j=1; j<14; j++) {
					if(map[i][j] == 1) {
						num++;
						label(i, j);
					}
				}
			}
			return num-2;
		}


	}


	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()) {

			int[][] map = new int[14][14];

			// 外を埋める
			for(int i=0; i<14; i++) {
				map[0][i] = 0;
				map[13][i] = 0;
				map[i][0] = 0;
				map[i][13] = 0;
			}

			for(int i=1; i<13; i++) {
				String line = sc.next();
				for(int j=1; j<13; j++) {
					map[i][j] = Integer.parseInt(line.split("")[j-1]);
				}
			}

			Island island = new Main().new Island(map);
			System.out.println(island.count());
		}

		sc.close();


	}
}


Measured memory_bytes: 30172
N, x = map( int, input().split())
A = list( map( int, input().split()))
ans = 0
Sums = 0
A.sort()
for i in range(N-1):
    Sums += A[i]
    if Sums > x:
        break
    ans += 1
Sums += A[N-1]
if Sums == x:
    ans += 1
print(ans)

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

int main()
{
    string S; cin >> S;
    ll K; cin >> K;
    ll index = 0;
    char num = '1';
    rep(i,S.length()) {
        if (S[i] != '1') {
            index = i;
            num = S[i];
            break;
        }
    }
    if (K <= index) {
        cout << 1 << endl;
    }
    else {
        cout << num << endl;
    }



}


Measured memory_bytes: 3532
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	int n, time, c, t, ans = 10000;
	scanf("%d %d", &n, &time);
	while (n--) {
		scanf("%d %d", &c, &t);
		if (t <= time)
			ans = min(ans, c);
	}
	if (ans > 9999)
		printf("TLE\n");
	else
		printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int X; cin >> X;
  if (X <= 599) cout << 8 << endl;
  else if (X <= 799) cout << 7 << endl;
  else if (X <= 999) cout << 6 << endl;
  else if (X <= 1199) cout << 5 << endl;
  else if (X <= 1399) cout << 4 << endl;
  else if (X <= 1599) cout << 3 << endl;
  else if (X <= 1799) cout << 2 << endl;
  else                cout << 1 << endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include<iostream>
typedef long long ll;
const int mod=1e9+7;
ll n;
using namespace std;
int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int lcm(int a,int b){
    //if()
    return a*b/gcd(a,b);
}
ll qpow(ll a,ll b){
    ll ans=1,base=a;
    while(b){
        if(b&1){
            ans=ans*base%mod;
        }
        base=base*base%mod;
        b=b>>1;
    }
    return ans;
}
int main(){
    cin>>n;
    ll ans=((qpow(10,n)+qpow(8,n)-2*qpow(9,n))%mod+mod)%mod;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3624
def bubblesort(c, n):
	for i in range(n):
		for j in range(n-1, 0, -1):
			if (c[j][1] < c[j-1][1]):
				c[j], c[j-1] = c[j-1], c[j]

def selectionsort(c, n):
	for i in range(n):
		minj = i
		for j in range(i, n):
			if (c[j][1] < c[minj][1]):
				minj = j
		c[i], c[minj] = c[minj], c[i]

def output(c):
	for i in range(len(c)):
		if i != 0: print(" ", end="")
		print("{}{}".format(c[i][0], c[i][1]), end="")
	print()

def main():
	n = int(input())
	data = input().split()
	cards = []

	for c in data:
		cards.append((c[0],int(c[1])))
	cards1 = cards[:]
	cards2 = cards[:]

	bubblesort(cards1, n)
	output(cards1)
	print("Stable")

	selectionsort(cards2, n)
	output(cards2)
	if (cards1 == cards2):
		print("Stable")
	else:
		print("Not stable")

if __name__ == "__main__":
	main()

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

int main(){
  int A,B,C;
  cin >>A>>B>>C;
  
  string ans;
  
  if(A==5&&B==5&&C==7)ans="YES";
  else if(A==5&&C==5&&B==7)ans="YES";
  else if(B==5&&C==5&&A==7)ans="YES";
  else ans = "NO";
  
  cout <<ans<< endl;
}


Measured memory_bytes: 256
import java.util.Comparator;
import java.util.Scanner;


public class Main {
    Scanner sc = new Scanner(System.in);
    int n;
    public void run(){
        n = sc.nextInt();
        solve();
    }
    public void solve(){
        if(n < 1200){
            System.out.println("ABC");
        }
        else if(n < 2800){
            System.out.println("ARC");
        }
        else{
            System.out.println("AGC");
        }
    }

    public static void main(String[] args){
        new Main().run();
    }

    static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }
    static class Edge{
        int to, cost;
        public Edge(int a, int b){
            this.to = a;
            this.cost = b;
        }
    }
    class MyComparator implements Comparator {
        @Override
        public int compare (Object arg0, Object arg1) {
            int x = ((Pair)arg0).first;
            int y = ((Pair)arg1).first;

            if (x < y) {
                return 1;
            } else if (x > y) {
                return -1;
            } else{
                return 0;
            }
        }
    }
    static class UnionFind{
        int par[];
        int rank[];

        //n要素で初期化
        public UnionFind(int maxn){
            par = new int[maxn];
            rank = new int[maxn];

            for(int i = 0; i < maxn; i++){
                par[i] = i;
                rank[i] = 0;
            }
        }

        //木の根を求める
        int find(int x){
            if(par[x] == x){
                return x;
            }
            else {
                return par[x] = find(par[x]);
            }
        }

        // xとyの属する集合を併合
        void unite (int x, int y){
            x = find(x);
            y = find(y);
            if(x == y){
                return;
            }

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

        // xとyが同じ集合に属するか否か
        boolean same(int x, int y){
            return find(x) == find(y);
        }
    }

}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e15;

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); }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}


int n;
ll a[3005];
ll dp[3005][3005]; // dp[i][j]:=[i,j)の総得点


ll rec(int i, int j){
  if(dp[i][j]!=-1) return dp[i][j];
  
  int turn = n-(j-i);
  ll res;
  if(turn%2==0){
    // 先手
    res=max(rec(i+1,j)+a[i], rec(i,j-1)+a[j-1]);
  }else{
    // 後手
    res=min(rec(i+1,j)-a[i], rec(i,j-1)-a[j-1]);
  }
  
  return dp[i][j]=res;
}

int main(){
  cin>>n;
  rep(i,n) cin>>a[i];
  memset(dp, -1, sizeof(dp));
  rep(i,n+1) dp[i][i]=0;
  
  cout<<rec(0,n)<<endl;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

ll f[101010], rf[101010];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    rf[0] = inv(f[0]);
    for(ll i=1;i<101010;i++){
      f[i] = (f[i - 1] * i) % MOD;
      rf[i] = inv(f[i]);
    }
}

ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % MOD;

    return (a * bc) % MOD;
}


int main() {
  init();
  
  ll n, m;
  cin >> n >> m;
  ll rt = sqrt(m);
  ll so[rt+1];
  fill(so,so+rt+1,0);
  ll num = m;
  for (ll i=2;i<=rt;i++){
    while(num%i == 0){
      so[i] += 1;
      num /= i;
    }
    if (num == 1) break;
  }
  ll ans = 1;
  if (num != 1) ans *= n;
  for (ll i=2;i<=rt;i++){
    if (so[i] != 0){
      //cout << i << " " << n << " " << so[i] << " " << C(so[i]+n-1,n-1) << endl;
      ans *= C(so[i]+n-1,n-1);
      ans = ans%MOD;
    }
  }
  //cout << C(2,1) << endl;
  //cout << f[2] << " " << rf[1] << endl;
  
  cout << ans << endl;
}

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

int N;
int* H[3];
int* opti[3];

int happiness(int n, int c)
{
    int maxi = -1;
    if(n == N)
        opti[c-1][n-1] = H[c-1][n-1];
    
    if(opti[c-1][n-1] != -1)
        return  opti[c-1][n-1];

    for(int j = 1;j <= 3;j++)
        if(j != c)
            maxi = max(H[c-1][n-1]+happiness(n+1,j),maxi);
    opti[c-1][n-1] = maxi;
    return opti[c-1][n-1];        
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif //*
    cin >> N;
    int H[3][N];
    for(int i = 1;i <= N;i++)
    {
        cin >> H[0][i-1];
        cin >> H[1][i-1];
        cin >> H[2][i-1];
    }
    for(int i = 1;i <= 3;i++)
        ::H[i-1] = H[i-1];
    
    int opti[3][N];
    for(int i = 1;i <= 3;i++)
        for(int j=1;j<= N;j++)
            opti[i-1][j-1] = -1;

    for(int i = 1;i <= 3;i++)
        ::opti[i-1] = opti[i-1];

    int maxi = -1;    
    for(int i = 1;i <= 3;i++)    
        maxi = max(happiness(1,i),maxi);
    cout << maxi;  
}   


Measured memory_bytes: 13672
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    for0(i,n) for(int i=0;i<n;i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    Sort(s) sort(s.begin(),s.end())
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long int
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
    
    int n;
    cin>>n;
    ll s=0;
    forn(i,n)
    {
        for(int j=i;j<=n;j+=i){
            s+=j;
        }
    }
    cout<<s;
    
End;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
using namespace std;
void search(int p,vector<int>e,vector<int> foot,int*sum){
	foot[p]=1;
	int flag=0;
	for(int i=0;i<foot.size();i++){
		if(foot[i]==0) flag=1;
	}
	if(flag==0){
		*sum+=1;
		foot[p]=0;
		return;
	}
	for(int i=0;i<foot.size();i++){
		if(e[p*foot.size()+i]==1&&foot[i]==0){
			search(i,e,foot,sum);
		}
	}
	foot[p]=0;
	return;
}

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> e(n*n,0);
	int a,b;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		a--;
		b--;
		e[a*n+b]=1;
		e[b*n+a]=1;
	}
	vector<int> foot(n,0);
	int sum=0;
	search(0,e,foot,&sum);
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  long long ans=0;
  for(int i=0; i<n-1; i++) {
    if(a[i]>a[i+1]) {
      ans+=a[i]-a[i+1];
      a[i+1]+=a[i]-a[i+1];
    }
  }
  cout << ans << endl;
  return 0;
}

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


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


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

    int x;
    cin >> x;

    cout << (x==7 or x == 5 or x == 3 ? "YES\n" : "NO\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  set<int> kind;
  int a,b,c;
  cin >> a >> b >> c;
  kind.insert(a);
  kind.insert(b);
  kind.insert(c);
  cout << kind.size() << endl;
}


Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int n;
	cin >> n;
	vector<int> arr(n);
	vector<int> cnt(1e6 + 25);
	bool a = 1, b = 1;
	for(int i = 0, x; i < n; i++)
		cin >> arr[i], cnt[arr[i]]++;
	for(int i = 2; i < cnt.size(); i++) {
		int res = 0;
		for(int j = i; j < cnt.size(); j += i) {
			res += cnt[j];
		}
		if(res == n)
			a = 0;
		if(res >= 2)
			b = 0;
	}
	if(b)
		cout << "pairwise coprime\n";
	else if(a)
		cout << "setwise coprime\n";
	else
		cout << "not coprime\n";

	return 0;
}


Measured memory_bytes: 11048
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
//#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    int a,b,c; cin >> a >> b >> c;
    if(c<a)return cout << "NO" << endl,0;
    if(c-a<=b)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
	long long n, a[5];
	std::cin >> n;
	for (int i = 0; i < 5; i++)
		std::cin >> a[i];
	int mins = 0;
	for (int i = 1; i < 5; i++)
		mins = (a[mins] < a[i]) ? mins : i;
	long long b = ((n%a[mins]) ? (n / a[mins] + 1) : (n / a[mins])) + 4;
	std::cout << b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define f(i,s,e) for(ll i=s;i<e;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
ll n,w,dp[102][100005];
pair<ll,ll> arr[102];

ll func(ll ind,ll wei){
    if(ind==n+1)
        return 0;

    ll &ret = dp[ind][wei];
    if(ret!=-1)
        return ret;

    ll ans=func(ind+1,wei);
    if(wei>=arr[ind+1].first)
        ans=max(ans,arr[ind+1].second+func(ind+1,wei-arr[ind+1].first));

    return ret=ans;

}
int main(){
    fast;

    cin>>n>>w;

    f(i,1,n+1)
        cin>>arr[i].first>>arr[i].second;

    memset(dp,-1,sizeof(dp));
    cout<<func(0,w);

}


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

ll dp[1000+5][1000+5];
ll arr[1000+5][1000+5];
ll N,M;

ll mod = 1000*1000*1000+7;


ll solve(ll i, ll j){
	if (i==0 && j == 0) return arr[i][j];
	if(i<0 || j<0 || !arr[i][j]) return 0;
	
	if (dp[i][j] != -1) return dp[i][j];
	
	dp[i][j] = (solve(i-1,j)%mod + solve(i, j-1)%mod)%mod;
	return dp[i][j];
}

int main(){
	memset(dp, -1, sizeof dp);
	cin>>N>>M;
	
	char c;
	for(ll i = 0;i<N;i++){
		for(ll j = 0;j<M;j++){
			cin>>c;
			if(c == '.') arr[i][j] = 1;
			if(c == '#') arr[i][j] = 0;
		}
	}
	
	cout<< solve(N-1, M-1)<<endl;;
	
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B,C,D;
  string a,b,c;
  cin >>a>>b>>c;
  cout << a[0] << b[1] << c[2] << endl;
}


Measured memory_bytes: 256
while True:
    data = input().split()
    a = int(data[0])
    op = data[1]
    b = int(data[2])
    r = 0

    if op == "?":
        break

    if op == "+":
        r = a+b
    elif op == "-":
        r = a-b
    elif op == "*":
        r = a*b
    elif op == "/":
        r = a//b
    else:
        r = a%b
    print(r)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  ll k; cin >> k;
  cout << (k/2)*((k/2)+(k%2));
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <set>
const int maxlongint=2147483647;
const int mo=1e9+7; 
const int N=105;
using namespace std;
short f[N][N][N][N],n,m,a[N][N],ans,sx,sy,v[N][N],v1[N][N];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            char c=getchar();
            while(c!='.' && c!='o' && c!='E') c=getchar();
            v[i][j]=v1[i][j]=a[i][j]=(c=='o');
            v[i][j]+=v[i][j-1];
            v1[i][j]+=v1[i-1][j];
            if(c=='E') sx=i,sy=j;
        }
    for(short i=sx;i>=1;i--)
        for(short j=sy;j>=1;j--)
            for(short i1=sx;i1<=n;i1++)
                for(short j1=sy;j1<=m;j1++)
                {
                    if(1<i && i1+1<sx+i)
                        f[i-1][j][i1][j1]=max((int)f[i-1][j][i1][j1],(int)f[i][j][i1][j1]+v[i-1][min((int)j1,m-sy+j)]-v[i-1][max((int)j-1,j1-sy)]);
                    if(i1<n && sx+i1<n+i)
                        f[i][j][i1+1][j1]=max((int)f[i][j][i1+1][j1],(int)f[i][j][i1][j1]+v[i1+1][min((int)j1,m-sy+j)]-v[i1+1][max((int)j-1,j1-sy)]);
                    if(1<j && j1+1<sy+j)
                        f[i][j-1][i1][j1]=max((int)f[i][j-1][i1][j1],(int)f[i][j][i1][j1]+v1[min((int)i1,n-sx+i)][j-1]-v1[max((int)i-1,i1-sx)][j-1]);
                    if(j1<m && sy+j1<m+j)
                        f[i][j][i1][j1+1]=max((int)f[i][j][i1][j1+1],(int)f[i][j][i1][j1]+v1[min((int)i1,n-sx+i)][j1+1]-v1[max((int)i-1,i1-sx)][j1+1]);
                }
for(short i=sx;i>=1;i--)
        for(short j=sy;j>=1;j--)
            for(short i1=sx;i1<=n;i1++)
                for(short j1=sy;j1<=m;j1++) ans=max(f[i][j][i1][j1],ans);
    cout<<ans<<endl;
}

Measured memory_bytes: 209024
#include<iostream>
using namespace std;
int main(){
  //  for(int i=0;i<5;i++){
  int L,A,B,C,D,rest,try1,try2,goal;
    cin >> L ;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    try1=A/C;
    if(A%C>0){try1++;}

    try2=B/D;
    if(B%D>0){try2++;}
    
    if(try1>try2){goal=try1;}
    else{goal=try2;}
    rest=L-goal;
    cout << rest << endl;


  
  return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int v, ans;
  v = b + c -a;
  
  if(v>=0) ans = v;
  else ans =0;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
c = [list(map(int,input().split())) for i in range(3)]

q1 = c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]
q2 = c[0][0] - c[0][2] == c[1][0] - c[1][2] == c[2][0] - c[2][2]
q3 = c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]
q4 = c[0][0] - c[2][0] == c[0][1] - c[2][1] == c[0][2] - c[2][2]

print("Yes" if q1 and q2 and q3 and q4 else "No")

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N; cin >> N;
    ll t = 1, a = 1;
    rep(i, N) {
        ll T, A; cin >> T >> A;
        ll tmp = max((T+t-1)/T, (A+a-1)/A);
        t = T * tmp;
        a = A * tmp;
    }
    cout << t + a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long 
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=200005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int A[MAXN], B[MAXN], pA[MAXN], pB[MAXN];
int N, M, K, ans;
void guess(int x){
	//take top x from A
	int rem = K - pA[x];
	if (rem < 0) return;
	int s = 0, e = M+1;
	while (e-s > 1){
		int m = (s+e)/2;
		if (rem >= pB[m]) s=m;
		else e = m;
	}
	ans = max(ans, x + s);
}
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin  >> N >> M >> K;
	FOR(i,1,N) cin >> A[i];
	FOR(i,1,M) cin >> B[i];
	FOR(i,1,N) pA[i] = pA[i-1] + A[i];
	FOR(i,1,M) pB[i] = pB[i-1] + B[i];
	FOR(i,0,N) guess(i);
	cout<<ans;
}


Measured memory_bytes: 9896
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#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)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, a[20010], b[20010];
signed main() {
    cin >> N;

    a[0] = b[N-1] = 1;
    rep(i,1,N) a[i] = a[i-1] + N + 10;
    repr(i,N-2,0) b[i] = b[i+1] + N + 10;

    rep(i,0,N) {
        int p; cin >> p; p--;
        b[p] += i;
    }

    rep(i,0,N) cout << (i == 0 ? "" : " ") << a[i];
    cout << endl;
    rep(i,0,N) cout << (i == 0 ? "" : " ") << b[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define INF 1e4
#define sz(x) (int)x.size()

int main() {
    st s, t;
    cin >> s >> t;
    int sz_s = sz(s);
    int sz_t = sz(t);
    int ans = sz_t;
    rep(i, sz_s - sz_t + 1){
        int cnt = 0;
        rep(j, sz_t){
            if(t.at(j) != s.at(i + j)) cnt++;
        }
        chmin(ans, cnt);
    }
    /*rep(i, sz_t){
        rep(j, sz_s){
            if(s.at(j) == t.at(i)){
                int cnt = 0;
                rep(k, sz_t){
                    if(j - i + k < 0 || j - i + k >= sz_s) break;
                    if(t.at(k) != s.at(j - i + k)){
                        cnt++;
                    }      
                }
                chmin(ans, cnt);
            }
        }     
    }*/
    cout << ans << endl;
    return 0;
}

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

int main(){
 int N;
 cin >> N;
 string S,T;
 cin >> S >> T;
 string ans;
 for (int i = 0; i < N; i++){
    ans+=S.at(i);
    ans+=T.at(i);

 }
 cout << ans << endl;
 
}

Measured memory_bytes: 256
# ABC170

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

a.sort()
a_max = max(a)
dp = [True for _ in range(a_max+1)]

ans = 0
for i in range(n):
    if dp[a[i]]:
        for j in range(0, a_max+1, a[i]):
            dp[j] = False
        if i > 0:
            if a[i] == a[i-1]:
                continue
        if i < n-1:
            if a[i] == a[i+1]:
                continue
        ans += 1

print(ans)


Measured memory_bytes: 32368
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long int llint;

int K;

int dp[201][201];

int gcd(int a, int b) {
	if (dp[a][b] != 0) { return dp[a][b]; }
	if (b == 0) { 
		return a;
	}
	return dp[a][b] = gcd(b, a % b);
}

int main() {
	cin >> K;
	llint sum = 0;
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int k = 1; k <= K; k++) {
				sum += gcd(i, gcd(j, k));
			}
		}
	}
	cout << sum << endl;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;


class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

    bool is_union(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        return ra == rb;
    }
};


int main() {

    int n, m, k;
    cin >> n >> m >> k;

    vector<vector<int>> friends(n);
    vector<vector<int>> blocks(n);

    UnionFind uf(n);

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        friends[a].push_back(b);
        friends[b].push_back(a);
        uf.connect(a, b);
    }


    rep(i, k) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        blocks[a].push_back(b);
        blocks[b].push_back(a);
    }

    rep(i, n) {
        int size = uf.size(i);
        size--;
        for (int j : friends[i]) {
            if (uf.is_union(i, j)) size--;
        }
        for (int j : blocks[i]) {
            if (uf.is_union(i, j)) size--;
        }
        cout << size << ' ';
    }

    cout << endl;
}


Measured memory_bytes: 12232
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int d = 0;
        ArrayList<ArrayList<Integer>> arraylist = new ArrayList<ArrayList<Integer>>(N);
        
        for(int i = 0;i < N;i++) {
            arraylist.add(new ArrayList<Integer>());
        }

        for(int i = 0; i < (2 * K); i++){
            if(i % 2 == 0){
                d = scanner.nextInt();
            }else{
                for(int s = 0; s < d; s++){
                    arraylist.get(scanner.nextInt() - 1).add(i);
                }
            }
        }
        
        int count = 0;
        for(int i = 0;i < N;i++) {
            if(arraylist.get(i).size() == 0) {
                count += 1;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 46380
#include <iostream>

using namespace std;

int main(){
	int n;
	cin>>n;
	int countFB=0;
	long long int sum = 0;
	
	for(int i = 0; i < n+1; i++){
		if(!(i%5 ==0 || i%3 ==0)){
			sum+=i;
			}
		}
	cout<<sum;
	return 0;
	}


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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    long long r = 0, g = 0, b = 0;
    
    long long res = 0;
    for(int k=0; k<N; ++k) {
        if(S[k] == 'R') res += g * b;
        else if(S[k] == 'G') res += b * r;
        else res += r * g;

        for(int j=k-1; j-(k - j)>=0; --j) {
            int i = j - (k - j);
            if(S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) --res;
        }

        if(S[k] == 'R') ++r;
        else if(S[k] == 'G') ++g;
        else ++b;
    }

    cout << res << '\n';
}

Measured memory_bytes: 3616
H,W=map(int,input().split())
if H==1 or W==1:
    print(1)
    exit()
if W%2==0:
    print(H*W//2)
elif H%2==0:
    h=H//2
    w=W//2
    print((2*w+1)*h)
else:
    w=W//2
    h=H//2
    print((w+1)*(h+1)+(w*h))
 

Measured memory_bytes: 3060
#include <iostream>
#include<iomanip>
#include<vector>
using namespace std;

int main()
{int n;cin>>n;double p[n];
for (int i=0;i<n;i++)
{
    cin>>p[i];
}int nh=n/2+1;
double ans[n+1][nh+1];
for (int i=1;i<=nh;i++)
{
    ans[0][i]=0;
}
for (int i=0;i<=n;i++)
{
    ans[i][0]=1;
}
for (int i=1;i<=n;i++)
{   int pq=min(i,nh);
    for (int j=1;j<=pq;j++)
    {
        ans[i][j]=p[i-1]*ans[i-1][j-1]+(1-p[i-1])*ans[i-1][j];
    }
}
std::cout << std::fixed;
std::cout << std::setprecision(10) << ans[n][nh];

 return 0;   
}

Measured memory_bytes: 35072
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pr pair<int,int>
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    char str[N];
    int a[N],sum;void push(){for(int i=0;;i++){if(a[i]<=9)break;a[i]-=10,a[i+1]++,sum-=9;}}
    void main()
    {
        // int T=qread();
        // while(T--)
        {
            memset(a,0,sizeof a);scanf("%s",str+1);int ln=strlen(str+1);fo(i,1,ln) a[ln-i]=(str[i]-'0')*9;
            sum=0;fo(i,0,ln+1) {if(a[i]>9) a[i+1]+=a[i]/10,a[i]%=10;sum+=a[i];}
            for(int cnt=1;;cnt++) {a[0]++;sum++;push();
                if(cnt>=sum and sum%9==cnt%9){write2(ceil(cnt/9.0));break;}}
        }
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 4608
#include<iostream>
using namespace std;
int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if ((W >= x + r)&&(0<=x-r)) {
		if ((H >= y + r)&&(0<=y-r))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return(0);
}


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

int main(){
    int n;
    cin >> n;
    if(n/10 == 9 || n%10 == 9) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>

using namespace std;

bool dfs(int n, int u, int v, vector<int> *graph) {
  bool is_visited[55];
  for (int i = 0; i < 55; i++) {
    is_visited[i] = false;
  }

  stack<int> st;
  st.push(0);
 
  while (!st.empty()) {
    int cur = st.top(); st.pop();

    is_visited[cur] = true;
    
    for (int i = 0; i < graph[cur].size(); i++) {
      int next_v = graph[cur][i];

      // 辺を使わない処理
      if (cur == u && next_v == v) { continue; }
      if (cur == v && next_v == u) { continue; }

      if ( is_visited[next_v] == false ) {
        st.push(next_v);
      }
    }
  }

  for (int i = 0; i < n; i++) {
    if ( is_visited[i] == false ) {
      return false;
    }
  }
  return true;
}

int main() {
  int n, m;
  int aa[55], bb[55];
  vector<int> graph[55];

  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--; b--;

    aa[i] = a; bb[i] = b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  int ans = 0;
  for (int i = 0; i < m; i++) {
    int u = aa[i], v = bb[i];
    if ( dfs(n, u, v, graph) == false ) {
      ans++;
    }
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 256
// Try AtCoder
/// author: Leonardone @ NEETSDKASU
import std.stdio     : readln, writeln;
import std.string    : chomp;
import std.array     : split;
import std.conv      : to;
import std.algorithm : sort;

auto getVals(T)() { return readln.chomp.split.to!(T[]); }

void main() {
    auto n = getVals!int()[0];
    auto xs = getVals!long();
    xs.sort!("a > b");
    int c = 0;
    long ans = 1;
    for (int i = 1; i < n; i++) {
        if (xs[i] == xs[i-1]) {
            ans *= xs[i];
            xs[i] = -1;
            c++;
            if (c == 2) {
                writeln(ans);
                return;
            }
        }
    }
    writeln(0);
}

Measured memory_bytes: 4348
s = input()
a = -1
z = -1
for i in range(0, len(s)):
	if s[i] == 'A':
		a = i
		break
for i in range(0, len(s)):
	if s[-1-i] == 'Z':
		z = len(s)-1-i
		break
print(z-a+1)

Measured memory_bytes: 40048
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int x, y, z, K; cin >> x >> y >> z >> K;
  vector<int> a(x), b(y), c(z);
  for(int i = 0; i < x; i++) cin >> a[i];
  for(int i = 0; i < y; i++) cin >> b[i];
  for(int i = 0; i < z; i++) cin >> c[i];

  sort(a.rbegin(),a.rend());
  sort(b.rbegin(),b.rend());
  sort(c.rbegin(),c.rend());

  priority_queue<int,vector<int>,greater<int>> q; //最小値
  for(int i = 0; i < x; i++){
    for(int j = 0; j < y; j++){
      for(int k = 0; k < z; k++){
        int res = a[i] + b[j] + c[k];
        if(q.size() < K){
          q.push(res);
        }else {
          if(q.top() > res) break;
          q.pop();
          q.push(res);
        }
      }
    }
  }

  vector<int> ans;
  while(!q.empty()){
    ans.push_back(q.top());
    q.pop();
  }
  reverse(ans.begin(),ans.end());

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int n;
vector<string> p;
void dfs(string s,int a, int z){
	if(a==n){
		p.push_back(s);
		return;
	}
	for(int i=0;i<=min(n,z);i++){
		dfs(s+(char)('a'+i),a+1,z+(i==z));
	}
}

int main(){
	cin >> n;
	dfs("",0,0);
	REP(i,p.size()){
		cout << p[i] << endl;
	}
}

Measured memory_bytes: 7796
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}


# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.split("")
end

s_list = gets_nsp_list
t_list = gets_nsp_list

s_list.each_with_index do |c, i|
  unless c == t_list[i]
    puts "No"
    exit
  end
end
puts "Yes"

Measured memory_bytes: 14652
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, x, y;
	cin >> n >> x >> y;
	int a[n+1][n+1], s[n];
	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++) a[i][j]=fabs(i-j);
	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++)
			a[i][j]=min(a[i][j], min(a[i][x]+a[y][j]+1, a[i][y]+a[x][j]+1));
	for (int i=1; i<n; i++) s[i]=0;
	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++) s[a[i][j]]++;
	for (int i=1; i<n; i++) cout << s[i]/2 << endl;
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
         
    using namespace std;
                 
    #define pb push_back
    #define ll long long
    #define mp make_pair
    #define MOD 1000000007
    #define MAX 100000000
    #define MIN -1000000000
    #define LLINF 0x3f3f3f3f3f3f    
    #define INF 0x3f3f3f3f
    #define MAXN  100100

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int n;
        cin >> n;
        vector<int> a(n + 1); //1
        vector<int> b(n + 1); //2
        vector<int> c(n + 1); //3
        int atual = -1;
        for(int i = 1; i <= n; ++i){    
            cin >> a[i] >> b[i] >> c[i];
        }
        vector<vector<int>> dp(n + 1, vector<int>(3));
        for(int i = 0; i < 3; ++i){ 
            dp[0][i] = 0;
        }
        for(int i = 1; i <= n; ++i){    
            for(int j = 0; j < 3; ++j){ 
                if(j == 0){ 
                    dp[i][j] = max(dp[i-1][1] + b[i], dp[i - 1][2] + c[i]);
                }else if(j == 1){   
                    dp[i][j] = max(dp[i-1][0] + a[i], dp[i-1][2] + c[i]);
                }else{  
                    dp[i][j] = max(dp[i-1][0] + a[i], dp[i - 1][1] + b[i]);
                }
            }
        }
        cout << max({dp[n][1], dp[n][2], dp[n][0]}) << endl;
        return 0;
    }

Measured memory_bytes: 9760
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

int main() {
  int n;
  scanf("%d", &n);
  vi dp(n+1, INT_MAX/2);
  dp[0] = 0;
  vi add6 = {6};
  while (true) {
    int nx = add6.back() * 6;
    if (nx > n) {
      break;
    } else {
      add6.push_back(nx);
    }
  }
  vi add9 = {9};
  while (true) {
    int nx = add9.back() * 9;
    if (nx > n) {
      break;
    } else {
      add9.push_back(nx);
    }
  }

  FOR (i, 0, n) {
    dp[i+1] = min(dp[i+1], dp[i] + 1);
    for (int a6 : add6) {
      int ind = i + a6;
      if (ind > n) {
        break;
      }
      dp[ind] = min(dp[ind], dp[i] + 1);
    }
    for (int a9 : add9) {
      int ind = i + a9;
      if (ind > n) {
        break;
      }
      dp[ind] = min(dp[ind], dp[i] + 1);
    }
  }

  printf("%d\n", dp[n]);

  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        int j = i;
        while(j <= n){
            ans += (long long) j;
            j += i;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1728
#include<cstdio>
#include<iostream>
#include<list>
#include<algorithm>
#include<string>
using namespace std;

int main() {
    int q,x;
    string com;
    list<int> v;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&x);
            v.push_front(x);
        }else if(com=="deleteLast"){
            v.pop_back();
        }else if(com=="deleteFirst"){
            v.pop_front();
        }else if(com=="delete"){
            scanf("%d",&x);
            for(list<int>::iterator it=v.begin();it!=v.end();it++){
                if(*it==x){
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i=0;
    for(list<int>::iterator it=v.begin();it!=v.end();it++){
        if(i++) printf(" ");
        printf("%d",*it);
    }
    printf("\n");
    return 0;
}


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

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String s = br.readLine();	//１行目の文字を読み取る
        String p = br.readLine();	//２行目の文字を読み取る
        sb.append(s);				//sbに加えることにより文字の最後と最初を繋げた
        sb.append(s);
        if(sb.indexOf(p) != -1){
        	//指定文字列が対象文字列中の何番目に出現するかをindexOfで調べ
        	//対象文字列がなかった場合には-1が出るので!=条件にした
        	System.out.println("Yes");
        	//-1以外だったらYesが出力される
        }else{
        	System.out.println("No");
        	//-1だったらNoが出力される
        }
     }
}

Measured memory_bytes: 17040