akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007
int main(){
    ll n, m; cin >> n >> m; vector<ll> ansl(n+1,1); ansl[1]=((m-n+1)*(m-n))%MOD;
    FOR(i,2,n) ansl[i]=((((m-n+i)*(m-n+i-1))%MOD)*((ansl[i-1]+((i-1)*ansl[i-2]))%MOD)%MOD)%MOD;
    cout << ansl[n] << endl;
}

Measured memory_bytes: 7132
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;
 
int main() {
   int x,y,z;
   cin>>x>>y>>z;
   
   cout<<(x-z)/(y+z)<<endl;
  return 0;
}

Measured memory_bytes: 256
arr = list(map(int, input().split()))

possibleSolutions = []

possibleSolutions.append(arr[0] * arr[2])
possibleSolutions.append(arr[0] * arr[3])
possibleSolutions.append(arr[1] * arr[2])
possibleSolutions.append(arr[1] * arr[3])

print(max(possibleSolutions))

Measured memory_bytes: 9204
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

int main(){
    std::string S;
    std::cin >> S;
    int Q;
    std::cin >> Q;
    std::vector< int > T(Q);
    std::vector< int > F(Q);
    std::vector< char > C(Q);
    for(int i=0; i<Q; i++){
        std::cin >> T[i];
        if(T[i] == 2){
             std::cin >> F[i] >> C[i];
        }
    }
    
    std::string head, tail;
    bool reverse = false;
    
    for(int i=0; i<Q; i++){
        if(T[i] == 1){
            reverse = reverse ^ 1;
        }else{
            bool head_f = F[i] == 1;
            if(head_f ^ reverse){
                head = head + C[i];
            }else{
                tail = tail + C[i];
            }
        }
    }
    
    std::string ans;
    if(!reverse){
        std::reverse(head.begin(), head.end());
        ans += head;
        ans += S;
        ans += tail;
    }else{
        std::reverse(S.begin(), S.end());
        std::reverse(tail.begin(), tail.end());
        ans += tail;
        ans += S;
        ans += head;
    }
    std::cout << ans;
    
}


