akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n; cin >> n;
  vector<vector<int>> g(n);
  rep(i, n-1) {
      int a, b; cin >> a >> b;
      g[a-1].push_back(b-1);
      g[b-1].push_back(a-1);
  }
  vector<int> dist_1(n,-1), dist_n(n,-1);
  queue<int> p1;
  p1.push(0);
  dist_1[0] = 0;
  while (!p1.empty())
  {
    int v = p1.front(); p1.pop();
    for (auto nv: g[v]) {
      if (dist_1[nv] >= 0) continue;
      dist_1[nv] = dist_1[v] + 1;
      p1.push(nv);
    } 
  }
  queue<int> pn;
  pn.push(n-1);
  dist_n[n-1] = 0;
  while (!pn.empty())
  {
    int v = pn.front(); pn.pop();
    for (auto nv: g[v]) {
      if (dist_n[nv] >= 0) continue;
      dist_n[nv] = dist_n[v] + 1;
      pn.push(nv);  
    }
  }
  int b = 0, w = 0;
  rep(i,n) {
    if (dist_1[i] <= dist_n[i]) b++;
    else w++;
  }
  if (b > w) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
    return 0; 
}

Measured memory_bytes: 9604
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
//#define mod 998244353
#define inf 1000000000
#define pr1(a) cout << a << "\n"
#define pr2(a,b)cout << a <<  " " <<b<< "\n"
#define pr3(a,b,c) cout << a <<" " << b << " " << c << "\n"

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b){
    if(b==0)return a;
    gcd(b,a%b);
}
const int maxn = 2*1e5 + 10;
map<int,bool> vis;

int bfs(int k){

    queue<int> q;
    for(int i = 1;i<=9;i++){
        q.push(i);
    }

    while(!q.empty()){
        int cur = q.front(); 
        q.pop();

        if(vis[cur])continue;
        vis[cur] = 1;

        k--;
        if(k){
            int x = cur%10;
            int cc= cur*10 + x;

            if(x>0){
                q.push(cc-1);
            }
            q.push(cc);

            if(x<9){
                q.push(cc+1);
            }
            
        }
        else{
            return cur;
        }
    }
}
void solve(){

   int k;
   cin >> k;

   cout << bfs(k) << endl;

} 

signed main() 
{   
    IOS;
    int t = 1;
    // cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 8064
def main():
    A, B = map(int, input().split())

    # ans = AC(A, B)
    ans = editorial(A, B)
    print(ans)


def AC(A, B):
    ans = (A - 1) * (B - 1)
    return ans


def editorial(A, B):
    return A * B - A - B + 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve()
{
	ll int n,x,t;
	cin>>n>>x>>t;
	if(n%x==0)
	cout<<((n/x)*t);
	else
	cout<<(((n/x)+1)*t);
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<set>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  string s;
  cin >> s;

  set<char> v, h;
  for (char c:s) {
    if (c == 'N' || c == 'S') v.insert(c);
    if (c == 'E' || c == 'W') h.insert(c);
  }

  if (v.size() % 2 == 0 && h.size() % 2 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;


public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		m.input();
		m.solve();
		m.output();
	}
	
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//	InputUtil in = new InputUtil();
	PrintWriter out = new PrintWriter(System.out);

	String S = null;
	
	public void input() throws IOException {
		S = br.readLine();
	}

	public void solve() throws IOException {
	}
	
	public void output() {
		out.println(S.substring(0, S.length()-8));
		out.flush();
		
	}
}



class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}


