akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <iterator>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

vector<vector<int>> shift(vector<vector<int>> C, int s){
    int n = (int)C.size();
    vector<vector<int>>  ret(n, vector<int>(n));
    rep(i, n){
        rep(j, n){
            ret[i][j] = C[j][(i + s * j) % n];
        }
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int N = 42;
    vector<vector<int>>  A(N * N - N + 1, vector<int>(N));
    vector<vector<int>>  B(N - 1, vector<int> (N - 1));
    int cur = 1;
    rep(i, N){
        A[i][0] = 1;
        rep(j, 1, N){
            A[i][j] = cur + 1;
            cur++;
        }
    }
    rep(i, 1, N){
        rep(j, 1, N){
            B[i - 1][j - 1] = A[i][j];
        }
    }
    
    int ind = N;
    rep(i, N - 1){
        int t = i + 2;
        auto tmp = shift(B, i);
        rep(j, N - 1){
            A[ind][0] = t;
            rep(k, N - 1){
                A[ind][k + 1] = tmp[j][k];
            }
            ind++;
        }
    }
    
    cout << cur << " " <<  N <<  endl;
    rep(i, N * N - N + 1){
        voutput(A[i]);
    }
    
    vector<int> P(cur, 0);
    rep(i, N * N - N + 1){
        rep(j, N){
            P[A[i][j] - 1]++;
        }
    }
//    rep(i, cur){
//        if(P[i] != N){
//            output("ERROR1");
//        }
//    }
//
//    rep(i, N * N - N + 1) rep(j, i + 1, N * N - N + 1){
//        vector<int> intersection;
//
//        set_intersection(A[i].begin(), A[i].end()
//                         , A[j].begin(), A[j].end()
//                         , inserter(intersection, intersection.end()));
//        if(intersection.size() != 1){
//
//            cout << "ERROR2: " << i << ", " << j << endl;
//            voutput(intersection);
//        }
//    }
    
    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll MOD=998244353;
ll toori[301][90001]={};
ll toorihalf[301][90001]={};
int main(){
	int N,a[400],sum=0;
	scan(N);
	rep(i,N){
		scan(a[i]);
		sum+=a[i];
	}
	toori[0][0]=1;
	rep(i,N){
		rep(j,sum){
			if(j+a[i]<=90000){
				toori[i+1][j+a[i]]+=toori[i][j];
				toori[i+1][j+a[i]]%=MOD;
			}
			toori[i+1][j]+=toori[i][j]*2%MOD;
		}
	}
	toorihalf[0][0]=1;
	rep(i,N){
		rep(j,sum){
			if(j+a[i]<=90000){
				toorihalf[i+1][j+a[i]]+=toorihalf[i][j];
				toorihalf[i+1][j+a[i]]%=MOD;
			}
			toorihalf[i+1][j]+=toorihalf[i][j];
		}
	}
	ll all=1;
	rep(i,N){
		all*=3;
		all%=MOD;
	}
	ll over=0;
	for(int i=sum/2+(sum%2!=0);i<=sum;i++){
		over+=toori[N][i];
		over%=MOD;
	}
	if(sum%2==0) prin(((all-over*3+toorihalf[N][sum/2]*3)+MOD*3)%MOD);
	else prin(((all-over*3)+MOD*3)%MOD);
	return 0;
}


Measured memory_bytes: 422784
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	vector<pair<ll,ll>> P(N);
	ll SA=0,SB=0;
	REP(i,N){
		P[i].first=in();
		P[i].second=in();
		SB += P[i].second;
	}

	sort(ALL(P),[](pair<ll,ll>& l,pair<ll,ll>& r){return l.first+l.second>r.first+r.second;});

	int H=ceil(N/2.0);
	REP(i,H){
		SA += P[2*i].first;
		SB -= P[2*i].second;
	}
	
	out(SA-SB);
	return 0;
}


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

int main(){
  string weather;
  cin >> weather;
  if(weather == "Sunny")
    cout << "Cloudy" << endl;
  else if(weather == "Cloudy")
    cout << "Rainy" << endl;
  else if(weather == "Rainy")
    cout << "Sunny" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

int minimum=-1;


int main(){
	int n,row,num,col;
	scanf("%d",&n);
	int table[n][n];
	for(int i=0;i<n;i++){
		for(int k=0;k<n;k++){
			table[i][k] = 0;
		}
	}

	for(int i=0;i<n;i++){
		scanf("%d %d",&row,&num);
		for(int k=0;k<num;k++){
			scanf("%d",&col);
			table[row-1][col-1]=1;
		}
	}

	for(int i=0;i<n;i++){
		for(int k=0;k<n-1;k++){
			printf("%d ",table[i][k]);
		}
		printf("%d\n",table[i][n-1]);
	}

    return 0;
}



Measured memory_bytes: 3248
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

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

		int N = scan.nextInt();

		for (int i = 0; i < N; i++) {
			BigInteger a = new BigInteger(scan.next());
			BigInteger b = new BigInteger(scan.next());

			BigInteger c = a.add(b);

			if (ok(a) && ok(b) && ok(c)) {
				System.out.println(c);
			} else {
				System.out.println("overflow");
			}
		}

	}

	private static boolean ok(BigInteger z) {
		return z.toString().length() <= 80;
	}
}

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rere(i,a,b) for(int i=a;i<b;)
#define PB push_back
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	int k;
	int num = 0;

	cin >> s;
	cin >> k;

	rere(i, 0, k){
//		debug(num);
//		debug(s);
//		debug(k);
//		debug(" ");
		if (s[num] == 'a' && num != s.size() - 1)num++;
		else{
			if (k >= 'z' - s[num] + 1){
				k = k - ('z' - s[num] + 1);
				s[num] = 'a';				
			}
			else{
				if (num == s.size() - 1){
					s[num] = s[num] + k;
					k = 0;
				}
				else num++;
			}
		}
	}
	cout << s << endl;


	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int X = 3;
  for (int i=0;i<N;i++){
    string S;
    cin >> S;
    if (S=="Y"){
      X++;
      break;
    }
  }
  if (X==3){
    cout <<"Three"<<endl;
  }
  else {
    cout<<"Four"<<endl;
  }
}


Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  map<int, int> odd;
  map<int, int> even;
  for(int i=0; i<n; i++) {
    cin >> v[i];
    if(i%2==0) even[v[i]]++;
    else odd[v[i]]++;
  }
  vector< pair<int, int> > a;
  vector< pair<int, int> > b;
  for(auto i=odd.begin(); i!=odd.end(); i++){
    a.push_back({i->second, i->first});
  }
  for(auto i=even.begin(); i!=even.end(); i++){
    b.push_back({i->second, i->first});
  }
  a.push_back({0, -1});
  b.push_back({0, -1});
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int na = a.size();
  int nb = b.size();
  if(a[na-1].second != b[nb-1].second) {
    cout << n - a[na-1].first - b[nb-1].first << endl;
  }else{
    int ans = min(n - a[na-2].first - b[nb-1].first, n - a[na-1].first - b[nb-2].first);
    cout << ans << endl;
  }



  return 0;
}


