akhauriyash/Code-Regression huggingface dataset:
def popcnt(n):
   c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
   c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
   c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
   c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
   c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
   c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
   return c
n = int(input())
s = input()
f = []
f.append(0)
M = 200000
for i in range(1,M+1):
    x = i
    cnt = 0
    while x > 0:
        x = x % popcnt(x)
        cnt += 1
    f.append(cnt)

    
buf = s.count('1')
if buf == 0:
    for i in range(n):
        if s[i] == '1':
            print(0)
        else:
            print(1)
else:
    a = buf + 1
    pow2a = []
    pow2a.append(1)
    for i in range(M):
        pow2a.append((pow2a[i]*2) % a)
    b = buf - 1
    pow2b = []
    pow2b.append(1)
    if buf != 1:
        for i in range(M):
            pow2b.append((pow2b[i]*2) % b)
    asum = 0
    for i in range(n):
        if s[i] == '1':
            asum = (asum + pow2a[n - 1 - i]) % a
    bsum = 0
    if buf != 1:    
        for i in range(n):
            if s[i] == '1':            
                bsum = (bsum + pow2b[n - 1 - i]) % b
    if buf == 1:
        for i in range(n):
            if s[i] == '1':
                print(0)
            else:
                x = (asum + pow2a[n - 1 - i]) % a
                print(f[x] + 1)
    else:
        for i in range(n):
            if s[i] == '1':
                x = (bsum - pow2b[n - 1 - i] + b) % b
                print(f[x] + 1)
            else:
                x = (asum + pow2a[n - 1 - i]) % a
                print(f[x] + 1)                


Measured memory_bytes: 26944
#include<cstdio>
#include<algorithm>
#include<iterator>
#include<vector>
 
using namespace std;
 
int main(void) {
    while(1) {
        int m,nmin,nmax;
        vector<int> p;
        scanf("%d%d%d",&m,&nmin,&nmax);
        if(!m) break;
 
        for(int i=0; i<m; i++) {
            int p_;
            scanf("%d",&p_);
            p.push_back(p_);
        }
 
        sort(begin(p), end(p));
 
        int last=p[0];
        int maxgap=-1, res=-1;
        while(1) {
            auto ub = upper_bound(begin(p), end(p), last);
            if(ub == end(p)) break;
 
            last = *ub;
 
            if(end(p) - ub > nmax || end(p) - ub < nmin) continue;
 
            if(maxgap < (*ub - *(ub-1))) {
                maxgap = (*ub - *(ub-1));
                res = end(p)-ub;
            }
             
        }
        printf("%d\n",res);
    }
    return 0;
}

Measured memory_bytes: 2664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;