Measured memory_bytes: 3372
/*input
10
1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int N = 3003;
vector < ll > v;
ll dp[N][N];

int main()
{
  int n;
  cin >> n;
  v.resize(n);
  ll sum = 0;
  for(auto &x: v) {
  	cin >> x;
  	sum += x;
  }

  for(int i = n; i >= 1; i --) {
  	for(int j = i; j <= n; j ++) {
  		ll a = v[i - 1] + min(dp[i + 2][j], dp[i + 1][j - 1]);
  		ll b = v[j - 1] + min(dp[i + 1][j - 1], dp[i][j - 2]);
  		dp[i][j] = max(a, b);
  	}
  }

  ll d = dp[1][n];
  sum -= d;
  cout << d - sum;
  return 0;
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll zero = 0;
ll INF = 10000000000;

int main(){
    ll N,K;
    cin >> N >> K ;
    vector<ll> h(N);
    for(ll i = 0; i < N; i++){
        cin >> h.at(i);
    }
    sort(h.begin(),h.end());
    ll mi = INF;
    for(ll i = 0; i < N-K+1 ; i++){
        mi = min(mi, h.at(i+K-1)-h.at(i));
    }
    printf("%lld\n", mi);
    
}

Measured memory_bytes: 1024
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1000000007 ))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define bigint __int128
#define sqrt sqrtl
#define cbrt cbrtl
#define endl '\n'
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef pair<float,float> ff;
typedef vector<ff> vff;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi;


vector<int> func(int n)
{
	vector<int>next(n);
	for(int i=0;i<n;i++)
	next[i]=(i+1)%n;
	
	vector<int>ans;
	
	int i=0;
	while( next[ next[i] ] != i )
	{
		int a=next[i];
		int b=next[ next[a] ];
		next[ next[a] ]=-1;
		next[a]=b;
		i=next[i];
	}
	for(int i=0;i<n;i++)
	{
		if(next[i]!=-1)
		{
			ans.push_back(i+1);
		}	
	}
	return ans;
}
int32_t main()
{
	IOS
	int n;cin>>n;
	int sum=0,ans=0;
	for(int i=0;i<n;i++)
	{
		int x;cin>>x;
		ans+=sum*x;
		sum+=x;
	}
	cout<<ans<<endl;
}
	
	
	
	
	
	
	
	

 


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

int main()
{
    char s[4];
    int sum,i,a,b;
    while(~scanf("%s",s))
    {
        sum=0;
        a=0;
        b=0;
        for(i=0; i<4; i++)
        {
            if(s[i]=='-')
            {
                a--;
            }
            else if(s[i]=='+')
            {
                b++;
            }
            sum=a+b;
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 256
import fractions
n, x = map(int, input().split())
X = list(map(int, input().split()))
X.append(x)
X.sort()
gcd = 0
for i in range(1, n + 1):
    gcd = fractions.gcd(gcd, X[i] - X[i-1])
print(gcd)


Measured memory_bytes: 88172
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <assert.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

string conv(ll n) { stringstream ss; ss << n << flush; return ss.str(); }

int main() {
    string str, res; cin>>str;
    res=str[0]+conv(sz(str)-2)+str[sz(str)-1];
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,x,l[120],d[120];
	d[0]=0;
	scanf("%d %d",&n,&x);
	for(int i=0;i<n;++i){
		scanf("%d",&l[i]);
		d[i+1]=d[i]+l[i];
	}
	int sum=0;
	for(int i=0;i<n+1;++i){
		if(d[i]<=x){
			++sum;
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define ci(n,a)   vi a(n); rep(i,(n)) cin>>a[i];
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define all(a)    begin(a),end(a)
#define pb(a)     push_back(a)
#define mp(a,b)   make_pair(a,b)
#define yn(a)     cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+7, LINF = 1e18;

const ll M = 100000;

int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a/(b+b+1)+(a%(b+b+1)!=0)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
def solve(string):
    n, *x = map(int, string.split())
    mid = n // 2
    x = [(i, _x) for i, _x in enumerate(x)]
    x = sorted(x, key=lambda x: x[1])
    ans = [[] for _ in range(n)]
    for i, _x in enumerate(x):
        ans[_x[0]] = str(x[mid][1]) if i < mid else str(x[mid - 1][1])
    return "\n".join(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 53532
#!/usr/bin/env python3
from functools import reduce
from itertools import combinations
from math import gcd

K = int(input())

sum = K * (K + 1) // 2

for i in combinations(range(1, K + 1), 2):
    sum += 6 * reduce(gcd, i)

for i in combinations(range(1, K + 1), 3):
    sum += 6 * reduce(gcd, i)

print(sum)


Measured memory_bytes: 74648
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>

// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{
  int N;
  cin>>N;

  vector<int> vec(N,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }

  sort(vec.begin(),vec.end(),std::greater<int>());
  int L1,L2,L3;
  i64 count = 0;
  for (int i = 0; i < N; i++)
  {
    L1 = vec[i];
    for (int j = i+1; j < N; j++)
    {
      L2 = vec[j];
      for (int k = j+1; k < N; k++)
      {
        L3 = vec[k];
        if(L1 < L2 + L3) count++;
        else break;
      }
      
    }

    
  }
  
  
    cout<<count;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=5e5+10;
int n,q;
char s[maxn];
int tr[maxn][26];
void add(int x,int p,int k){
	while(x<=n) tr[x][p]+=k,x+=x&-x;
}
int dor(int x,int p){
	int ret=0;
	while(x) ret+=tr[x][p],x-=x&-x;
	return ret;
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>s+1;
	for(int i=1;i<=n;i++) add(i,s[i]-'a',1);
	cin>>q;
	while(q--){
		int op,l,r;
		char c;
		cin>>op>>l;
		if(op==1){
			cin>>c;
			add(l,s[l]-'a',-1);
			s[l]=c;
			add(l,s[l]-'a',1);
		}else{
			cin>>r;
			int ans=0;
			for(int i=0;i<26;i++){
				if(dor(r,i)-dor(l-1,i)>0) ans++;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  rep(i,n) cin >> a.at(i);
  long long sum=0;
  rep(i,n){
    sum+=a.at(i);
    sum%=(1000000007*2);
  }
  long long sum_sq=0;
  rep(i,n){
    long long t;
    t=(a.at(i)*a.at(i))%(1000000007*2);
    sum_sq+=t;
    sum_sq%=(1000000007*2);
  }
  long long ans;
  ans = (sum*sum-sum_sq)/2;
  if(ans<0) ans+=1000000007;
  ans%=1000000007;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4812
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')

n, T = LI()
t = LI()
ans = 0
for i in range(n-1):
    ans += min(T, t[i+1] - t[i])
ans += T
print(ans)


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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(auto&& i : h){
        cin >> i;
    }
    sort(rbegin(h), rend(h));
    long long ans = 0;
    for(int i = k; i < n; i++){
        ans += h[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;cin>>n>>k;
    vector<ll> h(n);rep(i,n)cin>>h[i];
    sort(h.rbegin(),h.rend());
    ll ans = 0;
    for(int i=0; i<n; i++){
        if(k>0)k--;
        else ans += h[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
int n,k,match[605];
ll f[605][605],c[605];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		match[a]=b,match[b]=a;
	}
	c[0]=1;
	for(int i=1;i<=n;i++)c[i]=c[i-1]*(2*i-1)%MOD;
	for(int l=1;l<=2*n;l++)
	{
		int minn=2*n,maxx=0,num=0;
		for(int r=l;r<=2*n;r++)
		{
			if(match[r])minn=min(minn,match[r]),maxx=max(maxx,match[r]),num--;
			num++;
			if(minn>=l&&maxx<=r)f[l][r]=c[num>>1];
		}
	}
	ll ans=0;
	for(int i=1;i<=2*n;i++)
	{
		int num=0;
		for(int j=i+1;j<=2*n;j+=2)
		{
			if(match[j-1])num++;
			if(match[j])num++;
			for(int k=i+1;k<j;k+=2)
			  f[i][j]=(f[i][j]-f[i][k]*f[k+1][j])%MOD;
			ans=(ans+f[i][j]*c[n-(j-i+1)/2-k+num/2])%MOD;
		}
	}
	if(ans<0)ans+=MOD;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2944
fun main(args: Array<String>) {
  val k = readLine()!!.toInt()
  if (k < 10) {
    println(k)
    return
  }
  var a0 = mutableListOf("1", "2", "3", "4", "5", "6", "7", "8", "9")
  var s = 9
  while (true) {
    val a1 = mutableListOf<String>()
    for (v in a0) {
      if (v[v.length-1] != '0') {
        a1.add(v + (v[v.length-1]-1).toChar())
        s++
        if (s == k) {
          println(a1[a1.size-1])
          return
        }
      }
      a1.add(v + v[v.length-1])
      s++
      if (s == k) {
        println(a1[a1.size-1])
        return
      }
      if (v[v.length-1] != '9') {
        a1.add(v + (v[v.length-1]+1).toChar())
        s++
        if (s == k) {
          println(a1[a1.size-1])
          return
        }
      }
    }
    a0 = a1
  }
}

Measured memory_bytes: 48184
n = int(raw_input())
S = map(int, raw_input().split())

def merge(A, left, mid, right):
    cnt = 0
    n1 = mid - left
    n2 = right - mid
    L = [0] * (n1+1) 
    R = [0] * (n2+1)
    L[:n1] = A[left:mid]
    R[:n2] = A[mid:right]
    #for i in xrange(n1):
    #    L[i] = A[left + i]
    #for i in xrange(n2):
    #    R[i] = A[mid + i]
    L[n1] = float('inf')
    R[n2] = float('inf')
    i = 0
    j = 0
    for k in xrange(left,right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
            
        else:
            A[k] = R[j]
            j += 1
            cnt += n1 - i
    return cnt

def mergeSort(A, left, right):
    if right - left > 1:
        mid = int((left + right) / 2)
        v1 = mergeSort(A, left, mid)
        v2 = mergeSort(A, mid, right)
        v3 = merge(A, left, mid, right)
        return v1+v2+v3
    else:
        return 0

def main():
    v = mergeSort(S, 0, len(S))
    print v
    return 0

main()

Measured memory_bytes: 23616
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(in);
		int[] a = new int[3];
		for (i = 0; i < a.length; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(a);
		out.println((a[1]-a[0])+(a[2]-a[1]));
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

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

    int d, x;
    cin >> d >> x;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int total = 0;
    for (int i = 0; i < n; i++) {
        int eat_day = 1;
        while (eat_day <= d) {
            total++;
            eat_day += a[i];
        }
    }
    cout << total + x << endl;

    return 0;
}

Measured memory_bytes: 888
# 1 軒のホテルがあります。
# このホテルの宿泊費は、次のようになっています。
# 最初の K 泊までは、1 泊あたり X 円、
# K + 1 泊目以降は、1 泊あたり Y 円
# 高橋君は、このホテルに N 泊連続で宿泊することにしました。
# 高橋君の宿泊費は合計で何円になるか求めてください。

# 情報を取得
n = gets.to_i
k = gets.to_i
x = gets.to_i
y = gets.to_i

# 宿泊費用を格納する変数を宣言
sum = 0

# 宿泊費を計算
n.times do |i|
  if i + 1 <= k
    sum += x
  else
    sum += y
  end
end

# 結果を出力
puts sum

Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#define INF 1000000000
using namespace std;

int main(){
	int n;
	int cost[100][100];
	cin >> n;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++) cost[i][j] = INF;
		cost[i][i] = 0;
	}
	for(int i = 0;i < n;i++){
		int now,m;
		cin >> now >> m;
		for(int j = 0;j < m;j++){
			int a,b;
			cin >> a >> b;
			cost[i][a] = b;
		}
	}
	for(int k = 0;k < n;k++){
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				cost[i][j] = min(cost[i][j],cost[i][k] + cost[k][j]);
			}
		}
	}
	
	for(int i = 0;i < n;i++) cout << i << " " << cost[0][i] << endl;
	return 0;
}

Measured memory_bytes: 3120
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

a,b,x=map(int, input().split())

if ( 0 <= (x-a) and (x-a) <= b ):
    print("YES")
else:
    print("NO")






Measured memory_bytes: 9012
#include <iostream>
using namespace std;
int main()

{
 string x;
 string ar[7]={"SAT","FRI","THU","WED","TUE","MON" ,"SUN"};
 cin>>x;
    for(int i=0 ;i<7;i++)
    {
        if(ar[i]==x)cout<<1+i;
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k; cin >> k;
  int n = 50;
  vector<ll> ans(n);
  rep(i, n) ans[i] = i+k/n;
  k %= n;
  rep(i, n) {
    if(i < k) ans[i] += n+1;
    ans[i] -= k;
  }
  cout << n << "\n";
  rep(i, n) cout << ans[i] << " ";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3672
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[,] a=new int[s[0]+1,s[0]+1];
		for(int i=0;i<s[1];i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			a[q[0],q[1]]++;
		}
		for(int i=1;i<=s[0];i++){for(int j=1;j<=s[0];j++){a[i,j]+=a[i,j-1];}}
		for(int i=1;i<=s[0];i++){for(int j=1;j<=s[0];j++){a[i,j]+=a[i-1,j];}}
		for(int k=0;k<s[2];k++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			Console.WriteLine("{0}",a[q[1],q[1]]-a[q[0]-1,q[1]]-a[q[1],q[0]-1]+a[q[0]-1,q[0]-1]);
		}
	}
}

Measured memory_bytes: 16528
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

const ll mod = 1e9 + 7;
ll cache[2200];

ll solve(int n) {
	if (n <= 2) return 0;
	ll& ret = cache[n];
	if (ret != -1) return ret;

	ret = 1;
	for (int i = 3; i <= n; i++) {
		if (n - i >= 3) ret = (ret + solve(n - i)) % mod;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll S; cin >> S;
	memset(cache, -1, sizeof(cache));
	cout << solve(S) << '\n';
	return 0;
}

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

int main(){
  int a,b,c;
  cin >>a >>b >>c;
  for(int i = 1; i<=b; i++){
    if(i*a%b==c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		double d = in.nextDouble();
		double cand1 = Math.sqrt(Math.pow(d,2) / 2) * 2;
		double cand2 = Double.MIN_VALUE;
		if(d<=Math.sqrt(Math.pow((int)d,2)+1)){
			cand2 = (int)d + 1;
		}
		System.out.println(Math.max(cand1,cand2));
	}
}

Measured memory_bytes: 28104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

template<long long mod>
struct modint{
    long long num;

    constexpr modint(long long x = 0) : num((x + mod) % mod) {}

    constexpr modint &operator += (const modint& rhs){
        num = (num + rhs.num) % mod;
        return *this;
    }
    constexpr modint &operator -= (const modint& rhs){
        num  -= rhs.num;
        while(num < 0) num += mod;
        num %= mod;
        return *this;
    }
    constexpr modint &operator *= (const modint& rhs){
        num = num * rhs.num % mod;
        return *this;
    }
    constexpr modint &operator /= (modint rhs){
        int exp = mod - 2;
        while(exp > 0){
            if(exp % 2) *this *= rhs;
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }

    constexpr modint operator ++ (){
        ++num;
        return *this;
    }

    constexpr modint operator ++ (int n){
        modint tmp = *this;
        ++(*this);
        return tmp;
    }

    constexpr modint operator -- (){
        --num;
        return *this;
    }
    constexpr modint operator -- (int n){
        const modint tmp = *this;
        --(*this);
        return tmp;
    }

    constexpr modint operator + (const modint& rhs) const {
        return modint(*this) += rhs;
    }
    constexpr modint operator - (const modint& rhs) const {
        return modint(*this) -= rhs;
    }
    constexpr modint operator * (const modint& rhs) const {
        return modint(*this) *= rhs;
    }
    constexpr modint operator / (const modint& rhs) const {
        return modint(*this) /= rhs;
    }

    void modpow(long long exp){
        modint res = 1;
        while(exp > 0){
            if(exp % 2) res *= (*this);
            (*this) *= (*this);
            exp /= 2;
        }
        (*this) = res;
    }

    friend ostream &operator << (ostream& lhs, const modint& rhs){
        return lhs << rhs.num;
    }

    friend istream &operator >> (istream& lhs, modint& rhs){
        long long tmp;
        lhs >> rhs.num;
        return lhs;
    }
};

#define mint modint<1000000007>

int N, K;
mint sum = 0;
mint cnt[100010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    for(int i = 1; i <= K; i++){
        cnt[i] = K / i;
        cnt[i].modpow(N);
    }
    for(int i = K; i >= 1; i--){
        for(int j = i + i; j <= K; j += i){
            cnt[i] -= cnt[j];
        }
        sum += cnt[i] * i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4416
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
    }
    println!("{}", std::cmp::min(b/a, c));
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();
		sc.close();
		if(N>=10) {
			System.out.println(R);
		}else {
			System.out.println(R+(100*(10-N)));
		}
	}

}

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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	int resa = 0,resb=0;
	rep(i, S.size()) {
		if (S[i] == '0') resa++;
		else resb++;
	}
	if (resa == 0 || resb == 0) cout << 0 << endl;
	else cout << 2 * min(resa, resb) << endl;
	return 0;
}

Measured memory_bytes: 512
def f(a,b,c,d):
    return a*d-b*c

while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split())
        AB=[x2-x1,y2-y1]
        AP=[xp-x1,yp-y1]
        BC=[x3-x2,y3-y2]
        BP=[xp-x2,yp-y2]
        CA=[x1-x3,y1-y3]
        CP=[xp-x3,yp-y3]
        #print AB
        #print BC
        #print CA
        #print AP
        #print BP
        #print CP
        #print f(AB[0],AB[1],AP[0],AP[1])
        #print f(BC[0],BC[1],BP[0],BP[1])
        #print f(CA[0],CA[1],CP[0],CP[1])
        if (f(AB[0],AB[1],AP[0],AP[1]) < 0 and f(BC[0],BC[1],BP[0],BP[1]) < 0 and f(CA[0],CA[1],CP[0],CP[1]) < 0) or\
        (f(AB[0],AB[1],AP[0],AP[1]) > 0 and f(BC[0],BC[1],BP[0],BP[1]) > 0 and f(CA[0],CA[1],CP[0],CP[1]) > 0):
            print "YES"
        else:
            print "NO"
    except:
        break


Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,A,a,M,m;
  cin >> N;
  M=35;
  for(int i=0;i< N; i++){
    cin >> A;
    m=0;
    
    for(int j=0;j<30; j++){
      a=A;
      A /=2;
      if(A*2 ==a){
        m ++;}
      else{break;}
    }
    if(M >=m){
      M=m;}
    }        
  cout << M << endl;
}

Measured memory_bytes: 3400
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstdlib>
using namespace std;

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

int main() {
  string bu[10] = {"","',.!?,.!?","abcABC","defDEF","ghiGHI","jklJKL","mnoMNO","pqrsPQRS","tuvTUV","wxyzWXYZ"};
  string s;
  while(cin >> s) {
    int mae = 0;                // OÌüÍ
    int kai = 0;                // OÌüÍÜÅÅ»ÌlðA±ÅüÍ³ê½ñB
    FOR(i,s) {
      int n = *i-'0';
      if (mae == 0) {
        if (n == 0)
          cout << " ";
        else {
          mae = n;
          kai = 0;
        }
      } else {
        if (n != mae) {
          cout << bu[mae][kai%bu[mae].length()];
          mae = n;
          kai = 0;
        } else
          kai++;
      }
    }
    cout << bu[mae][kai%bu[mae].length()];
    cout << endl;
  }
}

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

#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,n) for(int i=0;i<(int)n;++i)

#define CLEAR(a) memset((a), 0, sizeof(a))

inline int toInt(string s) { int x; istringstream iss(s); iss >> x; return x; }
template<class T> inline string toString(T x) { ostringstream oss; oss <<x ; return oss.str(); }
template<class T> inline T sqr(T x) { return x * x; }

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

static const auto io_sync_off = []() {
    // turn off sync
    std::ios::sync_with_stdio(false);
    // untie in/out streams
    std::cin.tie(nullptr);
    return nullptr;
}();

int main(int argc, char *argv[]) {
    vi n(3, 0);
    cin >> n[0] >> n[1] >> n[2];
    SORT(n);
    cout << n[2] * 10 + n[1] + n[0] << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    string s;
    cin >> s;
    unsigned int sizemax = 0;
    for(unsigned int i = 0; i < s.size(); i++){
        if(sizemax > s.size() - i) break;
        if(s[i] != 'A') continue;
        for(unsigned int j = i+1; j < s.size(); j++){
            if(s[j] == 'Z') sizemax = max(sizemax, j - i + 1);
        }
    }
    cout << sizemax << endl;
    return 0;
}

Measured memory_bytes: 640
/* exB */

