akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//3
		int m = sc.nextInt();//4
		int[][] list = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				list[i][j] = sc.nextInt();
			}
		}
		int[] list2 = new int[m];
		for (int i = 0; i < m; i++) {
				list2[i] = sc.nextInt();
		}
int ans;
		for(int i = 0; i < n; i++) {
			ans = 0;
			for(int j = 0; j < m; j++) {
				ans += list[i][j] * list2[j];
			}
			System.out.println(ans);
		}
	}
}



Measured memory_bytes: 41072
#include<stdio.h>
static const int A=100;
int min(int a, int b){ return a < b ? a : b; }
int main(){
  int i, j, r, l, y;
  int n, q[A+1], e[A+1][A+1];
  scanf("%d", &n);
  for (i=1;i<=n;i++){
    scanf("%d %d", &q[i-1], &q[i]);
  }

  for(i=1;i<=n;i++)e[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=0;i<=n-l+1;i++){
      j=i+l-1;
      e[i][j] = (1<<21);
      for(r=i;r<=j-1;r++){
	e[i][j]=min(e[i][j],e[i][r]+e[r+1][j]+q[i-1]*q[r]*q[j]);
	y=e[i][r]+e[r+1][j]+q[i-1]*q[r]*q[j];

      }
    }
  }



  printf("%d\n", e[1][n]);
  
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n, m, nr, dp[300], i, j, dpn[300], sum;
char lit[]={'A','C','G','T'};
map <string,int> harta;
char s[5];
bool eegal(string s2)
{
   if((s2[0]=='A'&&s2[1]=='C'&&s2[2]=='G')||(s2[1]=='A'&&s2[2]=='C'&&s2[3]=='G'))
    return 1;
   return 0;
}
bool valid(string s2)
{
    if(eegal(s2))
        return 0;
    for(int i=0;i<=2;i++)
        {
            swap(s2[i],s2[i+1]);
            if(eegal(s2))
            return 0;
            swap(s2[i],s2[i+1]);
        }
    return 1;
}
void primele_4()
{
    for(int i1=0;i1<4;i1++)
        for(int i2=0;i2<4;i2++)
            for(int i3=0;i3<4;i3++)
                for(int i4=0;i4<4;i4++)
    {
        char c1=lit[i1],c2=lit[i2],c3=lit[i3],c4=lit[i4];
        //string s;
        s[0]=c1,s[1]=c2,s[2]=c3,s[3]=c4;
        string s2=s;
        //cout<<s2<<' '<<nr<<'\n';
        //cout<<valid(s2)<<'\n';
        if(valid(s2))
        {
            nr++;
            harta[s2]=nr;
        }
    }
}
int main()
{
    primele_4();
    cin>>n;
    if(n==3)
    {
        cout<<61;
        return 0;
    }
    if(n==4)
    {
        cout<<nr;
        return 0;
    }
    map<string,int>::iterator it;
    for(it=harta.begin();it!=harta.end();it++)
        {
            dp[(it->second)]=1;
           // cout<<(it->second)<<' '<<(it->first)<<'\n';
        }
    for(j=5;j<=n;j++)
    {
        map<string,int>::iterator it;
        map<string,int>::iterator it2;
        for(it=harta.begin();it!=harta.end();it++)
            for(it2=harta.begin();it2!=harta.end();it2++)
            {
                string t1=(it->first);
                string t2=(it2->first);
                if(t2[1]==t1[0]&&t2[2]==t1[1]&&t2[3]==t1[2])
                    dpn[(it->second)]=(dpn[(it->second)]+dp[(it2)->second])%mod;
            }
        for(i=1;i<=nr;i++)
            dp[i]=dpn[i],dpn[i]=0;
    }
    for(i=1;i<=nr;i++)
    {
        sum=(sum+dp[i])%mod;
    }
    cout<<sum;
    //map<string,int>::iterator it;
    //for(it=harta.begin();it!=harta.end();it++)
      //  cout<<(it->second)<<' '<<(it->first)<<'\n';
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
    const int N=(int)1e5+100;
    const int M=(int)2e6+100;
    const int inf=(int)1e9+100;
#define filename ""
    pair<int,int> x[N];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n,i,a,b;
    cin>>n;
    fo(i,n)
    {
        cin>>a>>b;
        x[i]={a-b,b+a};
    }
    sort(x,x+n);
    int l=x[0].fi;
    int ans=0;
    fo(i,n)
    {
        if (x[i].fi>=l)
        {
            ans++;
            l=x[i].se;
        }
        else
        {
            l=min(l,x[i].se);
        }
    }
    cout<<ans;
}


Measured memory_bytes: 1024
from collections import Counter

if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    M = int(input())
    T = list(map(int, input().split()))

    counter_d = Counter(D)
    counter_t = Counter(T)

    ans = "YES"
    for point, num in counter_t.items():
        if counter_d.get(point) is None or counter_d.get(point) < num:
            ans = "NO"
            break

    print(ans)