Measured memory_bytes: 22996
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char c1[] = sc.next().toCharArray();
        char c2[]=sc.next().toCharArray();
        if(c1[0]==c2[2]&&c1[1]==c2[1]&&c1[2]==c2[0]) System.out.println("YES");
        else System.out.println("NO");


    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main(){
  int N;
  cin>>N;
  int count=0;
  int min=1000000000;
  int ss[7];
  for (int i=6;i>=0;i--){
    ss[6-i]=(int)pow(6,i);
  }
  int nn[6];
  for (int i=5;i>=0;i--){
    nn[5-i]=(int)pow(9,i);
  }
  int six,nine;
  for (int i=0;i<=N;i++){
    count=0;
    six=i;nine=N-i;
    for (int i=0;i<7;i++){
      int d=six/ss[i];
      count+=d;
      six-=d*ss[i];
      if (six==0) break;
    }
    for (int i=0;i<6;i++){
      int d=nine/nn[i];
      count+=d;
      nine-=d*nn[i];
      if (nine==0) break;
    }
    min=(min<count)?min:count;
  }
  cout<<min;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

#include<unistd.h>
char buff[1 << 22];
template <int size>
struct Buffer{
    int idx = 0;
    Buffer(){ read(0, buff, size); }
    void next(int& ret){
        // int ret = 0;
        ret = 0;
        // while(!(buff[idx] & 0x10)){ idx++; }
        while(buff[idx] & 0x10){ ret = ret * 10 + buff[idx++] - '0'; }
        idx++;
        // while(!isdigit(buff[idx])){ idx++; }
        // while(isdigit(buff[idx])){ ret = ret * 10 + buff[idx++] - '0'; }
        // return ret;
    }
};
struct FastInput {
    Buffer<1 << 22> buf;
    template <class T>
    FastInput& operator >> (T& num) { buf.next(num); return *this; }
    // FastInput& operator >> (T& num) { num = buf.next(); return *this; }
    void tie(int){ }
    template <class S, class T>
    friend FastInput& operator >> (FastInput& in, pair<S, T>& p){ return in >> p.first >> p.second; }
    template <class T>
    friend FastInput& operator >> (FastInput& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
};
FastInput fin;
#define cin fin

enum { SIZE = 1 << 20 };
char buf[SIZE];
int accs[512][512];
pair<int, int> pqs[100000];
int main(){
    int n, m, q;
    cin >> n >> m >> q;
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        accs[1][r]++;
        accs[l + 1][r]--;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            accs[i + 1][j] += accs[i][j];
            accs[i][j] += accs[i][j - 1];
        }
    }
    char* ptr = buf + SIZE;
    for(int i = 0; i < q; i++){
        cin >> pqs[i].first >> pqs[i].second;
    }
    for(int i = q - 1; i >= 0; i--){
        int p = pqs[i].first, q = pqs[i].second;
        *--ptr = '\n';
        div_t num2;
        num2.quot = accs[p][q];
        do{
            num2 = div(num2.quot, 10);
            *--ptr = num2.rem | '0';
        }while(num2.quot);
    }
    write(1, ptr, buf + SIZE - ptr);
}


Measured memory_bytes: 6784
n,k = map(int,input().split())
A = list(map(int, input().split()))

from itertools import accumulate
for i in range(k):
    imos = [0]*(n+1)
    for j in range(n):
        d = A[j]
        l = max(0, j-d)
        r = min(n-1, j+d)
        imos[l] += 1
        imos[r+1] -= 1
    imos = list(accumulate(imos))
    for j in range(n):
        A[j] = imos[j]
    if A == [n]*n:
        break

print(*A)


Measured memory_bytes: 193028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

ll ans,arr[11],a[51],b[51],c[51],d[51],n,m,q;

void solve(int rank,int num){
    if(rank == n+1){
        ll tmp = 0;
        rep(i,q){
            if(arr[b[i]]-arr[a[i]] == c[i])tmp += d[i];
        }
        ans = max(ans,tmp);
    }
    else{
        rep(i,num,m + 1){
            arr[rank] = i;
            solve(rank+1,i);
        }
    }
}

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

    cin>>n>>m>>q;
    rep(i,q)cin>>a[i]>>b[i]>>c[i]>>d[i];
    solve(0,1);
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3640
// I am Varun Das from Jadavpur University
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define dbg(x) cerr << #x << " = " << x << endl
#define INF LLONG_MAX
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//cout<<fixed<<setprecision(12);
ll n,a[10004];
cin>>n;
ll dp[3004][3004];
memset(dp,0,sizeof(dp));
loop(i,0,n) cin>>a[i];
rep(i,n-1,0){
    loop(j,i,n){
        if(i==j) dp[i][j] = a[i];
        else{
            dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
        }
    }
}
cout<<dp[0][n-1];
	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
 #include <algorithm>
 #include <vector>
 #include <array>
 
 struct Node {
     int id;
     int degree;
     int parent = -1;
     int depth = 0;
     int type = 0; //0:root, 1:internal node, 2:leaf
     std::vector<int> children;
 };
 
 void configureNodes(std::vector<Node> &Nodes, Node &node) {
     if (node.children.size() == 0) {
         return;
     } else {
         for (auto &&c : node.children) {
             Nodes[c].parent = node.id;
             Nodes[c].depth = node.depth + 1;
             configureNodes(Nodes, Nodes[c]);
         }
     }
 }
 
 void showNodes(std::vector<Node> &Nodes) {
     for (auto &&e : Nodes) {
         std::cout << "node " << e.id << ": parent = " << e.parent << ", ";
         std::cout << "depth = " << e.depth << ", ";
         
         if (e.type == 0) std::cout << "root, ";
         else if (e.type == 1) std::cout << "internal node, ";
         else std::cout << "leaf, ";
         
         std::cout << "[";
         for (auto i=e.children.begin(); i!=e.children.end(); i++) {
             std::cout << *i;
             if (i != e.children.end()-1) std::cout << ", ";
         }
         std::cout << "]";
         std::cout << std::endl;
     }
     
 }
 
 int main()
 {
     int N, temp;
     std::array<bool, 100000> check = {};
     std::cin >> N;
     
     std::vector<Node> Nodes;
     
     for (int i=0; i<N; ++i) {
         Node newNode;
         std::cin >> newNode.id;
         std::cin >> newNode.degree;
         for (int j=0; j<newNode.degree; ++j) {
             std::cin >> temp;
             newNode.children.push_back(temp);
         }
         if (newNode.children.size()==0) newNode.type = 2;
         else newNode.type = 1;
         
         Nodes.push_back(newNode);
     }
     
     std::sort(Nodes.begin(), Nodes.end(), [](const Node &a, const Node &b){return a.id < b.id;});
     
     for (auto &&e : Nodes) {
         for (auto &&c : e.children) {
             check[c] = true;
         }
     }
     
     auto root = std::find(check.begin(), check.end(), false);
     configureNodes(Nodes, Nodes[std::distance(check.begin(), root)]);
     Nodes[std::distance(check.begin(), root)].type = 0;
     showNodes(Nodes);
 }


