akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


int main() {
	
	int n;
	cin >> n;
	VI a(n);
	map<int, int> m;
	ll ans = 0;
	REP(i, n) {
		cin >> a[i];
		ans += m[i - a[i]];
		m[i + a[i]]++;
	}
	cout << ans << endl;

}


Measured memory_bytes: 21044
#include<iostream>
#include<algorithm>
using namespace std;
bool compare(const pair<int,int> a,const pair<int,int> b) {
    return a.first>b.first;
}
int main(){
    int n;
    cin>>n;
    pair<int,int> *team;
    team=new pair<int,int>[n+1];
    for(int i=1;i<=n;++i){
        team[i].first=0;
        team[i].second=i;
    }
    int a,b,c,d;
    for(int i=0,nmax=n*(n-1)/2;i<nmax;++i){
        cin>>a>>b>>c>>d;
        if(c<d){
            team[b].first+=3;
        }else if(c>d){
            team[a].first+=3;
        }else{
            ++team[a].first;
            ++team[b].first;
        }
    }
    sort(team+1,team+n+1,compare);
    int *win;
    win=new int[n+1];
    win[team[1].second]=1;
    for(int i=2;i<=n;++i) {
        if(team[i-1].first==team[i].first){
            win[team[i].second]=win[team[i-1].second];
        }else{
            win[team[i].second]=i;
        }
    }
    for(int i=1;i<=n;++i) {
        cout<<win[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3120
b1,b2,b3 = map(int,input().split())
if b1 == 1 and b2 == 0 and b3 == 0:
    print("Close")
elif b1 == 0 and b2 == 1 and b3 == 0:
    print("Close")
elif b1 == 1 and b2 == 1 and b3 == 0:
    print("Open")
elif b1 == 0 and b2 == 0 and b3 == 1:
    print("Open")
else:
    print("Close")


Measured memory_bytes: 5592
N,A,B,C,D=map(int,input().split())
S=input()
A-=1
B-=1
C-=1
D-=1
def test(i,m):
    while i<N :
        if i==m:
            return(1)
        if i+1<N and S[i+1]==".":
            i+=1
        elif i+2<N and S[i+2]==".":
            i+=2
        else:
            return(0)
    return(0)


if C<D:

    if test(A,C) and test(B,D):
        print("Yes")
    else:
        print("No")
else:
    T=B-1
    if "..." in S[T:min(D+2,N-1)] and test(A,C) and test(B,D):
        print("Yes")
    else:
        print("No")


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	int n , p;
	cin >> n>>p;
	ll odd =0;
	rep(i,n){
		int a;cin >> a;
		if(a%2 ==0) ;
		else odd ++;
	}
	ll ans = 0;
	if(odd == 0){
		if( p == 0){
			ans = pow(2,n);
		}else ans = 0;
	}else{
		ans = pow(2,n-1);
	}
	cout << ans << endl;


}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
char a[100+5],b[100+5];
int n,ans,cnt;
int main()
{
	scanf("%d",&n);
	scanf("%s%s",a,b);
	for(int i=0;i<n;i++)
	{
		int temp=0;
		for(int j=i;j<n;j++)
		{
			int x=j-i;
			if(a[j]!=b[x])
				break;
			temp++;
		}
		cnt=max(cnt,temp);
	}
	ans=n*2-cnt;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  int H,W;
  cin >> H >> W;
  vector<string> a(H);
  vector<ll> rmh,rmw;
  for (int i = 0; i < H; i++) {
    cin >> a[i];
    bool can=true;
    for (int l = 0; l < W; l++) {
      if(a[i][0] != a[i][l] || a[i][l] == '#')can = false;
    }
    if(can)rmw.pb(i);
  }
  for (int i = 0; i < W; i++) {
    bool can=true;
    for (int l = 0; l < H; l++) {
      if(a[0][i] != a[l][i] || a[l][i] == '#')can = false;
    }
    if(can)rmh.pb(i);
  }
  for (int i = 0; i < H; i++) {
    if(!(binary_search(all(rmw),i))){
      for (int l = 0; l < W; l++) {
        if(!(binary_search(all(rmh),l)))cout << a[i][l];
      }
      cout << endl;
    }
  }

}


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

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    string s; cin >> s;
    for(int i = 1; i < s.length(); i++) {
        if(s[i] == s[i-1]) {
            cout << i << " " << i+1;
            return 0;
        }
        if(i > 1) {
            if(s[i] == s[i-2]) {
                cout << i-1 << " " << i+1;
                return 0;
            }
        }
    }    
    cout << -1 << " " << -1;
}

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

using namespace std;

int main()
{
//    freopen("in.txt","r",stdin);

    int m,f,r;
    while(scanf("%d %d %d",&m,&f,&r)&&(m!=-1||r!=-1||f!=-1))
    {
        if(m==-1||f==-1||(m+f)<30)
        {
                cout<<"F"<<endl;
                continue;
        }
        else if((m+f)>=80)
            cout<<"A"<<endl;
        else if((m+f)>=65)
            cout<<"B"<<endl;
        else if((m+f)>=50)
            cout<<"C"<<endl;
        else
        {
            if(r>=50)
                cout<<"C"<<endl;
            else
                cout<<"D"<<endl;
        }
    }
}



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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 1e4 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

const ll LOG = 130;

ll dp[MAXN][110][2];

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	str k;
	ll D;
	cin >> k >> D;
	ll n = k.size();
	dp[0][0][1] = 1;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < D; j++){
			for(int dig = 0; dig < 10; dig++){
				if(dig < (k[i] - '0')){
					dp[i + 1][ (j + dig) % D ][0] += dp[i][j][0];
					dp[i + 1][ (j + dig) % D ][0] += dp[i][j][1];
					dp[i + 1][ (j + dig) % D ][0] %= MOD;
				} else if ( dig == (k[i] - '0') ){
					dp[i + 1][ (j + dig) % D ][0] += dp[i][j][0];
					dp[i + 1][ (j + dig) % D ][1] += dp[i][j][1];
					dp[i + 1][ (j + dig) % D ][0] %= MOD;
					dp[i + 1][ (j + dig) % D ][1] %= MOD;
				} else {
					dp[i + 1][ (j + dig) % D ][0] += dp[i][j][0];
					dp[i + 1][ (j + dig) % D ][0] %= MOD;
				}
			}
		}
	}
	
	cout << (dp[n][0][1] + dp[n][0][0] + 1000000006) % MOD;
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 17408
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val st = scala.collection.mutable.Set[Long]()
    for (i <- 0 until n) {
      val a = sc.nextLong
      if(st.contains(a)) st.remove(a) else st.add(a)
    }

    println(st.size)
  }
}