Measured memory_bytes: 57056
#include <stdio.h>
void date_diff(int *a, int x) {*a=*a-x+1;}
bool cmp(int a, int b, int c, int x, int y, int z) {if (a!=x) return a>x;if (b!=y) return b>y;return c>=z;}
int main() {int y,m,d;while (scanf("%d %d %d",&y,&m,&d)!=EOF) {if (cmp(y,m,d,1989,1,8)) {printf("heisei");date_diff(&y,1989);} else if (cmp(y,m,d,1926,12,25) && !cmp(y,m,d,1989,1,8)) {printf("showa");date_diff(&y,1926);} else if (cmp(y,m,d,1912,7,30) && !cmp(y,m,d,1926,12,25)) {printf("taisho");date_diff(&y,1912);} else if (!cmp(y,m,d,1868,9,8)) {puts("pre-meiji");continue;} else {printf("meiji");date_diff(&y,1868);} printf(" %d %d %d\n",y,m,d);} return 0;}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll DP[55][3000];

int main() {
  ll N, A;
  cin>>N>>A;
  ll x[N];
  for(ll i=0;i<N;++i) {
    cin>>x[i];
    x[i] -= A;
  }
  DP[0][1500]++;
  DP[0][1500+x[0]]++;
  for(ll i=0;i<N-1;++i) {
    for(ll j=0;j<3000;++j) {
      DP[i+1][j] += DP[i][j] + DP[i][j-x[i+1]];
    }
  }
  cout<<DP[N-1][1500]-1<<endl;
}



Measured memory_bytes: 4724
from sys import stdin
 
def main():
    n,m = [int(x) for x in stdin.readline().split()]
    cards = [int(x) for x in stdin.readline().split()]
    cards.sort()
 
    bcs = [tuple(map(int,x.split())) for x in stdin.readlines()]
    bcs.sort(key=lambda x:x[1], reverse=True)
 
    ans = 0
    minIndex = 0
    isFinished = False
 
    for b,c in bcs:
 
        for _ in range(b):
            if minIndex < n and cards[minIndex] < c:
                ans += c
                minIndex += 1
            else:
                isFinished = True
                break
        
        if isFinished:
            break
 
    if minIndex < n:
        ans += sum(cards[minIndex:])
 
    print(ans)
    
if __name__=='__main__':
    main()

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

int main(){

	  while(1){
			int e; cin >> e;
			if(!e) break;
			/*
			int mini = e;
			for(int x=0; x<=e; x++){
				  for(int y=0; y*y<=e; y++){
						for(int z=0; z*z*z<=e; z++){
							  if(x + y*y + z*z*z == e)
									mini = min(mini,x+y+z);
						}

				  }
			}
			*/
			int mini = e;
			for(int z=0; z*z*z<=e; z++){
				  for(int y=0; z*z*z + y*y<=e; y++){
						int x = e - z*z*z - y*y;
						mini = min(mini,x+y+z);	
				  }
			}
			
			
			cout << mini << endl;

	  }

}

Measured memory_bytes: 1160
//#define DEB1 //output check function
//#define DEB2 //same output, input from input.txt

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VVI = vector<VI>;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


#ifdef DEB1
#define DPRINT(x) cout<< #x << "=" << (x) << endl; // print at debug mode
#else
#define DPRINT(x) ;
#endif
#ifdef DEB1
#define DCHECK(x) cout<< "debug check" << #x << endl;
#else
#define DCHECK(x) ;
#endif
 


/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9

// Main program
void solve(){
    string s;
    cin >> s;
    bool flag = 0;
    REP(i,3){
        if(s[i]==s[i+1]){
            flag = 1;
        }
    }
    (flag)? cout << "Bad" << endl : cout << "Good" << endl;


}



// ----------------------------------------------
int main() {

#ifdef DEB2
    cout << "DEBUG MODE"  << endl;
	ifstream in("input.txt"); //for debug
	cin.rdbuf(in.rdbuf()); //for debug
#endif

	int T=1; 

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

const int INF = 1e9;

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

    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    REP(i, R) {
        int rr;
        cin >> rr;
        r[i] = rr - 1;
    }
    vector<vector<int>> dist(N, vector<int>(N, INF));
    REP(i, N) dist[i][i] = 0;
    REP(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        A--; B--;
        dist[A][B] = dist[B][A] = C;
    }
    REP(k, N) REP(i, N) REP(j, N) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    vector<vector<int>> dp(1 << R, vector<int>(R, INF));
    REP(i, R) dp[1 << i][i] = 0;
    REP(S, 1 << R) {
        REP(i, R) {
            if (S >> i & 1 == 0) continue;
            REP(j, R) {
                dp[S | 1 << j][j] = min(dp[S | 1 << j][j], dp[S][i] + dist[r[i]][r[j]]);
            }
        }
    }
    int ans = INF;
    REP(i, R) ans = min(ans, dp[(1 << R) - 1][i]);
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main() {
  LL H, W, N;
  cin >> H >> W >> N;
  map<LL,int> m;
  int dy[] = {-2, -2, -2, -1, -1, -1, 0, 0, 0};
  int dx[] = {-2, -1, 0, -2, -1, 0, -2, -1, 0};
  REP(i, N) {
    LL A, B;
    cin >> A >> B;
    --A; --B;
    REP(j, 9) {
      LL y = A + dy[j], x = B + dx[j];
      if(y >= 0 && y < H-2 && x >= 0 && x < W-2) {
        m[y * W + x]++;
      }
    }
  }
  LL ret[10] = {(H-2)*(W-2)};
  for(const auto& p : m) {
    ret[p.second]++;
    ret[0]--;
  }
  REP(i, 10) {
    cout << ret[i] << endl;
  }
}

Measured memory_bytes: 56448
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
       Scanner sc=new Scanner(System.in);
       String str=sc.next();
       if(str.charAt(str.length()-1)=='s')
    	   System.out.println(str+"es");
       else
    	   System.out.println(str+"s");
	}

}