#include<stdio.h>
#include<string.h>
#define SIZE 1001

int main(void){
    char s[SIZE], t[SIZE];
    int i, j, len_s, len_t, count, min = 1000;

    scanf("%s", s);
    scanf("%s", t);
    len_s = strlen(s);
    len_t = strlen(t);

    for(i=0; i<len_s-len_t+1; i++){
        count = 0;
        for(j=0; j<len_t; j++){
            if(s[i+j] != t[j]){
                count++;
            }
        }
        if(min > count){
            min = count;
        }
    }

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


Measured memory_bytes: 1732
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscan(r, &n)

	var e = make([]int, n)

	for x := 0; x < n; x++ {
		fmt.Fscan(r, &e[x])
	}

	fmt.Printf("%v\n", strings.Trim(fmt.Sprint(e), "[]"))

	for i := 1; i < n; i++ {
		v := e[i]
		j := i - 1
		for j >= 0 && e[j] > v {
			e[j+1] = e[j]
			j--
		}
		e[j+1] = v
		fmt.Printf("%v\n", strings.Trim(fmt.Sprint(e), "[]"))
	}
}



Measured memory_bytes: 1280
n,m = map(int,input().split())
route = [0]*(n+10)
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        route[b] += 1
    if b == n:
        route[a] += 1