Measured memory_bytes: 53848
import sys

n, k, q, *lst = map(int, sys.stdin.read().split())
point = [0] * (n + 1)
for i in lst:
  point[i] += 1
for idx, i in enumerate(point):
  if idx == 0:
    continue
  if k + i - q < 1:
    print('No')
  else:
    print('Yes')

Measured memory_bytes: 13940
#include <iostream>
#include <deque>
using namespace std;
 
deque<pair<int,int> > Deq;
 
int Dfs(int iDx, int markeD, int D) {
  if(iDx == Deq.size()) {
    return markeD;
  }
   
  int enD = Dfs(iDx+1, markeD, D);
  if(D >= Deq[iDx].first) {
    enD = max(enD, Dfs(iDx+1, markeD+Deq[iDx].second, D-Deq[iDx].first));
  }
   
  return enD;
}
 
int main() {
   
  int D; cin >> D;
  int x; cin >> x;
  string a; int p;
  for(int i=0; i<x; i++) {
    cin >> a >> p;
    if(a == "D") {
      Deq.push_back(make_pair(1, p));
    }
  }
   
  int y; cin >> y;
  string b; int q;
  for(int i=0; i<y; i++) {
    cin >> b >> q;
    if(b == "DD") {
      Deq.push_back(make_pair(2, q));
    }
  }
   
  cout << Dfs(0, 0, D) << endl;
   
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n, k;
  cin >> n >> k;
  
  vector<double> s(n + 1, 0);
  double temp;
  
  for(int i = 1; i < n + 1; i++){
    cin >> temp;
    temp += 1.0;
    temp *= 0.5;
    s.at(i) = s.at(i - 1) + temp;
  }
  
  double sum = 0, max = 0;
  
  for(int i = k; i < n + 1; i++){
    sum = s.at(i) - s.at(i - k);
    if(sum > max){
      max = sum;
    }
  }
  
  cout << fixed << max << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pi pair<int, int>
#define edge pair<pi, int>

vector<edge> e;

void solve(int n, int l) {
	e.push_back(edge(pi(n - 1, n), 0));
	if (l > 1) {
		if (l % 2 == 1)
			e.push_back(edge(pi(1, n), l - 1));
		e.push_back(edge(pi(n - 1, n), l / 2));
	}
	if (n > 2)
		solve(n - 1, l / 2);
}

int main() {
	int l;
	scanf("%d", &l);
	solve(20, l);
	printf("20 %d\n", e.size());
	for (edge ee : e) {
		printf("%d %d %d\n", ee.first.first, ee.first.second, ee.second);
	}
}

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



Measured memory_bytes: 3180
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll a,b,c,x,y,i,s=0;cin>>x>>y>>a>>b>>c;vi a1(a),b1(b),c1(c),v,xx;
	for(i=0;i<a;i++) cin>>a1[i];for(i=0;i<b;i++) cin>>b1[i];for(i=0;i<c;i++) cin>>c1[i];
	sort(rall(a1));sort(rall(b1));sort(all(c1));
	for(i=0;i<x;i++) v.pb(a1[i]);for(i=0;i<y;i++) v.pb(b1[i]);sort(rall(v));
	while((ll)v.size()&&(ll)c1.size()){
		if(v.back()<c1.back()) xx.pb(c1.back()),c1.pop_back(),v.pop_back();
		else break;
	}for(i=0;i<v.size();i++) s+=v[i];for(i=0;i<xx.size();i++) s+=xx[i];
	cout<<s<<endl;
}


