akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1
int lcm (int a, int b ){
    int r,tmp;
    while( 1 ) {
        if( a < b ) { tmp = a; a = b; b = tmp; }
        if( b < 1 ) continue;
        while( (r = a % b) != 0 ) {
            a = b;
            b = r;
        }
        return b;
    }
}
int main() {

    int N, a[100022] = {};

    Scd(N);
    Rep(i,N){
        Scd(a[i]);
    }
    sort(a,a+N);

    int d[100002] = {};
    int ans = lcm(a[0],a[1]);
    Repe(i,N,2){
        ans = lcm(ans,a[i]);
    }
    printf ("%d\n", ans );

    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long a,b,c,d,n,x,y,z,i,j,k;
    a=0;
    b=0;
    c=0;
    d=0;
    cin>>n;
    string s;
    for (i=0;i<n;i++)
    {
    	cin>>s;
    	if (s=="AC")
    	{
    		a++;
		}
		else if (s=="WA")
		{
			b++;
		}
		else if (s=="TLE")
		{
			c++;
		}
		else if (s=="RE")
		{
			d++;
		}		
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> v(n), w(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i] >> w[i];
    }
    vector<vector<pair<ll, ll>>> s(512);
    s[0].emplace_back(0, 0);
    for (int i = 0; i < min(n, 512); i++) {
        s[i] = s[(i - 1) / 2];
        for (int j = s[i].size() - 1; j >= 0; j--) {
            s[i].emplace_back(s[i][j].first + w[i], s[i][j].second + v[i]);
        }
        sort(s[i].begin(), s[i].end());
        for (int j = 1; j < s[i].size(); j++) {
            s[i][j].second = max(s[i][j].second, s[i][j - 1].second);
        }
    }
    int q;
    cin >> q;
    while (q--) {
        ll vx, l;
        cin >> vx >> l;
        vx--;
        if (vx == 0) {
            if (w[0] <= l) {
                cout << v[0] << '\n';
            } else {
                cout << 0 << '\n';
            }
            continue;
        }
        ll ans = 0;
        vector<pair<ll, ll>> t(1);
        while (vx >= 512) {
            for (int i = t.size() - 1; i >= 0; i--) {
                t.emplace_back(t[i].first + w[vx], t[i].second + v[vx]);
            }
            vx--;
            vx /= 2;
        }
        sort(t.begin(), t.end());
        for (int i = 1; i < t.size(); i++) {
            t[i].second = max(t[i].second, t[i - 1].second);
        }
        int j = s[vx].size() - 1;
        for (int i = 0; i < t.size(); i++) {
            int wei = t[i].first, val = t[i].second;
            while (j > 0 && wei + s[vx][j].first > l) {
                j--;
            }
            if (wei + s[vx][j].first > l) {
                break;
            }
            ans = max(ans, val + s[vx][j].second);
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 10068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    int ans=((a*(a+1))/2)+((b*(b+1))/2);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
string s1,s2;
cin>>s1>>s2;
if(s1[0]=='H'){
if(s2[0]=='H')cout<<'H'<<endl;
else cout<<'D'<<endl;
}
else{
if(s2[0]=='D')cout<<'H'<<endl;
else cout<<'D'<<endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n, a, b; cin >> n >> a >> b;
    int ans = 0;

    rep(i,n){
        int tmp = i+1;
        int dig = 0;
        rep(i,5){
            dig += tmp%10;
            tmp /= 10;
        }

        if(a<= dig && dig <= b) ans += i+1;
    }

    cout << ans << endl;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<ll> x(n); 
  rep(i,n) cin>>x[i];
  
  ll ans=1e9;
  rep(i,n-k+1){
    ans = min(ans,x[i+k-1]-x[i]+min(abs(x[i]),abs(x[i+k-1])));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
/* ex9_2
   YSK722 */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 100001

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if (new == NULL)
        exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if (tmp == NULL)
        exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    char text[SIZE], top;
    int i = 0, count = 0;
    //最初のノードの指す先
    node *first = NULL;
    scanf("%s", text);
    while (text[i] != '\0'){
        if (first == NULL){
            push(&first, text[i]);
            i++;
            continue;
        }
        top = pop(&first);
        if (text[i] != top)
            count += 2;
        else{
            //スタックにノードを追加
            push(&first, top);
            push(&first, text[i]);
        }
        i++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 4904
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int x1,x2,y1,y2,x3,y3,x4,y4;
  int y[4];
  cin >> x1 >> y1 >> x2 >> y2;

  for(int x = -500; x <= 500; x++){
    for(int y = -500; y <= 500; y++){
      bool q1 = ( pow(x-x1,2) + pow(y-y1,2) ) == (pow(x2-x1,2) + pow(y2-y1,2));
      bool q2 = ((x-x1)*(x2-x1) + (y-y1)*( y2 -y1) == 0);
      if(q1 && q2){
        x4 = x;
        y4 = y;
        x3 = x4 + (x2 - x1);
        y3 = y4 + (y2 - y1);
        if((x2-x1)*(y4-y1) - (y2-y1)*(x4-x1) > 0) {cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl; return 0;}
      }
    }
  }


  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[100008];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	sort(a+1,a+n+1);
	a[n+1]=a[n]+888;
	int ans=0;
	for(int i=1;i<=n;++i) {
		int now=i;
		while(a[i+1]==a[now]) ++i;
		if((i-now+1)>=a[now]) ans+=i-now+1-a[now];
	    else ans+=i-now+1;	
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 512
S = input()
if S == "RRR":
    print(3)
if S == "RSS":
    print(1)
if S == "RSR":
    print(1)
if S == "SRS":
    print(1)
if S == "SSR":
    print(1)
if S == "SSS":
    print(0)
if S == "RRS":
    print(2)
if S == "SRR":
    print(2)


Measured memory_bytes: 9108
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1int;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[100][2];

int main() {
  clr(dp,0);
  ll n;
  cin>>n;
  string s1,s2;
  cin>>s1;
  cin>>s2;
  s1 += "+";
  s2 += "-";
  if(n==1){
    cout << 3 << endl;
    return 0;
  }
  if(s1[0]==s2[0]){
    dp[0][0] = 3;
  }
  else{
    dp[1][1] = 6;
  }
  rep(i,1,n){
    if(s1[i]==s2[i]){
      dp[i][0] += dp[i-1][0]*2;
      dp[i][0] += dp[i-1][1];
      dp[i][0] %= MOD;
    }
    else if(s1[i]==s1[i+1]){
      dp[i+1][1] += dp[i-1][0]*2;
      dp[i+1][1] += dp[i-1][1]*3;
      dp[i+1][1] %= MOD;
    }
  }
  ll ans = dp[n-1][0] + dp[n-1][1];
  ans %= MOD;
  cout << ans << endl;
  return 0;
}


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

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

  int ans=0;
  rep(i, N){
    int l,r;
    cin >> l >> r;
    ans += r-l+1;
  }

  cout << ans << endl; 
}

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

int main()
{
    int n;
    std::string s;
    std::cin>>n>>s;
    for(int i=0;i<(int)s.size();i++){
        if(s[i]+n>90){s[i]+=n;s[i]-=26;}
        else s[i]+=n;
    }
    std::cout<<s<<std::endl;
}


Measured memory_bytes: 256
r, g, b, n = map(int, input().split())

m1 = max(r, g, b)
m3 = min(r, g, b)
m2 = r+g+b-(m1+m3)

l1 = [m1*i for i in range(0, n//m1+1)]
cnt = 0

i = 0
while i*m1 <= n:
    j = 0
    while i*m1 + j*m2 <= n:
        if (n - (i*m1 + j*m2))%m3 == 0:
            cnt += 1
        j += 1
    i += 1
    
print(cnt)

Measured memory_bytes: 40684
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n;
  std::cin >> n;
  int flag=0;
  for (int i = 0; i < 60000; i++) {
    if((int)(i*1.08)==n){std::cout << i << '\n';flag=1;break;}
    if((int)(i*1.08)>n)break;
  }
  if(flag==0)std::cout << ":(" << '\n';

  return 0;
}


Measured memory_bytes: 256
// knapsack 2 with harder constraints
#include <bits/stdc++.h>
#define ll long long
using namespace std;

// dp[i][j] = minimum total weight required to get a value i with items 0...j
int v[101];
ll wt[101];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, value = 0, ans = 0;
	ll w;
	cin >> n >> w;
	for(int i = 1; i <= n; i++) {
		cin >> wt[i] >> v[i];
		value += v[i];
	}
	vector<vector<ll>> dp(value+1, vector<ll> (n+1));

	for(int i = 0; i <= n; i++) {
		dp[0][i] = 0;
	}
	for(int i = 1; i <= value; i++) {
		dp[i][0] = 1e18;
	}

	for(int i = 1; i <= value; i++) {
		for(int j = 1; j <= n; j++) {
			dp[i][j] = dp[i][j-1];
			if(i >= v[j]) {
				dp[i][j] = min(dp[i][j], dp[i-v[j]][j-1] + wt[j]);
			}
			if(dp[i][j] <= w) {
				ans = i;
			}
		}
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 82304
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

class DisjointSet{
public:
  vector<int> rank,p;

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
    for(int i=0;i<size;i++) makeSet(i);
  }

  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
  }

  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }

  void unite(int x,int y){
    link(findSet(x),findSet(y));
  }

  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
    }else{
      p[x]=y;
      if(rank[x]==rank[y]){
        rank[y]++;
      }
    }
  }

  int findSet(int x){
    if(x!=p[x]){
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
};

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

  //DisjointSet ds(26);

  int al[26]={};
  int al2[26]={};
  for(int i=0;i<26;i++){
    al[i]=-1;
    al2[i]=-1;
  }
  for(int i=0;i<s.size();i++){
    if(al[s[i]-'a']==-1){
      al[s[i]-'a']=t[i]-'a';
    }
    if(al2[t[i]-'a']==-1){
      al2[t[i]-'a']=s[i]-'a';
    }
      //al2[t[i]-'a']=s[i]-'a';
      //ds.unite(s[i]-'a',t[i]-'a');
      //cout<<al[i]<<endl;
    //}else{
      if(al[s[i]-'a']!=t[i]-'a'){
        cout<<"No"<<endl;
        return 0;
      }
      if(al2[t[i]-'a']!=s[i]-'a'){
        cout<<"No"<<endl;
        return 0;
      }
    //}
    //cout<<al[s[i]-'a']<<endl;
  }

  /*for(int i=0;i<26;i++){
    cout<<al[i]<<endl;
    if(al[i]==-1) continue;
    /*if(!ds.same(i,al[i])){
      cout<<"No"<<endl;
      return 0;
    }*/
    /*if(i!=al[al[i]]&&al[al[i]]!=-1){
      cout<<i<<" "<<al[i]<<" "<<al[al[i]]<<endl;
      cout<<"No"<<endl;
      return 0;
    }*/
  //}

  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 776
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    e_value = [(1 + i)/2 for i in p]
    c_value = [e_value[0]]
    for i in range(1, n):
        c_value.append(c_value[i-1] + e_value[i])
    ans = 0
    for i in range(k-1, n):
        if i == k-1:
            ans = c_value[i]
        else:
            ans = max(ans, c_value[i]-c_value[i-k])
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 33464
C = 1000000007

def permutarion(n)
  acc = 1
  (1..n).each {|i| acc = (acc * i) % C}
  acc
end

n, m = gets.split.map(&:to_i)

result = if n == m
           permutarion(n) ** 2 * 2 % C
         elsif n == m + 1 || m == n + 1
           permutarion(m) * permutarion(n) % C
         else
           0
         end
         
puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, K;
vector<pair<int,int>> arr;

int main() {
    cin >> N >> K;
    arr.resize(N);
    for (int i = 0; i < N; i++) {
        int tempa, tempb;
        scanf("%d%d", &tempa, &tempb);
        arr[i] = make_pair(tempa, tempb);
    }
    sort(arr.begin(), arr.end());
    int ans;
    for (int i = 0; i < N; i++) {
        K -= arr[i].second;
        if (K<=0) {
            ans = arr[i].first;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    unordered_set<string> set;
    long long int n;
    cin>>n;
    while(n!=0){ 
      string s;
      cin>>s;
      set.insert(s);
      n--;
    }
    cout<<set.size()<<endl;
    return 0;
}

Measured memory_bytes: 17668
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,k;
	cin>>n;
	vl v(n),sum(n+1);
	rep(i,n)cin>>v[i];
	rep(i,n)sum[i+1]=sum[i]+v[i];
	ll mn=sum[n];
	rep(i,n)chmin(mn,abs(sum[n]-sum[i+1]-sum[i+1]));
	cout<<mn<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int[] kadomatsu = new int[n];
        for(int i = 0; i < n; i++) {
            kadomatsu[i] = sc.nextInt();
        }
        System.out.println(dfs(kadomatsu, n, 0, a, 0, b, 0, c, 0));
    }
    private static int dfs(int[] kadomatsu, int n, int currentN, int a, int currentA, int b, int currentB, int c, int currentC) {
        if(currentN == n) {
           if(currentA != 0 && currentB != 0 && currentC != 0) {
               return  Math.abs(a - currentA) + Math.abs(b - currentB) + Math.abs(c - currentC) - 30;
           }
           return Integer.MAX_VALUE;
        }
        int candidate1 = dfs(kadomatsu, n, currentN + 1, a, currentA, b, currentB, c, currentC);
        int candidate2 = dfs(kadomatsu, n, currentN + 1, a, currentA + kadomatsu[currentN], b, currentB, c, currentC);
        candidate2 = candidate2 == Integer.MAX_VALUE ? Integer.MAX_VALUE : candidate2 + 10;
        int candidate3 = dfs(kadomatsu, n, currentN + 1, a, currentA, b, currentB + kadomatsu[currentN], c, currentC);
        candidate3 = candidate3 == Integer.MAX_VALUE ? Integer.MAX_VALUE : candidate3 + 10;
        int candidate4 = dfs(kadomatsu, n, currentN + 1, a, currentA, b, currentB, c, currentC + kadomatsu[currentN]);
        candidate4 = candidate4 == Integer.MAX_VALUE ? Integer.MAX_VALUE : candidate4 + 10;

        return Math.min(candidate1, Math.min(candidate2, Math.min(candidate3, candidate4)));
    }
}


Measured memory_bytes: 22484
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int M1 = sc.nextInt();
		int D1 = sc.nextInt();
		int M2 = sc.nextInt();
		int D2 = sc.nextInt();

		if (M1 != M2) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}

	}
}

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

namespace AtcoderCS
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            var A = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();

            bool isRising = false;
            long money = 1000;
            long stock = 0;

            for(long i = 0; i < N; i++)
            {
                if(!isRising && i < N - 1 && A[i] < A[i+1])
                {
                    long buyCount = money / A[i];
                    stock += buyCount;

                    money -= buyCount * A[i];
                    isRising = true;
                }else if(isRising && (i == N-1 || A[i] > A[i + 1]))
                {
                    money += stock * A[i];
                    stock = 0;
                    isRising = false;
                }
            }

            Console.WriteLine(money);
        }
    }
}


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