Measured memory_bytes: 38592
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
	double L;
	cin >> L;

	double edge = L / 3;
	double ans = edge * edge * edge;



	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>

using namespace std;

int sum(int n) {
	if (n == 1)return 1;

	return n + sum(n - 1);
}

int main() {
	long long int h;
	cin >> h;
	queue<long long int> q;
	q.push(h);
	long long int count = 0;
	int i = 0;
	while (!(q.empty())) {
	
		long long int a = q.front();
		q.pop();
		if (a == 1) {
			i++;
			continue;
		}
		q.push(a / 2);
		i++;
	}
	count = 1;
	for (int j = 0; j < i; j++) {
		count *= 2;
	}
	cout << count-1 << endl;
	return 0;
}



Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	L = [[0] * 10 for i in range(10)]
	for i in range(1, N + 1):
		A = str(i)
		x = int(A[0])
		y = int(A[-1])
		L[x][y] += 1
	
	ans = 0
	for i in range(1, 10):
		for j in range(1, 10):
			ans += L[i][j] * L[j][i]

	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 40940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    V<> a(n);
    REP(i,n) cin >> a[i];
    sort(rall(a));
    ll res = 0;
    queue<int> q;
    REP(i,n){
        q.push(a[i]);
        if(i) q.push(a[i]);
        if(i){
            res += q.front();
            q.pop();
        }
    }
    cout << res << endl;
}

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

ll howmanytimes(ll x){
    ll count =0;
    ll sum =0;
    while(x>1){
        x/=2;
        count++;
    }
    for(ll i=0;i<count;i++){
        sum += pow(2,i);
    }
    return pow(2,count)+ sum;
}


int main() {
    ll H;
    cin >>H;
    ll a=howmanytimes(H);
    cout <<a<<endl;
}

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

const int N = 55;
const long long inf = 2e18;

string s[N];
int c[N], n;
long long dp[N][22][22][2];

long long yo(int k, int st, int en, int f) {
	string nw = s[k].substr(st, en - st + 1);
	string tmp(nw.rbegin(), nw.rend());
	long long &ans = dp[k][st][en][f];
	if (nw == tmp) return ans = 0;
	if (ans != -1) return ans;
	ans = inf;
	for (int i = 1; i <= n; i++) {
		int sz = min(en - st + 1, (int)s[i].size());
		if (f) {
			string X = s[k].substr(st, sz);
			string Y = s[i].substr((int)s[i].size() - sz);
			reverse(Y.begin(), Y.end());
			if (X == Y) {
				long long cur = c[i];
				if (en - st + 1 > sz) {
					cur += yo(k, st + sz, en, 1);
				}
				if (s[i].size() > sz) {
					cur += yo(i, 0, (int)s[i].size() - sz - 1, 0);
				}
				ans = min(ans, cur);
			}
		}
		else {
			string X = s[k].substr(en - sz + 1, sz);
			string Y = s[i].substr(0, sz);
			reverse(X.begin(), X.end());
			if (X == Y) {
				long long cur = c[i];
				if (en - st + 1 > sz) {
					cur += yo(k, 0, en - sz, 0);
				}
				if (s[i].size() > sz) {
					cur += yo(i, sz, (int)s[i].size() - 1, 1);
				}
				ans = min(ans, cur);
			}
		}
	}
	return ans;
}
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	long long ans = inf;
	for (int i = 1; i <= n; i++) {
		cin >> s[i] >> c[i];
	}
	memset(dp, -1, sizeof dp);
	for (int i = 1; i <= n; i++) {
		ans = min(ans, 1LL * c[i] + yo(i, 0, (int)s[i].size() - 1, 0));
		ans = min(ans, 1LL * c[i] + yo(i, 0, (int)s[i].size() - 1, 1));
	}
	if (ans == inf) ans = -1;
	cout << ans << '\n';
    return 0;
}

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