int main(){
	LL N, M;
	cin >> N >> M;
	if(N*2>=M) cout << M/2 << endl;
	else cout << N+(M-N*2)/4 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int N=100010;
int a[N];
int A,B,n;
bool ok(int x){
    int i;
    ll ans=0;
    for(i=1;i<=n;i++)
        if(a[i]>(ll)x*B) ans+=(a[i]-x*B-1)/A+1;
    return ans<=x;
}
int main(){
    int i,lb=0,rb=(int)1e9+10,mid;
    scanf("%d %d %d",&n,&A,&B);A-=B;
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    while(rb-lb>1){
        mid=lb+rb>>1;
        if(ok(mid)) rb=mid;
        else lb=mid;
    }
    printf("%d",rb);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long X, long long Y, long long Z) {
    cout << Z << " " << X << " " << Y << endl;
}

int main() {
    long long Y;
    long long X;
    long long Z;
    scanf("%lld", &X);
    scanf("%lld", &Y);
    scanf("%lld", &Z);
    solve(X, Y, Z);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
	fast;
	ll n;
	cin>>n;
	ll arr[n],max=INT_MIN,ans=0;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	for(int i=0;i<n;i++)
		if(arr[i]>=max)
			max=arr[i],ans++;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3512
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  300005

int main()
{
	ios
	ll n,i,j,x;
	cin>>n;
	map<ll,ll>m;
	for(i=0;i<n;i++){
		cin>>x;
		m[x]=i;
	}
	if(n==1){
		cout<<"0";return 0;
	}
	ll ans=0,cnt=1;
	i=2;
	while(i<=n){
		if(m[i-1]<m[i])cnt++;
		else cnt=1;
		ans=max(ans,cnt);
		i++;
	}
	cout<<n-ans;
	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int N;
	cin>>N;
	char S[600][300];
	rep(i,N)rep(j,N){
		cin>>S[i][j];
		S[N+i][j]=S[i][j];
	}
	int ans=0;
	rep(k,N){
		bool sym=true;
		rep(i,N)for(int j=i+1;j<N;j++){
			if(S[k+i][j]!=S[k+j][i])sym=false;
		}
		if(sym)ans+=N;
	}
	cout<<ans;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Grid Mori
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int n, a, b, c, d;

		n = parseInt(br.readLine());

		line = br.readLine();
		a = parseInt(line.substring(0, line.indexOf(' ')));
		b = parseInt(line.substring(line.indexOf(' ') + 1));

		line = br.readLine();
		c = parseInt(line.substring(0, line.indexOf(' ')));
		d = parseInt(line.substring(line.indexOf(' ') + 1));

		a--;
		b--;
		c--;
		d--;

		int min = Integer.MAX_VALUE;

		for (int w = 1; w <= n; w++) {
			int[] pa = new int[]{a % w, a / w};
			int[] pb = new int[]{b % w, b / w};
			int[] pc = new int[]{c % w, c / w};
			int[] pd = new int[]{d % w, d / w};
			int _min = 0;
			_min += Math.abs(pa[0] - pb[0]);
			_min += Math.abs(pa[1] - pb[1]);
			_min += Math.abs(pc[0] - pd[0]);
			_min += Math.abs(pc[1] - pd[1]);
			min = Math.min(min, _min);
		}

		System.out.println(min);
	}
}

Measured memory_bytes: 24216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		long[] street = new long[n];

		long res = 0l;
		for (int i = 0; i < n; i++) {
			street[i] = sc.nextLong();
		}
		
		for (int i = 1; i < n; i++) {
			res += (Math.min((street[i] - street[i-1]) * a, b));
		}
		
		System.out.println(res);
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 35640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<tuple<string, int, int>> guide(n);
    for (int i = 0; i < n; i++) {
        int a;
        string b;
        cin >> b >> a;
        guide.at(i) = make_tuple(b, -1 * a, i);
    }
    sort(guide.begin(), guide.end());
    for (int i = 0; i < n; i++) {
        int d, e;
        string c;
        tie(c, d, e) = guide.at(i);
        cout << e + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>

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

using namespace std;

const int inf = 1e9;

typedef pair<int, int> P;

struct E{
	E(int t, int c): t(t), c(c){} 

	int t, c;
};

int n;
vector<E> g[10000];
int d[10000];

int main(){
	scanf("%d", &n);
	rep(i, n){
		int u, k;
		scanf("%d%d", &u, &k);
		rep(j, k){
			int v, c;
			scanf("%d%d", &v, &c);
			g[u].push_back(E(v, c));
		}
	}

	fill_n(d, n, inf);

	priority_queue<P, vector<P>, greater<P> > q;
	d[0] = 0;
	q.push(P(0, 0));
	while(!q.empty()){
		P v = q.top();
		q.pop();
		if(v.first > d[v.second]){
			continue;
		}
		rep(i, g[v.second].size()){
			E e = g[v.second][i];
			if(d[e.t] > v.first + e.c){
				d[e.t] = v.first + e.c;
				q.push(P(d[e.t], e.t));
			}
		}
	}

	rep(i, n){
		printf("%d %d\n", i, d[i]);
	}
	return 0;
}

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

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

const int MAXN = 1e5;

int n, m;
vector<int> adj[MAXN+10];

bool vis[MAXN+10];
vector<int> order;

void dfs(int now)
{
    vis[now]=true;
    for(int nxt : adj[now]) if(!vis[nxt]) dfs(nxt);
    order.push_back(now);
}

int dp[MAXN+10], ans;

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

    scanf("%d%d", &n, &m);
    for(i=0; i<m; i++)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        adj[u].push_back(v);
    }

    for(i=1; i<=n; i++) if(!vis[i]) dfs(i);
    reverse(order.begin(), order.end());

    for(i=0; i<n; i++)
    {
        int now=order[i]; ans=max(ans, dp[now]);
        for(int nxt : adj[now]) dp[nxt]=max(dp[nxt], dp[now]+1);
    }

    printf("%d", ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_a() {
	ll r;
	ll ans = 0;
	cin >> r;

	ans = r * r;

	cout << ans << "\n";

	return;
}

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

	solve_abc_a();

	return 0;
}

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

int main(){
//srandom((unsigned long)time(NULL));
long long k,n;
cin>>k>>n;
vector<long long> a;
for(long long i=0;i<n;i++){
    long long x;
    cin>>x;
    a.emplace_back(x);
}
//cout<<1<<endl;
vector<long long> b;
b.emplace_back(k-a[n-1]+a[0]);
//cout<<"b[0]="<<b[0]<<endl;
for(long long i=0;i<n-1;i++){
    b.emplace_back(a[i+1]-a[i]);
}
//cout<<"b[1]="<<b[1]<<endl;
sort(b.begin(),b.end());
cout<<k-b[n-1]<<endl;

return 0;
}

Measured memory_bytes: 4848
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

typedef long long ll;
const int INF = (1<<28);

class Train
{
public:
	int x,y,c,id;

	Train() {}
	Train(int x, int y, int c, int id)
		:x(x),y(y),c(c),id(id)
	{}
};

class Edge
{
public:
  int src,dst,cst,cap,rev;
  Edge(int src, int dst, int cst, int cap, int rev)
    :src(src),dst(dst),cst(cst),cap(cap),rev(rev)
  {}
};

typedef vector<vector<Edge> > Graph;

void addEdge(int u, int v, int cap, int cost, Graph& graph)
{
  graph[u].push_back(Edge(u, v, cost, cap, graph[v].size()));
  graph[v].push_back(Edge(v, u, -cost, 0, graph[u].size()-1));
}

pair<int, int> minimumCostFlow(int S, int T, int L, Graph& graph)
{
  int V = graph.size();
  vector<int> dist(V), prevv(V), preve(V);

  int res = 0, fw = 0;
  while(1) {
    fill(dist.begin(), dist.end(), INF);
    dist[S] = 0;
    bool update = true;

    while(update) {
      update = false;
      for(int v = 0; v < V; v++) {
        if(dist[v] == INF) continue;

        for(int i=0; i<graph[v].size(); i++) {
          Edge& e = graph[v][i];
          int cost = e.cst;
          if(graph[e.dst][e.rev].cap != 0) cost = 0;

          if(e.cap > 0 && dist[e.dst] > dist[e.src] + cost) {
            dist[e.dst] = dist[e.src] + cost;
            prevv[e.dst] = e.src;
            preve[e.dst] = i;
            update = true;
          }
        }
      }
    }

    if(dist[T] == INF) break;

    int f = INF;
    for(int v = T; v != S; v = prevv[v])
      f = min(f, graph[prevv[v]][preve[v]].cap);

    res += dist[T];
    fw += f;

    for(int v = T; v != S; v = prevv[v]) {
      Edge& e = graph[prevv[v]][preve[v]];
      e.cap -= f;
      graph[v][e.rev].cap += f;
    }

	if(fw >= L) break;
  }

  return make_pair(res, fw);
}

int main()
{
	int N;
	while(cin >> N, N) {
		Graph graph(20000);
		vector<pair<int, int> > nodes;
		nodes.push_back(make_pair(0, -1));
		
		int K = 1;
		for(int i=0; i<N-1; i++) {
			int M;
			cin >> M;

			set<int> piyo;
			vector<Train> trains(M);
			for(int j=0; j<M; j++) {
				int x,y,c;
				cin >> x >> y >> c;
				trains[j] = Train(x,y,c,K++);
				piyo.insert(y);

				for(int k=0; k<nodes.size(); k++) {
					if(nodes[k].second <= x) {
						addEdge(nodes[k].first, trains[j].id, 1, 0, graph);
					}
				}
			}

			nodes.clear();
			for(set<int>::iterator it = piyo.begin(); it != piyo.end(); ++it)
			{
				nodes.push_back(make_pair(K++, *it));
			}

			for(int i=0; i<trains.size(); i++) {
				for(int j=0; j<nodes.size(); j++) {
					if(trains[i].y == nodes[j].second) {
						addEdge(trains[i].id, nodes[j].first, 1, trains[i].c, graph);
					}
				}
			}

			for(int i=0; i<nodes.size(); i++) {
				addEdge(nodes[i].first, K, 1, 0, graph);
				nodes[i].first = K++;
			}
		}

		for(int i=0; i<nodes.size(); i++)
			addEdge(nodes[i].first, K, 1, 0, graph);

		int G;
		cin >> G;

		pair<int, int> pr = minimumCostFlow(0, K, G, graph);

		cout << pr.second << " " << pr.first << endl;
	}
}

Measured memory_bytes: 3976
#include<cstdio>
#include<algorithm>
int main(){
	long long int n;
	scanf("%lld",&n);
	long long int a[5]={};
	for(int i=0;i<5;i++){
		scanf("%lld",&a[i]);
	}
	std::sort(a, a+5);
	long long int ans;
	if(n%a[0]==0)ans=n/a[0]+4;
	else ans=n/a[0]+5;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define pb push_back
#define pp(a, b) pair <a, b>
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pi pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define itr iterator
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
 
 
using namespace __gnu_pbds;
using namespace std;
 
template <class T> T printr(T p){ cout << p << '\n'; return 0; }
template <class T> T printe(T p){ cout << p << '\n'; exit(0); }
template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
 
 
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif
 
ll power(ll x, ll y, ll p){ 
   ll res = 1;
   x = x % p;  
   while (y > 0) {
      if (y & 1) 
         res = (res * x) % p; 
      y = y >> 1;
      x = (x * x) % p; 
   }
   return res;
}
 
const ll INF = (ll)(8e18);
const ll MOD = 1e9 + 7;
 
const int maxn = 200010;

ll a[maxn];

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ll n; cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    ll ans = 1;
    for(int i = 1; i <= n; i++){
        if(a[i] == ans) ans += 1;
    }
    if(ans == 1) ans = -1;
    else ans = n - ans + 1;
    cout << ans << '\n';
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
  int r1, r2;
  double r3;

  cin >> r1 >> r2;

  r3 = (r1 * r2) / (double)(r1 + r2);

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

  return 0;
}

Measured memory_bytes: 256
s = gets.chomp
t = gets.chomp

(s.length - t.length).downto(0) do |i|
  i.upto(i+t.length-1) do |j|
    break if s[j] != t[j-i] && s[j] != "?"
    if j == i+t.length-1
      0.upto(s.length-1) do |k|
        if s[k] == "?" && (k < i || k > j)
          s[k] = "a"
        elsif k >= i && k<= j
          s[k] = t[k-i]
        end
      end
      puts s
      exit
    end
  end
end

puts "UNRESTORABLE"


Measured memory_bytes: 1788
N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

Measured memory_bytes: 2940
#include <stdio.h>
int main()
{
  int n,i,j,u[100],k,v,adj[100][100],l;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      adj[i][j]=0;
    }
  }
  for(i=0;i<n;i++)
    {
      scanf("%d",&u[i]);
      scanf("%d",&k);
      for(j=0;j<k;j++)
	{
	  scanf("%d",&v);
	  adj[i][v-1]=1;
	}
    }
  for(i=0;i<n;i++){
    if(i>0)
      printf("\n");
    for(j=0;j<n;j++){
      printf("%d",adj[i][j]);
      if(j!=n-1)
	printf(" ");
    }
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2048
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		Set set = new HashSet<Integer>();

		set.add(A);
		set.add(B);
		set.add(C);


		if (set.size() == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23636
D = int(input())
C = list(map(int,input().split())) #C[i]AiCを実施しないと下がる満足度
S = [] #S[i][j] i日目にAjcというコンテストを実施した場合に上がる満足度
for i in range(D): #コンテストは0index
    temp = list(map(int,input().split()))
    S.append(temp)

since = [0 for _ in range(26)] #最後に開催されてから何日経ったか。
for i in range(26):
    since[i] += C[i]
for i in range(D):
    contest= max(since)
    idx = since.index(contest)
    print(idx+1) #1indexに直す。
    for j in range(26):
        if j != idx:
            since[j] += C[j]
        else:
            since[j] = C[j]


Measured memory_bytes: 68580
use std::io;

fn main() {

	let mut line = String::new();

	// expectは、エラーの場合、引数の文字列でpanic!を呼び出す
	io::stdin().read_line(&mut line).expect("Failed to read line.");

	// println!("{:?}",line.split(" ").collect::<Vec<&str>>());

	let l1 : Vec<i64> = line.trim().split(" ").map(|val| val.parse().unwrap()).collect();
	let (n,x,t) = (l1[0], l1[1], l1[2]);

	let ans = ( ((n as f64) / (x as f64)).ceil() as i64) * t;

	println!("{}", ans );


}

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

using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define Loop(i, a, b) for(int i = a ; i < b ; ++i)
#define loop(i, n) Loop(i, 0, n)
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define vl vector<ll>
#define vvl vector<vl>
#define pll pair<ll, ll>
#define vll vector<pll>
#define vvll vector<vll>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18+5
#define inf 1e9+5
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

template <typename T> T max(T a, T b, T c){ return max(a, max(b, c));}
template <typename T> T min(T a, T b, T c){ return min(a, min(b, c));}

int M = 1e9+7; //check


int main() {
	_69e27;
	int n;
	string s;
	cin >> n >> s;
	string t = s.substr(0, n/2);
	if(s == t+t) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<vector>
using namespace std;
int E[300000], W[300000];
int A[200000], B[200000][20];
int main() {

	/*int n;
	string s;
	cin >> n;
	cin >> s;
	int i;
	int e = 0, w = 0;
	for (i = 0; i < n; i++) {
		if (s[i] == 'E') {
			e++;
		}
		else {
			w++;
		}
		E[i] = e; W[i] = w;
	}
	int MIN = E[n - 1] - E[0];
	for (i = 1; i < n; i++) {
		
		if (MIN > W[i - 1] + E[n - 1] - E[i]) {
			MIN = W[i - 1] + E[n - 1] - E[i];
		}
	}
	cout << MIN << endl;
	return 0;*/

	int n;
	cin >> n;
	long long int i, j, a;
	int bin[21];
	bin[0] = 1;
	for (i = 1; i < 21; i++) {
		bin[i] = bin[i - 1] * 2;
	}
	for (i = 0; i < n; i++) {
		cin >> A[i];
		a = A[i];
		j = 0;
		while (a > 0) {
			if (a % 2 == 1) {
				B[i][j] = 1;
			}
			else {
				B[i][j] = 0;
			}
			a = a / 2;
			j++;
		}
	}
	long long int sum = 0;
	i = 0; j = 0;
	int k, c[20], flag;
	for (k = 0; k < 20; k++)c[k] = B[0][k];
	while (1) {
		flag = 0;
		for (k = 0; k < 20; k++) {

			if (c[k] > 1)flag = 1;
		}
		if (flag == 1) {
			//j動かす
			j++;
			for (k = 0; k < 20; k++) {
				if (B[j - 1][k] == 1)c[k]--;
			}
			//if (j == i)sum++;
			//if (j == n - 1) {
			//	cout << sum << endl;
			//	return 0;
			//}
		}
		else {
			//i動かす
			sum = sum + i - j + 1;
			if (i == n - 1) {
				cout << sum << endl;
				return 0;
			}
			//cout << sum << endl;
			i++;
			for (k = 0; k < 20; k++) {
				if (B[i][k] == 1)c[k]++;
			}
			//if (i == n - 1) {
			//	flag = 0;
			//	for (k = 0; k < 20; k++) {
					
			//		if (c[k] > 1)flag = 1;
			//	}
			//	cout << sum + flag * (i - j + 1) << endl;
			//	return 0;
			//}
		}
		//cout << "i = " << i << ": j = " << j << endl;
	}






}

Measured memory_bytes: 20040
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

// Larsson-Sadakane's Suffix array Construction: O(n (log n)^2)
struct SAComp {
  const int h, *g;
  SAComp(int h, int* g) : h(h), g(g) {}
  bool operator() (int a, int b) {
    return a == b ? false : g[a] != g[b] ? g[a] < g[b] : g[a+h] < g[b+h];
  }
};
int *buildSA(char* t, int n) {
  int g[n+1], b[n+1], *v = new int[n+1];
  rep(i,n+1) v[i] = i, g[i] = t[i];
  b[0] = 0; b[n] = 0;

  sort(v, v+n+1, SAComp(0, g));
  for(int h = 1; b[n] != n ; h *= 2) {
    SAComp comp(h, g);
    sort(v, v+n+1, comp);
    rep(i, n) b[i+1] = b[i] + comp(v[i], v[i+1]);
    rep(i, n+1) g[v[i]] = b[i];
  }
  return v;
}
// Naive matching O(m log n)
int find(char *t, int n, char *p, int m, int *sa) {
  int a = 0, b = n;
  while (a < b) {
    int c = (a + b) / 2;
    if (strncmp(t+sa[c], p, m) < 0) a = c+1; else b = c;
  }
  return strncmp(t+sa[a], p, m) == 0 ? sa[a] : -1;
}
int n,m,k;
string s;
char *sc,t[500];
int *sa,len;

ll ck(){
	ll res=0;
	for(int l=0,r=0;l<m;l++){
		while(r<l)r++;
		while(r<m){
			char tmp=t[r+1];
			t[r+1]=0;
			bool res=find(sc,len,t+l,r-l+1,sa)>=0;
			t[r+1]=tmp;
			if(!res)break;
			r++;
		}
		res+=r-l;
	}
	return res;
}

const string rec(int l,int r){
	if(l>=r)return "";
	
	if(isdigit(s[l])){
		int i,x=0,d=0;
		for(;l<r&&isdigit(s[l]);l++){
			x*=10; x+=s[l]-'0';
			x=min(x,400);
		}
		for(i=l;i<r;i++){
			if(s[i]=='(')d++;
			if(s[i]==')')d--;
			if(d==0)break;
		}
		string res="", tmp=rec(l+1,i);
		if(x==1)return tmp;
		
		rep(i,x-1){
			res+=tmp;
			if(res.size()>400)break;
		}
		const string str=res+tmp;
		if(str.size()<=800)return str+rec(i+1,r);
		const string head400=str.substr(0,min((int)str.size(),400));
		const string tail400=str.substr(max(0,(int)str.size()-400));
		
		const string tail=tmp.substr(max(0,(int)tmp.size()-400));
		const string head=tmp.substr(0,min(400,(int)tmp.size()));
		
		return head400+"@"+tail+res+head+"@"+tail400+rec(i+1,r);
	}
	return s[l]+rec(l+1,r);
}
int main(){
	cin>>n>>m>>k;
	cin>>s;
	s=rec(0,n);
	len=s.size();
	sc=(char*)malloc(len+1);
	sprintf(sc,"%s",s.c_str()); s.clear();
	sa=buildSA(sc,len);
	
	int ansi=0; ll ans=0;
	rep(i,k){
		cin>>t;
		ll tmp=ck();
		if(tmp>ans)ans=tmp, ansi=i;
	}
	cout<<ansi+1<<" "<<ans<<endl;
	
	return 0;
	
}

Measured memory_bytes: 3048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#define ll long long
#define MOD 1000000007
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(isdigit(ch)) re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n;
ll dp[2000010],sum[2000010];
void add(ll &a,ll b){
	a+=b;
	if(a>=MOD) a-=MOD;
}
int main(){
	n=read();
	int i;
	dp[1]=1;
	for(i=1;i<=n;i++){
		if(i>=3) add(dp[i],sum[i-3]);
		add(dp[i],dp[i-1]);
		(sum[i]=sum[i-1]+dp[i])%=MOD;
	}
	ll ans=0;
	for(i=1;i<n;i++) add(ans,dp[i]*(n-1)%MOD*(n-1)%MOD);
	for(i=1;i<n-1;i++) add(ans,dp[i]*(i+1)%MOD);
	add(ans,(dp[n]*n+dp[n-1]*(n-1))%MOD);
	cout<<ans<<'\n';
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string s;
    cin >> s;
    int N = s.size();
    string t = "keyence";
    int k = N - 7;
    for (int i = 0; i <= N - k; i++) {

        string u = s.substr(0, i) + s.substr(i + k);
        if (u == t) {
            cout << "YES" << endl;
            return;
        }
    }
    cout << "NO" << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();

    #ifdef LOCAL_ENV
    assert(cin.rdstate() & ios_base::eofbit);
    #endif
}


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

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

using namespace std;
typedef long double ld;

const ld pi = acos((ld)-1.0);
const ld eps = 1e-6;

ld solve(vector<ld> r, int n) {
  ld mx_area = 0.0;
  do {
    ld mn_prod = 1e+8;
    REP(i,n) {
      mn_prod = min(mn_prod, r[i]*r[(i+1)%n]);
    }
    ld la = -mn_prod, ra = mn_prod;
    REP(i,100) {
      ld mid = (la + ra) / 2.0;
      ld sum_theta = 0.0;
      REP(j,n) {
        sum_theta += acos(mid/(r[j]*r[(j+1)%n]));
      }
      if (sum_theta < 2*pi) ra = mid;
      else la = mid;
    }
    ld lambda = la;
    ld area = 0.0;
    ld sum_theta = 0.0;
    REP(i,n) {
      ld theta = acos(lambda / (r[i] * r[(i+1)%n]));
      sum_theta += theta;
      area += 0.5 * r[i] * r[(i+1)%n] * sin(theta);
    }
    if(abs(sum_theta - 2*pi) > eps) continue;
    mx_area = max(mx_area, area);
  } while(next_permutation(begin(r),end(r)));
  return mx_area;
}

int main() {
  int n;
  cin>>n;
  vector<ld> r(n);
  REP(i,n) cin>>r[i];
  sort(begin(r),end(r));
  ld mx_area = 0.0;
  REP(i,1<<(n-1)) {
    bitset<7> bs(i);
    vector<ld> subr;
    if (bs.count() < 2) continue;
    REP(j,n-1) {
      if(bs[j]) subr.push_back(r[j]);
    }
    subr.push_back(r.back());
    mx_area = max(mx_area, solve(subr, subr.size()));
  }
  cout<<setprecision(10)<<fixed<<mx_area<<endl;
  return 0;
}

Measured memory_bytes: 1324
import java.util.Scanner;

public class Main {

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

	    long a=gl();
	    long b=gl();
	    long x=gl();
	    
	    long c=a%x;
	    long d=b%x;
        long e =((b-d)-(a-c)) / x;
        if(c==0)e++;

        System.out.println(e);
//        if (xo>w || yo>h) {
//        	System.out.print(0);
//        }else {
//        	System.out.print((h-yo)*(w-xo));
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    ll a[n];
    
    map<ll, ll> mp;
    map<ll, ll> mp1;
    rng(i, 0, n){
        cin >> a[i];
        mp[a[i]]++;
    }
    
    ll res = 0;
    for( auto it = mp.begin(); it != mp.end(); it++){
        ll curr = it->second;
        if( curr > 1){
            ll tmp = (curr*(curr-1))/2;
            res += (curr*(curr-1))/2;
            curr--;
            mp1[it->first] = tmp - (curr*(curr-1))/2;
        }
    }
    
    rng(i, 0, n){
        cout<<res-mp1[a[i]]<<"\n";
    }
    
	return 0;
}






Measured memory_bytes: 19072
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
using ll = long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
 
#define MOD 1000000007
void init();
void solve();

signed main()
{
    init();
    solve();
}

ll A, B, C;

void init()
{
    cin >> A >> B >> C;
    C = min(A+B+1, C);
    cout << B + C << endl;
}


void solve()
{
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
 #define rep(i,n) for(int i=0;i<n;i++)
 using namespace std;
  int main(){
      string s,t;
      cin >> s >> t;
        int ans = t.size();
        int k= s.size()-t.size()+1;
        rep(i,k){
            int diff=0;
            rep(j,t.size()){
                if(t[j]!=s[i+j]){
                    diff++;
                }
            }
            ans = min(ans,diff);
        }

        cout << ans << endl;
        return 0;

  }

Measured memory_bytes: 3636
#include <stdio.h>

int main(void) {
  int n, x, i, j, k;
  while(1) {
    int cnt = 0;
    scanf("%d %d", &n, &x);
    if (n == 0 && x == 0) break;
    for (i = 1; i <= n - 2; i++) {
      if (i >= x) break;
      for (j = i + 1; j <= n - 1; j++) {
        if (i + j >= x) break;
        for (k = j + 1; k <= n; k++) {
          if (i + j + k == x) cnt++;
          if (i + j + k >= x) break;
        }
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}



Measured memory_bytes: 2008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string S;
  string Sbeg,Send;
  char A;
  int Q,x;
  int count=0;
  cin>>S>>Q;
  rep(i,Q){
    cin>>x;
    if(x==1){
      count++;
    }else if(x==2){
      cin>>x>>A;
      if(x==1){
        if(count%2==1){
          Send=Send+A;
        }else{
          Sbeg=A+Sbeg;
        }
      }
      else if(x=2){
        if(count%2==1){
          Sbeg=A+Sbeg;
        }else{
          Send=Send+A;
        }
      }
    }
  }
  S=Sbeg+S+Send;
  if(count%2==1){
  reverse(S.begin(),S.end());
  }
  cout<<S<<endl;
}


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

mod = 998244353

pows = [1]
for i in range(10000):
    pows.append((pows[-1] * 2) % mod)

dp = [0] * (s + 1)
dp[0] = 1
if a[0] <= s:
    dp[a[0]] = 1

for i in range(1, n):
    dp_new = [0] * (s + 1)
    dp_new[0] = 1
    for j in range(1, s + 1):
        dp_new[j] = dp[j] * 2

        if j - a[i] > 0:
            dp_new[j] += dp[j-a[i]]
        elif j == a[i]:
            dp_new[j] += pows[i]
        dp_new[j] %= mod

    dp = dp_new

print(dp[-1])


Measured memory_bytes: 68700
/// 1行の文字を空白で分割してVec<T>にする。
fn readone_multi<T : std::str::FromStr>(count : usize) -> Vec<T> {
    let mut v : Vec<T> = Vec::with_capacity(count);
    for _ in 0..count {
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        v.push(input.trim().parse().ok().unwrap());
    }
    v
}

fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let input : usize = input.trim().parse().ok().unwrap();
    let input = input;
    let vec : Vec<i32> = readone_multi(input);
    let mut max = 0;
    let mut maxcount : usize = 0;
    let mut maxlength = 0;
    let mut second = 0;
    for i in 0..input {
        if vec[i] > max {
            if second < max {
                second = max;
            }
            max = vec[i];
            maxcount = i;
            maxlength = 1;
            continue;
        }
        if vec[i] == max {
            maxlength += 1;
            continue;
        } 
        if vec[i] > second {
            second = vec[i];
        }
    }
    if maxlength > 1 {
        for _ in 0..input {
            println!("{}", max)
        }
        return;
    }
    for i in 0..input {
        if i == maxcount {
            println!("{}", second);
            continue;
        }
        println!("{}", max)
    }
}



Measured memory_bytes: 5628
#include <cassert>
#include <iostream>

using namespace std;

constexpr int ceil_sqrt(int x) {
  int ans = 0;
  while (ans*ans < x) { ++ans; }
  return ans;
}

template<int size>
struct Sieve {
  constexpr Sieve(): factor(), primes() {
    factor[0] = factor[1] = 1;
    for (int p = 2; p < size; ++p) {
      primes[p] = primes[p-1] + (factor[p]?0:1);
      if (factor[p]) { continue; }
      for (int n = 2*p; n < size; n += p) {
        factor[n] = p;
      }
    }
  }
  constexpr bool is_prime(int n) const {
    assert(n < size);
    return !(factor[n]);
  }
  int factor[size];
  int primes[size];
};

constexpr int NMAX = 1000010;

int main() {
  int N = 0;
  const auto sieve = Sieve<NMAX>();
  while (cin >> N) {
    cout << sieve.primes[N] << endl;
  }
  return 0;
}



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

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(x, y) memset(x, y, sizeof x);
#define y1 asdgh
#define int long long
#define double long double
#define endl '\n'
//mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
//#pragma warning(disable:4996)
//#pragma comment(linker, "/STACK:336777216")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*------------------------------<Debugging Stuff>---------------------------------*/

template<class L, class R> ostream& operator<<(ostream &os, pair<L , R> P) {
      return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R , class M> ostream& operator<<(ostream &os, tuple<L , R , M> P) {
      return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")";
}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
      os << "{ "; for(auto v : V) os << v << " "; return os << "}";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

/*------------------------------</Debugging Stuff>--------------------------------*/
const int maxn = (int) 1e6 + 6;
const double EPS = 1e-9;
const int INF = (int) 1e18 + 18;
const int mod = (int) 1e9 + 7;

signed main() {
      
      fio;
      string s; cin >> s;
      map<char , int> cnt;
      for(int i = 0; i < 4; i++) cnt[s[i]]++;
      
      cout << ((int) cnt.size() == 2 ? "Yes" : "No") << endl;
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      return 0;
}

// IMPORTANT -:
// check base cases n = 0 , n = 1
// max / min questions - check for binary search
// difference array might be interesting


Measured memory_bytes: 892
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

//define

#define                boost_                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                iter_(i,n)                     for (int i = 0; i < int(n); i++)
#define                for_n(i, n)                    for (int i = 1; i <= int(n); i++)
#define                pb                             push_back
#define                mp                             make_pair
#define                itr                            ::iterator
#define                s_sort(s)                      sort(s.begin(),s.end())
#define                n_sort(a)                      sort(a,a+n)
#define                thank_you                      return 0
#define                thanks                         return
#define                pii                            pair<int,int>
#define                precise_impact                 cout<<setprecision(10)<<fixed;

using namespace std;

//data type
typedef long long int ll;
typedef unsigned long long int ulli;
typedef double db;


//constants
#define PI acos(-1.00)
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
int egcd(int a,int b,int &x,int &y){
    if(a==0){
        x=0;
        y=1;
        return b;
    }
    int x1,y1;
    int d=egcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return d;
}

void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    int t=1;
    //cin>>t;
    while(t--)
        solve();

    thank_you;
}


void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)||(a==5 && b==5 && c==7))
       cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}



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

const int N = 1e5 + 5;
int n,m;
long long a[N];
unordered_map<int, int> cnt;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m;
    for (int i = 1; i <= n; i++)cin>>a[i];
    
    cnt[0] ++;
    for (int i = 1; i <= n; i++){
        a[i] = a[i] + a[i-1];
        cnt[a[i]%m] ++;
    }
    
    long long ans = 0;
    for(auto i:cnt){
        if(i.second>=2){
            ans += (long long)(i.second-1)*i.second /2;
        }
    }
    
    cout<<ans<<endl;
    
    
    
    
    
    return 0;
}



Measured memory_bytes: 4492
x,y = map(int, input().split())
if (x<0 and y>0) or (x>0 and y<0) or \
   (x>0 and y==0) or (x==0 and y<0):
    print(abs(abs(x)-abs(y))+1)
elif x>y:
    print(abs(abs(x)-abs(y))+2)
else:
    print(abs(abs(x)-abs(y)))
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define pp push_back
#define fr first
#define sc second

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0) ,cout.tie(0);
    cout.precision(18);
    double r; cin >> r;
    cout << 2.0 * acos(-1) * r << '\n';

    return 0;
}


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