int kind[5] = {' ','A','C','G','T'};

vector<int>hash[2500000];

int convertion(string s){
  int d = 1;
  int sum = 0;
  for(int i = s.size() - 1;i >= 0;i--){
    for(int j = 1;j < 5;j++){
      if(kind[j] == s[i]){sum += d * j;break;}
    }
    d *= 5;
  }
  return sum;
}

int main(){
  ios_base::sync_with_stdio(false);
  string q,s;
  int n;
  cin >> n;
  while(n--){
    cin >> q >> s;
    if(q == "insert"){
      int sum = convertion(s);
      hash[sum / 100].push_back(sum);
    }
    if(q == "find"){
      int sum = convertion(s);
      bool flag = false;
      for(int i = 0;i < hash[sum / 100].size();i++){
	if(hash[sum / 100][i] == sum){cout << "yes" << endl;flag = true;break;}
      }
      if(!flag)cout << "no" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 63596
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    vec b(n);
    rep(i,n){
        b[a[i]-1]=i;
    }
    int cnt=1;
    int ans=0;
    rep(i,n-1){
        if(b[i]<b[i+1]) cnt++;
        else cnt=1;
        chmax(ans,cnt);
        //debug(cnt);
    }
    cout<<n-ans<<endl;
    
}

Measured memory_bytes: 3456
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String weather = scanner.nextLine();
		String ans = "";
		if(weather.equals("Sunny"))
			ans = "Cloudy";
		else if(weather.equals("Cloudy"))
			ans = "Rainy";
		else
			ans = "Sunny";
		
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 21716
#include <iostream>
using namespace std;
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
    char suit;
    int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; ++i) L[i] = A[left + i];
    for (int i = 0; i < n2; ++i) R[i] = A[mid + i];

    L[n1].value = R[n2].value = SENTINEL;
    int i ,j;
    i = j = 0;
    for (int k = left; k < right; ++k) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[], int n, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int partition(struct Card A[], int n, int p, int r) {
    struct Card x = A[r];
    int i = p - 1;
    for (int j = p; j < r; ++j) {
        if (A[j].value <= x.value) {
            i = i + 1;
            struct Card tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    struct Card tmp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = tmp;
    return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
    if (p < r) {
        int q = partition(A, n, p, r);
        quickSort(A, n, p, q - 1);
        quickSort(A, n, q + 1, r);
    }
}

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

    struct Card *A = new struct Card[n];
    struct Card *B = new struct Card[n];
    for (int i = 0; i < n; ++i) {
        cin >> A[i].suit;
        B[i].suit = A[i].suit;
        cin >> A[i].value;
        B[i].value = A[i].value;
    }

    for (int i = 0; i < n; ++i) {
    }

    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n - 1);

    int stable = 1;
    for (int i = 0; i < n; ++i) {
        if (A[i].suit != B[i].suit) stable = 0;
    }

    if (stable == 1) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    for (int i = 0; i < n; ++i) {
        cout << B[i].suit << " " << B[i].value << endl;
    }

    delete[] A;
    delete[] B;
    return 0;
}

Measured memory_bytes: 3380
from math import sqrt

person = int(input())
longs = list(map(int, input().split(" ")))

longsi_dic = {}
for i in range(len(longs)):
    if str(i + longs[i]) not in longsi_dic:
        longsi_dic[str(i + longs[i])] = 0
    longsi_dic[str(i + longs[i])] += 1

longsj_dic = {}
for j in range(len(longs)):
    if str(j - longs[j]) not in longsj_dic:
        longsj_dic[str(j - longs[j])] = 0
    longsj_dic[str(j - longs[j])] += 1

sum = 0
for val, sumi in longsi_dic.items():
    if val not in longsj_dic:
        continue
    sum += int(sumi) * int(longsj_dic[val])

print(sum)

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

int main() {
    int N; cin >> N;
    ll A, B; cin >> A >> B;
    vector<ll> X(N);
    rep(i, N){
        cin >> X[i];
    }

    ll ans = 0;
    for (int i = 1; i < N; i++){
        ll d = X[i] - X[i-1];
        d *= A;
        if(d > B){
            ans += B;
        } else {
            ans += d;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define INF 1e9+5
signed main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    
    vector<int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
            dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
def main():
    A = int(input())  # 500円の枚数
    B = int(input())  # 100円の枚数
    C = int(input())  # 50円の枚数
    X = int(input())
    result = 0
    for a in range(A + 1):
        for b in range(B + 1):
            for c in range(C + 1):
                total = 500 * a + 100 * b + 50 * c
                if total == X:
                    result += 1

    print(result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
///in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  //  ll p=100;
    //while(p--){
    ll t;
    cin>>t;
    bool f=0;
    for(int i=1;i<=9;i++)
    {
        if(t%i==0)
        {
            if(t/i>=1 && t/i<=9)
            {
                f=1;break;
            }
        }
    }
    if(f==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}





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

using namespace std;
using ll = long long;

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

    int a, b, v, w, t;

    cin >> a >> v >> b >> w >> t;

    if(abs(a - b) <= static_cast<ll>(t) * (v - w)) printf("YES\n");
    else printf("NO\n");

    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    int n, x;
    while (cin>>n) {
        int counts = 0;
        vector<int> cnt;
        while (n--) {
            cin >> x;
            cnt.push_back(x);
        }
        for (int i = 0; i < cnt.size(); i++) {
            int key = i;
            for (int j = i; j < cnt.size(); j++) {
                if (cnt[j] < cnt[key]) {
                    key = j;                   
                }
            }
            if (key != i) {
                counts++;int a = cnt[key];cnt[key] = cnt[i];cnt[i] = a;
            }
            
        }
        cout<<cnt[0];
        for (int i = 1; i < cnt.size(); i++) cout<<" "<<cnt[i];
        cout<<endl<<counts<<endl;
    }
    return 0;
}

Measured memory_bytes: 3152
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
string s;
cin >> s;
ll n;
cin >> n;
rep(i,s.size()){
    if((ll)('{' - s[i]) <= n && s[i] != 'a'){
        n -= (ll)('{' - s[i]);
        s[i] = 'a';
    }
}
n %= 26;
ll k = (ll)(s.back());
rep(i,n){
    if(k == 122)
        k = 97;
    else
        k++;
}
s.back() = char(k);
cout << s << endl;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a;
    int64_t sum = 0;
    for(int i = 0;i < n;i++) {
        cin >> a;
        sum += a;
    }
    cout << sum - n << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func isMatched(a, b [][]int) (matched bool) {
	matched = false
L1:
	for i := 0; i <= len(a)-len(b); i++ {
	L2:
		for j := 0; j <= len(a)-len(b); j++ {
			for k := 0; k < len(b); k++ {
				for l := 0; l < len(b); l++ {
					if a[i+k][j+l] != b[k][l] {
						continue L2
					}
				}
			}
			matched = true
			break L1
		}
	}
	return
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	a := make([][]int, N)
	b := make([][]int, M)
	for i := 0; i < N; i++ {
		a[i] = make([]int, N)
		var tmp string
		fmt.Scan(&tmp)
		for j, r := range tmp {
			switch r {
			case '.':
				a[i][j] = 0
			case '#':
				a[i][j] = 1
			}
		}
	}
	for i := 0; i < M; i++ {
		b[i] = make([]int, M)
		var tmp string
		fmt.Scan(&tmp)
		for j, r := range tmp {
			switch r {
			case '.':
				b[i][j] = 0
			case '#':
				b[i][j] = 1
			}
		}
	}
	if isMatched(a, b) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
lol = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451, 1471, 1481, 1511, 1531]
a = int(input())

ans = ''
for i in range(a):
    ans = ans + str(lol[i]) + ' '

print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

int main() {
    int N;
    cin >> N;
    if (N % 1000 == 0)
        cout << 0 << endl;
    else
        cout << 1000 - (N % 1000) << endl;
}

Measured memory_bytes: 3620
while True:
    m, f, r = map(int, input().split())
    score = ""
    if m < 0 and f < 0 and r < 0:
        break
    if m == -1 or f == -1:
        score = "F"
    if m + f >= 80:
        score = "A"
    if m + f >= 65 and m + f < 80:
        score = "B"
    if m + f >= 50 and m + f < 65:
        score = "C"
    if m + f >= 30 and m + f < 50:
        if r >= 50:
            score = "C"
        else:
            score = "D"
    if m + f < 30:
        score = "F"
    if m == -1 or f == -1:
        score = "F"
    print(score)



Measured memory_bytes: 5596
while True:

    input_count = int(input())

    if input_count == 0:
        break

    data = [int(input()) for _ in range(input_count)]

    counter = [0] * 12

    for item in data:
        counter[item // 10] += 1

    counter[6] = sum(counter[6:])
    counter = counter[:7]

    counter = [str(item) for item in counter]
    print("\n".join(counter))



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

int main(){
    int A, B, C, X;
    int c[3][3]; 
    int ans=0;
    bool flag = true;
    cin >> A >> B >> C >> X;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if(X == 500*i +100*j + 50*k)ans++;
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m),c(n);
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if(a[i]==0){
      c[b[i]]++;
    }
    if(b[i]==n-1){
      c[a[i]]++;
    }
  }
  bool can=false;
  for(int i=0;i<n;i++){
    if(c[i]==2){
      can=true;
    }
  }
  if(can){
    cout << "POSSIBLE" << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}


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

struct edge{
	int from;
	int to;
	ll cost;
};

vector<edge> graph;

vector<int> checkgraph[3000];
bool besucht[3000];

void checkdfs( int punkt ){
	if( besucht[punkt] ) return;
	besucht[punkt] = true;
	for( auto nextp : checkgraph[punkt] ){
		checkdfs( nextp );
	}
}

int main(){
	int n, m; ll p; cin >> n >> m >> p;
	const int s = 0, g = n-1;
	for( int i = 0; i < m; ++i ){
		int a, b, c; cin >> a >> b >> c;
		--a; --b;
		graph.push_back( (edge){a, b, -(c-p)} );
		checkgraph[a].push_back(b);
	}
	checkdfs(0); 
	vector<ll> d(n);
	fill_n( d.begin(), n, infll );
	d[s] = 0;
	int k = n-1;
	while( k-- ){
		for( auto e : graph ){
			if( !besucht[e.from] ) continue;
			d[e.to] = min(d[e.to], d[e.from]+e.cost);
		}
	}
	bool negativ[n];
	fill_n( negativ, n, false );
	for( auto e : graph ){
		if( !besucht[e.from] ) continue;
		if( d[e.to] > d[e.from]+e.cost ){
			d[e.to] = d[e.from]+e.cost;
			negativ[e.to] = true;
		}
	}
	k = n;
	while( k-- ){
		for( auto e : graph ){
			if( !besucht[e.from] ) continue;
			if( negativ[e.from] ) negativ[e.to] = true;
		}
	}
	if( negativ[g] ) cout << -1 << endl;
	else cout << max(0ll, -d[g]) << endl;
	return 0;
}

/*

基本方針: ベルマンフォードを動かす

負閉路について:
	ベルマンフォードは負の閉路がどこかにあることを検出できるが，そのままでは
	スタートからゴールに行く過程に負閉路があるかどうかはわからない
	・例 3 のノード 2 のような例（スタートから行けるがゴールには行けない）
		→	N-1 回ループを回したあと N 回目を回して，変化があった（⇔負閉路が存在する）ところから
			辿ってゴールに行けるかどうかを確かめる
	・例 3 のノード 3 のような例（ゴールには行けるがスタートからは行けない）
		→	グラフを DFS してたどり着く可能性のある場所を列挙しておく 

嘘解法: たくさん回してゴールの最短距離が更新されたら過程に負の回路がある
		これは正しくない（次のような例では C が更新されないが B で無限にループすることで最短距離を更新できる）
		　B ↩ -10
	-10　↗　 ↘ -10
		A ─→ C
		　-999

*/

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m, i, j;
		int sum = 0, max = 0, count = 0;
		while(true){
			n = sc.nextInt();
			m = sc.nextInt();
			if(n == 0 || m == 0) break;
			int[] a = new int[n];
			for(i = 0; i < n ; i++) {
				a[i] = sc.nextInt();
			}
			for(i = 0; i < n ; i++) {
				for(j = 0; j < n ; j++) {
					if(i == j) {
						continue;
					}
					sum = a[i] + a[j];
					if(m >= sum) {
						if(sum > max) {
							max = sum;
							count++;
						}
					}
				}
			}
			if(count != 0) {
				System.out.println(max);
			}else{
				System.out.println("NONE");
			}
			sum = 0;
			max = 0;
			count = 0;
		}
		sc.close();
	}
}


Measured memory_bytes: 52044
n = int(input())
L = []
for i in range(n):
    L.append(input())
from collections import Counter
L =Counter(L)
L = L.most_common()

li = []
a = L[0][1]
for i in range(len(L)):
    if L[i][1] == a:
        li.append(L[i][0])
li.sort()
for i in range(len(li)):
    print(li[i])

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll X; cin >> X;
  ll result = 360 / gcd(360,X);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") {
        cout << "No\n";
    }
    else {
        cout << "Yes\n";
    }
}


