akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>
#include<atcoder/all>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll k;
	cin >> k;
	rep(i, 0, k) {
		cout << "ACL";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
#define ll long long
#define pi 3.141592653589793238
int main(){
  double a,b,x;
  scanf("%lf%lf%lf",&a,&b,&x);
  x/=a;
  if(a*b<2*x){
    b=2*b - 2*x/a;
  }else {
    a = 2*x/b;
  }
  printf("%.7f\n",atan(b/a)*180/pi);
  return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
sn = input()

result = True
for i in range(len(sn)):
  if (i == a+1-1) and (sn[i] != "-"):
    result = False
    break
  else :  
    if (i != a+1-1) and ( ord(sn[i]) < 48) or ( 57 < ord(sn[i])):
      result = False
      break

if result:
  print("Yes")
else :
  print("No")

Measured memory_bytes: 9128
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 
s=input()
n=len(s)
a=[]
for i in range(n):
  if s[i]=='P':
    a.append('P')
  else:
    a.append('D')
print(convert(a))

Measured memory_bytes: 11096
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define mkp make_pair
#define pii pair<int,int>
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=2e5+5;
char s[maxn];
ll dp[10000+5];

int main(){
    ll n,p;
    cin>>n>>p;
    cin>>(s+1);
    ll ans=0;
    if(p==2||p==5){
        for(int i=1;i<=n;i++){
            if((s[i]-'0')%p==0){
                ans+=i;
            }
        }
    }
    else {
        ll tmp=0;
        ll base=1;
        for(int i=n;i>=1;i--){
            tmp=(tmp+(s[i]-'0')*base)%p;
            base=(base*10)%p;
            dp[tmp]++;  
        }
        ans+=dp[0]+1ll*dp[0]*(dp[0]-1)/2;
        for(int i=1;i<=p-1;i++){
            ans+=1ll*(dp[i]-1)*dp[i]/2;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

const int inf = 99999;

int prim(int a[101][101], int n)
{
	int r = 0, cost[101], t;
	bool vis[101];
	
	fill(vis, vis+101, true);
	fill(cost, cost+101, inf);
	cost[0] = 0;
	
	while(1){
		t = -1;
		
		for(int i = 0; i < n; i++){
			if(vis[i] && (t == -1 || cost[i] < cost[t])){
				t = i;
			}
		}
		
		if(t == -1){
			break;
		}
		vis[t] = false;
		r += cost[t];
		
		for(int i = 0; i < n; i++){
			cost[i] = min(cost[i], a[t][i]);
		}
	}
	
	return r;
}

int main()
{
	int s, d, t, a[101][101];
	
	while(cin>>s>>d && s && d){
		fill(&a[0][0], &a[100][100], inf);
		for(int i = s; i < 101; i++){
			a[i][i] = 0;
		}
		for(int i = 0; i < s; i++){
			for(int j = 0; j < s; j++){
				a[i][j] = 0;
			}
		}
		
		for(int i = 0; i < s; i++){
			for(int j = 0; j < d; j++){
				cin >> t;
				if(t == 0){
					t = inf;
				}
				a[i][s+j] = a[s+j][i] = t;
			}
		}
		
		for(int i = 0; i < d; i++){
			for(int j = i+1; j < d; j++){
				cin >> t;
				if(t == 0){
					t = inf;
				}
				a[s+i][s+j] = a[s+j][s+i] = t;
			}
		}
		
		cout << prim(a, s+d) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
    int x;
    int y;
}a[10];
int cmp(struct node t,struct node r)
{
    return t.y<r.y;
}
int main()
{
    int sum=0;
    for(int i=0;i<5;i++)
    {
        cin>>a[i].x;
        if(a[i].x%10==0)
        {
            a[i].y=0;
        }
        else
        a[i].y=10-a[i].x%10;
    }
    if(a[0].x==a[1].x&&a[1].x==a[2].x&&a[2].x==a[3].x&&a[3].x==a[4].x)
    {
        sum=4*(10-(a[0].x%10))+4*a[0].x+a[0].x;
    }
    else
    {
        sort(a,a+5,cmp);
        for(int i=0;i<4;i++)
        {
            sum+=(a[i].x+a[i].y);
        }
        sum=sum+a[4].x;
    }
    cout<<sum<<endl;
}


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

using namespace std;

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

#define int ll

string s;

int solve(int l, int r){
	for(int i=l+1 ; i<r ; i++)
		if(s[i] == '>' && s[i-1] == '<'){
			int ret = (i-l)*(i-l+1)/2 + (r-i)*(r-i+1)/2;
			int mn = min(i-l, r-i);
			ret -= mn;
			return ret;
		}
	return (r-l)*(r-l+1)/2;
}

signed main(){
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> s;
    int l=0, ans=0;
    for(int i=1 ; i<s.size() ; i++){
    	if(s[i] == '<' && s[i-1] == '>'){
    		ans += solve(l, i);
    		l = i;
    	}
    }
    ans += solve(l, s.size());
    cout << ans << "\n";
}

























Measured memory_bytes: 1172
#include<cstdio>
bool a[300000];
int main(void)
{
    int n,k,t,cnt=0,num=0;
    scanf("%d %d" ,&n,&k);
    for(int i=0;i<n;i++)
        scanf("%d" ,&t);
    while(a[n-1]==false){
        for(int i=cnt;i<cnt+k;i++)
            a[i]=true;
        cnt+=k-1;
        num++;
    }
    printf("%d" ,num);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n,m;

int main(){
    cin >> n >> m;
    if (n == 0 || m == 0){
        cout << "Zero";
    }
    else if (n < 0 && m < 0){
        int t = abs(n - (m + 1));
        if (t % 2 != 0){
            cout << "Negative";
        }
        else {
            cout << "Positive";
        }
    }
    else if (n > 0 && m > 0){
            cout << "Positive";
    }
    else if (n < 0 && m > 0){
        cout << "Zero";
    }
    return 0;
}


Measured memory_bytes: 256
start = "fff0fff" "ff123ff" "f45678f" "ff9abff" "fff0fff"
result1 = {}
result1[start] = 0
stack = [start]

while (nxt = stack.shift)
  next if result1[nxt] >= 10
  doit1 = ->(idx) {
    [1, -1, 7, -7].each do |di|
      next_index = idx + di
      next if next_index < 0 or next_index >= 35
      next if (c = nxt[next_index]) == "f" or c == "0"
      next_field = nxt.dup
      next_field[idx] = c
      next_field[next_index] = "0"
      next if result1[next_field]
      result1[next_field] = result1[nxt] + 1
      stack << next_field
    end
  }
  doit1.(nxt.index("0"))
  doit1.(nxt.rindex("0"))
end

pat = Array.new(5)
until (pat[0] = gets.to_i) == -1
  pat[0] = pat[0].to_s(16).center(7, "f")
  4.times {|i| pat[i + 1] = gets.split.map {|a| a.to_i.to_s(16)}.join.center(7, "f") }
  
  if (ans = result1[start = pat.join])
    puts ans
    next
  end
  
  result2 = {}
  result2[start] = 0
  stack = [start]
  str = "NA"
  f = true
  
  while (nxt = stack.shift) and f
    next if result2[nxt] >= 10
    doit2 = ->(idx) {
      [1, -1, 7, -7].each do |di|
        next_index = idx + di
        next if next_index < 0 or next_index >= 35
        next if (c = nxt[next_index]) == "f" or c == "0"
        next_field = nxt.dup
        next_field[idx] = c
        next_field[next_index] = "0"
        next if result2[next_field]
        if result1[next_field]
          str = (result1[next_field] + result2[nxt] + 1).to_s
          return false
        end
        result2[next_field] = result2[nxt] + 1
        stack << next_field
      end
      true
    }
    f = doit2.(nxt.index("0"))
    f = doit2.(nxt.rindex("0")) if f
  end
  puts str
end


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

 int N, K;
 vector<int> d;
 vector<vector<int>> A;

 void input() {
 cin >> N >> K;
 d.resize(K);
 A.resize(K, vector<int>());
 for(int i = 0; i < K; i++) {
 cin >> d[i];
 A[i].resize(d[i]);
 for(int j = 0; j < d[i]; j++) {
 cin >> A[i][j];
 }
 }
 }

 void solve() {
 int ans = 0;
 for(int i = 1; i <= N; i++) {
 bool have = false;
 for(auto v : A) {
 for(auto p : v) {
 if(p == i) have = true;
 }
 }
 if(!have) ans++;
}
 cout << ans << endl;
 }

 int main() {
 input();
 solve();
 }


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

int main(){
int n,k;
cin>>n>>k;
vector<int> trees(n);
int min=1e9;
for(int i=0;i<n;i++){
	cin>>trees[i];
}
sort(trees.begin(),trees.end());
for(int i=0;i<=n-k;i++){
if(min>trees[i+k-1]-trees[i]){
	min=trees[i+k-1]-trees[i];
}
}
cout<<min<<endl;

return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main() {
    int h, w;
    while (1) {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) { break; }

        for (int i=0; i<h; ++i) {
            for (int j=0; j<w; ++j) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  vector<int> v(3);
  rep(i, 3) cin >> v[i];
  sort(v.begin(), v.end());
  pr(v[0] + v[1]);

  return 0;
}

Measured memory_bytes: 3600
n,y=map(int,input().split())
count=0
for i in range(n+1):
  for j in range(n+1):
    k=n-i-j
    if k>=0 and k<=n:
      if i*10000+j*5000+k*1000==y:
        print(i,j,k)
        exit()
print(-1,-1,-1)

Measured memory_bytes: 9136
n, m = map(int, input().split())


l_max = 0
r_min = float('inf')

for i in range(m):
    l, r = map(int, input().split())
    l_max = max(l_max, l)
    r_min = min(r_min, r)

if r_min >= l_max:
    ans = int(r_min-l_max+1)
else :
    ans = 0
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  int H,W,i,j;
  while(1){
    scanf("%d%d",&H,&W);
    if(H==0 && W==0)break;
    else{
      for(i=0;i<H;i++){
	if(i==0 || i==H-1)
	  {
	    for(j=0;j<W;j++){printf("#");}
	    printf("\n");  
	  }
	else if(!(i==0 || i==H-1))
	  {
	    for(j=0;j<W;j++){
	    if(j==0 || j==W-1)printf("#");
	    else printf(".");
	    
	    }
	    printf("\n");
	  }
      }
    printf("\n"); 
    }
  }
  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
//#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF =0; 

signed main(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i=1;i<=n;++i){
        string s = to_string(i);
        if(s.size() == 1 || s.size() == 3 || s.size() == 5 ) ++cnt;
    }   
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[]
s=0
for i in range(n+2):
  l.append(s)
  s+=i+1
if n not in l:
  print('No')
else:
  k=l.index(n)+1
  ans=[[] for i in range(k)]
  c=0
  for i in range(k):
    for j in range(i+1,k):
      ans[i].append(c+1)
      ans[j].append(c+1)
      c+=1
  print('Yes')
  print(k)
  for i in range(k):
    print(k-1,*ans[i])


Measured memory_bytes: 48160
def make_counts_str(l, r)
    left = l / 2 + r / 2
    right = l / 2 + r / 2
    left += l % 2
    right += r % 2
    return [0] * (l - 1) + [left, right] + [0] * (r - 1)
end

str = gets.chomp
r_counts = str.split(/L+/).map(&:size)
l_counts = str.split(/R+/).map(&:size).drop(1)
puts l_counts.zip(r_counts).map{|r, l| make_counts_str(l, r)}.flatten.join(" ")


Measured memory_bytes: 11884
#include<stdio.h>

int main(){

  int a,b,c,d,e,f;

  double x,y;

  while((scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f))!=EOF){

    y=(double)(c*d-a*f)/(b*d-a*e);
    x=(double)(c-b*y)/a;


    if (((int)(x*10000)%10)>=5){
      x += 0.001;
    }
    if (((int)(y*10000)%10)>=5){
      y += 0.001;
    }

    

    printf("%.3f %.3f\n",x,y);


  }

  return 0;

}

Measured memory_bytes: 0
#include <stdio.h>

int main(int argc, char *argv[]){
  int W,H,x,y,r;
  double up, down, left, right; //north, south, west, east points on the circle, respectively.
  //get data and calcurate variable
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
  up=y+r;
  down=y-r;
  left=x-r;
  right=x+r;
  //in circle or not.
  if( up>H )
    printf("No\n");
  else if(  down<0 )
    printf("No\n");
  else if( left<0 )
    printf("No\n");
  else if( right>W )
    printf("No\n");
  else
    printf("Yes\n");
  return(0);
}



Measured memory_bytes: 2104
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    double x[3];
    int n;
    double a=0,r;
    for(;;){
        for(int i = 0;i < 3; i++)cin >> x[i];
        if(x[0] == 0&&x[1] == 0&&x[2] == 0)break;
        sort(x,x+3);

        a = sqrt((x[0]*x[0])+(x[1]*x[1]));

        cin >> n;

        for(int i = 0;i < n; i++){
            cin >> r;
            if(a < 2*r)cout << "OK" << endl;
            else cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;

int n, m;

int main(){
    string s[60];
    cin >> n >> m;
    for(int i=0; i< n; i++) cin >> s[i];
    int field[n][m];
    for(int i=0; i < n; i++)for(int j=0; j < m; j++) field[i][j] = stoi(s[i].substr(j, 1));
    for(int i=0; i< n; i++){
        for(int j=0; j < m; j++){
            if(i+j == 0) continue;
            int a = 9999999, b = 999999;
            if(i != 0) a = field[i-1][j];
            if(j != 0) b = field[i][j-1];
            field[i][j] = field[i][j] + min(a, b);
        }
    }
    cout << field[n-1][m-1] << endl;
}

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

using namespace std;

string s;

int main() {
    cin >> s;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'B') {
            s = s.substr(0, max(0, i - 1)) + s.substr(i + 1);

            i -= 2;
        }

        i = max(i, -1);
    }

    cout << s << '\n';

    return 0;
}


Measured memory_bytes: 256
#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 ll long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
const ll mod=998244353;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> data_struct;

int main()
{
	ll n,k;
	cin>>n>>k;
	set<ll> st;
	for(ll i=0;i<k;i++)
	{
		ll x,y;
		cin>>x;
		for(ll j=0;j<x;j++)
		{
			cin>>y;
			st.insert(y);
		}
	}
	cout<<(n-st.size());
}

Measured memory_bytes: 3628
n = int(input())
ans = [0]*(n+1)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            
            a = i**2 + j**2 + k**2 + i*j + j*k + k*i
            
            if a < n+1:
                ans[a] += 1
for i in range(1,n+1):
    print(ans[i])

Measured memory_bytes: 74328
#include<cstdio>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	if(n==3) printf("2 5 63");
	else if(n<=15000) {
		if(n%3==1) {
			for(int i=1;i<=(n/3)*3-1;++i) printf("%d ",i*2);
			printf("%d %d",3,9);
		}
		else if(n%3==2) {
			for(int i=1;i<=(n/3)*3;++i) printf("%d ",i*2);
			printf("%d %d",3,9);
		}
		else {
			for(int i=1;i<=(n/3-1)*3;++i) printf("%d ",i*2);
			printf("%d %d %d",30000,3,9);
		}
	}
	else {
		if(n%2==0) {
			for(int i=1;i<=15000;++i) printf("%d ",i*2);
			for(int i=1;i<=n-15000;++i) printf("%d ",i*6-3);
		}
		else {
			for(int i=1;i<=14999;++i) printf("%d ",i*2);
			for(int i=1;i<=n-14999;++i) printf("%d ",i*6-3);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-03-22 20:59:36 +0900
# LastModified: 2020-03-22 22:25:25 +0900
#


import os
import sys


def main():
    S = input()
    N = len(S)
    S_b = S[:(N-1)//2]
    S_a = S[(N+1)//2:]
    for i in range((N+1)//2-1):
        if S[i]!=S[-(i+1)]:
            print("No")
            return 
    for i in range((len(S_b)+1)//2):
        if S_b[i]!=S_b[-(i+1)]:
            print("No")
            return 
    for i in range((len(S_a)+1)//2):
        if S_a[i]!=S_b[-(i+1)]:
            print("No")
            return 
    print("Yes")



if __name__ == "__main__":
    main()


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

string str;

int main(){
    cin >> str;

    int cc=0;

    while(str.size()){
        str.pop_back();
        string t;
        for(int i=0;i<(int)str.size()/2;i++)
            t.push_back(str[i]);
        if(t+t == str)
            cc=max(cc,(int)t.size()*2);
    }

    cout << cc << endl;

    return 0;
}


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

using namespace std;


#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search  >
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search  >=
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))

/* a=target variable, b=bit number to act upon 0-n */
#define BIT_SET(a,b) ((a) |= (1<<(b)))
#define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
#define BIT_FLIP(a,b) ((a) ^= (1<<(b)))
#define BIT_CHECK(a,b) ((a) & (1<<(b)))
#define BIT_COUNT(a) (__builtin_popcount(a))

 
/* x=target variable, y=mask */
#define BITMASK_SET(x,y) ((x) |= (y))
#define BITMASK_CLEAR(x,y) ((x) &= (~(y)))
#define BITMASK_FLIP(x,y) ((x) ^= (y))
#define BITMASK_CHECK(x,y) (((x) & (y)) == (y))

typedef long long LL;
typedef unsigned long long ULL;

vector<int> G[100000];
int parent[100000];
int n;
LL MOD = 1e9+7;
LL memo[100000][2];


void addSelf(LL &a, LL b)
{
	a += b;
	if(a >= MOD)
		a -= MOD;
}

void multSelf(LL &a, LL b)
{
	a *= b;
	a %= MOD;
}

void getParent(int cur)
{
	for(auto adj : G[cur]){
		if(parent[adj] == -1){
			parent[adj] = cur;
			getParent(adj);
		}
	}
}

LL dp(int i, int j)
{
	// cout << i+1 << " " << j+1 << endl;
	auto &dpm = memo[i][j];
	if(dpm != -1)
		return dpm;

	if(sz(G[i]) == 1 && G[i][0] == parent[i]) // folha
		return dpm = 1;
	if(sz(G[i]) == 0)
		return dpm = 1;

	dpm = 1;
	
	for(auto k : G[i]){
		if(parent[i] == k) continue;
		
		if(j == 1){
			multSelf(dpm, dp(k,0));
		}
		else{
			LL sum = 0;
			addSelf(sum, dp(k,0));
			addSelf(sum, dp(k,1));
			multSelf(dpm,sum);
		}
	}
	return dpm;
}



int main(void)
{
	fastIO();
	
	cin >> n;
	FOR(i,0,n-1){
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	
	MEMSET(parent,-1);
	parent[0] = 0;
	getParent(0);

	MEMSET(memo,-1);

	LL ans = dp(0,0);
	addSelf(ans,dp(0,1));

	cout << ans << endl;

	// FOR(i,0,n){
	// 	FOR(j,0,2){
	// 		cout << i+1 << " " << j << " " << memo[i][j] << endl;
	// 	}
	// }

	


}




Measured memory_bytes: 16000
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

double A;
ll B;
ll C;
ll N;
ll M;
ll K;

int main(){

    
    cin >> A;

    cout << 2 * A * M_PI << endl;
    

}

Measured memory_bytes: 3692
import java.util.*

fun main() {
  val N = readInt()
  val edges = Array(N) { hashMapOf<Int, Int>() }
  repeat(N - 1) {
    val (u, v, w) = readInts()
    edges[u - 1][v - 1] = w
    edges[v - 1][u - 1] = w
  }
  val colors = Array(N) { 0 }
  val queue = LinkedList<Int>()
  queue.add(0)
  while (queue.isNotEmpty()) {
    val n = queue.pop()
    edges[n].forEach {
      colors[it.key] = if (it.value % 2 == 0) colors[n] else (colors[n] + 1) % 2
      queue.add(it.key)
      edges[it.key].remove(n)
    }
  }
  println(colors.joinToString("\n"))
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readStrings() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }

fun myBinarySearch(begin: Int, end: Int, isOk: (key: Int) -> Boolean): Int {
  var ng = begin
  var ok = end

  while (Math.abs(ok - ng) > 1) {
    val mid = (ok + ng) / 2
    if (isOk(mid)) {
      ok = mid
    } else {
      ng = mid
    }
  }

  return ok
}

fun <T> List<T>.myBinarySearch(isOk: (T) -> Boolean): Int {
  return myBinarySearch(-1, size) { index -> isOk(get(index)) }
}

fun <T> Array<T>.myBinarySearch(isOk: (T) -> Boolean): Int {
  return myBinarySearch(-1, size) { index -> isOk(get(index)) }
}


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



int func(int N){
    int num = 0;
    int kaisuu = 0;
    int b=N;
    while(b>0){
        b=b/2;
        kaisuu++;
    }
    rep(i,kaisuu+1){
        if((N>>i)&1){
            num++;
        }
    }
    return N%num;
}

int main() {
    int n;
    string a;
    cin >> n >> a;
    vector<int> x(n);
    rep(i,n){x[i]=a[n-1-i]-'0';}
    int cnt=0; rep(i,n) if(x[i]==1) cnt++;
    int def_ans_plus=0,def_ans_minus=0;
    vector<int> cnt_plus(n,1),cnt_minus(n,1);
    vector<int> ans(n+1,1);
    vector<int> now(n+1,0);
    rep(i,n-1){
        cnt_plus[i+1]=(cnt_plus[i]*2)%(cnt+1);
        if(cnt!=1){cnt_minus[i+1]=(cnt_minus[i]*2)%(cnt-1);}
    }
    rep(i,n){
        if(x[i]==1){
            def_ans_plus+=cnt_plus[i]; def_ans_plus=def_ans_plus%(cnt+1);
            if(cnt!=1){def_ans_minus+=cnt_minus[i]; def_ans_minus=def_ans_minus%(cnt-1);}
        }
    }
    rep(i,n){
        if(x[n-1-i]==0){
            now[i+1] = (def_ans_plus+cnt_plus[n-1-i])%(cnt+1);
        }else{
            int tmp = def_ans_minus-cnt_minus[n-1-i];
            if(tmp<0) tmp+=cnt-1; 
            now[i+1] = tmp;
            if(cnt==1){ans[i+1]=0; now[i+1]=0;}
        }
    }
    bool end = false;
    while(end==false){
        end = true;
        REP(i,n){
            if(now[i]!=0){
                now[i]=func(now[i]);
                ans[i]++;
                end=false;
            }
        }
    }
    REP(i,n){ 
    cout << ans[i] << endl;
    }
}

Measured memory_bytes: 7572
#include<cstdio>
#include<vector>
#include<map>

using namespace std;

using ll=long long;
using vll=vector<ll>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vll a(n);
		map<ll, int> m;

		ll sum=0;
		m[0]++;
		for(int i=0;i<n;i++)
		{
			scanf("%lld", &a[i]);
			sum+=a[i];
			m[sum]++;
		}

		ll ans=0;
		for(auto it=m.begin();it!=m.end();++it)
		{
			ll t=it->second;
			ans+=t*(t-1)/2;
		}
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 14336
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int N, i;
    string s, t, s1, t1;

    cin >> N >> s >> t;

    for(i=N; i>=1; i--){
        s1 = s.substr(N-i, i);
        t1 = t.substr(0, i);

        if(s1 == t1){
            break;
        }
    }

    cout << N*2-i << endl;

    return 0;
}

Measured memory_bytes: 256
H, W, A, B = map(int, open(0).read().split())

S = [["1"] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if (i < B and j < A) or (i >= B and j >= A):
            S[i][j] = "0"

print("\n".join("".join(s) for s in S))


Measured memory_bytes: 13952
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int n, k;
int ta;
vector<int> mu;
int l = 1;
int cnt;
int wa;

signed main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		ta = i;
		wa = 1;
		while (ta <= k - 1) {
			ta *= 2;
			wa *= 2;
		}
		mu.push_back(wa);
	}
	rep(i, mu.size()) {
		l = lcm(l, mu[i]);
	}
	rep(i, mu.size()) {
		cnt += l / mu[i];
	}
	long double a = cnt * 1.0, b = l, c = n;
	cout << setprecision(10) << a / (b * c) << endl;
}

Measured memory_bytes: 1400
sX,sY,tX,tY = list(map(int,input().split()))
ans = ""
a1 = 'U' * (tY-sY) + 'R' * (tX-sX)
a2 = 'D' * (tY-sY) + 'L' * (tX-sX)
a3 = "L" + "U" * (tY-sY+1) + "R" * (tX-sX+1) + "D"
a4 = "R" + "D" * (tY-sY+1) +"L" * (tX-sX+1) +"U"
print(a1+a2+a3+a4)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

char re(char a) {
    return (a == 'L' ? 'R' : 'L');
}

int main() {
    init();

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int cnt = 1;
    vector<char> c;
    VI t;
    FOR(i, 1, n) {
        if (s[i - 1] == s[i])cnt++;
        else {
            t.push_back(cnt);
            c.push_back(s[i - 1]);
            cnt = 1;
        }
    }
    t.push_back(cnt);
    c.push_back(s[n - 1]);

    int size = max(1, (int)t.size() - k * 2);
    cout << n - size << "\n";

    
}

Measured memory_bytes: 972
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  long long x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[5101][5010];
int l[5101][5010];
int j[5011];

long long x,y,z,mod=1000000007;
//string r;
char r[3];

P u[1];
queue<P> q;
stack<int> s;
//set<int> s;
map<int,int> p;

vector<int> v[3];


bool as(P a,P b)
{
  if(a.x!=b.x)
  return a.x<b.x;
  return a.y>b.y;
}

int main()
{
  scanf("%d %d",&a,&b);
  o[0][0]=l[a+1][0]=1;
  for(int t=1;t<=a;t++)
  {
    o[t][0]=l[t][0]=1;
    scanf("%d",&j[t]);
    for(int w=0;w<=b;w++)
    {
      if(o[t-1][w]&&w+j[t]<=b) o[t][w+j[t]]=1;
      if(o[t-1][w]) o[t][w]=1;
    }
  }
  for(int t=a;t;t--)
  {
    for(int w=0;w<=b;w++)
    {
      if(l[t+1][w]&&w+j[t]<=b) l[t][w+j[t]]=1;
      if(l[t+1][w]) l[t][w]=1;
    }
  }
  k=a;
  for(int t=1;t<=a;t++)
  {
    for(int w=0;w<=b;w++)
      o[t-1][w]+=o[t-1][w-1];
    m=0;
    for(int w=0;w<=b-1;w++)
    {
      if(b-w-j[t]-1>=0)
      {
        if(l[t+1][w]&&(o[t-1][b-1-w]-o[t-1][b-w-j[t]-1]))
        {
          m=1;
          break;
        }
      }
      else if(l[t+1][w]&&o[t-1][b-1-w])
      {
        m=1;
        break;
      }
    }
    k-=m;
    //printf("%d ",m);
  }
  printf("%d",k);
}
//1
//21




Measured memory_bytes: 198912
#include <bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
int main(){
    ll n;cin>>n;
    ll ans=(n*(n+1)*(n+2))/6;
    for(int i=1;i<n;i++){
        int x,y;cin>>x>>y;
        if(x>y) swap(x,y);
        ans-=x*(n-y+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <stack>
#include <vector>

using namespace std;
int main() {
  int n;
  cin >> n;
  vector<stack<int>> s(n);
  int q, t, x;
  cin >> q;
  while (cin >> q >> t) {
    if (q == 0) {
      cin >> x;
      s[t].push(x);
    } else if (q == 1) {
      if (!s[t].empty())
        cout << s[t].top() << endl;
    } else {
      if (!s[t].empty())
        s[t].pop();
    }
  }
}


Measured memory_bytes: 4356
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int X;cin >> X;
    X /= 200;
    if(2 == X )cout << 8 << endl;
    else if(3 == X)cout << 7 << endl;
    else if(4 ==X)cout << 6 << endl;
    else if(5 == X)cout << 5 << endl;
    else if(6 ==X)cout << 4 << endl;
    else if(7 == X)cout << 3 << endl;
    else if(8 == X)cout << 2 << endl;
    else if(9 == X)cout << 1 << endl;

}

Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;


    List<int>[] es;
    int[] color;
    

    void calc()
    {
        cin = new Scanner();
        int H = cin.nextInt();
        int W = cin.nextInt();
        int[,] dist = new int[10, 10];
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                dist[i, j] = cin.nextInt();
            }
        }

        for (int k = 0; k < 10; k++)
        {
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    dist[i, j] = Math.Min(dist[i, j], dist[i, k] + dist[k, j]);
                }
            }
        }

        int ans = 0;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                int a = cin.nextInt();
                if (a == -1) continue;
                ans += dist[a, 1];
            }
        }
        Console.WriteLine(ans);


    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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


Measured memory_bytes: 3636
import os
import sys
from io import BytesIO, IOBase


def main():
    n = int(input())
    arr = list(map(int, input().rstrip().split()))
    product = 1
    if 0 in arr:
        print(0)
        return
    for num in arr:
        if product * num > 10**18:
            product = -1
            break
        product *= num
    print(product)

#.........................................FAST INPUT OUTPUT.......................................
BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#....................................END OF FAST I/O............................................

if __name__ == "__main__":
    main()

Measured memory_bytes: 96876
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
 
const ll INF = 2e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

const ll mod = 998244353ll;
// const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod){ll x=1;while(b){while(!(b&1)){(a*=a)%=mod;b>>=1;}(x*=a)%=mod;b--;}return x;}
void YES(bool cond){ if(cond){ p("YES");}else{ p("NO");} return;}
void Yes(bool cond){ if(cond){ p("Yes");}else{ p("No");} return;}


ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}


bool multicase = false;

ll n,m,num,a,b,c,d,e,h,q;
ll w, k, ans;

ll x[500005], y[500005], z[500005];
ll dp[5005][5005];
string s;

void solve(){
    cin >> n >> k;
    for(ll i=0;i<n;i++){
        cin >> x[i];
    }
    dp[0][0] = mypow(2ll, n, mod);
    ll rev = mypow(2ll, mod - 2, mod);
    for(ll i=0;i<n;i++){
        for(ll j=0;j<=k;j++){
            if(j + x[i] <= k){
                dp[i+1][j+x[i]] += dp[i][j] * rev;
                dp[i+1][j+x[i]] %= mod;
            }

            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
        }
    }
    ll ans = dp[n][k];
    ans %= mod;
    p(ans);
    return;
}


int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 85964
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n, m;
	cin >> n >> m;
	vi a(n), b(n);
	rep(i, m) {
		int s, t;
		cin >> s >> t;
		s--; t--;
		if(s > t) swap(s, t);
		if(s == 0) a[t] = 1;
		if(t == n-1) b[s] = 1;
	}
	rep(i, n) if(a[i] && b[i]) {
		cout << "POSSIBLE" << endl;
		return 0;
	}
	cout << "IMPOSSIBLE" << endl;	
	return 0;
}

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

struct edge {
    int from, to;
    int64_t cost;
    edge(int x=0, int y=0, int64_t z=0):to(y), from(x), cost(z) {}
};


int main() {
    int n;
    n = 14;
    int l;
    cin >> l;
    cout << n << endl;
    int x = 1;

    vector<edge> ans;
    
    rep(i, 12) {
        rep(j, 3) {
            ans.push_back(edge(i+1, i+2, x*j));
        }
        x *= 3;
    }
    for(int i=13; i>0; --i) {
        while(l >= x) {
            l -= x;
            ans.push_back(edge(i, 14, l));
        }
        x /= 3;
    } 

    cout << ans.size() << endl;
    for(edge e:ans) {
        cout << e.from << ' ' << e.to << ' ' << e.cost << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int ans = 0;
  for (int i=0;i<S.size();i++){
    if (!(S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T')) continue;  
    for (int j=i;j<S.size();j++){
      if (!(S[j] == 'A' || S[j] == 'G' || S[j] == 'C' || S[j] == 'T')) break;
      ans = max(ans,j-i+1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3544
def main():
    from itertools import accumulate as acc
    N=int(input())
    s=input()
    ind=[[0 for j in range(N)] for i in range(10)]
    first=[-1 for i in range(10)]
    last=[-1 for i in range(10)]


    for i in range(len(s)):
        k=int(s[i])
        if first[k]==-1: first[k]=i
        last[k]=i
        ind[k][i]=1
        
    for i in range(10):
        ind[i]=list(acc(ind[i]))

    ans=0
    for i in range(10):
        for j in range(10):
            f=first[i]
            l=last[j]
            if f!=-1 and f+1<l:
                for k in range(0,10):
                    if ind[k][f]<ind[k][l-1]: ans+=1
                    

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14376
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;


int main(){

    while(true){
        ll N,K; cin>>N>>K;
        if(N==0&&K==0)break;
        
        vector<ll> S(K);
        REP(i,K)cin>>S[i];
        
        vector<ll> need(K);
        REP(i,N)REP(j,K){
            ll t; cin>>t;
            need[j]+=t;
        }
        
        bool flag=true;
        REP(i,K)if(need[i]>S[i])flag=false;
        if(flag)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        
    }
    
    return 0;
}

Measured memory_bytes: 3076
def main():
    n = int(input())
    a = list(map(int, input().split()))
    C = [0, 0, 0]
    ans = 1
    for x in a:
        d = C.count(x)
        if d == 0:
            ans = 0
            break
        ans *= d
        ans %= 1000000007
        ind = C.index(x)
        C[ind] += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 52908
import copy

s = list(input())
s_t = copy.deepcopy(s)
##if s[0] =="A" and "C" in s[2:-2]:
#    if
counter = 0
 
if s[0] != "A":
    print("WA")
    exit()
 
if not "C" in s[2:-1]:
    print("WA")
    exit()
 

c = False
komojo = True

for i in range(len(s)):
    if  2 <= i <= len(s)-2:
        if s[i] == "C":
            if c == True:
                print("WA")
                exit()
            elif c != True:
                c = True
            #continue
        elif not s[i].islower():
            komojo = False
    elif i != 0 and not s[i].islower():
        komojo = False
        

if c and komojo:
    print("AC")
else:
    print("WA")




Measured memory_bytes: 38512
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var x = int.Parse(Console.ReadLine());
        var now = 0;
        var k = 0;
        while (true)
        {
            k++;
            now += x;
            if (now >= 360)
            {
                now -= 360;
            }
            if (now == 0)
            {
                break;
            }
        }
        Console.WriteLine(k);
    }
}

Measured memory_bytes: 27460