if 2 in route:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,i,j,a,cnt=0;
    string ch;
    cin>>ch;
    a=ch.size();
    for(i=0;i<a;i++)
    {
        if((ch[i]=='A' && ch[i+1]=='B')|| (ch[i]=='B'&& ch[i+1]=='A'))
        {
            cnt++;
        }

    }
    if(cnt>=1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i, cnt = 0;
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        for(i = 0; i < n; i++) {
        	String a = sc.next();
        	BigInteger b = new BigInteger(a);
        	if(b.isProbablePrime(5)) cnt++;
        }
        System.out.println(cnt);
	}
}


Measured memory_bytes: 54660
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;
using ll = long long int;

const double PI = 3.1415926535897932384626433;

int main(){
    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    for(int i = 0; i < n; i++)cin >> x[i] >> y[i];

    double maxlength = 0.0;
    for(int i = 0; i < 360; i++){
        double xd = cos((double)i/180*PI);
        double yd = sin((double)i/180*PI);
        ll nowx = 0;
        ll nowy = 0;
        for(int j = 0; j < n; j++){
            if (xd*x[j] + yd*y[j] >= 0){
                nowx += x[j];
                nowy += y[j];
            }
        }

        double length = sqrt((double)(nowx*nowx + nowy*nowy));
        maxlength = max(maxlength, length);
    }

    cout << fixed << setprecision(15) << maxlength << endl;
    return 0;
}