Measured memory_bytes: 10236
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a==b && a*b==0){
    printf("%d",a+b);
  }
  else if(b%a==0){
    printf("%d",a+b);
  }
  else{
    printf("%d",b-a);
  }
  return 0;
}

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

using namespace std;

int main(){
  long long K;
  cin >> K;
  
  long long t = 0;
  int c = -1;
  for(int i = 0; i < K; i++){
    t *= 10;
    t += 7;
    t %= K;
    if(!t){
      c = i + 1;
      break;
    }
  }
  
  cout << c << endl;
  
  return 0;
}

Measured memory_bytes: 3632
// luogu-judger-enable-o2
#include <cstdlib>
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define  INF 0x3f3f3f3f
//__builtin_popcount
using namespace std;
//priority_queue
const ll MAX=100000;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}

ll F[100003];
ll Find(ll a)
{
    return F[a]<0?a:F[a]=Find(F[a]);
}
ll same(ll a,ll b)
{
    if(Find(a)==Find(b))return 1;
    return 0;
}
void up(ll a,ll b)
{
    ll x,y;
    x=Find(a);
    y=Find(b);//cout<<F[x]<<" "<<F[y]<<endl;
    if(x!=y)
        F[y]+=F[x],F[x]=y;


}
int a[200003],b[200003];
int sum[200003];
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
    scanf("%d",&a[i]),b[i]=a[i],sum[a[i]]++;
  sort(b+1,b+1+n);
  for(int i=1;i<=n;i++)
  {
      if(a[i]!=b[n])cout<<b[n]<<endl;
      else {
        if(sum[b[n]]==1)cout<<b[n-1]<<endl;
        else cout<<b[n]<<endl;
      }
  }
}



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

int main() {
  int n;
  string l;
  cin >> n >> l;
  vector<int> s(n + 1, 0);
  vector<int> ans(n, 0);
  
  for (int i = 0; i < n; i++){
    if (l.at(i) == 'W'){
      s.at(i + 1) = s.at(i) + 1;
    }
    else{
      s.at(i + 1) = s.at(i);
    }
  }
  
  for (int i = 0; i < n; i++){
    ans.at(i) = s.at(i) + (n - (i + 1) - (s.at(n) - s.at(i + 1)));
  }
  
  sort(ans.begin(), ans.end());
  
  cout << ans.at(0) <<endl;

}

Measured memory_bytes: 3076
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll dp[200010][2];
ll pre[200010];
int main(){
	rep(i,0,200005)pre[i]=-1;
	ll n;
	scanf("%lld",&n);
	ll t;
	scanf("%lld",&t);
	pre[t]=0;
	dp[0][1]=1;
	rep(i,1,n){
		ll t;
		scanf("%lld",&t);
		dp[i][1]=(dp[i-1][0]+dp[i-1][1])%MOD;
		if(pre[t]!=-1&&pre[t]!=i-1)dp[i][0]=(dp[pre[t]][0]+dp[pre[t]][1])%MOD;
		pre[t]=i;
//		printf("%lld %lld\n",dp[i][0],dp[i][1]);
	}
	printf("%lld",(dp[n-1][0]+dp[n-1][1])%MOD);
}