//


Measured memory_bytes: 6520
N,M = map(int, input().split())

from collections import defaultdict
neighbor = defaultdict(list)
Rneighbor = defaultdict(list)
edges = []
for i in range(M):
  a,b,c = map(int, input().split())
  a,b = a-1, b-1
  edges += [(a,b,c)]
  neighbor[a].append(b)
  Rneighbor[b].append(a)

# only vertices that are reachable from 1 or N
v1 = set()
v1.add(0)
stack = [0]
while stack:
  v = stack.pop()
  for u in neighbor[v]:
    if u not in v1:
      v1.add(u)
      stack.append(u)

vn = set()
vn.add(N-1)
stack = [N-1]
while stack:
  v = stack.pop()
  for u in Rneighbor[v]:
    if u not in vn:
      vn.add(u)
      stack.append(u)

V = v1 & vn

edges = [(a,b,c) for a,b,c in edges if a in V and b in V]
score = [float('-inf')]*N
score[0] = 0

updated = True
i = 0

positive_cycle = False

while updated:
  if i == len(V):
    positive_cycle = True
    break

  updated = False
  for a,b,w in edges:
    if score[b] < score[a] + w:
      score[b] = score[a] + w
      updated = True
  i += 1

if positive_cycle:
  print('inf')
else:
  print(score[N-1])

Measured memory_bytes: 4212
import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        long a=sc.nextLong();
        int count=0;
        for(int i=0;i<=100;i++){
            a=a/2;
            count++;
            if(a==0)
                break;
        }
        long m=(long)Math.pow(2,count)-1;
        System.out.println(m);
    }
}

Measured memory_bytes: 23892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp44 {
    class Program {
        static void Main(string[] args) {
            string[] s = Console.ReadLine().Split(',').ToArray();
 
            Console.WriteLine(string.Join(" ", s));
        }
    }
}


Measured memory_bytes: 13268
import heapq
import sys
def dijkstra(e,dist,s,used):
  q=[]
  heapq.heappush(q,(0,0,s))
  while q:
    d,x,m=heapq.heappop(q)
    if not used[x][m]:
      continue
    dist[x][m]=d
    used[x][m]=False
    for cost,newx,silver in e[x][m]:
      if used[newx][silver]:
        heapq.heappush(q,(dist[x][m]+cost,newx,silver))
  return dist
def main():
  input=sys.stdin.readline
  n,m,s=map(int,input().split())
  if s>2500:
    s=2500
  edge=[[[] for i in range(2501)] for _ in range(n)]
  for _ in range(m):
    u,v,a,b=map(int,input().split())
    u-=1
    v-=1
    for j in range(a,2501):
        edge[u][j].append((b,v,j-a))
        edge[v][j].append((b,u,j-a))
  for i in range(n):
    c,d=map(int,input().split())
    for j in range(2501-c):
        edge[i][j].append((d,i,j+c))
  dist=[[10**18]*2501 for _ in range(n)]
  used=[[True]*2501 for _ in range(n)]
  dist=dijkstra(edge,dist,s,used)
  #print(edge)
  #print(dist)
  for i in range(1,n):
    print(min(dist[i]))