using namespace std;

#define endl "\n"

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

    int n;
    cin >> n;

    vector<int> A(n);

    for (int &i : A) cin >> i;

    vector<vector<long long>> dp(n, vector<long long>(n, 0));

    for (int i = 0; i < n; i++) {
        dp[i][i] = A[i];
    }

    for (int d = 1; d < n; d++) {
        for (int i = 0; i < n - d; i++) {
            dp[i][i + d] = max(A[i] - dp[i + 1][i + d], A[i + d] - dp[i][i + d - 1]);
        }
    }

    cout << dp[0][n - 1] << endl;

    return 0;
}


Measured memory_bytes: 73648
n, m, x, y = map(int, input().split())
x_list = [int(i) for i in input().split()]
y_list = [int(i) for i in input().split()]

x_max = max(x_list)
y_min = min(y_list)

for z in range(x + 1, y + 1):
    if x_max < z and z <= y_min:
        print('No War')
        exit()
print('War')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define MOD  (int)(1e9+7)
 
#define float long double
 
 
int ADD(int &a,int &b)
{
  return (a%MOD + b%MOD )%MOD;
}
 
 
 
int ADD(int &a,int &b,int &c)
{
  return ( ADD(a,b) + c%MOD )%MOD;
}
 
 

 
 
 
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
 
 
bool  isPalindrome(string str) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = str.size() - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            
            return false; 
        } 
    } 
	return true;
	
} 
int32_t main()
{
  FAST;
 
  float n;
  cin >> n;
  n=n/3;
  cout<<fixed<<setprecision(12)<<n*n*n;
}

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import Data.Maybe


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    [a,b] <- r'
    let r = filter (\x -> floor (x * 0.08) == a && floor (x * 0.1) == b) [1..1500]
    print $ round $ if r == [] then -1 else head r