int main() {
  int N;
  double bunbo=0;
  cin >> N;
  for(int i=0;i<N;i++){
    double A;
    cin >> A;
    bunbo += double(1/A);
  }
   
  cout << double(1/bunbo) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	cin>>k;
	int sum = 0;
	for(int i = 1; i <= k; i++){
		for(int j = 1; j <= k; j++){
			for(int z = 1; z <= k; z++){
				int gcd = __gcd(i,j);
				gcd = __gcd(gcd, z);
				sum += gcd;
			}
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include <math.h>
#include<map>
using namespace std;

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

	int a,b,c;
	cin >> a >> b >> c;

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

	return 0;

}

Measured memory_bytes: 256
#include<complex>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<iostream>
#include<queue>
using namespace std;
#define fr first
#define sc second

struct line: public vector< complex<double> >{
  line(){};
  line( const complex<double>& a, const complex<double>& b){
    push_back(a);
    push_back(b);
  }
};
struct circle {
  complex<double> p; double r;
  circle():p(0,0),r(0){};
  circle(const complex<double> &p, double r) : p(p),r(r){}
};

typedef complex < double > P;
typedef line               L;
typedef vector< L >        LLL;
typedef vector< P >        Ps;
typedef circle             C;
const double EPS = 1e-9;
const double INF = 1e8;

double cross( P a, P b){
  return imag( conj(a) * b);
}
double dot( P a, P b){
  return real( conj(a) * b);
}
int ccw( P a, P b, P c){
  b -= a, c -= a;
  if(cross(b,c) > EPS)    return 1;  // a → b で 時計方向におれて c
  if(cross(b,c) < -EPS)    return -1; // a → b で 反時計方向におれて c
  if(dot(b,c) < -EPS)      return 2;  // c -- a -- b
  if(norm(b) < norm(c) - EPS) return -2; // a -- b -- c
                        return 0;  // a -- c -- b
}
bool intersect( L a, L b){
  return ccw( a[0], a[1], b[0]) * ccw( a[0], a[1], b[1]) <= 0 &&
    ccw( b[0], b[1], a[0]) * ccw( b[0], b[1], a[1]) <= 0;
}
Ps crosspoint(C c1, C c2){
  double d = abs(c1.p - c2.p);
  double s = (c1.r + c2.r + d) / 2;
  double S = sqrt( s * ( s - c1.r) * ( s - c2.r) * ( s - d));
  double h = 2 * S / d;
  P v = ( c2.p - c1.p) / ( abs( c2.p - c1.p));
  double m = sqrt( c1.r * c1.r - h * h);
  Ps ret;
  ret.push_back( c1.p + m * v + h * v * P(0,1));
  ret.push_back( c1.p + m * v - h * v * P(0,1));
  return ret;
}
struct dC{
  double cost;
  P pos;
  int nowi,nowj;
  bool operator < (const dC &left) const {
    return cost > left.cost;
  }
};
L make_2_cross(C c1, C c2){
  Ps a(crosspoint( c1, c2));
  return L( a[0], a[1]);
}

int main(){
  C prev, now;
  int n;

  while(cin >> n , n){
    LLL ls;

    cin >> prev.p.real() >> prev.p.imag() >> prev.r;
    ls.push_back( L( prev.p, prev.p));

    for(int i = 1 ; i < n ; i++ ){
      cin >> now.p.real() >> now.p.imag() >> now.r;
      ls.push_back( make_2_cross( prev, now));
      prev = now;
    }
    ls.push_back( L( prev.p, prev.p)); // G

    priority_queue< dC > que;
    que.push((dC){ 0, ls[0][0], 0, 0});
    bool used[101][2] = {{}};
    double ret = INF;
    while(!que.empty()){
      dC p = que.top();
      que.pop();
      if(p.nowj == n){
        ret = p.cost;
        break;
      }
      if(used[p.nowj][p.nowi]++) continue;
      for(int i = 0 ; i < 2 ; i++ ){
        for(int j = p.nowj + 1 ; j <= n ; j++ ){
          L l = L( p.pos, ls[j][i]);
          bool flag = true;
          for(int k = j - 1 ; k > p.nowj ; k-- ){
            if(!intersect( l, ls[k])){
              flag = false;
              break;
            }
          }
          if(flag) que.push( (dC){ abs( l[0] - l[1]) + p.cost, l[1], i, j});
        }
      }
    }
    cout << fixed << setprecision(7) << ret << endl;
  }
}

Measured memory_bytes: 1364
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Five_Count = 0;
		int Thousand_Count = 0;
		int num = 0;
		for(int i = 0;i < X;i++) {
			num = X % 500;
			Thousand_Count = X / 500;
			Five_Count = num / 5;
		}
		System.out.println(Thousand_Count * 1000 + Five_Count * 5);
	}
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll h,w,cnt,flag;
    cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,h) rep(j,w) cin >> a[i][j];
    vector<ll> remh(h,0),remw(w,0);
    rep(i,h){
        cnt = 0;
        rep(j,w){
            if(a[i][j]=='.') cnt++;
        }
        if(cnt==w) remh[i] = 1;
    }
    rep(i,w){
        cnt = 0;
        rep(j,h){
            if(a[j][i]=='.') cnt++;
        }
        if(cnt==h) remw[i] = 1;
    }
    rep(i,h){
        if(remh[i]==1) continue;
        rep(j,w){
            if(remw[j]==0) cout << a[i][j];
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        out.println(in.s().contains("7") ? "Yes" : "No");
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 25352
# coding: utf-8

# In[9]:


import numpy as np


# In[22]:


N,T = map(int, input().split())
data = []
for _ in range(N):
    c,t = map(int, input().split())
    data.append([c, t])
data = np.array(data)


# In[23]:


if data[data[:,1] <= T].any():
    print(min(data[data[:,1] <= T][:,0]))
else:
    print("TLE")



Measured memory_bytes: 12492
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		long ans = solve();
		System.out.println(ans);
	}

	public static long solve() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[][] dist = new int[n][n];
		boolean[][] path = new boolean[n][n];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				int item = sc.nextInt();
				dist[i][j] = item;
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == j) continue;
				path[i][j] = true;
			}
		}

		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (i == j || k == i || k == j) continue;
					if (dist[i][j] > dist[i][k] + dist[k][j]) {
						return -1;
					}
					if (dist[i][j] == dist[i][k] + dist[k][j]) {
						path[i][j] = path[j][i] = false;
					}
				}
			}
		}

		long total = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (path[i][j] == true) total += dist[i][j];
			}
		}
		return total / 2;
	}
}