Measured memory_bytes: 4864
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int[] a = new int[3];
      	for(int i = 0; i < 3; i++){
        	a[i] = sc.nextInt();
        }
      	Arrays.sort(a);
      	System.out.println(a[2] - a[0]);
    }
}

Measured memory_bytes: 35732
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
 
 
public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		List<Shop> shops = new ArrayList<>();
		int count = 1;
		for(int i=0;i<N;i++){
			Shop shop = new Shop(sc.next(),Integer.parseInt(sc.next()),i+1);
			shops.add(shop);
		}
		//System.out.println(shops.get(0).name);
		shops.sort((a,b)->{
			if(a.name.equals(b.name)){
				return Integer.compare(b.point,a.point);
			}else{
				return a.name.compareTo(b.name);
			}
		});
		for(Shop s : shops){
			System.out.println(s.number);
		}
		
		
	}
	
}
class Shop{
	String name;
	int point;
	int number;
	public Shop(String name, int point, int number) {
		this.name = name;
		this.point = point;
		this.number = number;
		// TODO Auto-generated constructor stub
	}
}



Measured memory_bytes: 28752
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


struct UnionFind {
    vector<ll> par;
        
    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }
    
    ll find(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }
    
    bool same(ll x, ll y) {
        return find(x) == find(y);
    }
    
    bool unite(ll x, ll y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    ll size(ll x) {
        return -par[find(x)];
    }

    void print(ll x){
        rep(i,x){
            cout<<par[i]<<endl;
        }
        return ;
    }
};









void solve() {
    ll n,m;
    cin>>n>>m;
    ll a[200010],b[200010];
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
    }
    UnionFind uf(n);
    rep(i,m){
        uf.unite(a[i],b[i]);
    }
    ll ans =0;
    rep(i,n){
        // cout<<i<<" "<<uf.size(i)<<endl;

        chmax(ans,uf.size(i));
    }
    cout<<ans<<endl;





}







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


    ll t=1;
    rep(i,t){
        solve(); 
    }


    return 0;
}

Measured memory_bytes: 7948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else if (A + B > C + D){
    cout << "Left" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}


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

s = input()
t = input()

def isMatch(idx):
    si = idx
    ti = 0
    while si<len(s) and ti<len(t):
        if s[si]==t[ti]:
            si += 1
            ti += 1
            continue
        if s[si]=="?":
            si += 1
            ti += 1
            continue
        if s[si]!=t[ti]:
            return False
    return ti==len(t)

ret = None
for i in range(len(s)-1,-1,-1):
    if isMatch(i):
        ret = s[:i]+t+s[i+len(t):]
        break

if ret is None:
    print("UNRESTORABLE")
else:
    print(ret.replace("?", "a"))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;

int arr[150][5000];

int main() {

    
   
    int n;
    cn n;
    string s;
    cn s;
    ll cnt=0;
    
      
    for (int i = 0; i <n ; ++i)
    {
    	arr[s[i]][i]++;
    }

    for (int i = 1; i <n ; ++i)
    {
    	arr['R'][i]+=arr['R'][i-1];
    }
    for (int i = 1; i <n ; ++i)
    {
    	arr['G'][i]+=arr['G'][i-1];
    }
    for (int i = 1; i <n ; ++i)
    {
    	arr['B'][i]+=arr['B'][i-1];
    }


    for (int i =0 ; i <n ; ++i)
    {
    	int jj=2*(i);

    	for(int j=0; j<i ; j++){
    	    int l=jj-j;

    	    if(l>=0 && l<n && j<i && i<l){

               if(s[i]!=s[j] && s[j]!=s[l] && s[i]!=s[l])cnt++;
    	    }
    	}
    }

    ll sum=0;
   
    int x='R'^'B'^'G';

    for (int i = 0; i < n; ++i)
    {    
    	for (int j = i+1; j <n; ++j)
    	{
           if(s[i]!=s[j]){

           	char c=x^s[i]^s[j];

           	sum=sum+arr[c][n-1]-arr[c][j];
    	     	
    	}
           }
    }



ct sum-cnt,nl;


    return 0;
}


