akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vvi a(m+1);
		vi b(n);
		for(int i=0;i<n;i++){
			char c;
			int x;
			cin>>c>>x;
			a[x].push_back(i);
			b[i]=(c=='R'?1:-1);
		}
		int res=0;
		while(1){
			res++;
			vvi c(m+1);
			for(int j=1;j<m;j++) if(!a[j].empty()){
				for(auto k:a[j]){
					c[j+b[k]].push_back(k);
				}
			}
			for(int j=1;j<m;j++) if(c[j].size()>=2){
				b[c[j][0]]*=-1;
				b[c[j][1]]*=-1;
			}
			a=c;
			int num=0;
			for(int i=1;i<m;i++) num+=a[i].size();
//			cout<<res<<endl;
			if(num==0){
				cout<<res<<' '<<(a[0].empty()?a[m][0]:a[0][0])+1<<endl;
				break;
			}
/*			for(int i=0;i<=m;i++){
				cout<<i<<':';
				for(auto j:a[i]) cout<<j<<' ';
				cout<<endl;
			}*/
/*			if(!a[0].empty()||!a[m+1].empty()){
				cout<<res<<' '<<(a[0].empty()?a[m+1][0]:a[0][0])+1<<endl;
				break;
			}*/
		}
	}
}


Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s,t; cin >> s >> t;
  int a,b; cin >> a >> b;
  string u; cin >> u;
  if(u==s) a--;
  else b--;
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
 unsigned int key;
 struct Node *next;
 struct Node *prev;
};

typedef struct Node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur;
  cur = nil->next;
  while(cur!=nil&&cur->key!=key){
    cur=cur->next;
  }
  return cur;
}

void init(){
  nil=(NodePointer)malloc(sizeof(struct Node));
  nil->next=nil;
  nil->prev=nil;
}
void printlist(){
  NodePointer cur=nil->next;
  int isf=0;
  while(1){
    if(cur==nil)break;
    if(isf++>0)printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t==nil)return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}
void deleteFirst(){
  deleteNode(nil->next);
}
void deleteLast(){
    deleteNode(nil->prev);
  }
void deleteKey(int key){
  deleteNode(listSearch(key));
}
void insert(int key){
  NodePointer x=(NodePointer)malloc(sizeof(struct Node));
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}
int main(){
  int key,n,i;
  int size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0]=='d'){
      if(strlen(com)>6){
	if(com[6]=='F')deleteFirst();
	else if(com[6]=='L')deleteLast();
      }
      else{
	deleteKey(key);
	nd++;
      }
      size--;
    }
  }
  printlist();
  return 0;
}



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

#define int long long
#define MAX 1000000
#define INF 1000000000
#define pb push_back
#define F first
#define S second

signed main(){
    int A,B;
    cin>>A>>B;
    int result = max(A+B, max(A-B, A*B));
    cout<<result<<endl;
    return 0;
}

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