Measured memory_bytes: 3692
// {{{ by WangYenJen
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll;
typedef pair<int,int> pii;
// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))
// input
inline bool SR(int &x) {
	return scanf("%d",&x) == 1;
}
inline bool SR(ll &x) {
	return scanf("%lld",&x) == 1;
}
inline bool SR(double &x) {
	return scanf("%lf",&x) == 1;
}
inline bool SR(char *s) {
	return scanf("%s",s) == 1;
}
inline bool RI() {
	return true;
}
template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
	return SR(x) && RI(tail...);
}
// output
inline void SP(const int x) {
	printf("%d",x);
}
inline void SP(const ll x) {
	printf("%lld",x);
}
inline void SP(const double x) {
	printf("%.16lf",x);
}
inline void SP(const char *s) {
	printf("%s",s);
}
inline void PL() {
	puts("");
}
template<typename I , typename... T> inline void PL(const I x , const T... tail) {
	SP(x);
	if(sizeof...(tail)) putchar(' ');
	PL(tail...);
}
// debug
#define WangYenJen
#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
    cerr << s << " = " << x << endl;
}
template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
    int c = 0;
    while(*s != ',' || c != 0) {
        if(*s == '(' || *s == '[' || *s == '{') c++;
        if(*s == ')' || *s == ']' || *s == '}') c--;
        cerr << *s++;
    }
    cerr << " = " << x << " , ";
    _DOING(s + 1 , tail...);
}
#define debug(...) \
do {\
    fprintf(stderr , "%s:%d - ",__PRETTY_FUNCTION__,__LINE__);\
    _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);