Measured memory_bytes: 636
import bisect
def main():
  X, N = map(int, input().split())
  if N == 0:
    print(X)
    return
  P = set(map(int, input().split()))

  NP = sorted(list(set(range(102)) - P))
  right = bisect.bisect(NP, X)
  left = right - 1
  if left == -1 or abs(X - NP[left]) > abs(X - NP[right]):
    print(NP[right])
  else:
    print(NP[left])

main()

Measured memory_bytes: 9104
#include <stdio.h>
#define M 1001
int dist[M][M];
int main(){
	int n,m,s,g1,g2,i,j,k,l;
	for(;scanf("%d%d%d%d%d",&n,&m,&s,&g1,&g2),n;){
		for(i=1;i<=n;i++)for(j=1;j<=n;j++)dist[i][j]=(i!=j)*(1<<29);
		for(i=0;i<m;i++)scanf("%d%d%d",&j,&k,&l),dist[j][k]=l;
		for(k=1;k<=n;k++)for(i=1;i<=n;i++)for(j=1;j<=n;j++){
			if(dist[i][j]>dist[i][k]+dist[k][j])dist[i][j]=dist[i][k]+dist[k][j];
		}
		for(m=1<<29,i=1;i<=n;i++){
			if(m>dist[s][i]+dist[i][g1]+dist[i][g2])m=dist[s][i]+dist[i][g1]+dist[i][g2];
		}
		printf("%d\n",m);
	}
}

Measured memory_bytes: 1420
#include <iostream>
#include <vector>
using namespace std;
inline int gcd(int x,int y){
	if (!y) return x;
	return gcd(y,x%y);
}
inline int lcm(int x,int y){
	return (x*y)/gcd(y,x%y);
}
int main(){
	int n,x;
	vector<int> v;
	cin>>n;
	for (int i=1;i<=n;++i) cin>>x,v.push_back(x);
	for (int i=0;i<n-1;++i){
		v[i+1]=lcm(v[i],v[i+1]);
	}
	cout<<v[n-1]<<endl;
	return 0;
}

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

signed main(void){
    int n,m,a,b,c;
    cin>>n;
    int ans=0;
    int tako[n];
    rep(i,n)
    cin>>tako[i];
    rep(i,n){
        rep(j,n){
            if(i!=j)
            ans+=tako[i]*tako[j];
        }
    }
    
    cout<<ans/2<<endl;
    
    
}


Measured memory_bytes: 256