Measured memory_bytes: 51692
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

typedef struct{
  char suit;
  int value;
}Card;

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

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

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

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

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

  return i + 1;
}

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

int main(){
  int n, i, v;
  Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%s %d",S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

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

  for(i = 0; i < n; i++){
    //マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable == 1) printf("Stable\n");
  else printf("Not stable\n");
  for(i = 0; i < n; i++) printf("%c %d\n",B[i].suit, B[i].value);

  return 0;
}



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

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

  int n, m, c;
  cin >> n >> m >> c;

  int b[m];
  int a[n][m];

  for (int i = 0; i < m; ++i) cin >> b[i];
  for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin >> a[i][j];

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int sum = 0;
    for (int j = 0; j < m; ++j) sum += a[i][j] * b[j];
    if (sum + c > 0) ++ans;
  }

  cout << ans << '\n';

  return (0);
}

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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;

main(){
	int n;
	cin >> n;
	
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(i%3!=0 && i%5!=0){
			ans += i;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <vector>
#include <list>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#include <math.h>

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b)*c / 2<<endl;
	return 0;
}

Measured memory_bytes: 764
def main():
    from itertools import product
    import numpy as np

    H,W,K = map(int, input().split())
    S = (np.array([list(map(int,list(input()))) for _ in range(H)]).T).tolist()

    if sum(sum(s) for s in S)<=K:
        print(0)
    else:
        answer = (H-1) * (W-1)
        for X in product([False,True], repeat=H-1):
            ans = np.sum(X)
            if ans >= answer:
                continue
            M = [[0]]
            for i, x in enumerate(X):
                if x:
                    M.append([])
                M[-1].append(i+1)
            D = [0]*len(M)
            for s in S:
                for k, m in enumerate(M):
                    D[k] += sum(s[i] for i in m)
                if any(d > K  for d in D):
                    ans += 1
                    if ans >= answer:
                        break
                    for k, m in enumerate(M):
                        D[k] = sum(s[i] for i in m)
                    
                    if any(d > K for d in D):
                        ans = answer + 1
                        break

            answer = min(answer,ans)

        print(answer)

main()

Measured memory_bytes: 12604
data class Move(val y: Int, val x: Int, var ny: Int, var nx: Int)

fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map { it.toInt() }
    val table = listOf<MutableList<Int>>().toMutableList()
    (1..H).forEach {
        table.add(readLine()!!.split(" ").map { it.toInt() }.toMutableList())
    }

    var reverse = false
    var move : Move? = null
    table.forEachIndexed { y, row ->
        val range = if (reverse) {
            row.size - 1 downTo 0
        } else {
            0..(row.size - 1)
        }

        for (x in range) {
            if (move != null) {
                move!!.ny = y
                move!!.nx = x
                operate(table, move!!)
                move = null
            }

            val value = row.get(x)
            val isOdd = value.mod(2) == 1
            if (isOdd) {
                move = Move(y, x, -1, -1)
            } else {
                move = null
            }
        }

        println(" ")
        reverse = !reverse
    }

    printResult()
}

val movements = listOf<Move>().toMutableList()
fun operate(table: MutableList<MutableList<Int>>, move: Move) {
    val pointVal = table.get(move.y).get(move.x)
    table.get(move.y).set(move.x, pointVal - 1)
    val newPointVal = table.get(move.ny).get(move.nx)
    table.get(move.ny).set(move.nx, newPointVal + 1)
    movements.add(move)
}