if __name__=="__main__":
  main()

Measured memory_bytes: 167388
using System;
using System.Linq;
namespace DPL_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string [] first = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(first[0]);
            var m = int.Parse(first[1]);
            int [] coinCnt = new int [n+1];

            string [] types = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < types.Length; j++)
            {
                var money = int.Parse(types[j]);
                for (int i = 0; i < n+1; i++)
                {
                    if(i - money >= 0){
                        if(coinCnt[i] == 0){
                            coinCnt[i] = coinCnt[i - money] + 1;
                        }else{
                            coinCnt[i] = coinCnt[i-money] + 1 < coinCnt[i] ? 
                                coinCnt[i-money] + 1 : coinCnt[i];
                        }
                    }
                }
            }
            Console.WriteLine(coinCnt[n]);
        }
    }
}




Measured memory_bytes: 17992
//References: GeeksForGeeks
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;
static int ans =0;
class Graph 
{ 
	int V;
	list<int> *adj;
	void bridgeUtil(int v, bool visited[], int disc[], int low[], 
					int parent[]); 
public: 
	Graph(int V);
	void addEdge(int v, int w);
	void bridge();
}; 

Graph::Graph(int V) 
{ 
	this->V = V; 
	adj = new list<int>[V]; 
} 

void Graph::addEdge(int v, int w) 
{ 
	adj[v].push_back(w); 
	adj[w].push_back(v);
} 
void Graph::bridgeUtil(int u, bool visited[], int disc[], 
								int low[], int parent[]) 
{
	static int time = 0; 

	visited[u] = true; 
 
	disc[u] = low[u] = ++time; 
	list<int>::iterator i; 
	for (i = adj[u].begin(); i != adj[u].end(); ++i) 
	{ 
		int v = *i;
		if (!visited[v]) 
		{ 
			parent[v] = u; 
			bridgeUtil(v, visited, disc, low, parent); 

			low[u] = min(low[u], low[v]); 
			if (low[v] > disc[u]) 
				ans++;
		} 
		else if (v != parent[u]) 
			low[u] = min(low[u], disc[v]); 
	} 
	// cout<<ans<<endl;
} 
 
void Graph::bridge() 
{ 
	bool *visited = new bool[V]; 
	int *disc = new int[V]; 
	int *low = new int[V]; 
	int *parent = new int[V]; 

	for (int i = 0; i < V; i++) 
	{ 
		parent[i] = -1; 
		visited[i] = false; 
	} 
	for (int i = 0; i < V; i++) 
		if (visited[i] == false) 
			bridgeUtil(i, visited, disc, low, parent); 
} 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	int dp[n]={0};
	Graph g1(n); 
	for(int i= 0,j,k ; i<m; i++)
	{
		cin>>j>>k,--j,--k;
		g1.addEdge(j,k);
	}
	g1.bridge();
	cout<<ans<<endl;
	return 0; 
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << a + b + c + max({a, b, c}) * ((1 << k) - 1) << endl;
}


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

int main(){
  char a,b;
  cin >> a >> b;
  if (a == 'H'){
    if (b == 'H'){
      cout << "H" << endl;
    }
    else {
      cout << "D" << endl;
    }
  }
  else {
    if (b == 'H'){
      cout << "D" << endl;
    }
    else {
      cout << "H" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int x; cin >> x;
	int a; cin >> a;
	int ans = x >= a ? 10 : 0;
	cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  char input[10] = {0};
  fgets(input, 10, stdin);
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 3; j++){
      if(input[j] > input[j + 1]){
        char buf = input[j];
        input[j] = input[j + 1];
        input[j + 1] = buf;
      }
    }
  }
  if(input[0] == input[1] && input[2] == input[3] && input[1] != input[2]){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 
// 	#ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

fast;

ll a,b,c,d;
cin>>a>>b>>c>>d;

ll ans=a*c;

ans=max({ans,a*c,a*d,b*c,b*d});

if((a<=0 and b>=0) or (c<=0 and d>=0))
	ans=max(ans,(ll)0);

cout<<ans;


}


Measured memory_bytes: 3648
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long M = sc.nextLong();
        long ans=0;
        if(2*N<=M){
            ans=N+(M-2*N)/4;
        }else{
            ans=M/2;
        }
        System.out.println(ans);
    }
}


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define list_input(x, n) x[n]; rep(i,n){ cin >> x[i];}
#define ll long long