Measured memory_bytes: 5872
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int max = 0;
		String s2[] = {"A","C","G","T"};
		int count = 0;
		s = s+"j";
		for(int i = 0; i < s.length(); i++){
			if(s2[0].equals(s.substring(i,i+1))){
				count++;
			}else if(s2[1].equals(s.substring(i,i+1))){
				count++;
			}else if(s2[2].equals(s.substring(i,i+1))){
				count++;
			}else if(s2[3].equals(s.substring(i,i+1))){
				count++;
			}else{
					max = Math.max(max,count);
					count = 0;
			}
		}
		System.out.print(max);
	}
}


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

int main(){
  int Q,H,S,D,N;
  cin >> Q >> H >> S >> D >> N;
  vector<double> a(4),b(4);
  a.at(0)=Q*4;
  a.at(1)=H*2;
  a.at(2)=S;
  a.at(3)=D/2.0;
  for(int i=0;i<4;i++){
    b.at(i)=a.at(i);
  }
  sort(a.begin(),a.end());
  if(a.at(0)==b.at(0)){
    cout << (long int) N*4*Q << endl;
  }else if(a.at(0)==b.at(1)){
    cout << (long int) N*2*H << endl;
  }else if(a.at(0)==b.at(2)){
    cout << (long int) N*S << endl;
  }else{
    if(N%2==0){
      cout << (long int) N/2*D << endl;
    }else{
      if(a.at(1)==b.at(0)){
        cout << (long int) (N-1)/2*D+4*Q << endl;
      }else if(a.at(1)==b.at(1)){
        cout << (long int) (N-1)/2*D+2*H << endl;
      }else{
        cout << (long int) (N-1)/2*D+S << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int n,k;
  cin>>n>>k;
  int s=0;
  for(int i=1;i<=n;i+=2) s++;

  YES(s>=k);


}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll dp[303][303][303];
ll mod = 1e9 + 7;

int check(int r,int g,int b,int L,int R) {
	int cnt = 0;
	if (L <= r && r <= R)cnt++;
	if (L <= g && g <= R)cnt++;
	if (L <= b && b <= R)cnt++;
	return cnt;
}

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

	int N, M;
	cin >> N >> M;
	vector<vector<int>>v[330];
	for (int i = 0; i < M; i++) {
		int L, R, X;
		cin >> L >> R >> X;
		v[R].pb({ L,X });
	}

	dp[0][0][0] = 1;
	for (int r = 0; r <= N; r++) {
		for (int g = 0; g <= N; g++) {
			for (int b = 0; b <= N; b++) {
				int c1 = (r == g) && (r != 0);
				int c2 = (g == b) && (g != 0);
				int c3 = (b == r) && (b != 0);
				if (c1 || c2 || c3) {
					dp[r][g][b] = 0;
					continue;
				}

				int ma = max(max(r,g),b);
				fore(x, v[ma]) {
					int R = ma;
					int L = x[0];
					int X = x[1];
					if (check(r, g, b, L, R) != X)dp[r][g][b] = 0;
				}
				
				dp[ma+1][g][b] += dp[r][g][b];
				dp[r][ma+1][b] += dp[r][g][b];
				dp[r][g][ma+1] += dp[r][g][b];
				dp[ma+1][g][b] %= mod;
				dp[r][ma+1][b] %= mod;
				dp[r][g][ma+1] %= mod;
			}
		}
	}


	ll ans = 0;
	for (int r = 0; r <= N; r++) {
		for (int g = 0; g <= N; g++) {
			for (int b = 0; b <= N; b++) {
				if (max(max(r, g), b) == N) {
					ans += dp[r][g][b];
				}
				ans %= mod;
			}
		}
	}
	puts(ans);

	return 0;
}

Measured memory_bytes: 217344
s = int(input())
sList = [s]
i = 0
while i >= 0:
    if sList[i] % 2 == 0:
        s = sList[i] // 2
    else:
        s = sList[i] * 3 + 1
    sList.append(s)
    if sList[0:i + 1].count(s) == 1:
        print(i + 2)
        break
    i += 1


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
void fff()
{
	ld d, t, s;
	cin >> d >> t >> s;
	if(d/s <= t)cout << "Yes\n";
	else cout <<"No\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 3740
"use strict"

function main(input) {
  input = input.split(/\n/)
  const rowscols = input[0].split(/\s/).map(v => ~~v)
  const marks = input.slice(1, input.length).map(v => v.split("")) //印
  let ans = "" //new Array(rowscols[0])
  for (let r = 0; r < rowscols[0]; r++) {
    for (let c = 0; c < rowscols[1]; c++) {
      if (marks[r][c] == ".") {
        let cnt = 0
        //左右斜めのマスをチェックする
        if (r > 0 && c > 0 && marks[r - 1][c - 1] == "#") cnt++
        if (r > 0 && marks[r - 1][c + 0] == "#") cnt++
        if (r > 0 && c < rowscols[1] - 1 && marks[r - 1][c + 1] == "#") cnt++

        if (c > 0 && marks[r + 0][c - 1] == "#") cnt++
        if (c < rowscols[1] - 1 && marks[r + 0][c + 1] == "#") cnt++

        if (r < rowscols[0] - 1 && c > 0 && marks[r + 1][c - 1] == "#") cnt++
        if (r < rowscols[0] - 1 && marks[r + 1][c + 0] == "#") cnt++
        if (
          r < rowscols[0] - 1 &&
          c < rowscols[1] - 1 &&
          marks[r + 1][c + 1] == "#"
        )
          cnt++
        ans += cnt
      } else {
        ans += "#"
      }
    }
    ans += "\n"

    // console.log(ans[r])
  }

  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7756
N = int(input())
XL = []
for _ in range(N):
    x,l = map(int,input().split())
    #腕の右端が左にあるものから調べる
    XL.append([x+l,x-l])
XL.sort()

ans, t = 0, -1e9
for i in range(N):
    if t <= XL[i][1]:
        ans += 1
        t = XL[i][0]
print(ans)

Measured memory_bytes: 20196
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

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

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

  ll a,b;
  std::cin>>a>>b;

  rep(i,1,4){
    if(i!=a&&i!=b){
      std::cout<<i<<"\n";
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct node{int p,l,r;};
node T[100005];
int n,D[100005];
void print(int u){
	cout<<"node "<<u<<": ";
	cout<<"parent = "<<T[u].p<<", ";
	cout<<"depth = "<<D[u]<<", ";
	if(T[u].p==-1 ){
		cout<<"root, ";
	}
	else if(T[u].l==-1){
		cout<<"leaf, ";
	}
	else{
		cout<<"internal node, ";
	}
	cout<<"[";
	for(int i=0,c=T[u].l;c!=-1;i++,c=T[c].r){
		if(i){
			cout<<", ";
		}
		cout<<c;
	}
	cout<<"]"<<endl;
}
int rec(int u,int p){
	D[u]=p;
	if(T[u].r!=-1){
		rec(T[u].r,p);
	}
	if(T[u].l!=-1){
		rec(T[u].l,p+1);
	}
}
int main(){
	int d,v,c,l,r;
	cin>>n; 
	for(int i=0;i<n;i++){
		T[i].p=T[i].l=T[i].r=-1;
	}
	for(int i=0;i<n;i++){
		cin>>v>>d;
	    for(int j=0;j<d;j++){
	    	cin>>c;
	    	if(j==0){
	    		T[v].l =c;
			}
			else{
				T[l].r=c;
			}
			l=c;
			T[c].p=v;
		}
	}
	for(int i=0;i<n;i++){
		if(T[i].p==-1){
			r=i;
		}
	}
	rec(r,0);
	for(int i=0;i<n;i++){
		print(i);
	}
	return 0;
}


Measured memory_bytes: 7644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n;
  cin >> n;
  pair<ll,ll> a[n];
  set<pair<ll,ll>> st1;
  REP(i,n) {
    cin >> a[i].fi >> a[i].se;
    st1.insert(a[i]);
  }
  int ans = n;
  sort(a,a+n);
  REP(i,n) {
    for (int j = i+1; j < n; j++) {
      ll p = a[j].fi - a[i].fi;
      ll q = a[j].se - a[i].se;
      int cost = 0;
      set<pair<ll,ll>> st = st1;
      ll bx = INF;
      ll by = INF;
      for (int k = 0; k < n; k++) {
        if (st.find(a[k]) == st.end()) continue;
        bx = a[k].fi;
        by = a[k].se;
        cost++;
        st.erase({a[k].fi,a[k].se});
        while (st.find({bx+p,by+q}) != st.end()) {
          bx += p;
          by += q;
          st.erase({bx,by});
        }
      }
      ans = min(ans,cost);
    }
  }
  cout << ans << endl;
  
}

int main(int argc, char *argv[]){

  /*Regular*/
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }

  // /*ICPC*/
  // while (cin >> t >> d >> l, t) {
  //   solve();
  // }

  //solve();
  return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
import java.io.*;

public class Main {
    private static ArrayList<Integer> [] G;

    private static int dfs(int u) {
        int r = 0;
        ArrayList<Integer> aux = new ArrayList<>();
        for (int v : G[u])
            aux.add(1 + dfs(v));
        Collections.sort(aux);
        for (int x : aux) {
            if (x > r) r = x;
            else r++;
        }
        return r;
    }

    public static void main(String[] args) throws Exception {
        IO io = new IO(null, null);
        int n = io.getNextInt();
        int [] A = new int[n+1];

        for (int i = 2;i <= n;i++)
            A[i] = io.getNextInt();

        G = new ArrayList[n+1];
        for (int i = 1;i <= n;i++)
            G[i] = new ArrayList<>();

        for (int i = 2;i <= n;i++)
            G[A[i]].add(i);

        io.println(dfs(1));

        io.close();
    }

    private static final int onebillion7 = 1000000007;
}



class IO{
    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter writer;
    private String inputFile,outputFile;

    public boolean hasMore() throws IOException{
        if(st != null && st.hasMoreTokens()) return true;
        if(br != null && br.ready()) return true;
        return false;
    }

    public String getNext() throws FileNotFoundException, IOException{
        while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String getNextLine() throws FileNotFoundException, IOException{
        return br.readLine().trim();
    }

    public int getNextInt() throws FileNotFoundException, IOException{
        return Integer.parseInt(getNext());
    }
    public long getNextLong() throws FileNotFoundException, IOException{
        return Long.parseLong(getNext());
    }

    public void print(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f" ,x);
    }
    public void println(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f\n" ,x);
    }
    public void print(Object o) throws  IOException{
        writer.print(o.toString());
    }

    public void println(Object o) throws  IOException{
        writer.println(o.toString());
    }
    public IO(String x,String y) throws FileNotFoundException, IOException{
        inputFile = x;
        outputFile = y;
        if(x != null) br = new BufferedReader(new FileReader(inputFile));
        else br = new BufferedReader(new InputStreamReader(System.in));
        if(y != null) writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile)));
        else writer = new PrintWriter(new OutputStreamWriter(System.out));
    }

    protected void close() throws IOException{
        br.close();
        writer.close();
    }
    public void outputArr(Object [] A) throws IOException{
        int L = A.length;
        for (int i = 0;i < L;i++) {
            if(i > 0) writer.print(" ");
            writer.print(A[i]);
        }
        writer.print("\n");
    }
}

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

int main()
{
    int n, x, m[101]; cin >> n >> x;

    int sum = 0, M = 1001001001;
    for (int i = 0; i < n; i++){
        cin >> m[i];
        sum += m[i];

        if(m[i] < M){
            M = m[i];
        }
    }
    int ans = n + (x - sum) / M;
    cout << ans << endl;
}

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

int main() {
    ll N; cin >> N;
    ll ans = 0;
    for (int i = 1; i < 1e6+1; i++){
        ll n = N - i;
        if(n%i == 0){
            ll x = n / i;
            if(x > i){
                ans += x;
            } else {
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (int i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;
 
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,d;cin>>n>>d;
    ll ans = 0;
    rep(i,0,n){
        ll x,y;cin>>x>>y;
        if (sqrt(x*x+y*y)<=d){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#include <map>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<int,int>;
const ll M = 1e9+7, mx = 301;
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; void chmax(ll& x, ll y) {if (x<y) x=y;}; void chmin(ll& x, ll y) {if (x>y) x=y;};
ll pou(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x; x = x * x; a >>= 1;} return an;}

int main() {
  ll n; cin>>n;
  //ll k=1;
  //while(n>pou(26,k)) {n-=pou(26,k++);}
  string an;
  while(n>0) {
    if (n%26==0) {
      an+='z';
      n-=1; n/=26;
    } else {
      an+=(char)('a'+n%26-1);
      n/=26;
    }
  }
  reverse(an.begin(),an.end());
  cout<<an<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
#define endl "\n"
//#pragma GCC optimize(2)
using namespace std;
const int N=1e3+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
int n,m,a,b;
char p[N][N];
int main(){
	cin>>n>>m>>a>>b;
	FOR(i,1,n)FOR(j,1,m)p[i][j]='.';
	for(int i=1;m&1&&i<n&&b>0;i+=2)
		p[i][m]='^',p[i+1][m]='v',b--;
	if(b&1&&n&1&&m>=3&&n>=3){
		if(m%2==0){
			p[n-1][m]='^',p[n][m]='v',b--;
		}
		else p[n-1][m-2]='^',p[n][m-2]='v',b--;
	}
	FOR(i,1,n-1)
		for(int j=1;j<=m-(m&1)&&b>0;j++)
			if(p[i][j]=='.'&&p[i+1][j]=='.')
				p[i][j]='^',p[i+1][j]='v',b--;
	if(b){
		cout<<"NO"<<endl;return 0;
	}
	FOR(i,1,n)
		for(int j=1;j<m&&a>0;j++)
			if(p[i][j]=='.'&&p[i][j+1]=='.')
				p[i][j]='<',p[i][j+1]='>',a--;
	if(a){
		cout<<"NO"<<endl;return 0;
	}
	cout<<"YES\n";
	FOR(i,1,n){
		FOR(j,1,m)cout<<p[i][j];
		cout<<endl;
	}
}

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

using namespace std;

#define int long long

int n, K;

int calc(int cnt) {
    return cnt + 3 * cnt * (cnt - 1) + cnt * (cnt - 1) * (cnt - 2);
}

signed main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> K;
    if(K % 2) {
        int cnt = 0;
        for (int i = K; i <= n; i += K) cnt ++;
        cout << calc(cnt);
    }
    else {
        K /= 2;
        int cnt0 = 0, cnt1 = 0;
        for (int i = K; i <= n; i += K) {
            if( (i / K) % 2) cnt1 ++;
            else cnt0 ++;
        }
        cout << calc(cnt1) + calc(cnt0);
    }

    return 0;
}


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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){
			String[] inputData = br.readLine().split(" ");
			int h = Integer.parseInt(inputData[0]);
			int w = Integer.parseInt(inputData[1]);

			if(h == 0 && w == 0){
				break;
			}
			for(int i = 0; i < h; i ++){
				for(int j = 0; j < w ; j ++){
					if(i == 0 || j == 0 || i == h-1 || j == w-1){
						sb.append("#");
					}else{
						sb.append(".");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		}

		System.out.print(sb);
	}

}

Measured memory_bytes: 25436
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    std::ios::sync_with_stdio(false);
    string a;
    cin>>a;
    int cot1=0,cot0=0;
    for(int i=0;i<a.length();i++){
        if(a[i]=='1') cot1++;
        else cot0++;
    }
    cout<<min(cot0,cot1)*2<<endl;
}



Measured memory_bytes: 512
#include<stdio.h>

int main(){

  int m[100],f[100],r[100];
  int i,total[100];





  while(1){
    i=0;
  scanf("%d %d %d",&m[i],&f[i],&r[i]);

  total[i]=m[i]+f[i];

 
  if(m[i]==-1 && f[i]==-1 && r[i]==-1)
    break;

  else if(m[i]==-1 || f[i]==-1 ){
   
    puts("F");
  }


  else if(m[i]==-1 && f[i]==-1 && r[i]==-1)
    break;

  else if(total[i] >= 80)
    puts("A");

  else if(total[i] >= 65 && total[i] < 80)
    puts("B");

  else if(total[i] >= 50 && total[i] < 65)
    puts("C");


  else if(total[i] >= 30 && total[i] < 50 ){
    if( r[i] >=50 )puts("C");
   
    else  puts("D");
    }

  
  else if(total[i] < 30 )
    puts("F");

  i++;
  }

  return 0;
}

Measured memory_bytes: 584
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor, pi
import bisect
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

def main():
    r = int(input())
    print(2 * pi * r)

if __name__ == '__main__':
    main()
 


Measured memory_bytes: 10468
#include <queue>
#include <vector>
#include <cstring>
#include <iostream>
using namespace std;
int H, W, ax, ay, bx, by, x[52][52], dp[52][52][52][52];
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int main() {
	while(cin >> W >> H >> ax >> ay >> bx >> by) {
		for(int i = 0; i < H + 2; i++) {
			for(int j = 0; j < W + 2; j++) {
				x[i][j] = 1;
				if(i && i != H + 1 && j && j != W + 1) cin >> x[i][j];
			}
		}
		memset(dp, -1, sizeof(dp)); dp[ay][ax][by][bx] = 0;
		queue<vector<int> > que; que.push({ax, ay, bx, by});
		bool flag = false;
		while(!que.empty()) {
			vector<int> v1 = que.front(); que.pop();
			for(int i = 0; i < 4; i++) {
				vector<int> v2 = v1;
				if(!x[v1[1] + dy[i]][v1[0] + dx[i]]) v2[0] += dx[i], v2[1] += dy[i];
				if(!x[v1[3] - dy[i]][v1[2] - dx[i]]) v2[2] -= dx[i], v2[3] -= dy[i];
				if(v2[0] == v2[2] && v2[1] == v2[3]) {
					flag = true; break;
				}
				if(dp[v2[1]][v2[0]][v2[3]][v2[2]] == -1) {
					dp[v2[1]][v2[0]][v2[3]][v2[2]] = dp[v1[1]][v1[0]][v1[3]][v1[2]] + 1;
					que.push(v2);
				}
			}
			if(flag) {
				cout << dp[v1[1]][v1[0]][v1[3]][v1[2]] + 1 << endl; break;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
}

Measured memory_bytes: 32292
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function (chunk) {
    var a = chunk.split(' ');
    var b = parseInt(a[0],10);
    var c = parseInt(a[1],10);
    var menseki = b*c;
    var nagasa = 2*(b+c);
    console.log(menseki+' '+nagasa);
});

Measured memory_bytes: 15448
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll k, x;
	cin >> k >> x;

	if (500ll * k >= x)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#if 1
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define stoi stoll
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int i=0; i < (n); ++i)
#define FOR(i,a,b) for (int i=(a); i < (b); ++i)
using namespace std;

int pow(int x, int n) {int res=1; while(n){if(n&1)res*=x;x*=x;n>>=1;} return res;}
int get_gcd(int a, int b){while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//-------------------------テンプレここまで-------------------------//

signed main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string ss[3] = {"Sunny", "Cloudy", "Rainy"};

  string s;
  cin >> s;

  if(s == ss[0]) cout << ss[1] << endl;
  else if (s == ss[1]) cout << ss[2] << endl;
  else cout << ss[0] << endl;

  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

vector<ll> G[101010];

void dfs(ll now, ll par, ll d, vector<ll> &dist){
	dist[now] = d;
	REP(i, G[now].size()){
		ll next = G[now][i];
		if(next == par){
			continue;
		}
		dfs(next, now, d+1, dist);
	}
	return;
}

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

    ll N, u, v;
    cin >> N >> u >> v;
    u--, v--;
    REP(i, N-1){
    	ll A, B;
    	cin >> A >> B;
    	A--, B--;
    	G[A].push_back(B);
    	G[B].push_back(A);
    }

    vector<ll> tak(N, 0), ao(N, 0);
    dfs(u, -1, 0, tak);
    dfs(v, -1, 0, ao);
    //cout << tak << endl;
    //cout << ao << endl;

    ll res = 0;

    REP(i, N){
    	if(G[i].size()==1){
    		if(tak[i]<ao[i]){
    			//ll val = (tak[v]%2);
    			res = max(ao[i]-1, res);
    		}
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 13952
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7

        



N, M, Q  = map(int,input().split())
query = []
for q in range(Q):
    a,b,c,d = map(int,input().split())
    a-=1
    b-=1
    query.append((a,b,c,d))




old = []
for i in range(1,M+1):
    old.append([i])

for j in range(N-1):
    new = []
    for e in old:
        for i in range(e[-1],M+1):
            new.append(e+[i])
    old = new


#print (new)
mx = 0
for n in new:
    score = 0
    for a,b,c,d in query:
        if (n[b] - n[a] == c):
            score += d
    mx = max(score,mx)
print (mx)

Measured memory_bytes: 107536
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

vector<string> player = {"First\n", "Second\n"};

int n;
vi a;
void execute_gcd() {
  int ret = a[0];
  FOR (i, 1, n) {
    ret = __gcd(ret, a[i]);
  }
  if (ret == 1) {
    return;
  }
  rep (i, n) {
    a[i] /= ret;
  }
}

void judge(int turn) {
  int odd, even;
  odd = even = 0;
  rep (i, n) {
    if ((a[i]&1) == 1) {
      odd += 1;
    } else {
      even += 1;
    }
  }
  if ((even&1) == 1) {
    cout << player[turn];
    exit(0);
  }
  if (odd > 1) {
    cout << player[1 - turn];
    exit(0);
  }
  rep (i, n) {
    if ((a[i]&1) == 1) {
      if (a[i] == 1) {
        cout << player[1 - turn];
        exit(0);
      }
      a[i] -= 1;
      execute_gcd();
      return;
    }
  }
}

int main() {
  scanf("%d", &n);
  a.resize(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }

  int turn = 0;
  while (true) {
    judge(turn);
    turn = 1 - turn;
  }

  return 0;
}


Measured memory_bytes: 1272
import collections

N = int(input())

input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line] 

Line2 = Line

c = collections.Counter(Line2)

# print(c)

mapped_list = map(lambda x: (x-1)*x/2,c.values())
nukanai_sum = sum(list(mapped_list))

# print(nukanai_sum)

# print(Line)

for i in Line:
    ans = nukanai_sum

    ans -= ((c[i]-1)*c[i]/2-(c[i]-2)*(c[i]-1)/2)
    print(int(ans))

Measured memory_bytes: 27192
use std::io::*;
use std::str::FromStr;

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

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let n = read::<i64>();
  let mut p = vec![];
  for _ in 0..n {
    p.push(read::<i64>())
  }
  let mut cnt = 0;

  for i in 0..n - 2 {
    let idx = i as usize;
    let one = p[idx];
    let two = p[idx + 1];
    let three = p[idx + 2];

    if one < two && two < three || three < two && two < one {
      cnt += 1;
    }
  }

  println!("{}", cnt);
}



Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>

using namespace std;

const int mod = 1000000007;

int main() {
	int n, m, a;
	cin >> n >> m;

	set<int> broken;
	for (int i = 0; i < m; i++) {
		cin >> a;
		broken.insert(a);
	}


	vector<int> dp(n + 5, 0);
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		if (broken.count(i+1) == 0) { dp[i+1] = (dp[i] + dp[i+1]) % mod; }
		if (broken.count(i+2) == 0) { dp[i+2] = (dp[i] + dp[i+2]) % mod; }
	}

	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 5376