Measured memory_bytes: 3668
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  int ans = 0, i = 0;
  while (i < n) {
    int j = i;
    while (j < n - 1 && a[j + 1] == a[i]) j++;
    ans += (j - i + 1) / 2;
    i = j + 1;
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define cinspeed ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N = 1010;

using namespace std;

int main()
{
    cinspeed;

    string s,t;
    cin >> s >> t;
        cout << t << s<<"\n";


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0;
    rep(i, n) {
		if (i%2==0 && a[i]%2==1)
                    cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3496
#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,k,n;
    int a=0,b=0;
    char x[1000];
    char y[1000];
    scanf("%d",&n);
    getchar();
    while(n--)
    {
        scanf("%s",x);

        scanf("%s",y);

        if(strcmp(x,y)==0)
            {
                a=a+1,b=b+1;
        }
        if(strcmp(x,y)<0)
            {
                b=b+3;
        }
        if(strcmp(x,y)>0)
            {
                a=a+3;
        }

    }
    printf("%d %d\n",a,b);
}



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

int main() {
  int n,k,r,s,p;
  long long int ans=0;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  vector<bool> flg(n,false);
  for(int i=0;i<n;i++){
    if (i>=k && t[i] == t[i-k] && flg[i-k]) continue;
    if (t[i] == 'r') ans += p;
    if (t[i] == 's') ans += r;
    if (t[i] == 'p') ans += s;
    flg[i] = true;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
import collections
n = int(input())
a = list(map(int, input().split()))
cnt = collections.Counter(a)
total = 0
for key in cnt.keys():
    total += cnt[key]*(cnt[key]-1) // 2
for i in a:
    ans = total
    ans -= cnt[i] * (cnt[i]-1) / 2
    ans += (cnt[i]-1) * (cnt[i]-2) / 2
    print(int(ans))

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  long long n, x, m; scanf("%lld%lld%lld", &n, &x, &m);
  map<long long, int> mp;
  vector<long long> cum;
  cum.push_back(0);
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    if (mp.count(x)) {
      // loop found
      const long long &prev = mp[x];
      n -= i;
      ans += (cum.back()-cum[prev])*(n/(i-prev));
      ans += cum[prev+n%(i-prev)]-cum[prev];
      break;
    }
    ans += x;
    cum.push_back(ans);
    mp[x] = i;
    (x *= x) %= m;
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 6776
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int h, w, k;
int c[20][1500];
int cond = 0;

int area( int px, int py, int x, int y){
	return c[y][x] - c[y][px] - c[py][x] + c[py][px];
}


int main(){
	cin >> h >> w >> k;
	for( int i = 0; i < h; ++i ){
		string s; cin >> s;
		for( int j = 0; j < w; ++j ){
			c[i+1][j+1] = c[i][j+1] + c[i+1][j] - c[i][j];
			if( s[j] == '1' ) c[i+1][j+1] += 1;
		}
	}
	int ans = inf;
	for( cond = 0; cond < (1<<(h-1)); ++cond ){
		int pre_x = 0;
		int columncnt = 0;
		for( int x = 1; x <= w; ++x ) {
		int pre_y = 0;
		for( int y = 1; y <= h; ++y ){
			if( cond & 1<<(y-1) || y == h ){
				if( area( pre_x, pre_y, x, y ) > k ){
					pre_x = x-1;
					++columncnt;
				}
				if( area( pre_x, pre_y, x, y ) > k ){
					columncnt = 1e9;
                    break;
				}
				pre_y = y;
				}	
			}
		}
		ans = min( ans, columncnt+__builtin_popcount(cond) );
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def f(x):
    res = (x+1)//2%2
    
    for i in range(1, 50):
        n = x%2**(i+1)
        
        if n>=2**i and (n-2**i)%2==0:
            res += 2**i
    
    return res

A, B = map(int, input().split())

if A==0:
    print(f(B))
else:
    print(f(B)^f(A-1))


Measured memory_bytes: 61992
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B;
    cin >> A >> B;
    int ans = 0;
    rep(i,A,B+1){
        string s = to_string(i);
        if(s[0] == s[4] && s[1] == s[3]){
            ans++;
        }
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 888
N, M = map(int, input().split())
K_S = [[int(i) for i in input().split()] for _ in range(M)]
P = [int(i) for i in input().split()]
tot_cnt = 0

def check(combo):
    '''combo is list of string and returns boolean'''
    cnt = 0
    for i in range(M):
        tot = 0
        for j in K_S[i][1:]:
            tot += int(combo[j - 1])
        cnt += 1 if tot % 2 == P[i] else 0
    return cnt == M

for i in range(2**N):
    combo = list("{:010b}".format(i))[::-1]
    if check(combo):
        tot_cnt += 1

print(tot_cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
typedef long long int ll;
#define pb push_back
const ll MAX = 3e5 + 10;
const ll MAXN = 1e12 + 7;

ll bsl(ll a[],ll n,ll k){
	ll l=0,r=n-1; ll ans=-1;
	while(l<=r){
		ll m=(l+r)/2;

		if(a[m]<=k){
			ans = m;
			l=m+1;
		} 
		else r=m-1;
	}

	if(ans == -1) return 0;
	else return a[ans];
}

ll bsr(ll a[],ll n,ll k){
	ll l=0,r=n-1; ll ans=-1;
	while(l<=r){
		ll m=(l+r)/2;

		if(a[m]>=k){
			ans = m;
			r=m-1;
		} 
		else l=m+1;
	}

	if(ans == -1) return 0;
	else return a[ans];
}

int main()
{
	ll q,n,m; cin>>n>>m>>q;

	ll a[MAX],b[MAX];

	for(ll i=0;i<n;i++) cin>>a[i];
	for(ll i=0;i<m;i++) cin>>b[i];
	
	sort(a,a+n); sort(b,b+m);

	for(ll i=0;i<q;i++){
		ll d; cin>>d;
		ll la=bsl(a,n,d);
		ll ra=bsr(a,n,d);
		ll lb=bsl(b,m,d);
		ll rb=bsr(b,m,d);
		ll ans=MAXN;
		if(la and lb) ans=min(ans,max(d-la,d-lb));
		if(ra and rb) ans=min(ans,max(ra-d,rb-d));
		if(la and rb) ans=min(ans,2*min(d-la,rb-d)+max(d-la,rb-d));
		if(lb and ra) ans=min(ans,2*min(ra-d,d-lb)+max(ra-d,d-lb));

		cout<<ans<<endl;

	}	
}

Measured memory_bytes: 5376
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <iomanip>
using namespace std;

const long long MAX_N = 4e2 + 8, MAX_K = 1e5 + 5, MOD = 1e9 + 7, inf = 1000000LL * 1000000LL * 1000000LL;
long long n, k;
long long a[MAX_N];
long long psum[MAX_N];
long long dp[MAX_N][MAX_N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (long long i = 0; i < n; i++)
		cin >> a[i];

	psum[0] = a[0];
	for (long long i = 0; i < n; i++)
		psum[i] = a[i] + psum[i - 1];

	for (long long i = 1; i < n; i++)
		for (long long j = 0; j + i < n; j++) {
			dp[j][j + i] = inf;
			for (long long k = j; k < i + j; k++)
				dp[j][j + i] = min(dp[j][j + i], dp[j][k] + dp[k + 1][j + i]);

			dp[j][j + i] += psum[j + i] - (j? psum[j - 1]: 0LL);
		}

	cout << dp[0][n - 1] << "\n";
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n[4];
    rep(i, 4) {
        cin >> n[i];
    }
    int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0;
    rep(i, 4) {
        if (n[i] == 1) cnt1++;
        if (n[i] == 7) cnt2++;
        if (n[i] == 9) cnt3++;
        if (n[i] == 4) cnt4++;
    }
    if (cnt1 && cnt2 && cnt3 && cnt4) {
        puts("YES");
    } else {
        puts("NO");
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int>w(n);
  for(int i=0; i<n; i++)cin >> w[i];
  int sum=accumulate(w.begin(), w.end(), 0);
  int ret=10000000;
  int psum=0;
  for(int i=0; i<n; i++){
    psum+=w[i];
    ret = min(ret, abs(psum-(sum-psum)));
  }
  cout << ret;
  return 0;
}

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

string S;
int a[4];

int main() {
  cin >> S;
  for (int i = 0; i < 4; i++) a[i] = S[i] - '0';

  string left;

  for (int i = 0; i < (1 << 3); i++) {
    int sum = a[0];
    left = to_string(a[0]);
    for (int j = 0; j < 3; j++) {
      if (i & (1 << j)) {
        sum += a[j+1];
        left += "+" + to_string(a[j+1]);
      } else {
        sum -= a[j+1];
        left += "-" + to_string(a[j+1]);
      }
    }
    if (sum == 7) {
      break;
    }
  }
  cout << left + "=7" << endl;
}

Measured memory_bytes: 256
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const int maxn = 105;

int n;
int a[maxn];
int f[maxn][maxn], g[maxn][maxn];

inline int mul(int x, int y){return (1ll * x * y) % INF;}
inline int add(int x, int y){return (x + y) % INF;}
inline int sub(int x, int y){return (x - y + INF) % INF;}

inline int qpow(int x, int y){
	int ret = 1;
	for(; y; y >>= 1){
		if(y & 1)
			ret = mul(ret, x);
		x = mul(x, x);
	}
	return ret;
}

void solve(int l, int r){
	int mn = INF, ept = 0;
	f[l][r] = g[l][r] = 1;
	REP(i, l, r){
		mn = min(mn, a[i]);
	}
	REP(i, l, r){
		a[i] -= mn;
		if(!a[i]) ++ept;
	}
	for(int i = l; i <= r; ){
		if(a[i]){
			int j;
			for(j = i; a[j]; ++j);
			solve(i, j - 1);
			f[l][r] = mul(f[l][r], add(f[i][j - 1], g[i][j - 1]));
			g[l][r] = mul(g[l][r], g[i][j - 1]);
			i = j + 1;
		}
		else ++i;
	}
	g[l][r] = mul(g[l][r], 2);
	f[l][r] = mul(f[l][r], qpow(2, ept));
	f[l][r] = sub(f[l][r], g[l][r]);
	g[l][r] = mul(g[l][r], qpow(2, mn - 1));
	f[l][r] = add(f[l][r], g[l][r]);
	//printf("l = %d r = %d f = %d g = %d\n", l, r, f[l][r], g[l][r]);
	return;
}

int main(){
	scanf("%d", &n);
	FOR(i, 0, n){
		scanf("%d", a + i);
	}
	solve(0, n - 1);
	printf("%d\n", f[0][n - 1]);
	return 0;
}



Measured memory_bytes: 384
// A - Weather Prediction

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

int main(){
	string S;
	cin >> S;

	string ans;
	if (S == "Sunny") ans = "Cloudy";
	else if (S == "Cloudy") ans = "Rainy";
	else if (S == "Rainy") ans = "Sunny";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d %d" (fun n y ->
  try
    for i = 0 to min n ((y / 1000 - n) / 9) do
      for j = 0 to min (n - i) ((y / 1000 - n - 9 * i) / 4) do
        if 9 * i + 4 * j = y / 1000 - n then begin
          Printf.printf "%d %d %d\n" i j (n - i - j);
          raise Not_found
        end
      done
    done;
    print_endline "-1 -1 -1"
  with Not_found -> ())

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	while (1) {
		int n;
		cin >> n;
		if (n == 0) { break; }
		int m, a, b, cou = 0;
		cin >> m;
		for (int i = 0; i < m; ++i) {
			cin >> a >> b;
			cou += b - a;
		}
		if (cou >= n) { cout << "OK" << endl; }
		else { cout << n - cou << endl; }
	}
}


Measured memory_bytes: 3096
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal, ROUND_CEILING
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W, M = MAP()

h, w = ZIP(M)
cnt_h = Counter(h)
hm = max(cnt_h.values())
cnt_w = Counter(w)
wm = max(cnt_w.values())
hl = [k for k, v in cnt_h.items() if v == hm]
wl = [k for k, v in cnt_w.items() if v == wm]

s = set()
for h_, w_ in zip(h, w):
    s.add((h_, w_))

ans = hm + wm

for i in hl:
    for j in wl:
        if (i, j) not in s:
            break
    else:
        continue
    break
else:
    ans -= 1
print(ans)


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

int main(void){

    long long int a, b, k;
    cin>>a>>b>>k;
    
    vector<long long int> c;
    
    int t=a+k<b?a+k:b;
    for(int i=a; i<min(a+k, b+1); i++){
        cout<<i<<endl;
    }
    for(int i=max(b-k+1, a+k); i<=b; i++){
        cout<<i<<endl;
    }
    

}


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

#define MAXN (100010)


int n;
int lfson[MAXN], sz[MAXN], deg[MAXN], f[MAXN], dep[MAXN];
int delta[MAXN];
std::vector<int> vec[MAXN];
struct cmp{
	bool operator() (int a, int b){
		return dep[a] < dep[b];
	}
};
std::priority_queue<int, std::vector<int>, cmp> pq;
bool vis[MAXN];

void dfs(int u, int fa){
	sz[u] = 1;
	for(auto v : vec[u]){
		if(v == fa) continue;
		f[v] = u;
		dep[v] = dep[u] + 1;
		dfs(v, u);
		sz[u] += sz[v];
		if(sz[v] == 1){
			lfson[u] ++;
			pq.push(v);
		}
	}
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i < n; ++ i){
		int u, v;
		scanf("%d%d", &u, &v);
		vec[u].push_back(v);
		vec[v].push_back(u);
		++ deg[u];
		++ deg[v];
	}
	for(int i = 1; i <= n; ++ i){
		if(deg[i] != 1){
			dfs(i, 0);
			break;
		}
	}
	while(!pq.empty()){
		int u = pq.top();
		pq.pop();
		int v = f[u];
		if(lfson[v] != 1){
			return printf("First\n"), 0;
		}
		//v = f[v];
		if(!f[v]) continue;
		delta[f[v]] += delta[u] + delta[v] + 2;
		sz[f[v]] -= delta[u] + delta[v] + 2;
		v = f[v];
		if(sz[v] == 1){
			pq.push(v);
			if(f[v]){
			    lfson[f[v]] ++;
			}
		}
	}
	printf("Second\n");
	return 0;
}

Measured memory_bytes: 8576
import numpy
import numpy
import itertools

H, W, K = map(int, input().split())
c = []
for _ in range(H):
    line = list(input().replace('.', '0').replace('#', '1'))
    c.append(line)

c = numpy.array(c, dtype = numpy.int)
ans = 0

for pi in itertools.product([0,1], repeat = H):
    for pj in itertools.product([0,1], repeat = W):
        Ii = numpy.array(pi) == 1
        Ij = numpy.array(pj) == 1
        d = c.copy()
        d[Ii, :] = 0
        d[:, Ij] = 0
        if numpy.sum(d) == K:
            ans += 1

print(ans)

Measured memory_bytes: 27256
#include <iostream>
#include <vector>

using namespace std;

class BipartiteMatch {
public:
    explicit BipartiteMatch(int N, int M) : 
        N(N), M(M), g(N+M), match(N+M, -1), visit(N+M, 0)
    {}
public:
    void addEdge(int a, int b){
        g[a].push_back(b+N);
        g[b+N].push_back(a);
    }
    int maximumMatch(){
        int res = 0;
        fill(match.begin(), match.end(), -1);
        for(int i=0;i<N;i++){
            fill(visit.begin(), visit.end(), 0);
            if(search_(i)) ++res;
        }
        return res;
    }
    int getMatch(int t) const { return t < N ? match[t] - N : match[t]; }
private:
    bool search_(int u){
        if(u < 0) return true;
        for(auto next : g[u]){
            if(visit[next]) continue;
            visit[next] = 1;
            if(search_(match[next])){
                match[u] = next, match[next] = u;
                return true;
            }
        }
        return false;
    }
private:
    const int N, M;
    vector<vector<int>> g;
    vector<int> match;
    vector<int> visit;
};

int main(){
    int N, M;
    while(cin >> N >> M){
        vector<vector<int>> A(N, vector<int>(M));
        for(auto& v : A){
            for(auto& t : v) cin >> t;
        }
        vector<vector<int>> B(N, vector<int>(M));
        for(int i=0;i<M;i++){
            BipartiteMatch bm(N, N);
            vector<vector<int>> target(N, vector<int>(N, -1));
            for(int j=0;j<N;j++){
                for(int k=0;k<M;k++){
                    if(!A[j][k]) continue;
                    int idx = (A[j][k]-1)/M;
                    if(target[j][idx] != -1) continue;
                    bm.addEdge(j, idx);
                    target[j][idx] = k;
                }
            }
            bm.maximumMatch();
            for(int j=0;j<N;j++){
                int t = bm.getMatch(j);
                B[j][i] = A[j][target[j][t]];
                A[j][target[j][t]] = 0;
            }
        }
        vector<vector<int>> C(N, vector<int>(M));
        for(int i=0;i<N;i++){
            for(int j=0;j<M;j++){
                for(int k=0;k<N;k++) if((B[k][j]-1)/M == i) C[i][j] = B[k][j];
            }
        }
        for(auto& v : B){
            cout << v[0];
            for(int i=1;i<v.size();i++) cout << " " << v[i];
            cout << endl;
        }
        for(auto& v : C){
            cout << v[0];
            for(int i=1;i<v.size();i++) cout << " " << v[i];
            cout << endl;
        }
    }
}

Measured memory_bytes: 556
N, M = map(int, input().split())
A = []
B = []
for i in range(N):
  A.append(list(map(int, input().split())))
for i in range(M):
  B.append(list(map(int, input().split())))
for i in range(N):
  ans = M
  d = abs(A[i][0] - B[M-1][0]) + abs(A[i][1] - B[M-1][1])
  for j in range(M-2, -1, -1):
    dis = abs(A[i][0] - B[j][0]) + abs(A[i][1] - B[j][1])
    if d >= dis:
      d = dis
      ans = j + 1
  print(ans)

Measured memory_bytes: 66380
use std::io;


/// https://beta.atcoder.jp/contests/abc053/tasks/abc053_b
fn main() {
    let s = read_one::<String>().chars().collect::<Vec<char>>();
    let mut idx_a = 0;
    let mut idx_z = 0;

    for j in 0..s.len() {
        if s[j] == 'A' { idx_a = j; break; }
    }

    for j in (0..s.len()).rev() {
        if s[j] == 'Z' { idx_z = j; break; }
    }

    println!("{}", idx_z - idx_a + 1);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352