Measured memory_bytes: 3660
import sys
def input(): return sys.stdin.readline().rstrip()
import numpy as np
def main():
    n,k,s=map(int,input().split())
    ans=np.array([0]*n)
    ans[:k]+=s
    if s!=10**9:
        ans[k:]+=10**9
    else:
        ans[k:]+=10**9-1
    print(*ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 19112
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int* l = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> l[i];
	}
	int ans = 0;
	for (int i = 0;i < n;i++) {
		for (int j = i+1;j < n;j++) {
			for (int k = j + 1;k < n;k++) {
				if (l[i] != l[j] && l[i] != l[k] && l[j] != l[k] && l[i] < l[j] + l[k] && l[j] < l[i] + l[k] && l[k] < l[i] + l[j]) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3192
import java.util.*;
import java.io.*;

class Main {

	void solve() {
		
		int x = inint(), t = inint();
		out.println(Math.max(0, x - t));
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}
	
	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}
	
	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 20820
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const int MOD = 1000000007;

int main() {
    // 入力
    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    for (int i = 0; i < H; ++i) cin >> field[i];
    
    // DP テーブル定義
    vector<vector<long long> > dp(H+1, vector<long long>(W+1, 0));
    dp[1][1] = 1;

    // DPループ
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            // 行けない地点だったら無視
            if (field[i-1][j-1] == '#') continue;

            // 場合分けして求める
            if (i > 1) dp[i][j] += dp[i-1][j];
            if (j > 1) dp[i][j] += dp[i][j-1];
            dp[i][j] %= MOD;
        }
    }
    
    // 答えの出力
    cout << dp[H][W] << endl;
}


Measured memory_bytes: 9216
#include<functional>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<numeric>
using namespace std;
using ll = long long;

int main() {
    int n,a;cin>>n>>a;
    vector<int> x(n+1);x[0]=0;for (int i=1;i<n+1;i++) cin>>x[i];
    vector<vector<vector <ll>>> dp(n+1,vector<vector<ll>>(n+1,vector<ll>(n*50+1,ll(0))));

    for (int i=0;i<n+1;i++) {
      for (int j=0;j<n+1;j++) {
        for (int k=0;k<n*50+1;k++) {                
          if (i==0 and j==0 and k==0)dp[i][j][k]=1;
          else if (i>0 and k<x[i]) dp[i][j][k] = dp[i-1][j][k];
          else if (i>0 and j>0 and k-x[i]>=0) dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i]];
          else dp[i][j][k] = 0;
        }
      }
    }
    ll gross = 0;
    for (int i=1;i<n+1;i++) gross += dp[n][i][i*a];
    cout << gross << endl;
    return 0;
}