#else
#define debug(...)
#endif
// random function
inline int RAND() {
	static int x = 880301;
	return (x = x * 0xdefaced + 1) & 0x7fffffff;
}
// }}}

const int MAX_N = 100000 + 10;
int a[MAX_N];
unordered_set<int> rd;
int main() {
    int n;
    RI(n);
    REP(i , n) RI(a[i]);
    for(int i = 0; i < n; i += 2) rd.insert(a[i]);
    int ans = 0;
    sort(a , a + n);
    for(int i = 1; i < n; i += 2) ans += rd.count(a[i]);
    PL(ans);
    return 0;
}


Measured memory_bytes: 2700
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long a = sc.nextLong();
		BigDecimal b = new BigDecimal(sc.next());
		System.out.println(b.multiply(BigDecimal.valueOf(a)).toBigInteger());
	}
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 33120
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> odd;
    rep(i,n){
        if(a[i]%2!=0){
            odd.push_back(a[i]);
        }
    }
    if(odd.size()%2!=0){
        cout << "NO" << endl;
        return 0;
    }else{
        cout << "YES" << endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  ll n, res = 1;
  string s;
  cin >> n >> s;
  ll num[30]={};

  for (auto c : s) num[c - 'a']++;
  for (int i = 0; i < 26; ++i) {
    res *= num[i] + 1;
    res %= MOD;
  }

  cout << res - 1 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const int inf = 1<<30;
const LL maxn = 1010;

int W, H, N;
int X1[maxn], X2[maxn], Y1[maxn], Y2[maxn];
bool fld[maxn * 3][maxn * 3];
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
int compress(int *x1, int *x2, int w){
    vector<int> xs;
    for(int i = 0; i < N; i++){
        for(int d = -1; d <= 1; d++){
            int tx1= x1[i] + d, tx2 = x2[i] + d;
            if(0 <= tx1 && tx1 < w) xs.push_back(tx1);
            if(0 <= tx2 && tx2 < w) xs.push_back(tx2);
        }
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    for(int i = 0; i < N; i++){
        x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
        x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
    }
    return xs.size();
}
void solve(){
    W = compress(X1, X2, W);
    H = compress(Y1, Y2, H);
    ms(fld, 0);
    for(int i = 0; i < N; i++){
        for(int y = Y1[i]; y <= Y2[i]; y++){
            for(int x = X1[i]; x <= X2[i]; x++){
                fld[y][x] = true;
            }
        }
    }
    int ans = 0;
    for(int y = 0; y < H; y++){
        for(int x = 0; x < W; x++){
            if(fld[y][x]) continue;
            ans++;
            queue<pair<int, int> > que;
            que.push(make_pair(x, y));
            while(!que.empty()){
                int sx = que.front().first, sy = que.front().second;
                que.pop();
                for(int i = 0; i < 4; i++){
                    int tx = sx + dx[i], ty = sy + dy[i];
                    if(tx < 0 || W <= tx || ty < 0 || H <= ty) continue;
                    if(fld[ty][tx]) continue;
                    que.push(make_pair(tx, ty));
                    fld[ty][tx] = true;
                }
            }
        }
    }
    printf("%d\n", ans);
}
int main()
{
    while(cin >> W >> H, W || H){
        cin >> N;
        for(int i = 0; i < N; i++){
            cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
            X2[i]--, Y2[i]--;
        }
        solve();
    }
    return 0;
}



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

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

#define pb push_back
#define fr first
#define sc second

const ll M = 998244353;

ll modpow(ll x,ll k){
	if(k == 0)return 1;
	ll ret = modpow(x,k/2);
	ret *= ret; ret %= M;
	if(k%2 == 1){
		ret *= x;
		ret %= M;
	}
	return ret;
}

int main(){
	int N;
	int x[202],y[202];
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%d%d",&x[i],&y[i]);
	}
	
	ll ret = modpow(2,N);
	ret += M-N-1; if(ret>=M)ret -= M;
	
	for(int i = 1 ; i <= N ; i ++){
		for(int j = i+1 ; j <= N ; j ++){
			ll cnt = 0;
			for(int k = 1 ; k <= N ; k ++){
				if(k == i || k == j)continue;
				if(x[k] < min(x[i],x[j]))continue;
				if(x[k] > max(x[i],x[j]))continue;
				if(y[k] < min(y[i],y[j]))continue;
				if(y[k] > max(y[i],y[j]))continue;
				if((x[k]-x[i])*(y[j]-y[i])-(y[k]-y[i])*(x[j]-x[i]) == 0)cnt ++;
			}
			ret += M-modpow(2,cnt); if(ret>=M)ret -= M;
		}
	}
	cout << ret << endl;
}
	



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

using namespace std;

inline long double rad2deg(long double t)
{
  return (t * 180.0) / M_PI;
}

long double solve1(long double a, long double b, long double x)
{
  long double t = atan2(2.0 * x, a * b * b);
  return 90.0 - rad2deg(t);
}

long double solve2(long double a, long double b, long double x)
{
  long double t = atan2(a * a * a, 2.0 * (a * a * b - x));
  return 90.0 - rad2deg(t);
}

int main()
{
  long double a, b, x;
  cin >> a >> b >> x;
  
  long double t = -1.0;
  if (2.0 * x < a * a * b) {
    t = solve1(a, b, x);
  } else {
    t = solve2(a, b, x);
  }
  
  cout << setprecision(12) << t << endl;
  
  return 0;
}

Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim*/

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

typedef long long ll;
typedef vector<int> vi;
typedef vector <long long> vll;
typedef pair<int, int> pii;
///*-*-*-*-*-*-*-*-*-*-*-*-*-*-Macro Start-*-*-*-*-*-*-*--*-*-*-*-*/

#define Faster_IO              ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F                      first
#define S                      second
#define pb                     push_back
#define MP                     make_pair
#define sf                     scanf
#define pf                     printf
#define PI                     (2*acos(0))
#define to_radian(degree)      ((pi/180)*degree)
#define to_degree(radian)      ((180/pi)*radian)
#define SQ(a)                  (a)*(a)
#define SORT(x)                sort(x.begin(),x.end())
#define rSORT(x)               sort(x.rbegin(),x.rend())
#define SetPrint(a,x)          cout<<fixed<<setprecision(x)<<a<<endl
#define show(vec)              for (int i=0; i<vec.size(); i++)cout << vec[i] << " ";
#define lines                  cout <<"\n" <<"---------------" << "\n";
#define YES                    printf("YES\n")
#define NO                     printf("NO\n")
#define Yes                    printf("Yes\n")
#define No                     printf("No\n")
#define testcase(n)            int n; cin >> n; while(n--)
#define lcm(a,b)               ((a / __gcd(a,b) ) * b)
#define gcd(a,b)               __gcd(a,b)
#define all(vec)               vec.begin(), vec.end()
#define SUM(vec)               accumulate(vec.begin(), vec.end(), 0)
#define gcin(str)              getline(cin, str)
///*-*-*-*-*-*-*-*-*-*-*-*-*-*-Macro END-*-*-*-*-*-*-*--*-*-*-*-*/

///*-*-*-*-*-*-*-*-*-*-*-*-*-*-Template Start-*-*-*-*-*-*--*-*-*-*-*/

//template <class T> T isPrime(T n){if(n<=1)return 0;for(long long i=2;i*i<=n; i++)if(n%i==0)return 0;return 1;}
//template <class T> T bigmod(T X, T n, T M) {if (n==0) return 1;if (n%2) return ((X%M) * bigmod(X,n-1,M)) %M;else {long long int d = bigmod(X,n/2, M);return ((d%M) * (d%M))%M;}}

///*-*-*-*-*-*-*-*-*-*-*-*-*-*-Template END-*-*-*-*-*-*-*--*-*-*-*-*/


int main()
{
    Faster_IO
    #ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
    #endif

   
    char a;
    cin >> a;
    (a>='A' and a<='Z')?cout <<'A' << endl: cout << "a"<<"\n";
   
    return 0;
}


Measured memory_bytes: 3552
/* ****HARRYoo7**** */

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

#define N  100005
#define hell 1e9


int main()
{
	int h,w;
	int ch,cw;
	int dh,dw;
	cin>>h>>w>>ch>>cw>>dh>>dw;
	string s[h];
	int dist[h][w];
	h--;w--;ch--;cw--;dh--;dw--;
	for(int i=0;i<=h;i++){
		cin>>s[i];
	}
	for(int i=0;i<=h;i++){
		for(int j=0;j<=w;j++){
			dist[i][j]=hell;
		}
	}
	deque< pair<int,int> > q;
	q.push_back({ch,cw});
	dist[ch][cw]=0;
	while(!q.empty()){
		pair<int,int> u=q.front();
		int th=u.first;
		int tw=u.second;
		q.pop_front();
		if(th+1<=h){
			if(dist[th+1][tw]>dist[th][tw]&&s[th+1][tw]=='.'){
				dist[th+1][tw]=dist[th][tw];
				q.push_front({th+1,tw});
			}
		}
		if(th-1>=0){
			if(dist[th-1][tw]>dist[th][tw]&&s[th-1][tw]=='.'){
				dist[th-1][tw]=dist[th][tw];
				q.push_front({th-1,tw});
			}
		}
		if(tw+1<=w){
			if(dist[th][tw+1]>dist[th][tw]&&s[th][tw+1]=='.'){
				dist[th][tw+1]=dist[th][tw];
				q.push_front({th,tw+1});
			}
		}
		if(tw-1>=0){
			if(dist[th][tw-1]>dist[th][tw]&&s[th][tw-1]=='.'){
				dist[th][tw-1]=dist[th][tw];
				q.push_front({th,tw-1});
			}
		}
		for(int i=-2;i<=2;i++){
			for(int j=-2;j<=2;j++){
				int r=th+i;
				int c=tw+j;
				if(r>=0&&r<=h&&c>=0&&c<=w){
					if(s[r][c]=='.'&&dist[r][c]>dist[th][tw]+1){
						dist[r][c]=dist[th][tw]+1;
						q.push_back({r,c});
					}
				}
			}
		}
	}
	if(dist[dh][dw]==hell){
		cout<<"-1";
	}
	else{
		cout<<dist[dh][dw];
	}
	return 0;
}

Measured memory_bytes: 9436
package main

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

var sc *bufio.Scanner

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

func bico(n, r int) int {
	if n < r {
		return 0
	}
	if n < 2*r {
		r = n - r
	}

	ret := 1.0
	for i := 1; i <= r; i++ {
		ret *= float64(n - i + 1)
		ret /= float64(i)
	}
	return int(ret)
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, p := nextInt(), nextInt()

	cnt0, cnt1 := 0, 0
	for i := 0; i < n; i++ {
		a := nextInt()
		switch {
		case a%2 == 0:
			cnt0++
		default:
			cnt1++
		}
	}

	ans0 := 0
	ans1 := 0
	for j := 0; j <= cnt0; j++ {
		ans0 += bico(cnt0, j)
	}
	for k := p; k <= cnt1; k += 2 {
		ans1 += bico(cnt1, k)
	}

	fmt.Println(ans0 * ans1)
}


Measured memory_bytes: 640
while True:
    n = int(raw_input())
    if n == 0:
        break

    a = [[] for i in range(n + 1)]
    for i in range(n + 1):
        if i < n:
            a[i] = map(int, raw_input().split())
            a[i].append(sum(a[i]))
        else:
            a[i] = [sum([a[j][k] for j in range(n)]) for k in range(n + 1)]

    s = ""
    for i in range(n + 1):
        s += "".join(map(lambda x: str(x).rjust(5, " "), a[i])) + "\n"
    print s,

Measured memory_bytes: 4252
#include <stdio.h>

int p_judge(int x){
	if(x<2 || (x!=2 && x%2==0)) return 0;
	int i=3;
	while(x >= i*i)
	{
		if(x%i==0) return 0;
		i+=2;
	}
	return 1;
}

int main(){
	int N;
	scanf("%d",&N);	
	int count=0,new=3;
	for(int new=3;count<N;new+=10){
		if(p_judge(new)==1)
		{
			printf("%d ",new);
			count++;
		}
	}
	return 0;
}
	


Measured memory_bytes: 128
#include <stdio.h> 

int main(void){
    int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(-100 <=x,y<=100 && 0<W,H,r<=100){
	    if(0<=x-r && 0<=y-r &&x+r<=W && y+r<=H){
	    	printf("Yes\n");
	    	}else{
        	printf("No\n");
	        }
    	}
    return 0;
}


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

typedef pair<int,int> P;
const int INF = 500000000;

int main(){
    int n,k;
    string s;
    char a;
    cin >> n >> k >> s;
    k--;
    if (s[k] == 'A') a = 'a';
    else if (s[k] == 'B') a = 'b';
    else a = 'c';
    s[k] = a;
    cout << s << "\n";
}

Measured memory_bytes: 256