fun printResult() {
    println(movements.size)
    movements.forEach {
        println("${it.y + 1} ${it.x + 1} ${it.ny + 1} ${it.nx + 1}")
    }
}


Measured memory_bytes: 61036
// C - Train Ticket
#include <stdio.h>
#include <string.h>

int main(void){
    char abcd[4], op[3];
    int abcdInt[4], i, j, sum;
    scanf("%s", abcd);
    for(i=0; i<4; i++){
        abcdInt[i] = abcd[i]-'0';
    }
    for(i=0; i<(1<<4); i++){
        sum=abcdInt[0];
        for(j=0; j<3; j++){
            if(i & (1<<j)){
                op[j]='+';
                sum+=abcdInt[j+1];
            }else{
                op[j]='-';
                sum-=abcdInt[j+1];
            }
        }
        if(sum==7) break;
    }

    for(i=0; i<3; i++){
        printf("%d%c", abcdInt[i], op[i]);
    }
    printf("%d=7\n", abcdInt[3]);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, T;
  cin >> S >> T;

  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i)) {
      cnt++;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>


using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);

}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
struct edge { int to, cost; };
std::vector<edge>v[100];
bool u[100];


int main() {
	std::string s;
	std::cin >> s;
	ll ans = 0;
	for (int i = 0;i < s.size();i++) {
		for (int j = 0;i + j < s.size();j++) {
			if (i + j == s.size() - 1) {
				ans += (s[i] - '0')*pow(10, j)*pow(2, s.size() - j - 1);
			}
			else {
				ans += (s[i] - '0')*pow(10, j)*pow(2, s.size() - j - 2);
			}
		}
	}
	std::cout << ans << std::endl;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong N, cnt, before;
	vector<llong> A;

	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}

	multiset<llong> ans;
	ans.insert(-1);
	for (int i = 0; i < N; ++i) {
		auto it = ans.lower_bound(A[i]);
		if (it == ans.begin()) {
			ans.insert(A[i]);
		} else {
			--it;
			ans.erase(it);
			ans.insert(A[i]);
		}
	}

	cout << ans.size() << endl;

	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define MAXN 50