signed main() {
    ll N, K;

    cin >> N >> K;

    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }

    ll ans = 0;

    vector<ll> m(2100, 0);
    vector<ll> n(2100, 0);
    REP(i, N) {
        m[A[i]]++;
    }

    REPS(i, 2100-1) {
        n[i] = n[i-1] + m[i];
    }

    REP(i, N) {
        ll add = 0;
        FOR(j, i+1, N) {
            if (A[i] > A[j]) {
                add++;
            }
        }
        // cout << "add = " << add << endl;
        ans += add * K;

        ll a = (K-1) * (K) / 2;
        a %= MOD;

        ans += n[A[i]-1] * a;
        // cout << "a = " << a << ", n[A[i]-1] = " << n[A[i]-1] << endl;
        ans %= MOD;
        // cout << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,T;
  cin>>N>>T;
  int mi=1e9+1;
  int mp=0;
  int ans=0;
  REP(i,N){
    int A;
    cin>>A;
    int p=A-mi;
    if(p>mp){
      mp=p;
      ans=1;
    }else if(p==mp)ans++;
    mi=min(mi,A);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
s=[]
count=0
for i in range(m):
    tmp=list(map(int,input().split()))
    s.append(tmp[1:])

p=list(map(int,input().split()))
p=list(map(bool,p))
p=list(map(lambda x:not x,p))

for i in range(2**n):
    tmp_p=p[:]#shallow copy
    for j in range(n):
        if i >> j & 1:
            for k in range(m):
                if j+1 in s[k]:
                    tmp_p[k]^=True#toggle

    if all(tmp_p):
        count+=1
print(count)


Measured memory_bytes: 3064
n=int(input())
D={}
for i in range(n):
    s=input()
    if s in D:
        D[s]+=1
    else:
        D[s]=1
M=max(D.values())
ans=[]
for d in D:
    if D[d]==M:
        ans.append(d)
print(*sorted(ans),sep="\n")

Measured memory_bytes: 34008
#include<iostream>
using namespace std;
int sum[1000001],d,a[1000001];
int main()
{
  int n,k,s;
  cin>>n>>k>>s;
  if (s==1e9)
    {
      for (int i=1;i<=k;++i)
	cout<<1000000000<<' ';
      for (int i=k+1;i<=n;++i)
	cout<<1<<' ';
      cout<<endl;
      return 0;
    }
  for (int i=1;i<=k;++i)
    cout<<s<<' ';
  for (int i=k+1;i<=n;++i)
    cout<<1000000000<<' ';
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main(){
  long long n,m,l,a[100][100],b[100][100],c[100][100]={0};
  cin>>n>>m>>l;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
      cin>>b[i][j];
    }
  }
  for(int d=0;d<n;d++){
    for(int e=0;e<l;e++){
      for(int f=0;f<m;f++){
	c[d][e]+=a[d][f]*b[f][e];

      }
    }
  }
  for(int q=0;q<n;q++){
    for(int w=0;w<l;w++){
      cout<<c[q][w];
      if(w!=l-1)
	cout<<" ";
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3288
#include<stdio.h>
#include<math.h>

int main(){

  int n, t, count, i, j;
  int num[10000];

  scanf("%d",&n);

  for(i=0; i < n; i++){
    scanf("%d",&num[i]);
  }
  count = n;

  for (i = 0; i < n; i++){
    if (num[i] == 2) {
    }
    else if(num[i] % 2 == 0){
      count--; 
    }
    else{
      t = sqrt(num[i]);
      for(j=3; j<=t; j=j+2){
        if(num[i] % j == 0){
          count--;  
          break;  
        }
      }  
    }
  }

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

  return 0;
}

Measured memory_bytes: 1880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define push_back pb

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    int n;string s;
    cin >> n >> s;
    ll ans = 0;
    int nG = 0;
    rep(i, 0, n){if(s[i]=='G')nG++;}

    rep(i, 0, n){
        if(s[i]=='R'){
            rep(j, i+1, n){
                if(s[j]=='B'){
                    ans += nG;
                    if(2*j-i<n){if(s[2*j-i]=='G'){ans--;}}
                    if(0<=2*i-j){if(s[2*i-j]=='G'){ans--;}}
                    if((i+j)%2==0){if(s[(i+j)/2]=='G'){ans--;}}
                }
            }
        }
    }

    rep(i, 0, n){
        if(s[i]=='B'){
            rep(j, i+1, n){
                if(s[j]=='R'){
                    ans += nG;
                    if(2*j-i<n){if(s[2*j-i]=='G'){ans--;}}
                    if(0<=2*i-j){if(s[2*i-j]=='G'){ans--;}}
                    if((i+j)%2==0){if(s[(i+j)/2]=='G'){ans--;}}
                }
            }
        }
    }
    

    cout << ans;

   
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;

int n;
ll a, b;
ll ans = 0;
vector<pair<ll, ll> >V;
bool judge = true;

int main(){
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> a >> b;
    V.push_back(make_pair(b, a));
  }
  sort(V.begin(), V.end());
  for(int i = 0; i < V.size(); ++i){
    ans += V[i].second;
    //cout <<"check: " << ans << " " << V[i].first << endl;
    if(ans > V[i].first){
      judge = false;
      //break;
    }
  }
  if(judge == true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<double,ll,ll>T;
#define PI 3.14159265358979
const ll MOD = 1e12 + 7;

//union_find木テンプレ
//問いに応じて最大の頂点数を定めること
#define MAXN 100100
long int par[MAXN];//親番号
long int rank[MAXN];//木の深さ
long int siz[MAXN];//属する集団のサイズ
//初期化関数
void init(int n) {
    rep(i, n) { par[i] = i; ::rank[i] = 0; siz[i] = 1; }
}
//木の根を求める関数
int find(int x) {
    if (par[x] == x) { return x; }
    else { return par[x] = find(par[x]); }
}
//xとｙの集合を併合する関数
void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y)return;
    if (::rank[x] < ::rank[y]) {
        par[x] = y;
        siz[y] += siz[x];
    }
    else {
        par[y] = x;
        siz[x] += siz[y];
        if (::rank[x] == ::rank[y])::rank[x]++;
    }
}
//同じかどうかとサイズがいくらか。
bool same(int x, int y) { return find(x) == find(y); }
int size(int x) { return siz[find(x)]; }

const int MAX = 510000;
//この設定だとn<10^7が限界。maxの０を一個増やせば100msかかるが一桁増やせる。
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;
}



int main(){
  ll N,M;
  cin>>N>>M;
  init(N+1);
  vector<ll>A(M);
  vector<ll>B(M);
  vector<ll>ans(M);
  rep(i,M){cin>>A[i]>>B[i];}
  ll mem=N*(N-1ll)/2ll;
  rep(i,M){ans[i]=0ll;}
  rep(i,M){
  	ans[M-i-1ll]=mem;
  	if(!same(A[M-1-i],B[M-1-i])){
      ll a=size(A[M-1-i]);
      ll b=size(B[M-1-i]);
      ll c=a+b;
      mem+=(a*(a-1ll)/2ll);
      mem+=(b*(b-1ll)/2ll);
      mem-=(c*(c-1)/2);
      unite(A[M-1-i],B[M-1-i]);
    }
  }
  rep(i,M){cout<<ans[i]<<endl;}
}

Measured memory_bytes: 7680
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    ans=1
    for i in 1:parseInt(sqrt(n))+1
        if i^2<=n
            ans=i^2
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 110536
import queue

dx = [0, 0, -1, 1]
dy = [1, -1, 0, 0]

h, w = map(int, input().split())
s = []
for i in range(h) :
    s.append(input())

ans = 0

for i in range(h) :
    for j in range(w) :
        if s[i][j] == '#' :
            continue
        dist = [[-1 for i in range(w)] for j in range(h)]
        q = queue.Queue()
        q.put([j,i])
        dist[i][j] = 0
        cnt = 0
        while not q.empty() :
            xy = q.get()
            for k in range(4) :
                x = xy[0] + dx[k]
                y = xy[1] + dy[k]
                if y < 0 or y >= h or x < 0 or x >= w :
                    continue
                if s[y][x] == '#' :
                    continue
                if dist[y][x] != -1 :
                    continue
                q.put([x, y])
                dist[y][x] = dist[xy[1]][xy[0]] + 1
        for k in range(h) :
            for l in range(w) :
                ans = max(ans, dist[k][l])


print(ans)


Measured memory_bytes: 3952
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
	int a,b,c,d,e,f,g;
	double A,B,C,D,E,F,G,H,I,L,M,N,O,P,Q,R[50],J,K,X[50],Y[50],AI,UE,OKA,KI,KU,KE,KO,SA;
	scanf("%d",&a);
	
	for(b=0;b<a;b++){
		scanf("%lf %lf %lf %lf %lf %lf",&A,&B,&C,&D,&E,&F);
		G=-2.0*A*D+2.0*C*D+2.0*A*F-2.0*C*F+2.0*B*C-2.0*B*E-2.0*C*D+2.0*E*D;
		H=D-F;
		I=B+D;
		J=B-D;
		K=B-D;
		L=D+F;
		M=D-F;
		O=-H*I*J+K*L*M-A*A*D+A*D*C+A*A*F-A*C*F-A*C*D+C*C*D+A*C*F-C*C*F+B*C*C-B*C*E-C*C*D+E*C*D+B*C*E-B*E*E-C*E*D+E*E*D;
		X[b]=O/G;
		if(G==0.0){AI=A;UE=B;OKA=C;KI=D;KU=E;KE=F;A=OKA;B=KI;C=KU;D=KE;E=AI;F=UE;
		G=-2.0*A*D+2.0*C*D+2.0*A*F-2.0*C*F+2.0*B*C-2.0*B*E-2.0*C*D+2.0*E*D;
		H=D-F;
		I=B+D;
		J=B-D;
		K=B-D;
		L=D+F;
		M=D-F;
		O=-H*I*J+K*L*M-A*A*D+A*D*C+A*A*F-A*C*F-A*C*D+C*C*D+A*C*F-C*C*F+B*C*C-B*C*E-C*C*D+E*C*D+B*C*E-B*E*E-C*E*D+E*E*D;
		X[b]=O/G;
		}
		if(G==0.0){AI=A;UE=B;OKA=C;KI=D;KU=E;KE=F;A=OKA;B=KI;C=KU;D=KE;E=AI;F=UE;
		G=-2.0*A*D+2.0*C*D+2.0*A*F-2.0*C*F+2.0*B*C-2.0*B*E-2.0*C*D+2.0*E*D;
		H=D-F;
		I=B+D;
		J=B-D;
		K=B-D;
		L=D+F;
		M=D-F;
		O=-H*I*J+K*L*M-A*A*D+A*D*C+A*A*F-A*C*F-A*C*D+C*C*D+A*C*F-C*C*F+B*C*C-B*C*E-C*C*D+E*C*D+B*C*E-B*E*E-C*E*D+E*E*D;
		X[b]=O/G;
		}
		if(G==0.0)X[b]=0.0;

		
		H=-2*F+2*D;
		I=C-X[b];
		I=I*I;
		J=E-X[b];
		J=J*J;
		I=I-J;
		I=I+D*D-F*F;
		Y[b]=I/H;
		if(H==0.0){AI=A;UE=B;OKA=C;KI=D;KU=E;KE=F;A=OKA;B=KI;C=KU;D=KE;E=AI;F=UE;
		H=-2*F+2*D;
		I=C-X[b];
		I=I*I;
		J=E-X[b];
		J=J*J;
		I=I-J;
		I=I+D*D-F*F;
		Y[b]=I/H;
		}
		if(H==0.0){AI=A;UE=B;OKA=C;KI=D;KU=E;KE=F;A=OKA;B=KI;C=KU;D=KE;E=AI;F=UE;
		H=-2*F+2*D;
		I=C-X[b];
		I=I*I;
		J=E-X[b];
		J=J*J;
		I=I-J;
		I=I+D*D-F*F;
		Y[b]=I/H;
		}
		if(H==0.0)Y[b]=0.0;
		
		H=X[b]-A;
		I=Y[b]-B;
		H=H*H;
		I=I*I;
		H=H+I;
		R[b]=sqrt(H);
		
		
		
		

	}
	for(b=0;b<a;b++)printf("%.3lf %.3lf %.3lf\n",X[b],Y[b],R[b]);

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    for(int i = 0; i <= a; ++i) {
        for(int j = 0; j <= b; j++) {
            if((i*(b-j) + j*(a-i)) == c) {
                cout << "Yes" << '\n';
                return 0;
            }
        }
    }
    cout << "No" << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n1, n2;

  scanf("%d", &n1);
  scanf("%d", &n2);

  if (n1 > n2)
    printf("a > b\n");
  else if (n1 < n2)
    printf("a < b\n");
  else
    printf("a == b\n");

  return 0;
}




Measured memory_bytes: 1732
/*input
5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3

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

#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test int t;cin>>t;while(t--)
#define X first
#define Y second
#define pb push_back
#define all(s) s.begin(),s.end()

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

const int MOD = 1e9+7;
int n,m;
vector<vector<int>> adj;
vector<int> in,vis,src,dp;
int ans;

void find(int s){
    // cout << s << " " << dp[s] << "\n";
    vis[s] = true;
    if(dp[s]!=-1) return;
    dp[s] = 0;
    for(auto it: adj[s]){
        // cout << it << " " << s << "allchild\n";
        if(vis[it]){
            dp[s] = max(dp[it]+1,dp[s]);
            // cout << it << " "<< s <<  " " << dp[s] << "child\n";
            continue;
        }
        find(it);
        dp[s] = max(dp[it]+1,dp[s]);
        
    }
    // cout << s << " " << dp[s] << "--\n";
}

void solve(){
    cin >> n >> m;
    adj.resize(n+1);
    in.resize(n+1,0);
    for(int i=0,x,y;i<m;i++){
        cin >> x >> y;
        adj[x].pb(y);
        in[y]++;
    }
    src.clear();
    for(int i=1;i<=n;i++)
        if(in[i]==0)
            src.pb(i);

    vis.resize(n+1,false);
    dp.resize(n+1,-1);
    ans = 0;
    for(auto it: src){
        find(it);
        ans = max(ans,dp[it]);
        // cout << it << " " << dp[it] << "--\n";
    }
    // for(int i=1;i<=n;i++)
    //     cout << i << " " << dp[i] << "\n";
    cout << ans  << "\n";
}

int main(){
    FIN;   
    // test
    solve();
}

Measured memory_bytes: 11648
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();
		int result;

		int a = p+q;
		int b = q+r;
		int c = r+p;

		if(a<=b) {
			result = a;
			if(c<=a) {
				result = c;
			}
		}else {
			result = b;
			if(c<=b) {
				result = c;
			}
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 21972
/*
Author : Hocky Yudhiono
5/30/2020 7:17:37 PM

1. You can sort the query if offline!
2. Don't bring the dp remaining state when dfsing on DP on Tree.
3. Try to reverse (Think from the back) if you stuck.
4. Be careful when submitting Div. 2 D-F, dont waste it on stupid WAs.
5. Try to reduce a problem
*/

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef vector<int> vi;
typedef pair<LL,LL> PLL;
typedef pair<LL,int> PLI;
typedef pair<int,int> PII;
typedef pair<int,int> pii;
typedef vector<vector<LL>> VVL;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define popf pop_front
#define pf push_front
#define popb pop_back
#define mp make_pair
#define pb push_back
#define remove erase
#define fi first
#define se second

//If the time limit is strict, try not to use long double

//Remember to undefine if the problem is interactive
#define endl '\n'
#define DEBUG(X) cout << ">>> DEBUG(" << __LINE__ << ") " << #X << " = " << (X) << endl

const double EPS = 1e-9;
const int INFMEM = 63;
const int INF = 1061109567;
const LL LINF = 4557430888798830399LL;
const double DINF = numeric_limits<double>::infinity();
const LL MOD = 1000000007;
const int dx[8] = {0,0,1,-1,1,-1,1,-1};
const int dy[8] = {1,-1,0,0,1,-1,-1,1};
// Do dir^1 to get reverse direction
const char dch[4] = {'R','L','D','U'};
// const string ds[8] = {"E","W","S","N","SE","NW","SW","NE"};
const double PI = 3.141592653589793;

inline void open(string a){
    freopen((a+".in").c_str(),"r",stdin);
    freopen((a+".out").c_str(),"w",stdout);
}

inline void fasterios(){
    //Do not use if interactive
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

LL ceil(LL a, LL b){
    return (a-1)/b+1;
}
LL n;
LL sum[100005];
LL isi[100005];
LL take[100005];

void cant(){
    cout << -1 << endl;
    // cout << "Impossible" << endl;
    exit(0);
}

int main(){
    cin >> n;
    for(int i = 0;i <= n;i++){
        cin >> isi[i];
    }
    for(int i = n;i >= 0;i--) sum[i] = sum[i+1]+isi[i];
    LL ans = 0;
    LL cur = 0;
    for(int i = n;i >= 0;i--){
        cur += isi[i];
        take[i] = cur;
        if(i <= 62 && (1LL << i) < cur) cant();
        ans += cur;
        cur = (cur+1)/2;
    }
    ans = 0;
    cur = 1;
    for(int i = 0;i <= n;i++){
        ans += cur;
        cur -= isi[i];
        cur = min(cur*2, sum[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5988
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
h,w = i2()
if h == 1 or w == 1:
    print(1)
    exit()
print(h*w//2 if h*w%2 == 0 else h*w//2+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	char c[20];
	scanf("%s",c+1);
	bool flag=0;
	for(register int i=1;i<=a;++i)
		if(c[i]>'9'||c[i]<'0')
			flag=1;
	if(c[a+1]!='-') flag=1;
	for(int i=a+2;i<=a+b+1;++i)
		if(c[i]>'9'||c[i]<'0')
			flag=1;
	if(flag) printf("No\n");
	else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int a[200][3], cnt[101][3];
    for(int i = 0; i < 101; i++){
        for(int j = 0; j < 3; j++){
            cnt[i][j] = 0;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            int s; cin >> s;
            a[i][j] = s;
            cnt[s][j]++;
        }
    }

    for(int i = 0; i < n; i++){
        int res = 0;
        for(int j = 0; j < 3; j++){
            int s = a[i][j];
            if(cnt[s][j] == 1) res += s;
        }

        cout << res << endl;
    }

    return 0;
}

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

int main() {
  int N, K; cin >> N >> K;
  vector<int> hs(N);
  for (int& h : hs) {
    cin >> h;
  }

  int count = 0;
  for (int h : hs) {
    if (h >= K){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#define MAX 100000

struct Node{
  int p,r,l;
};
struct Node T[MAX];

int main(){
  int n,id,c[MAX],d[MAX],k,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=-1;
    d[i]=0;
    T[i].r=T[i].l=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    if(k!=0){
      for(j=0;j<k;j++){
        scanf("%d",&c[j]);
        T[c[j]].p=id;
        if(j==0){
          T[id].l=c[j];
        }
        else T[c[j-1]].r=c[j];
      }
    }
  }
  for(i=0;i<n;i++){
    j=i;
    while(1){
      if(T[j].p==-1) break;
      j=T[j].p;
      d[i]++;
    }
  }
 for(i=0;i<n;i++){
    printf("node %d:",i);
    printf(" parent = %d,",T[i].p);
    printf(" depth = %d,",d[i]);
    if(T[i].p==-1){
      printf(" root, [");
    }
    else if(T[i].l!=-1){
      printf(" internal node, [");
    }
    else printf(" leaf, [");
    id=T[i].l;
    j=0;
    while(1){
      if(id==-1) break;
      if(j!=0) printf(", ");
      printf("%d",id);
      id=T[id].r;
      j++;
    }
    printf("]\n");
  }
  return 0;
}



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

int main(){
    int N; cin >> N;
    vector<int> v;
    int cnt4=0, cnt2=0;
    for(int i=0; i<N; ++i){
        int a; cin >> a;
        v.push_back(a);
    }
    sort(v.rbegin(), v.rend());
    long long ans=0;
    int cnt=0;
    for(int i=0; i<N-1; ++i){
        if(v[i]==v[i+1]){
            if(ans==0) ans =1;
            ans *= v[i];
            cnt++;
            i+=1;
        }
        if(cnt==2) break;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 892
def main():
    MOD = 10 ** 9 + 7

    N, M = map(int, input().split())
    *x, = map(int, input().split())
    *y, = map(int, input().split())

    sx = 0
    for i, x_ in enumerate(x, 1):
        sx = (sx + x_ * ((i - 1) - (N - i))) % MOD

    sy = 0
    for i, y_ in enumerate(y, 1):
        sy = (sy + y_ * ((i - 1) - (M - i))) % MOD

    ans = sx * sy % MOD

    print(ans)


if __name__ == '__main__':
    main()

# ある矩形の面積は
# (x1-x0)(y1-y0)
# x,yの各要素はx1,x0,y1,y0として何回出現するか?
# 1-indexedで、i番目の要素が
# x1として数えられるのは,
# 相方のx0の候補数 = 1-indexedのx0のインデックス = i-1
# x0として数えられるのは、
# 相方のx1の候補数 = 1-indexedのN-x0のインデックス = N-i


Measured memory_bytes: 18624
n, *a = map(int, open(0).read().split())

ans = [0] * n
for i in range(n-1, -1, -1):
    cnt = 0
    for j in range(i+1, n+1, i+1): cnt += ans[j-1]
    if cnt%2!=a[i]: ans[i] = 1

print(sum(ans))
for i in range(n):
    if ans[i]: print(i+1)

Measured memory_bytes: 7112
n = int(input())
al = list(map(int, input().split()))

if n==2:
    print(max(al)-min(al))
    print(max(al),min(al))
    exit()

pos = []
neg = []
for a in al:
    if a>=0:
        pos.append(a)
    else:
        neg.append(a)

pos.sort()
neg.sort(reverse=True)
res = []

if len(pos)==0:
    x = neg[0]
    for a in neg[1:]:
        res.append((x,a))
        x -= a
elif len(neg)==0:
    x = pos[0]
    for a in pos[1:-1]:
        res.append((x,a))
        x -= a
    res.append((pos[-1],x))
    x = pos[-1]-x
else:
    p = pos[0]
    pos = pos[1:]

    x = neg[0]
    neg = neg[1:]

    for a in pos:
        res.append((x,a))
        x -= a
    res.append((p,x))
    x = p - x
    for a in neg:
        res.append((x,a))
        x -= a


print(x)
for a,b in res:
    print(a,b)

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

typedef long long LL;
const int M=1e5+5;
struct Event
{
	int w,k;
	void read(int k_)
	{
		k=k_;
		scanf("%d",&w);
	}
	bool operator<(const Event &B) const
	{
		return w<B.w;
	}
}e[M*2];
vector<Event> vec;

int main()
{
	int n,m; scanf("%d%d",&n,&m);
	int k=0;
	for(int i=0;i<n;i++)
		e[k++].read(0);
	for(int i=0;i<m;i++)
		e[k++].read(1);
	n++; m++;
	int c=0,r=0;
	LL ans=0;
	sort(e,e+k);
	for(int i=0;i<k;i++)
	{
		if(e[i].k) ans+=1LL*e[i].w*(n-r),c++;
		else ans+=1LL*e[i].w*(m-c),r++;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
	int n,m,x,y,temp,maxx,maxy;
	maxx = -101;
	maxy = 101;
	cin >> n >> m >> x >> y;
	if(x >= y)cout << "War" << endl;
	else{
		while(n--){
			cin >> temp;
			if(temp > maxx) maxx = temp;
		}
		while(m--){
			cin >> temp;
			if(temp < maxy) maxy = temp;
		}
		temp = maxx + 1;
		if(temp > maxy) cout << "War" << endl;
		else{
			if(temp <= x || temp > y ) cout << "War" << endl;
			else cout << "No War" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int money = 100000;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		money *= 1.05;
		if (money % 1000 != 0) {
			money -= money % 1000;
			money += 1000;
		}
	}
	cout << money << endl;
	return 0;
}

Measured memory_bytes: 3068
import java.util.*;

import java.io.*;

public class Main{
	
	static long[][] memo;
	static char[][] grids;
	static int n , m;
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		String[] inp = br.readLine().split(" ");
		 n = Integer.parseInt(inp[0]);
		 m = Integer.parseInt(inp[1]);
		grids = new char[n][m];
		for(int i=0;i<n;i++)
		{
			String s=br.readLine();
			for(int j=0;j<m;j++)grids[i][j]=s.charAt(j);
		}
		memo = new long[n][m];
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)memo[i][j]=-1;
		System.out.println(dp(0,0));
		
		
		pw.flush();
		pw.close();
	}
	
	public static long dp(int i , int j)
	{
		if(i==n-1 && j==m-1)return 1;
		if(valid(i,j) && memo[i][j]!=-1) return memo[i][j];
		int temp=0;
		if(valid(i+1,j)) {
			temp+=dp(i+1,j);
		}
		if(valid(i,j+1)) temp+=dp(i,j+1);
		return memo[i][j]=temp%=((int)1e9+7);
		
	}
	
	
	public static boolean valid(int i , int j)
	{
		return (i>=0) && (i<n) && (j>=0) && (j<m) && (grids[i][j]=='.');
	}
	

}


Measured memory_bytes: 38128
#include <bits/stdc++.h>
#define v(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){int n,m,q[2]={0},s=0,a[10];long long dp[2][10],c[10];char z;cin>>n;v(i,n){cin>>z;if(z=='*')q[1-((n-i)%2)]++;else{z-='0';if((n-i)%2==0)z=(z*2-1)%9+1;s+=z;}}cin>>m;v(i,m)cin>>a[i];v(i,2)v(j,10)dp[i][j]=0;v(i,2)dp[i][0]=1;v(i,2){v(j,q[i]){v(k,10)c[k]=0;v(k,m)v(r,10)c[(r+a[k])%10]+=dp[i][r];v(k,10)dp[i][k]=c[k];}v(i,m)a[i]=(a[i]*2-1)%9+1;}long long ans=0;v(i,10)v(j,10)if((s+i+j)%10==0)ans+=dp[0][i]*dp[1][j];cout<<ans<<endl;return 0;}

Measured memory_bytes: 1156
/**
 * @jakestrj
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include "bits/stdc++.h"
using namespace std;
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define rep(i, j, k) for(int i=(j);i<(k);++i)
#define repi(i, j, k) for(int i=(j);i<=(k);++i)
#define per(i, j, k) for(int i=(j);i>(k);--i)
#define peri(i, j, k) for(int i=(j);i>=(k);--i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end(), greater<int>()
#define mem(a, b) memset(a, (b), sizeof(a))
#define mem2(a, b) memset(a, (b), sizeof(a[0][0])*len(a)*len(a[0]))
#define sz(x) ((int)(x).size())
#define len(x) (int)(sizeof(x)/sizeof(x[0]))
#define endl "\n"
#define INF 1e18
#define EPS 1e-9
#define PI 2*acos(0)
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
typedef tuple<int, int, int> trio;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef map<int,int> mpii;
typedef set<int> si;

#include <sstream>

#define U 'U'
#define D 'D'
#define L 'L'
#define R 'R'
struct C {
	void solve(std::istream& cin, std::ostream& cout) {
		int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
		int dx = tx-sx, dy = ty-sy;
		string res = "";
		res += string(dy, U);
		res += string(dx, R);

		res += string(dy, D);
		res += string(dx, L);

		res += string(1, L);
		res += string(dy+1, U);
		res += string(dx+1, R);
		res += string(1, D);

		res += string(1, R);
		res += string(dy+1, D);
		res += string(dx+1, L);
		res += string(1, U);

		cout << res << endl;
	}
};


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	C solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
    int H, W;

    while(1) {
        cin >> H >> W;
        if(H == 0 && W == 0) break;

        for(int j = 0; j < H; j++) {
            for(int i = 0; i < W; i++) {
                if(j==0 || j==H-1) {
                    cout << '#' ;
                    if(i == W-1) cout << endl;
                }
                else {
                    if(i==0 || i == W-1) cout << '#';
                    else cout << '.';

                    if(i==W-1) cout << endl;
                }
            }
        }

        cout << endl;
    }

}


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

int main() {
	vector<int> P_o_two = {1,2,4,8,16,32,64,101};
	int N; cin >> N;
	for( int i = 0; i < 7; i++ ){
		if( P_o_two[i] <= N && P_o_two[i+1] > N ){
			cout << P_o_two[i] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import math
from collections import defaultdict
def larger_nibeki(i):
    return 2 ** len(format(i, 'b'))
N, *A = map(int, open(0).read().split())
A.sort(reverse=True)
C = defaultdict(int)
for a in A:
    C[a] += 1
ans = 0
for a in A:
    if C[a] == 0:
        continue
    C[a] -= 1
    partner = larger_nibeki(a) - a
    if C[partner] > 0:
        ans += 1
        C[partner] -= 1
print(ans)

Measured memory_bytes: 56632
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int N, M, D;

	while (true)
	{
		scanf("%d", &N);
		scanf("%d", &M);

		if (N == 0 && M == 0) { break; }

		vector<int> C(N + 1); C.push_back(0);

		for (int i = 1; i <= N; i++)
		{
			scanf("%d", &C[i]);
		}

		vector<int> r;

		for (int i = 0; i <= N; i++)
		{
			for (int j = i; j <= N; j++)
			{
				if (C[i] + C[j] <= M)
				{
					r.push_back(C[i] + C[j]);
				}
			}
		}

		sort(r.begin(), r.end());

		int ret = 0, lc = 0, rc = r.size() - 1;

		while (rc - lc >= 0)
		{
			if (r[lc] + r[rc] > M)
			{
				rc--;
			}
			else
			{
				ret = max(ret, r[lc++] + r[rc]);
			}
		}

		printf("%d\n", ret);
	}

	return 0;
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 300005 ;
const long long mod = 1e9+7;
int n;
int arr[301];
ld dp[301][301][301];
ld solve(int one, int two, int three, int& n)
{
    if(one < 0 || two < 0 || three < 0)
        return 0;
    if(three == 0 && two == 0 && one == 0)
        return 0;
 
    if(dp[one][two][three] >0 )
        return dp[one][two][three];
 
    int remaining = one + two + three;
    ld exp_val = n+one*solve(one-1,two,three,n) + two*solve(one+1,two-1,three,n) +
                    three*solve(one,two+1,three-1,n);
 
    return dp[one][two][three] = ((1.0*exp_val)/(1.0*remaining));
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int i,j,one=0,two=0,three=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        if(arr[i]==1)
            one++;
        else if(arr[i]==2)
            two++;
        else
            three++;
    }
    memset(dp,-1,sizeof(dp));
    cout<<fixed<<setprecision(9)<<solve(one,two,three,n)<<endl;
}

Measured memory_bytes: 426496
#include <iostream>
#include <string>

using namespace std;

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

	int ans = 0;
	for (auto c : s) {
		if  (c == '+') {
			ans++;
		} else {
			ans--;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] g = new int[N][N];
		for(int i=0; i<M; i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			g[a][b] = 1;
			g[b][a] = 1;
		}
		ArrayList<Integer> l = new ArrayList<Integer>();
		for(int i=1; i<N; i++) {
			l.add(i);
		}
		System.out.println(dfs(0, l, g));
	}
	
	static int dfs(int c, ArrayList<Integer> l, int[][] g) {
		if(l.isEmpty()) return 1;
		int ret = 0;
		for(int i=0; i<l.size(); i++) {
			int next = l.get(i);
			if(g[c][next] == 1) {
				ArrayList<Integer> tmpl = (ArrayList<Integer>)l.clone();
				tmpl.remove(l.get(i));
				ret += dfs(next, tmpl, g);
			}
		}
		return ret;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
}


Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll N, M, K;
combination comb( 200010 );

mint calc( ll N, ll M )
{
  mint n = N, m = M, k = K;
  
  return n*n*(m*m*(m-1)/2-(m-1)*m*(m*2-1)/6)*comb( M*N-2, K-2 ); 
}

int main()
{
  std::cin >> N >> M >> K;

  mint ans = calc( N, M ) + calc( M, N );

  std::cout << ans.x << std::endl;

  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
 
int main(){
	int K,N;
    cin >> K >> N;
    int A[200000];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    
    int dist_max = K-A[N-1] + A[0];
    int temp;
    for(int i=0; i<N-1; i++){
        temp = A[i+1] - A[i];
        if(dist_max < temp){
            dist_max = temp;
        }
    }

    cout << K-dist_max << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int color[101],d[101],f[101],t;
int a[101][101]={};
// white 0 gray 1 brack 2
void DFSvisit(int n,int u){
    t++;
    d[u]=t;
    color[u]=1;
    for(int i=1;i<=n;i++){
        if(a[u][i]==1 && color[i]==0){
            DFSvisit(n,i);
        }
    }
    color[u]=2;
    t++;
    f[u]=t;
}
void DFS(int n){
    for(int i=1;i<=n;i++){
        color[i]=0;
    }
    t=0;
    for(int i=1;i<=n;i++){
        if(color[i]==0){
            DFSvisit(n,i);
        }
    }
}
int main(){
    int n,k,m,l;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>m>>k;
        for(int j=0;j<k;j++){
            cin>>l;
            a[m][l]=1;
        }
    }
    DFS(n);
    for(int i=1;i<=n;i++){
        cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<iomanip>
#define INF INT_MAX
using namespace std;

double T, X;
double ans;
int main(){
	cin >> T >> X;
	ans = T / X;
	cout << fixed << setprecision(4) <<  ans << endl;
	
	return 0;
}

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

#define int long long

signed main()
{
    string S;

    cin >> S;

    int ans = S.size() * (S.size() - 1) / 2 + 1;
    for(int p = 0; p < 26; p++) {
        int cnt = 0;
        for(int i = 0; i < S.size(); i++) {
            if(S[i] == 'a' + p) cnt++;
        }
        ans -= (cnt - 1) * cnt / 2;
    }
    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<=n;i++)
typedef long long ll;
using namespace std;
int main()
{
   int N;
   cin >> N;
   vector<pair<int,int>>P(N);
   rep(i,0,N){
       cin >> P[i].first >> P[i].second;
   }

   sort(P.begin(),P.end(),greater<pair<int,int>>());
   
   cout << P[0].first+P[0].second << endl;
   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a[500005];
int n;
void maxHeapify(int i){
	int l=i*2,r=i*2+1;
	int jb;
	if(l<=n&&a[l]>a[i])jb=l;
	else jb=i;
	if(r<=n&&a[r]>a[jb])jb=r;
	if(jb!=i){
		swap(a[i],a[jb]);
		maxHeapify(jb);
	}
}
void buildMaxHeap(){
	for(int i=n/2;i>=1;i--)
		maxHeapify(i);
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	buildMaxHeap();
	for(int i=1;i<=n;i++){
		cout<<' '<<a[i];
	}cout<<endl;
	return 0;
}


Measured memory_bytes: 4960
#include <iostream>

using namespace std;

int N;
long long T, A;
long long t, a;

int main() {
	cin >> N;
	for(int i = 0; i < N; i++) {
		cin >> T >> A;
		if (i == 0 || (t <= T && a <= A)) {
			t = T;
			a = A;
		} else {
			long long k = max((t + T - 1) / T, (a + A - 1) / A);
			t = T * k;					
			a = A * k;
		}
	}
	cout << t + a;
	return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
ans=""
for u in range(ty-sy):
    ans+="U"
for r in range(tx-sx):
    ans+="R"
for d in range(ty-sy):
    ans+="D"
for l in range(tx-sx):
    ans+="L"
ans+="L"
for u in range(ty-sy+1):
    ans+="U"
for r in range(tx-sx+1):
    ans+="R"
ans+="DR"
for d in range(ty-sy+1):
    ans+="D"
for l in range(tx-sx+1):
    ans+="L"
ans+="U"
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;
class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        String num = scan.nextLine();
        int count = 0;
        for(int i = 0; i < 3; i++){
            char c = num.charAt(i);
            if(c == '1'){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <string>

int main()
{
    std::string S;
    std::cin >> S;
    bool flag = true;
    for (char c : S)
    {
        if (std::count(S.begin(), S.end(), c) != 1)
        {
            flag = false;
            break;
        }
    }

    if (flag) { std::cout << "yes" << std::endl; }
    else
    {
        std::cout << "no" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

#include <complex>
typedef complex<double> Point;
const double EPS = 1e-8;

// 入力ストリームから実数二つをとって Point へ
istream& operator >> ( istream &s, Point &a )
{
	double r, i;
	s >> r >> i;
	a = Point( r, i );
	return s;
}

// a == b
bool eq( const double a, const double b )
{
	return abs( a - b ) <= EPS;
}


// 外積（クロス積）
double cross( const Point &a, const Point &b )
{
	return a.real() * b.imag() - a.imag() * b.real();
}

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

	int n;
	cin >> n;
	REP( i, 0, n )
	{
		Point a, b, c, d;
		cin >> a >> b >> c >> d;
		cout << ( eq( cross( a - b, c - d ), 0 ) ? "YES" : "NO" ) << endl;
	}

	return 0;
}

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

int main() {
    int64_t n, x, ans = 0;
    cin >> n >> x;
    vector<int64_t> a(n);
    for (auto i = 0; i < n; i++) cin >> a[i];
    for (auto i = 0; i < n - 1; i++) {
        int64_t cnt = a[i] + a[i + 1] - x;
        if (cnt > 0)
            ans += cnt, a[i + 1] -= min(cnt, a[i + 1]);
    }
    cout << ans << endl;
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 2e5 + 5;
const long long MOD = 1e9 + 7;

int d, t, s;


int main() { speedhack()

	cin >> d >> t >> s;
	t = t * s;

	if (t >= d)
		cout << "Yes";
	else 
		cout << "No";

	return 0;
}

Measured memory_bytes: 3620