Measured memory_bytes: 52224
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int r;
	cin>>r;
	cout<<3*r*r;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define S second
#define F first
#define ll long long

using namespace std;

int main()
{
    int x1, y1, x2, y2, dx, dy;
    cin >> x1 >> y1 >> x2 >> y2;
    dy = y2 - y1;
    dx = x2 - x1;
    int x3 = x2 - dy;
    int y3 = y2 + dx;
    swap(dx, dy);
    dx *= -1;
    int x4 = x3 - dy;
    int y4 = y3 + dx;
    cout << x3 << " " << y3 << " " << x4 <<" "<<y4 << endl;
    return 0;
}


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

const ll MOD = 1e9+7;

template<int MOD> struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) v += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator += (const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator -= (const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator *= (const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator /= (const Fp& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
    return is >> x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
  friend constexpr Fp<MOD> modinv(const Fp<MOD> &a) noexcept {
    return modpow(a, MOD - 2);
  }
};

using mint = Fp<MOD>;

int N, K, M;
vector<vector<mint>> bit;

void add(int i, int a, mint w) {
  for (int x = a; x <= M; x += x & -x) bit[i][x] += w;
}

mint sum(int i, int a) {
  mint ret = 0;
  for (int x = a; x > 0; x -= x & -x) ret += bit[i][x];
  return ret;
}

int main () {

  cin >> N >> K;

  vector<int> r;
  stack<int> s;

  for(int i = 1;; ) {
    int j = N/(N/i) + 1;
    r.push_back(j - i);

    i = j;
    if(i > N) break;
  }

  M = r.size();
  bit = vector<vector<mint>>(K+1, vector<mint>(M+1, 0));

  for(int i = 0; i < M; i++) add(1, i+1, r[i]);

  for(int i = 1; i < K; i++) {
    for(int j = 0; j < M; j++) {
      add(i+1, j+1, sum(i, M-j)*r[j]);
    }
  }

  cout << sum(K, M) << endl;

  return 0;
}


Measured memory_bytes: 51196
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
   
    if(k%2==0){
        cout<<(a-b)<<endl;
    }
    else{
        cout<<(b-a)<<endl;
    }


    return 0;
}

Measured memory_bytes: 256