using namespace std;
typedef long long ll;
int n,flag;
int a[MAXN+1],b[MAXN+1];
int dp[MAXN];
long long ans;
bool solve(ll ans)
{
    for(int i=1;i<=n;i++)
    {
        if(a[i]==b[i])
        {
            continue;
        }
        flag=0;
        memset(dp,0,sizeof(dp));
        dp[a[i]]=1;
        for(int j=a[i];j>=0;j--)
        {
            if(((1ll<<j)&ans)>0)
            {
             //   printf(" a %d\n",j);
                for(int k=a[i];k>=0;k--)
                {
                    if(dp[k])
                    {
                        dp[k%(j+1)]=1;
                        if((k%(j+1))==b[i])
                        {
                            flag=1;
                        }
                    }
                }
            }
        }
        if(!flag)
        {
        //    printf("%d\n",i);
            return 0;
        }
    }
    return 1;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&b[i]);
    }
    ans=(1ll<<MAXN)-1;
    if(!solve(ans))
    {
        printf("-1");
        return 0;
    }
    for(int i=MAXN-1;i>=0;i--)
    {
        //printf("%lld\n",ans);
        ans^=1ll<<i;
        if(!solve(ans))
        {
            ans^=1ll<<i;
        }
    }
    printf("%lld\n",ans<<1);
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    n, q = read_h()
    s, = read_h(typ=str)
    rng = read_v(q, m=2)

    cnts = [0] * (n + 1)
    for i in range(len(s)):
        cnts[i + 1] = cnts[i] + (1 if s[i:i + 2] == 'AC' else 0)

    for l, r in rng:
        print(cnts[r - 1] - cnts[l - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 32312
#include<iostream> 
using namespace std;
int main()
{
	long long n,x;
	while(cin>>n>>x)
{
		long long a[100005]={0},count=0,aa,b;
		for(int i=0;i<n;i++){
		cin>>aa;
		if(aa>x){
			count+=aa-x;
			a[i]=x;
		}else{
			a[i]=aa;
		}
	}for(int i=1;i<n;i++){
		b=a[i]+a[i-1];
		if(b>x){
			count+=b-x;
			a[i]-=b-x;
		}
	}cout<<count<<endl;
		
}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

int main(){
	int N;
	int pt=0,px=0,py=0;
	std::cin>>N;

	for(int i=0;i<N;++i){
		int t,x,y;
		std::cin>>t>>x>>y;
		if((t-pt)-(x-px)-(y-py) < 0 
			|| ((t-pt)-(x-px)-(y-py))%2 == 1){
			std::cout<<"No";
			return 0;
		}	
	}
	std::cout<<"Yes";
	return 0;
}


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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbeginq(), v.rend()
const ll INF =  0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX = 1e5+5;

int n;
int a[2][105];
int dp[2][105];

int solve(int i, int j){
    if(j == n)
        return 0;
    int ans = a[i][j];
    if(i == 0)
        return ans + max(solve(i+1, j) , solve(i, j+1));
    else
        return ans + solve(i, j+1);
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(false);
    scanf("%d" , &n);
    for(int i = 0 ; i < n ; i++){
        scanf("%d" , &a[0][i]);
    }
    for(int i = 0 ; i < n ; i++){
        scanf("%d" , &a[1][i]);
    }

    printf("%d" , solve(0, 0));

    return 0;
}


Measured memory_bytes: 256
def main():
  n = int(input())
  ans = 100000
  for i in range(1, (n+2)//2):
    r = (n-i)//10000 + ((n-i)//1000)%10 + ((n-i)//100)%10 + ((n-i)//10)%10 + (n-i)%10 
    l = i//10000 + (i//1000)%10 + (i//100)%10 + (i//10)%10 + i%10
    ans = min(ans, r + l)
  print(ans)
  
if __name__ == '__main__':
  main()
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  int N,M,X,Y,cnt=0,Z=-100;
  cin>>N>>M>>X>>Y;
  int x[N],y[N];
  
  for(int i=0;i<N;i++){
    cin>>x[i];
    Z=max(Z,x[i]);
  }
  
  Z++;
  
  for(int i=0;i<M;i++){
    cin>>y[i];
    if(y[i]<Z){
      cnt++;
      break;
    }
  }
  
  if(Z>Y) cnt++;
  if(Z<=X) cnt++;
  
  if(cnt==0) cout<<"No War"<<endl;
  else cout<<"War"<<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
double dp[2][6005];
int qwq=3000;
int main(int argc, char** argv) {
	int n;
	cin >> n;
	dp[0][qwq]=1;
	for(int i=1;i<=n;i++)
	{
		double p;
		cin >> p;
		for(int j=1;j<=6000;j++)
			dp[i&1][j]=0;
		for(int j=1;j<=6000;j++)
			dp[i&1][j+1]+=dp[i&1^1][j]*p;
		for(int j=1;j<=6000;j++)
			dp[i&1][j-1]+=dp[i&1^1][j]*(1.0-p);
	}
	double ans=0;
	for(int i=qwq+1;i<=6000;i++)
		ans+=dp[n&1][i];
	printf("%.20lf",ans); 
	return 0;
}

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

using namespace std;

int main(){
    int N,res=0;
    string s;
    cin>>N>>s;

    for(int i=1;i<N;i++){
        vector<int> l(26);
        vector<int> r(26);
        for(int j=0;j<N;j++){
            if(j<i)
                l[s[j]-'a']++;
            else
                r[s[j]-'a']++;

            int cnt=0;
            for(int k=0;k<26;k++){
                if(l[k]>0&&r[k])
                    cnt++;
            }
            res = max(res,cnt);
        }
    }
    cout<<res;
}


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

int nt[10];

bool check(int x){
   while(x){
      if(nt[x%10]) return false;
      x/=10;
   }
   return true;
}


int main(){
   //ios_base::sync_with_stdio(0);
   //cin.tie(0);

   int n;
   cin >> n;
   int k; cin >> k;

   for(int i = 0, x; i<k; ++i) {
      cin >> x;
      nt[x] = 1;
   }


   for(int i = n; ; ++i)
      if(check(i)) return !printf("%d\n", i);



   return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
k = {}
for i in range(M):
  p,s = input().split()
  if p not in k:
    k[p] = [s]
  else:
    k[p].append(s)
ac = 0
wa = 0
for l in k:
  now = 0
  for m in k[l]:
    if m == "WA":
      now += 1
    elif m == "AC":
      ac += 1
      wa += now
      break
print(ac,wa)


Measured memory_bytes: 30156
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
    int k,x;cin >> k >> x;
    if(500*k >= x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	 int c[100];
	int a[100][100],b[100],d,k,j,n,m,i,x;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		for(x=0;x<m;x++){
			scanf("%d",&a[i][x]);
		}
	}
	for(j=0;j<m;j++){
		scanf("%d",&b[j]);
	}
	
	for(k=0;k<n;k++){
		for(d=0;d<m;d++){
			if(d==0){
				c[k]=0;
			}
			c[k]+=a[k][d]*b[d];
		
		}
		printf("%d\n",c[k]);
	}
	return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct RootedTree {
    RootedTree(int n, int root = 0) :
            mRoot(root) {
        mVertexTbl.resize(n);
    }

    void addEdge(int a, int b, long long int cost = 1) {
        mVertexTbl[a].child.push_back(pair<int, long long int>(b, cost));
        mVertexTbl[b].child.push_back(pair<int, long long int>(a, cost));
    }

    void build() {
        queue<tuple<int, int, long long int>> q;
        q.push(make_tuple(mRoot, -1, 0));
        while (!q.empty()) {
            auto t = q.front();
            q.pop();
            int index = get<0>(t);
            int parent = get<1>(t);
            long long int depth = get<2>(t);
            mVertexTbl[index].parent = parent;
            mVertexTbl[index].depth = depth;
            for (auto it = mVertexTbl[index].child.begin(); it != mVertexTbl[index].child.end();) {
                int nxt = (*it).first;
                if (nxt == parent) {
                    mVertexTbl[index].child.erase(it);
                    continue;
                }
                q.push(make_tuple(nxt, index, depth + (*it).second));
                ++it;
            }
        }
    }

    struct Vertex {
        vector<pair<int, long long int>> child;
        long long int depth = 0;
        int parent = -1;
        ll count = 0;
    };

    int mRoot;
    vector<Vertex> mVertexTbl;
};

ll dp[100005][3];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    RootedTree tree(N);
    REP(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        tree.addEdge(a, b);
    }
    tree.build();
    queue<ll> q;
    REP(i, N) {
        dp[i][0] = dp[i][1] = 1;
        if (tree.mVertexTbl[i].child.size() == 0)
            q.push(i);
    }

    while (!q.empty()) {
        ll t = q.front();
        q.pop();
        for (auto &v:tree.mVertexTbl[t].child) {
            dp[t][0] *= (dp[v.first][0] + dp[v.first][1]);
            dp[t][0] %= MOD;
            dp[t][1] *= dp[v.first][0];
            dp[t][1] %= MOD;
        }
        ll p = tree.mVertexTbl[t].parent;
        if (p >= 0) {
            if (++tree.mVertexTbl[p].count == tree.mVertexTbl[p].child.size())
                q.push(p);
        }
    }

    cout << (dp[0][0] + dp[0][1]) % MOD << endl;
    return 0;
}

Measured memory_bytes: 13680
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long 
#define ld long double
int main()
{
	ll n, k;
	cin >> n >> k;
	ll a[1000001];
	for (ll i = 0; i < n; i++)
	{
		ll x, y;
		cin >> x >> y;
		a[x - 1] += y;
	}
	ll f = k;
	for (ll i = 0; i < f; i++) {
		k -= a[i];
		if (k <= 0) {
			cout<<i+1<<endl; break;
		}
	}
	return 0;
}

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

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

const double PI = 2 * acos(0);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pipii;
typedef long double ld;
typedef vector<vector<ll>> matrix;

ll l[105];

int main() {
  int n;
  ll s;
  scanf("%d%lld", &n, &s);
  for(int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }
  int r = 0;
  sort(l, l+n);
  for(int i = 0; i < n; i++) {
    if(l[i] <= s) {
      s -= l[i];
      r++;
    }
  }
  if(r == n && s) r--;
  printf("%d\n", r);
}


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

ans=0
m_cnt=0
min_abs=10**18
for i in a:
    if i<0:
        m_cnt+=1
    tmp=abs(i)
    ans+=tmp
    min_abs=min(min_abs, tmp)
if m_cnt%2==0:
    print(ans)
else:
    print(ans-2*min_abs)

Measured memory_bytes: 14284
#include<stdio.h>
int main(void){
  int N;
  int i;
  int j=-1;
  scanf("%d",&N);
  for(i=1;i<=9;i++){
    if(N % i == 0){
      if(1<=N/i && N/i<=9){
        j=0;
        break;
      }
    }
  }
  if(j==0)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define MI          map<int, int>
#define PI          pair<int, int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
ll dp[N][2];
VI g[N];
void dfs(int u, int par=-1){
    dp[u][0]=1;//black
    dp[u][1]=1;//white
    for(auto v: g[u]){
        if (v!=par){
            dfs(v, u);
            dp[u][0] = (dp[u][0]*dp[v][1])%mod;
            dp[u][1] = (dp[u][1] * ( dp[v][0]+dp[v][1])%mod)%mod;
        }
    }
}
int main(){
    int n;sc(n);
    fr(i, 1, n-1){
        int u, v;sc(u);sc(v);
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1);
    lpr((dp[1][0] + dp[1][1])%mod);n_l;
    return 0;
}



Measured memory_bytes: 36992
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define N 1000011
#define LL long long
LL n;
LL f[N],sum[N];
int main(){
	scanf("%lld",&n);
	f[0]=1;
	f[1]=n;f[2]=n*n%MOD;
	sum[1]=f[1]+1;sum[2]=(f[1]+f[2]+1)%MOD;sum[0]=f[0]=1;
	for(int i=3;i<=n;i++){
		f[i]=((f[i-1]+sum[i-3])%MOD+(n-1)*(n-1)%MOD+(n-i+1))%MOD;
		sum[i]=(sum[i-1]+f[i])%MOD;
	}
	printf("%lld\n",f[n]);
}


Measured memory_bytes: 15872
import sys
import bisect
input = sys.stdin.readline

N, T = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]

c = 10 ** 18
for v in L:
    if c > v[0] and v[1] <= T:
        c = v[0]
        
if c == 10 ** 18:
    print("TLE")
else:
    print(c)

Measured memory_bytes: 3064