int main(){
  int A, B;
  cin >> A >> B;
  if (A <= 8 && B <= 8) {
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

int N, M, Q;
int A[51]{}, B[51]{}, C[51]{}, D[51]{};
int W[11];
int dfs(vector<int> v){
	int ans = 0;
	if((int)v.size() == N){
		rep(i,Q){
			if(v[B[i]] - v[A[i]] == C[i]) ans += D[i];
		}
		return ans;
	}
	else{
		if(v.size() == 0){
			for(int i=1;i<=M;i++){
				auto u = v;
				u.push_back(i);
				ans = max(ans, dfs(u));
			}
		}
		else{
			int t = v[(int)v.size()-1];
			for(int i=t;i<=M;i++){
				auto u = v;
				u.push_back(i);
				ans = max(ans, dfs(u) );
			}
		}
		return ans;
	}
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	cin >> N >> M >> Q;
	rep(i,Q){
		cin >> A[i] >> B[i]  >> C[i] >> D[i];
		--A[i]; --B[i];
	}
	vector<int> vec;
	cout << dfs(vec) << endl;
}

Measured memory_bytes: 3624
a = input().split(" ")
n = int(a[0])
m = int(a[1])
ac = dict()
wa = dict()
for i in range(m):
    v = input().split(" ")
    q = int(v[0])
    res = v[1]
    if q in ac:
        continue
    if res == "AC":
        ac[q] = wa.get(q, 0) + 1
    elif res == "WA":
        wa[q] = wa.get(q, 0) + 1

acs = len(ac)
was = 0
for k in ac.keys():
    was = was + wa.get(k, 0)
print(str(acs) + " " + str(was))


Measured memory_bytes: 15036
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;

long double pi = 3.14159265358979;

long double x[2],y[2];

long double dist(){
    return sqrt((x[0]-x[1])*(x[0]-x[1]) + (y[1]-y[0])*(y[1]-y[0]));
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);


    long double a,b,h,m;
    cin>>a>>b>>h>>m;

    long double theta = 2.0 * pi * h/12.0 + pi/6.0 * m/60.0;
    x[0] = cos(theta)*0 - sin(theta)*a;
    y[0] = sin(theta)*0 + cos(theta)*a;

    theta = 2.0 * pi * m/60.0;
    x[1] = cos(theta)*0 - sin(theta)*b;
    y[1] = sin(theta)*0 + cos(theta)*b;

    cout << dist() << endl;
    
}

Measured memory_bytes: 4184
function Main(input){
	input = input.split(" ").map(a=>~~a);
  var A = input.shift();
  var B = input.shift();
  
  return B%A ? B-A : B+A;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
8 20
`);

Measured memory_bytes: 7372
#include <iostream>

using namespace std;

int main(){
    int N,x,y;
    x = y = 0;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    for(int i=0;i<N;i++){
        if(a[i] > x){
            y = x;
            x = a[i];
        }else if(a[i] > y){
            y = a[i];
        }
    }
    for(int i=0;i<N;i++){
        if(x == a[i]) cout << y << endl;
        else cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 2432
use std::io::*;
use std::str::FromStr;
use std::char::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;

fn main(){
    let n:u8 = read();
    let s:Vec<char> = read::<String>().chars().collect();

    let t:Vec<char> = s.iter().cloned()
        .map(|x| (x as u8 + n) as char)
        .collect();
    //println!("{:?}", t);
    let ans:String = t.iter().cloned().map(|x| if x as u8 > 90 {(x as u8 - 26) as char} else {x} ).collect();
    println!("{}", ans);
}

Measured memory_bytes: 4352
s=input()
c=[]
for i in range(len(s)):
    if not s[i] in c:
        c.append(s[i])
count_max_list = []
for a in c:
    count=0
    count_max = 0
    for i in range(len(s)):
        if a==s[i]:
            count_max=max(count,count_max)
            count=0
        else:
            count+=1
    count_max=max(count,count_max)
    count_max_list.append(count_max)
print(min(count_max_list))

Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().strip()
n=input()
aa=list(map(int,input().split()))
c=0
while True:
    if all(a&1==0 for a in aa):
        aa = list(map(lambda a: a>>1, aa))
        c+=1
    else:
        break
print(c)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
const int N = 5e5+999;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int h,a;
       cin>>h>>a;
       cout<<(h+a-1)/a<<el;
    }
   return 0;
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


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

const int mod = 1e9 + 7;
int main(){
  int n;
  cin  >> n;

  VLL T(n),A(n);

  rep(i,n) cin >> T[i];
  rep(i,n) cin >> A[i];

  vector<bool> T_equal(n,false), A_equal(n,false);
  T_equal[0]    = true;
  A_equal[n-1]  = true;
  rep(i,n-1)                     if(T[i] != T[i+1]) T_equal[i+1] = true;
  for(int i = n-1; i >= 1; i--)  if(A[i] != A[i-1]) A_equal[i-1] = true;

  // rep(i,n) cout << T_equal[i] << " ";
  // cout << endl;
  // rep(i,n) cout << A_equal[i] << " ";
  // cout << endl;
  ll ans = 1;
  rep(i,n){
    if(T_equal[i] || A_equal[i] ){
      if(T_equal[i] && A_equal[i] && T[i] != A[i]){
        cout << 0 << endl;
        return 0;
      }else if(T_equal[i] && T[i] > A[i]){
        cout << 0 << endl;
        return 0;
      }else if(A_equal[i] && T[i] < A[i]){
        cout << 0 << endl;
        return 0;
      }
      continue;
    }
    ans = ( ans * min(T[i],A[i]) ) % mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

struct sieve {
    vector<int> lp, pr;
    sieve(int n) : lp(n + 1, -1) {
        for (int i = 2; i <= n; i++) {
            if (lp[i] == -1) {
                lp[i] = i;
                pr.push_back(i);
            }
            for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] <= n; j++) {
                lp[i * pr[j]] = pr[j];
            }
        }
    }
    bool is_prime(int x) { return lp[x] == x; }
    vector<int> factors(int x) {
        vector<int> f;
        while (x != 1) {
            f.push_back(lp[x]);
            x /= lp[x];
        }
        return f;
    }
    vector<pair<int, int>> factorize(int x) {
        vector<int> f = factors(x);
        if (f.size() == 0) return {};
        vector<pair<int, int>> a(1, pair<int, int>(f[0], 0));
        for (int p : f) {
            if (a.back().first == p) {
                a.back().second += 1;
            } else {
                a.emplace_back(p, 1);
            }
        }
        return a;
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int mxa = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mxa = max(mxa, a[i]);
    }
    sieve s(mxa);
    vector<vector<pair<int, int>>> f(n);
    for (int i = 0; i < n; i++) f[i] = s.factorize(a[i]);
    bool pc = true;
    bool sc = true;
    unordered_map<int, int> p;
    for (int i = 0; i < n; i++) {
        for (auto [j, ignore] : f[i]) {
            if (p[j]) pc = false;
            p[j] += 1;
        }
    }
    for (auto [k, v] : p) {
        if (v == n) {
            sc = false;
            break;
        }
    }
    if (pc) {
        cout << "pairwise coprime" << endl;
    } else if (sc) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const int SIZE = 100005;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ll MOD = 1E9 + 7;
#define rep(i,n) for (long long i=0;i<(n);++i)
#define repp(i,a,b) for (long long i=(a);i<(b);++i)
#define per(i,x) for(long long i = (x) ; i >= 0 ; --i)
#define perr(i,x,y) for(long long i = (x) ; i >= (y) ; --i)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(a) (a).begin(),(a).end()
#define lla(a) (a).rbegin(),(a).rend()
#define p(x) cout<<x<<" "
#define pn(x) cout<<x<<"\n"
#define p2(x,y) cout<<x<<" "<<y<<"\n"
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define p4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
#define p5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<"\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif


//template<class T>
//bool isPrime(T n){
//	if(n==1)return false;
//	T i = 2;
//	while(i*i<=n){
//	   if(n%i==0)return false;
//	   i+=1;
//	}
//    return true;
//}

// bool prime[100005];
// void seive()
// {
// 	memset(prime,true,sizeof(prime));
// 	prime[0]=0;
// 	prime[1]=0;
// 	for(ll p=2;p*p<=100000;p++)
// 	{
// 		if(prime[p]==true)
// 		{
// 			for(ll i=p*2;i<=100000;i+=p)
// 			prime[i]=false;
// 		}
// 	}	
// }

// ll power(ll n,ll k, ll mod){
// 	if(k==0)
// 		return 1;
// 	if(k==1)
// 		return n%mod;

// 	ll get=power(n,k/2,mod);
// 	ll ret = ((get%mod)*(get%mod))%mod;

// 	if(k%2)
// 		ret = ((ret%mod)*(n%mod))%mod;

// 	return ret%mod;
// }

vector<int> adj[SIZE];
bool vis[SIZE];
int in_deg[SIZE];
int dist[SIZE];

void dfs(int v){
	vis[v] = true;
	for(int u : adj[v]){
		--in_deg[u];
		dist[u] = max(dist[u],dist[v]+1);
		if(in_deg[u] == 0)dfs(u);
	}
}
int main(){
    
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    FAST;
	
	int n,m; cin>>n>>m;
	rep(i,n+1){
		vis[i] = false;
	}

	rep(i,m){
		int x,y; cin>>x>>y;
		adj[x].pb(y);
		++in_deg[y];
	}

	repp(i,1,n+1){
		if(!vis[i] && in_deg[i]==0){
			dfs(i);
		}
	}

	int ans = 0;

	repp(i,1,n+1){
		ans = max(ans,dist[i]);
	}

	pn(ans);

}

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

#define mp make_pair
#define pb push_back

using namespace std;

const int maxc = 100000;

struct edge{
	int u, v, c, f;
	edge(){};
	edge(int u, int v, int c, int f) : u(u), v(v), c(c), f(f){};
};

int n, m, nm, od;
vector<int> g[123];
char s[123];
vector<edge> e;
vector<int> Link;
int head[369], chk[369], d[369];

bool bfs(){
	queue<int> q;
	q.push(0);
	memset(d, 0, sizeof(d));
	d[0] = 1;
	while (!q.empty()){
		int u = q.front(); q.pop();
		int i = head[u];
		while (i){
			int v = e[i].v;
			if (!d[v] && e[i].f < e[i].c){
				d[v] = d[u] + 1;
				if (v == nm) return true;
				q.push(v);
			}
			i = Link[i];
		}
	}
	return false;
}

int dfs(int u, int delta){
	chk[u] = od;
	if (u == nm) return delta;
	int i = head[u];
	while (i){
		int v = e[i].v;
		if (d[v] == d[u] + 1 && chk[v] != od && e[i].f < e[i].c)
		if (int x = dfs(v, min(delta, e[i].c - e[i].f))){
			e[i].f += x;
			if (i % 2) e[i + 1].f -= x;
			else e[i - 1].f -= x;
			return x;
		}
		i = Link[i];
	}
	return 0;
}

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d",&m,&n);
	nm = n + m + 1;
	e.pb(edge(0, 0, 0, 0));
	for(int i = 1; i <= m; ++i){
		scanf("%s",&s);
		for(int j = 1; j <= n; ++j){
			if (s[j - 1] == 'T'){
				e.pb(edge(i, nm, maxc, 0));
				e.pb(edge(nm, i, 0, 0));
				e.pb(edge(j + m, nm, maxc, 0));
				e.pb(edge(nm, j + m, 0, 0));
			}
			else if (s[j - 1] == 'S'){
				e.pb(edge(0, i, maxc, 0));
				e.pb(edge(i, 0, 0, 0));
				e.pb(edge(0, j + m, maxc, 0));
				e.pb(edge(j + m, 0, 0, 0));
			}
			else if (s[j - 1] == 'o'){
				e.pb(edge(i, j + m, 1, 0));
				e.pb(edge(j + m, i, 0, 0));
				e.pb(edge(j + m, i, 1, 0));
				e.pb(edge(i, j + m, 0, 0));
			}
		}
	}
	Link.resize(e.size());
	for(int i = 1; i < e.size(); ++i){
		Link[i] = head[e[i].u];
		head[e[i].u] = i;
	}
	int ans = 0;
	while (bfs()){
		while (int x = (++od, dfs(0, maxc))) ans += x;
	}
	if (ans >= maxc) printf("-1"); else printf("%d",ans);
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;

  int64_t sum = 0;

  for (int64_t i = 1; i <= n; ++i) {
    // int cnt = 0;
    // int64_t j = i;
    // while (j) {
    //   j /= 10;
    //   ++cnt;
    // }
    // if (cnt % 2 == 1) {
    //   ++sum;
    // }
    if (to_string(i).size() % 2 == 1) {
      ++sum;
    }
  }
  cout << sum << '\n';

  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var n, a, b, sum, temp int
	fmt.Scan(&n, &a, &b)
	for i := 0; i <= n; i++ {
		var temp2 = i
		temp = 0
		for  temp2 > 0{
			temp += temp2%10
			temp2 /= 10
		}
		if temp >= a && temp <= b{
			sum += i
		}
	}
	fmt.Println(sum)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ios::sync_with_stdio(0);
	int x, y;
	cin >> x >> y;
	while(x>=0){
		if(x*4==y){
			cout << "Yes\n";
			return 0;
		}
		--x; y-=2;
	}
	cout << "No\n";
}


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

//繰り返し自乗法(modあり)
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

int main() {
  ll n;
  cin >> n;
  bool cond = true;
  vector<ll> A(n);
  map<ll, int> mp;
  rep(i, n){
    cin >> A[i];
    mp[A[i]]++;
  }
  for (ll j = n - 1; j >= 0; j -= 2){
    if(n % 2 == 0){
      if(mp[j] != 2){
        cond = false;
        break;
      }
    }else {
      if(j > 0){
        if(mp[j] != 2){
          cond = false;
          break;
        }
      }else {
        if(mp[j] != 1) {
          cond = false;
          break;
        }
      }
    }
  }
  cout << (cond ? RepeatSquaring(2, n / 2, MOD) : 0) << endl;
}

Measured memory_bytes: 4992
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef vector<long long int> vi;
typedef vector<vi> vvi;
typedef pair<long long int,long long int> ii;
typedef vector<ii> vii;
#define F first
#define S second

int n;


int main(){
    cin >> n;
    int cur = 1;
    string s;
    if (n == 0){
        cout << "0"; return 0;
    }
    while (n != 0){
        //cout << n << " " << cur << endl;
        if (n%2 ){
            s.push_back('1');
            n -= cur;
        }
        else s.push_back('0');
        cur = -cur;
        n /= 2;
    }
    reverse(s.begin(),s.end());
    cout << s;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long m = sc.nextLong();
    Map<Long, Set<Long>> map = new TreeMap<>();
    Set<Long> all = new TreeSet<>();
    List<String> result = new ArrayList<>();
    for (long i = 0; i < n; i++) {
      map.put(i, new HashSet<>());
      all.add(i);
      if (i > 0) {
        result.add("0");
      }
    }
    for (long i = 0; i < m; i++) {
      long a = sc.nextLong() - 1;
      long b = sc.nextLong() - 1;
      map.get(a).add(b);
      map.get(b).add(a);
    }
    Set<Long> t = new TreeSet<>();
    t.add(0l);
    all.remove(0l);
    while (all.size() > 0) {
      Set<Long> newT = new TreeSet<>();
      t.forEach(a -> {
        Set<Long> s = map.get(a);
        s.forEach(b -> {
          if (all.contains(b)) {
            newT.add(b);
            all.remove(b);
            result.set((int) (b - 1), Long.toString(a + 1));
          }
        });
      });
      t = newT;
    }
    System.out.println("Yes\n" + result.stream().collect(Collectors.joining("\n")));
  }
}


Measured memory_bytes: 121892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    
    long long int h[n+1];
    h[0]=0;
    for(long long int i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    long long int dp[n+1];
    dp[1]=0;
    dp[0]=0;
    dp[2]=abs(h[1]-h[2]);
    for(long long int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1] + abs(h[i]-h[i-1]),dp[i-2] + abs(h[i]-h[i-2]));
    }
    
    cout<<dp[n];
    
    
    
    
}

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

int main() {
    string s,o;
    cin >> s;
    for(int i = 0;i < s.size();i++) {
        if(s[i] == 'B') {
            if(o.size()) {
                o.pop_back();
            }            
        } else {
            o += s[i];
        }        
    }
    cout << o << endl;
}

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

int main(void)
{
	/*

	const double pi = std::acos(-1.0);

	double r, t;

	for(;;)
	{
		std::cin >> r >> t;

		if(r==0 && t==0)
		{
			break;
		}

		double tRad = t/360.0*2.0*pi;

		std::cout << "(x,y)=" << '(' << r*cos(tRad) << ',' << r*sin(tRad) << ")\n";
	}
	*/
	const double pi = std::acos(-1.0);

	double rIn, tIn;//tInの単位は°

	char c;

	double t = 0;//tの単位はrad

	double x=0, y=0;

	for(;;)
	{
		std::cin >> rIn >> c >> tIn;

		if(rIn==0 && tIn==0)
		{
			break;
		}

		x += rIn*(std::sin(t));

		y += rIn*(std::cos(t));

		t += tIn/360.0*2.0*pi;//°→radの変換した後tに足す

	}

	int xI =x, yI=y;

	std::cout << xI << '\n' << yI << '\n';
	
}

Measured memory_bytes: 0
from sys import stdin
input = stdin.readline
n, q = map(int ,input().split())
c = list(map(int, input().split()))
data = []
for i in range(q):
    data.append([i] + list(map(int, input().split())))
data.sort(key=lambda x : x[2])
ans = [0 for i in range(q)]
#####segfunc######
def segfunc(x,y):
    return x + y

def init(init_val):
    #set_val
    for i in range(len(init_val)):
        seg[i+num-1]=init_val[i]   
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0 
num = 2**(n-1).bit_length()
seg=[ide_ele]*(2*num - 1)
good_ball = dict()
pre_r = 0
count = 0
for i in range(q):
    index, l, r = data[i]
    l, r = l-1, r-1
    for j in range(pre_r, r+1):
        if c[j] in good_ball: 
            update(good_ball[c[j]], 0)           
        update(j, 1)
        good_ball[c[j]] = j
    pre_r = r + 1
    ans[index] = query(l, r+1)
for i in range(q):
    print(ans[i])

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

N,M,X,Y=map(int,input().split())
x= list(map(int, input().split()))
y= list(map(int, input().split()))


for z in range(X+1,Y+1):
    Flag = True
    for i in range(N):
        if x[i] >= z:
            Flag = False
            break
    for i in range(M):
        if y[i] < z or not(Flag):
            Flag = False
            break
    if Flag:
        print("No War")
        sys.exit()
print("War")


Measured memory_bytes: 3064
//#include"bits/stdc++.h"
#include<algorithm>
#include<cassert>
#include<cmath>
#include<climits>
#include<iostream>
#include<map>
#include<set>
#include<vector>
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define MP make_pair
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define DEB(x) cout<<"##"<<x<<"##"<<endl
const int INF=(int)2e9+9;
const int SIZE=(int)2e6+5;
//Brute force answers(BINARY SEARCH) symmetry
//Change perspective
struct Query{
    int l;
    int r;
    int ind;
};
int block;
bool cmp(Query &a,Query &b){
    return MP(a.l/block,a.r)<MP(b.l/block,b.r);
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,q;
    cin>>n>>q;
    int ar[n+1];
    Query ob[q];
    rep(i,n){
        cin>>ar[i+1];
    }
    rep(i,q){
        cin>>ob[i].l>>ob[i].r;
        ob[i].ind=i;
    }
    block=sqrt(n);
    sort(ob,ob+q,cmp);
    int ansq[q],left,right,ans=0,cnt[n+1]={0};
    left=1;
    right=0;
    rep(i,q){
        while(ob[i].l>left){
            cnt[ar[left]]--;
            if(cnt[ar[left]]==0){
                ans--;
            }
            left++;
        }
        while(ob[i].l<left){
            left--;
            cnt[ar[left]]++;
            if(cnt[ar[left]]==1){
                ans++;
            }
        }
        while(ob[i].r>right){
            right++;
            cnt[ar[right]]++;
            if(cnt[ar[right]]==1){
                ans++;
            }
        }
        while(ob[i].r<right){
            cnt[ar[right]]--;
            if(cnt[ar[right]]==0){
                ans--;
            }
            right--;
        }
        ansq[ob[i].ind]=ans;
    }
    rep(i,q){
        cout<<ansq[i]<<endl;
    }


}


Measured memory_bytes: 15412
#include<iostream>
#include<string>
using namespace std;
long long dp[65][65];
int main() {
	dp[0][0] = 1;
	for (int i = 0; i < 64; i++) {
		for (int j = 0; j < 64; j++) {
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j + 1] += dp[i][j];
		}
	}
	while (true) {
		long long n, k, c = 0; string S = "";
		cin >> n >> k; if (n == 0)break;
		for (int i = 0; i <= n; i++) {
			if (c + dp[n][i] >= k) { k -= c; c = i; break; }
			c += dp[n][i];
		}
		for (int i = n; i >= 1; i--) {
			if (c == 0) { S += "0"; }
			else {
				if (k <= dp[i - 1][c]) { S += "0"; }
				else { k -= dp[i - 1][c]; S += "1"; c--; }
			}
		}
		cout << S << endl;
	}
	return 0;
}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 300010, M = 2 * N;

int n, m, st, ed;
int h[N], e[M], ne[M], idx;
int q[N], d[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

int bfs(int st, int ed)
{
	memset(d, -1, sizeof d);
	int hh = 0, tt = -1;
	d[st * 3] = 0;
	q[ ++ tt] = st * 3;
	
	while (hh <= tt)
	{
		int t = q[hh ++ ];
		
		for (int i = h[t]; ~i; i = ne[i])
		{
			int j = e[i];
			if (d[j] != -1) continue;
			
			d[j] = d[t] + 1;
			q[ ++ tt] = j;
			
			if (j == ed * 3) break;
		}
	}
	
	int t = d[ed * 3];
	if (t % 3) return -1;
	else return t / 3;
}

int main()
{
	memset(h, -1, sizeof h);
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		
		add(a * 3, b * 3 + 1);
		add(a * 3 + 1, b * 3 + 2);
		add(a * 3 + 2, b * 3);
	}
	
	scanf("%d%d", &st, &ed);
	cout << bfs(st, ed) << endl;
	return 0;
}

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


int main() {
  int N;
  cin >> N;
  vector<int> a(N+1);
  rep(i,N){
      cin >> a[i+1];
  }
  /*vector<int> num(N+1);//num[i] = a[i]
  for(int i = 1;i<=N;i++){
      num[i] = a[i];
  }*/
  int c = 0;
  for(int i = 1;i<=N;i++){
      if(a[a[i]] == i){
          c++;
      }
  }
  cout << c/2 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int n,dp[101][101];
string s;

int main(){
	cin>>n>>s;
	int i=0,j=0,cs=0,bs=0;
	string ans;
	stack<bool> st;
	for(int i=n-1; i>=0; --i){
		if(s[i]=='('){
			if(!st.empty()){
				st.pop();
				--cs;
			}
			else
				++bs;
		}else{
			st.push(0);
			++cs;
		}
		ans+=s[i];
	}
	while(cs--)
		ans+='(';
	reverse(all(ans));
	while(bs--)
		ans+=')';
	cout<<ans<<endl;
	return 0;

}




Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
#define int long long 
#define ri register int 
using namespace std;
priority_queue<int> q; 
int a[100001],n,m;
signed main()
{
	scanf("%lld%lld",&n,&m);
	for(ri i=1;i<=m;i++) scanf("%lld",&a[i]);
	sort(a+1,a+m+1);
	ri tot=0;
	for(ri i=2;i<=m;i++) 
	{
		tot+=(a[i]-a[i-1]);
		q.push(a[i]-a[i-1]);
	}
	for(ri i=1;i<=min(m-1,n-1);i++)
	{
		tot-=q.top();
		q.pop();
	}
	printf("%lld",tot);
	return 0;
 } 

Measured memory_bytes: 2168
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextStr()

	for _, c := range n {
		if c == '7' {
			fmt.Println("Yes")

			return
		}
	}

	fmt.Println("No")
	return

}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
    long long a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    if((v-w) * t >= abs(a-b)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636