akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#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
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;

int main() {
    int N, K;
    cin>>N>>K;
    map<int, int> amap;
    int d;
    int A;
    for(int i=0;i<K;++i){
        cin>>d;
        for(int j=0;j<d;++j){
            cin>>A;
            amap[A]++;
        }
    }
    int ans = 0;
    for(int i=1;i<=N;++i){
        if(amap[i]==0)ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int n;
	cin >> n;
	cout << n*n*n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

void abc_170a();

void abc_171a();

void abc_172a();

void abc_173a();

void abc_174a();

int main()
{
  //abc_170a();
  //abc_171a();
  //abc_172a();
  //abc_173a();
  abc_174a();

}

void abc_170a()
{
  vector<int> x(5);
  for (int i = 0; i < 5; ++i) cin >> x[i];

  for (int i = 0; i < 5; ++i)
  {
    if (x[i] == 0)
    {
      cout << i + 1 << "\n";
      return;
    }
  }
}


void abc_171a()
{
  char c;
  cin >> c;

  if (c == tolower(c)) cout << "a\n";
  else cout << "A\n";
}

void abc_172a()
{
  int a;
  cin >> a;

  cout << a + a * a + a * a * a << "\n";
}

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

  if (N % 1000) cout << 1000 - N % 1000 << "\n";
  else cout << "0\n";
}

void abc_174a()
{
  int x;
  cin >> x;

  if (x >= 30) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
	int num_K;
	char str_S[101];
	int i;
	int word_count;

	scanf("%d", &num_K);
	scanf("%s", str_S);

	word_count = 0;

	for (i = 0; str_S[i] != '\0'; i++)
	{
		word_count++;
	}

	if (word_count > num_K)
	{
		for (i = 0; i < num_K; i++)
		{
			printf("%c", str_S[i]);
		}

		printf("...\n");
	}
	else
	{
		printf("%s\n", str_S);
	}

	return 0;
}

Measured memory_bytes: 1600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bs binary_search
#define pb push_back
#define pp pair<int,int>
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
int main()
{
    fastio
    ll n,k,s=0,i; cin>>n>>k; ll a[n];
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(i=0;i<k;i++) s+=a[i];
    cout<<s;
    return 0;
}

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

long long h,w,num1,num2,ans;
char mat[405][405];
bool vis[405][405];

void dfs(int x,int y){
    
    if(mat[x][y]=='.')num1++;
    else num2++;
    
    vis[x][y]=true;
    
    if(x-1>=0 && vis[x-1][y]==false && mat[x-1][y]!=mat[x][y])dfs(x-1,y);
    if(x+1<h && vis[x+1][y]==false && mat[x+1][y]!=mat[x][y])dfs(x+1,y);
    if(y-1>=0 && vis[x][y-1]==false && mat[x][y-1]!=mat[x][y])dfs(x,y-1);
    if(y+1<w && vis[x][y+1]==false && mat[x][y+1]!=mat[x][y])dfs(x,y+1);
}


int main(){

	cin>>h>>w;
	
	for(int i=0;i<h;i++){
	    for(int j=0;j<w;j++){
	        cin>>mat[i][j];
        }
    }
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(vis[i][j]==false){
                num1=num2=0;
                dfs(i,j);
                ans+=num1*num2;
                
                //cout<<num1<<" "<<num2<<endl;
            }
        }
    }
    
    cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 15488
#MLE注意！ not は使わず !=

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    import math
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = math.pi
    print(2*n*a)

if __name__ == '__main__':
    main()

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

int main(){
    int N=0,K=0;
    cin>>N;

    int C=4,D=7;

    int Ctmp=4,Dtmp=7;
    int tmp=0;

    for(Ctmp=4;Ctmp<=N;Ctmp+=C){
        for(Dtmp=0;Dtmp+Ctmp<=N;Dtmp+=D){
            if(Dtmp+Ctmp==N){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }

    for(Dtmp=7;Dtmp<=N;Dtmp+=D){
        for(Ctmp=0;Dtmp+Ctmp<=N;Ctmp+=C){
            if(Dtmp+Ctmp==N){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }




    cout<<"No"<<endl;

}

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

int main(){
	int n, n1, dig, sum, i;	
  	cin >> n;
  	n1 = n;
  
  	while(n){
    	dig = n%10;
      	sum += dig;
      	n /= 10;
    }
  	if(n1 % sum == 0) cout << "Yes" << endl;
  	else cout << "No" << endl;
  	return 0;
}

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

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

ll n;

int main(){
  cin>>n;
  ll ans=n/3;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

//clang++ -std=c++11 -stdlib=libc++ 
int main() {
  int N; cin>>N;
  map<ii, int> mp;
  auto make = [](int num) {
    int l = num%10;
    int h;
    while (num>0) {
      h=num;
      num/=10;
    }
    return ii(h,l);
  };

  for (int i=1; i<=N;i++) {
    ii p = make(i);
    mp[p]++;
  }

  ll ans = 0;
  for (int i=1; i<=N; i++) {
    ii p = make(i);
    ii q = ii(p.second, p.first);
    ans += mp[q];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const ll mod=1e9+7;
const ll sze=1e5+2;
int main(){
 string s,t;
 cin>>s>>t;
 cout<<t<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>
#include <set>



int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    
    int n; std::cin >> n;
    std::vector<int> A(n); for(auto& itr : A) std::cin >> itr;
    std::vector<long long int> dp(n + 1, 0);
    dp[0] = 1000;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j) if(A[i] < A[j]){
            const long long int res = (dp[i] / A[i]) * A[j] + (dp[i] % A[i]);
            if(res > dp[j]) dp[j] = res;
        }
        if(dp[i] > dp[i + 1]) dp[i + 1] = dp[i];
    }
    std::cout << dp[n] << '\n';



    
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (W >= x + r && x - r >= 0 && H >= y + r && y - r >= 0){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
import copy
N=int(input())
X=list(map(int,input().split()))
Y=copy.deepcopy(X)
Y.sort()
kiteichiA=Y[N//2-1]
kiteichiB=Y[N//2]
for i in range(N):
    if X[i]>=kiteichiB:
        print(kiteichiA)
    elif X[i]<=kiteichiA:
        print(kiteichiB)



Measured memory_bytes: 26724
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath> 
using namespace std; 
int main()
{ 
	int k, s;   

	cin >> k >> s;
	int ans = 0;
	for (int i = 0; i <=k ; i++)
	{
		for (int j=0;j<=k;j++)
		{
			 
			int p = s - i-j; 
			if (0<=p&&p<=k)
			{
				ans++;
			}


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

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

int main() {
  char str;
  
  cin >> str;
  if(str == 'A') cout << "T";
  else if(str == 'T') cout << "A";
  else if(str == 'C') cout << "G";
  else if(str == 'G') cout << "C";
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[][] A = new int[M][4];

		for(int i = 0 ; i < M ; i++){
			A[i][0] = Integer.parseInt(sc.next());
			A[i][1] = Integer.parseInt(sc.next());
			A[i][2] = i;
			A[i][3] = 1;
		}

		sc.close();
		for(int i = 0 ; i < M ; i++){
			A[i][2] = i;
		}

	    Arrays.sort(A, new Comparator<int[]>() {
	        public int compare(int[] o1, int[] o2) {

	        	if(o1[0]==o2[0]){
	        		return o1[1] - o2[1];
	        	}
	        	else{
	        		return o1[0] - o2[0];
	        	}
	        }
	    });

	    for(int i = 1 ; i < M ; i++){
	    	if(A[i-1][0] == A[i][0]){
	    		A[i][3] = A[i-1][3]+1;
	    	}

	    }


	    Arrays.sort(A, new Comparator<int[]>() {
	        public int compare(int[] o1, int[] o2) {
	        		return o1[2] - o2[2];
	        }
	    });

	    for(int i = 0 ; i < M ; i++){
	    	System.out.println(String.format("%06d", A[i][0]) + String.format("%06d", A[i][3]));
	    }
	}
}


Measured memory_bytes: 123304
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}


int main(){
	int n;
	while(cin >> n && n){
		int mx = -500;
		int mi = 500;
		for(int i = 0 ; i < n ; i++){
			int a,b,c,d,e;
			cin >> a >> b >> c >> d >> e;
			mx = max(mx,a+b+c+d+e);
			mi = min(mi,a+b+c+d+e);
		}
		cout << mx << " " << mi << endl;
	}
}

Measured memory_bytes: 0
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int maxn=100000+10;

int a[maxn],col[maxn],n;

inline int check(int ans)
{
	memset(col,0,sizeof col);
	int id_cnt=0,cnt=n;
	for(int i=1;i<=n;++i) if(a[i]==ans-1){
		col[i]=++id_cnt;--cnt;
		if(id_cnt > ans) return 0;
	}
	if(id_cnt==ans && cnt) return 0;
	return (cnt >= (ans-id_cnt)*2 );
}

int main()
{
	int x1=-1,x2=-1;cin>>n;
	for(int i=1;i<=n;++i) {
		scanf("%d",a+i);
		if(x1==-1) x1=a[i];
		else if(a[i]!=x1){
			if(x2==-1) x2=a[i];
			else if(a[i]!=x2) return puts("No"),0;
		}
	}
	if(x2==-1) 
	{
		if(check(x1+1) | check(x1)) puts("Yes");
		else puts("No");
	}
	else
	{
		if(check(max(x1,x2))) puts("Yes");
		else puts("No");
	}
	return 0;
}

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

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

    int n, k, i = 0;
    cin >> n >> k;
    while (n > 0)
    {
        n /= k;
        ++i;
    }
    cout << i << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define RG register
using namespace std;
struct node
{
	int a,b,c;
	node(int aa=0,int bb=0,int cc=0)
	{
		a=aa;b=bb;c=cc;
	}
}point[100005];
int t,n,m,q,pd[100005],vis[100005],father2[100005],father1[100005];
long long size1[100005],size2[100005],mina1[100005],mina2[100005];
bool flag;
bool cmp1(const node &a,const node &b)
{
	return a.a<b.a;
}
bool cmp2(const node &a,const node &b)
{
	return a.b<b.b;
}
int find1(int x)
{
	if(x==father1[x]) return x;
	int now=find1(father1[x]);
	size1[x]+=size1[father1[x]];
	return father1[x]=now;
}
int find2(int x)
{
	if(x==father2[x]) return x;
	int now=find2(father2[x]);
	size2[x]+=size2[father2[x]];
	return father2[x]=now;
}
bool union1(int x,int y,int val)
{
	int r1=find1(x),r2=find1(y);
	if(r1!=r2)
	{
		father1[r1]=r2;
		size1[r1]=size1[y]+val-size1[x];
	}
	else 
	{
		if(size1[x]-size1[y]!=val) return false;
	}
	return true;
}
bool union2(int x,int y,int val)
{
	int r1=find2(x),r2=find2(y);
	if(r1!=r2)
	{
		father2[r1]=r2;
		size2[r1]=size2[y]+val-size2[x];
	}
	else 
	{
		if(size2[x]-size2[y]!=val) return false;
	}
	return true;
}
int main()
{
	t=1;
	while(t--)
	{
		flag=false;
		scanf("%d%d",&n,&m);
		scanf("%d",&q);
		for(RG int i=1;i<=q;i++)
		{
			scanf("%d%d%d",&point[i].a,&point[i].b,&point[i].c);
		}
		for(int i=1;i<=n;i++)
		father1[i]=i,size1[i]=0;
		for(int i=1;i<=m;i++)
		father2[i]=i,size2[i]=0;
		for(RG int i=1;i<=q;i++)
		{
			if(point[i].c<0)
			{
				flag=true;
				break;
			}
		}
		sort(point+1,point+q+1,cmp1);
		for(int i=2;i<=q;i++)
		if(point[i].a==point[i-1].a)
		{
			if(!union2(point[i-1].b,point[i].b,point[i].c-point[i-1].c)) 
			{
				flag=true;
				break;
			}
		}
		sort(point+1,point+q+1,cmp2);
		for(int i=2;i<=q;i++)
		if(point[i].b==point[i-1].b)
		{
			if(!union1(point[i-1].a,point[i].a,point[i].c-point[i-1].c)) 
			{
				flag=true;
				break;
			}
		}
		memset(mina1,127,sizeof(mina1));
		memset(mina2,127,sizeof(mina2));
		for(int i=1;i<=q;i++)
		{
			int pos=find1(point[i].a);
			mina1[pos]=min(mina1[pos],point[i].c+size1[point[i].a]);
		}
		for(int i=1;i<=n;i++)
		{
			int pos=find1(i);
			mina2[pos]=min(mina2[pos],-size1[i]);
		}
		for(int i=1;i<=n;i++)
		if(father1[i]==i&&mina1[i]+mina2[i]<0) 
		{
			flag=true;
			break;
		}
		memset(mina1,127,sizeof(mina1));
		memset(mina2,127,sizeof(mina2));
		for(int i=1;i<=q;i++)
		{
			int pos=find2(point[i].b);
			mina1[pos]=min(mina1[pos],point[i].c+size2[point[i].b]);
		}
		for(int i=1;i<=m;i++)
		{
			int pos=find2(i);
			mina2[pos]=min(mina2[pos],-size2[i]);
		}
		for(int i=1;i<=m;i++)
		if(father2[i]==i&&mina1[i]+mina2[i]<0) 
		{
			flag=true;
			break;
		}
		if(flag)
		{
			printf("No\n");
		}
		else 
		{
			printf("Yes\n");
		}
	}
	return 0;
}
/*
6
2 2
3
1 1 0
1 2 10
2 1 20
2 3
5
1 1 0
1 2 10
1 3 20
2 1 30
2 3 40
2 2
3
1 1 20
1 2 10
2 1 0
3 3
4
1 1 0
1 3 10
3 1 10
3 3 20
2 2
4
1 1 0
1 2 10
2 1 30
2 2 20
1 1 
1
1 1 -1

1
3 3
4
1 1 0
1 3 10
3 1 10
3 3 20
*/

Measured memory_bytes: 5504
#include<iostream>
using namespace std;
int main(){
	int c1, c5, c10, c50, c100, c500;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	c5 *= 5;
	c10 *= 10;
	c50 *= 50;
	c100 *= 100;
	c500 *= 500; 
	if ((c1 + c5 + c10 + c50 + c100 + c500) >= 1000){
		cout << "1" << endl;
	}
	else cout << "0" << endl;
	return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

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

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    vector<ll> vll(1000);
    for (ll i = 0; i < 1000; i++) {
        vll[i] = i * i * i * i * i;
    }
    ll x;
    cin >> x;
    REP(i, 2)
    REP(j, 2)
    REP(k, 1000)
    REP(l, 1000)
    {
        ll a = vll[k];
        ll b = vll[l];
        if (i == 1)
            a *= -1;
        if (j == 1)
            b *= -1;
        if (a - b == x) {
            if (i == 0)
                cout << k;
            else
                cout << -k;

            cout << ' ';
            if (j == 0)
                cout << l;
            else
                cout << -l;

            cout << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;
int main(int argc, char *argv[]) {
	int n, k;
	cin >> n >> k;
	
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		double part_ans = 1.0 / n;
		int score = i;
		while (score < k) {
			score *= 2;
			part_ans /= 2;
		}
		ans += part_ans;
	}
	
	cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <iterator>
#include <unordered_map>
#include <map>

using namespace std;

using ll = long long;

int main()
{
	int N;
	vector<int> A;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		int t;
		cin >> t;
		A.push_back(t);
	}

	double ans = 0.0;
	for (int i = 0; i < N; i++)
	{
		ans += 1.0 / (double)A[i];
	}

	printf("%lf\n", 1 / ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;

struct Sum2d {
    vector<vector<int>> data;
    int n, m;

    Sum2d(int _n, int _m, vector<vector<int>> a) {
        n = _n;
        m = _m;
        data.resize(n + 1, vector<int>(m + 1));
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                data[i + 1][j + 1] = a[i][j];
            }
        }
        init();
    }

    void init() {
        for(int i = 0; i < n + 1; i++) {
            for(int j = 0; j < m; j++) {
                data[i][j + 1] += data[i][j];
            }
        }
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m + 1; j++) {
                data[i + 1][j] += data[i][j];
            }
        }
    }

    int calc(int i, int j, int h, int w) {
        return (data[i + h][j + w] - data[i][j + w] - data[i + h][j] +
                data[i][j]);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> g(h);
    for(int i = 0; i < h; i++) {
        cin >> g[i];
    }
    int ans = INF;
    for(int bit = 0; bit < (1 << (h - 1)); bit++) {
        int res = 0, sz = 1;
        for(int i = 0; i < h - 1; i++) {
            if(bit & (1 << i)) {
                res++;
                sz++;
            }
        }
        vector<int> cnt(sz, 0), add(sz, 0);
        for(int j = 0; j < w; j++) {
            int id = 0;
            for(int i = 0; i < h; i++) {
                if(g[i][j] == '1') {
                    add[id]++;
                }
                if(bit & (1 << i)) {
                    id++;
                }
            }
            bool ok = true;
            for(int i = 0; i < sz; i++) {
                if(add[i] > k) {
                    res = INF;
                }
                if(add[i] + cnt[i] > k) {
                    ok = false;
                }
            }
            if(!ok) {
                res++;
                for(int i = 0; i < sz; i++) {
                    cnt[i] = 0;
                }
            }
            for(int i = 0; i < sz; i++) {
                cnt[i] += add[i];
                add[i] = 0;
            }
        }
        chmin(ans, res);
    }
    cout << ans << endl;
}


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

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

    string ans = "Yes";
    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i]) ans = "No";
    }

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

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());

  ll k = -1;
  for (ll i = 0; i < s.size(); ++i) {
    bool match = false;
    if (s[i] == t[0] || s[i] == '?') {
      if (i+t.size() > s.size()) {
        break;
      }
      match = true;
      for (ll j = i+1; j < i+t.size(); ++j) {
        if (s[j] == '?') continue;
        if (s[j] == t[j-i]) continue;
        match = false;
        break;
      }
    }

    if (match) {
      k = i;
      break;
    }
  }

  if (k < 0) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  string ans;
  for (ll i = 0; i < s.size(); ++i) {
    if (i == k) {
      ans += t;
      i += t.size()-1;
    } else {
      ans += (s[i] == '?' ? 'a' : s[i]);
    }
  }
  
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int INF = 1e9 + 7;

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

int main() {
	int n;
	cin >> n;
	vector<int> s(n + 1, 0), sum(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		sum[i] = sum[i - 1] + s[i];
	}
	if (sum[n] % 10 != 0) cout << sum[n] << endl;
	else {
		int MAX = 0;
		for (int i = 1; i <= n; i++) {
			int x = sum[n] - s[i];
			if (x % 10 != 0) MAX = max(MAX, x);
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static int num;
    static List<int>[] adj;
    static void Solve()
    {
        num = Input.num;
        adj = Enumerable.Repeat(0, num).Select(_ => new List<int>()).ToArray();
        for(var i = 0; i < num - 1; i++)
        {
            var ab = Input.ar;
            adj[ab[0] - 1].Add(ab[1] - 1);
            adj[ab[1] - 1].Add(ab[0] - 1);
        }
        var dist = Enumerable.Repeat(num, num).ToArray();
        bfs(dist, 0);
        var max = 0;
        var maxj = 0;
        for(var i=1;i<num;i++)
            if (dist[i] > max) { max = dist[i];maxj = i; }
        dist = Enumerable.Repeat(num, num).ToArray();
        bfs(dist, maxj);
        var m = dist.Max();
        WriteLine(m % 3 == 1 ? "Second" : "First");
    }
    static void bfs(int[] dist,int init)
    {
        dist[init] = 0;
        var que = new Queue<int>();
        que.Enqueue(init);
        while (que.Count != 0)
        {
            var p = que.Dequeue();
            foreach (var ad in adj[p])
            {
                if (dist[ad] != num) continue;
                dist[ad] = dist[p] + 1;
                que.Enqueue(ad);
            }
        }
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

Measured memory_bytes: 49408
#include<iostream>
using namespace std;
typedef long long ll;
ll n,T;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n>>T;
	ll pre=-1,sum=0;
	for(int i=1;i<=n;++i){
		ll a;
		cin>>a;
		if(a<=pre){
			sum+=a+T-1-pre;
			pre=a+T-1;
		}else{
			pre=a+T-1;
			sum+=T;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

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

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};



int main(){
  int n; cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A[i];
  int ch = 0, ans=1, tmp=0;
  rep(i, n-1){
    if(ch==0){
      if(A[i]>A[i+1]) {ch=1; tmp=A[i+1];}
      else if(A[i]<A[i+1]) {ch = 2; tmp=A[i+1];}
    }   
    else if(ch==1){
      if(tmp>=A[i+1]) tmp=A[i+1];
      else {ch=0; ans++;}
    }
    else {
      if(tmp<=A[i+1]) tmp=A[i+1];
      else {ch=0; ans++;}
    } 
  }
  cout << ans << endl;
}
  
  





Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << '\n'
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const unsigned long long h = 1e9+7;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,ans = 0;
    cin >> n >> k;
    rep(i,k,n+2){
        ans += n*(n+1)/2-(n-i)*(n-i+1)/2-i*(i-1)/2+1;
        ans %= MOD;
    }
    PRINT(ans);
}    


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>

using ball = std::pair<int, int>; // 数字, 色

int main(){
    int X, Y, A, B, C;
    std::cin >> X >> Y >> A >> B >> C;
    std::vector<ball> all(A + B + C);
    for(int i = 0; i < A; i++){
        std::cin >> all[i].first;
        all[i].second = 1;
    }
    for(int i = 0; i < B; i++){
        std::cin >> all[A + i].first;
        all[A + i].second = 2;
    }
    for(int i = 0; i < C; i++){
        std::cin >> all[A + B + i].first;
        all[A + B + i].second = 3;
    }

    std::sort(all.begin(), all.end(), std::greater<ball>());

    long long out = 0;
    int redCnt = 0, greenCnt = 0, noCnt = 0;
    for(int i = 0; i < A + B + C; i++){
        if(redCnt == X){
            if(all[i].second == 1) continue;
            out += all[i].first;
            greenCnt++;
        }else if(greenCnt == Y){
            if(all[i].second == 2) continue;
            out += all[i].first;
            redCnt++;
        }else{
            out += all[i].first;
            if(all[i].second == 1){
                redCnt++;
            }else if(all[i].second == 2){
                greenCnt++;
            }else{
                // この場合は無色をどちらで換算するか？
                noCnt++;
            }
        }

        if(redCnt + greenCnt + noCnt == X + Y) break;
    }

    std::cout << out << std::endl;

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
 
template<class T>
using V = vector<T>;
template<class T>
using VV = V<V<T> >;
using pii = pair<int, int>;
 
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for(int i=m; i<n; i++)
#define ef emplace_front
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
 
const int INF = 1 << 30;
 
int main(){
    int H, W, C_h, C_w, D_h, D_w;
    cin >> H >> W >> C_h >> C_w >> D_h >> D_w;
    C_h--; C_w--; D_h--; D_w--;
    VV<char> S(H, V<char>(W));
    rep(i, H){
        rep(j, W) cin >> S.at(i).at(j);
    }
    
    VV<int> dis(H, V<int>(W, INF));
    deque<pii> update;
    V<int> h_list = {-1, 0, 1, 0}, w_list = {0, -1, 0, 1};
 
    dis.at(C_h).at(C_w) = 0;
    update.eb(mp(C_h, C_w));
 
    while(!update.empty()){
        pii p = update.front();
        update.pop_front();
        int pf = p.fi, ps = p.se;
        int d = dis.at(pf).at(ps);
        int h, w;
        rep(i, 4){
            h = pf + h_list.at(i);
            w = ps + w_list.at(i);
            if(0 <= h && h < H && 0 <= w && w < W && S.at(h).at(w) == '.' && dis.at(h).at(w) > d){
                dis.at(h).at(w) = d;
                update.ef(mp(h, w));
            }
        }
 
        d++;
        rep2(i, -2, 3){
            rep2(j, -2, 3){
                h = pf + i;
                w = ps + j;
                if(0 <= h && h < H && 0 <= w && w < W && S.at(h).at(w) == '.' && dis.at(h).at(w) > d){
                    dis.at(h).at(w) = d;
                    update.eb(mp(h, w));
                }
            }
        }
    }
    if(dis.at(D_h).at(D_w) == INF) cout << -1 << endl;
    else cout << dis.at(D_h).at(D_w) << endl;
}

Measured memory_bytes: 8644
import java.util.*;
import java.math.*;
 class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double sum = 100000;
		for(int i=0;i<n;i++){
			sum=sum+sum*0.05;
			BigDecimal bi = new BigDecimal(String.valueOf(sum));
			sum = bi.setScale(-3,BigDecimal.ROUND_UP).doubleValue();
		}
		System.out.printf("%.0f\n",sum);
	}
}

Measured memory_bytes: 17356
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int n,tdp[1001],x[1001];
vector<int> childe[1001];

bool dfs(int v){
    bool res;
    int mini=0,sa,ndp[5001]={},sum=0;
    res=true;
    for(int i=0;i<childe[v].size();i++){
        res=dfs(childe[v][i]);
        if(!res){
            return res;
        }
    }
    for(int i=0;i<childe[v].size();i++){
        mini+=min(x[childe[v][i]],tdp[childe[v][i]]);
        sum+=x[childe[v][i]]+tdp[childe[v][i]];
    }
    if(mini>x[v]){
        return false;
    }
    ndp[mini]=1;
    for(int i=0;i<childe[v].size();i++){
        sa=max(x[childe[v][i]],tdp[childe[v][i]])-min(x[childe[v][i]],tdp[childe[v][i]]);
        for(int j=x[v];j>=0;j--){
            if(ndp[j]&&j+sa<=x[v]){
                ndp[j+sa]=1;
            }
        }
    }
    for(int i=x[v];i>=0;i--){
        if(ndp[i]){
            tdp[v]=sum-i;
            return true;
        }
    }
    return true;
}

int main(){
    int p;
    scanf("%d",&n);
    for(int i=2;i<=n;i++){
        scanf("%d",&p);
        childe[p].push_back(i);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&x[i+1]);
    }
    if(dfs(1)){
        printf("POSSIBLE\n");
    }
    else{
        printf("IMPOSSIBLE\n");
    }
}

Measured memory_bytes: 8704
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    ll = [[a[i],b[i]] for i in range(M)]

    ll = sorted(ll, key=lambda x:x[1])

    endtime = 0
    ans = 0
    for i in range(M):
        if(endtime <= ll[i][0]):
            endtime = ll[i][1]
            ans += 1
        
    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]" 
    b = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 23592
#include<iostream>
#include<string.h>
#include<math.h>
#include<set>
#include<algorithm>
using namespace std;
int a[100000]; 
int main()
{
	long long l,r,min;
	int i,j;
	scanf("%lld%lld",&l,&r);
	if(r-l>=2019)
	{
		cout<<0;
	}
	else
	{
		l%=2019;
		r%=2019;
		if(r<=l)
			r+=2019;
		min=(l*r)%2019;
		for(i=l;i<r;i++)
			for(j=i+1;j<=r;j++)
			{
				if((i*j)%2019<min)
					min=(i*j)%2019;
			} 
		cout<<min;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 100000001;
ll t[100010][50];
const ll mod = 1000000007;
double rec(double n, double c) {
	if (n == 300) return n;

	return (c - 1.0) / c * (n + rec(n + 1,c));
}
void HSI() {

	int n, m;
	cin >> n >> m;
	double a = 100 * (n - m);
	double b = 1900 * m;
	double c = pow(2,m);
	double d = (c - 1) / c;
	double v = (a + b);

	//for (double i = 0; i < 300; i++)
	//{
	//	double s = i + 1;
	//	for (size_t j = 0; j < i; j++)
	//	{
	//		s *= (c - 1);
	//		s /= c;
	//	}
	//	res +=  s;
	//}
	//res = 1 +  rec(2,c);
	//cout << (int)(v * res / c) << endl;
	double res = v * c;
	cout << res << endl;
}

int main() {
	HSI();
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
main()
{
    int n;cin>>n;
    vector<string> a;
    rep(i,n)
    {
        string s;cin>>s;
        sort(begin(s),end(s));
        a.emplace_back(s);
    }
    sort(begin(a),end(a));
    long long ans=0,now=0;
    rep(i,n-1)
    {
        if(a[i+1]!=a[i]){ans+=now*(now+1)/2;now=0;}
        else now++;
    }
    ans+=now*(now+1)/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 5748
#include <stdio.h>

long exp(int x, int n) {
	int i;
	long ans = 1;

	for(i = 0; i < n; i++)
		ans *= x;

	return ans;
}

long conv_oct(long x) {
	int i;
	long ans;
	long temp;
	int a[32];

	for(i = 0, temp = x; temp; i++) {
		a[i] = temp % 8;
		temp = temp / 8;
	}

	for(ans = 0; i > 0; i--)
		ans += a[i - 1] * exp(10, i - 1);

	return ans;
}

int main() {
	long input;
	long ans;
	int a[32];
	int i, temp;

	do {
		scanf("%ld", &input);
		if(!input)
			break;
		for(i = 0, temp = input; temp; i++) {
			a[i] = temp % 8;
			temp = temp / 8;
		}

		for(ans = 0; i > 0; i--) {
			if(a[i - 1] > 3)
				a[i - 1]++;
			if(a[i - 1] > 5)
				a[i - 1]++;

			ans += a[i - 1] * exp(10, i - 1);
		}

		printf("%ld\n", ans);
	} while(1);

	return 0;
}

Measured memory_bytes: 600
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,K = LI()
    sa = (N - 1) * (N - 2) // 2 - K
    if sa < 0:
        print(-1)
        return

    ans = []
    for i in range(2,N+1):
        ans.append((1,i))
    i = 2
    j = 3
    while sa > 0:
        ans.append((i,j))
        sa -= 1
        j += 1
        if j > N:
            i += 1
            j = i + 1
    print(len(ans))
    for x in ans:
        print(x[0],x[1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 42988
debt = 100000
for i in 0...gets.chomp.to_i do
        debt *= 1.05
        debt = debt.to_i
        work = debt.to_s
        work = work[work.length - 3, work.length]
        if work != "000"
                debt = debt + 1000 - work.to_i
        end
end
puts debt



Measured memory_bytes: 6856
#include<stdio.h>

int gcm(long a,long b){
	if(a%b==0)return b;
	return gcm(b,a%b);
}

int main(){
	int n,i;
	long a[100000];
	scanf("%d",&n);
	scanf("%ld",&a[0]);
	for(i=1;i<n;i++){
		scanf("%ld",&a[i]);
		a[i]=gcm(a[i],a[i-1]);
	}
	printf("%ld\n",a[n-1]);
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    vector<int> n(3);
    rep(i, 3) cin >> n[i];

    sort(all(n));

    cout << (n[0] == 5 && n[0] == n[1] && n[2] == 7 ? "YES" : "NO") << '\n';
    return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;

int const SIZ = 50;
int fib[SIZ];

void prepare() {
    fib[0] = fib[1] = 1;
    for (int i=2; i<SIZ; ++i) {
        fib[i] = fib[i-1] + fib[i-2];
    }
}

int main() {
    ios::sync_with_stdio(false);

    prepare();

    int n;
    cin >> n;
    cout << fib[n] << endl;

    return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

int main(void){
	int n,p[30],i,cnt=0;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	
	for(i=1;i<n-1;i++){
		//printf("%d %d %d\n",p[i-1],p[i],p[i+1]);
		if(p[i-1] < p[i] && p[i] < p[i+1]){
			cnt++;
		}else if(p[i-1] > p[i] && p[i] > p[i+1]){
			cnt++;
		}
		//printf("\n");
	}
	printf("%d\n",cnt);
	
	return 0;
}

Measured memory_bytes: 128
from collections import*
n,*a=map(int,open(0).read().split())
def f(a):
  a=deque(a)
  deq=deque([a.popleft()])
  for i in range(n-1):
    if i%4==0:
      deq.appendleft(a.pop())
    elif i%4==1:
      deq.append(a.pop())
    elif i%4==2:
      deq.appendleft(a.popleft())
    else:
      deq.append(a.popleft())
  l=list(deq)
  return sum(abs(i-j)for i,j in zip(l,l[1:]))
s=sorted(a)
print(max(f(s),f(s[::-1])))


Measured memory_bytes: 14380
H,W,K = map(int, input().split())
C = [input() for _ in range(H)]
ANS = 0

for i in range(1<<W):
    D = [0]*37
    D[0] = 1

    for c in C:
        cnt = 0
        for b in range(6):
            if (i & (1<<b)) and c[b] == '#':
               cnt += 1

        for j in range(36-cnt, -1, -1):
            D[j+cnt] += D[j]

    ANS += D[K]

print(ANS)    


Measured memory_bytes: 9040
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			String s = sc.next();
			if (!map.containsKey(s))
				map.put(s, 0);
		}
		System.out.println(map.size());
	}
}

Measured memory_bytes: 77164
using System;

namespace ALDS1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = getint();
            string[] input = getsplit();
            string[] a = new string[n];
            string[] b = new string[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = input[i];
                b[i] = input[i];

            }
            for (int i = 0; i < n; i++)
            {
                for (int j = n-1; j > i ; j--)
                {
                    if (a[j][1] < a[j-1][1])
                    {
                        string k = a[j];
                        a[j] = a[j - 1];
                        a[j - 1] = k;
                    }
                }
            }
            for (int i = 0; i < n-1; i++)
            {
                Console.Write(a[i] + " ");
            }
            Console.WriteLine(a[n-1]);
            Console.WriteLine("Stable");
            for (int i = 0; i < n; i++)
            {
                int minj = i;
                for (int j = i; j < n; j++)
                {
                    if (b[j][1] < b[minj][1])
                    {
                        minj = j;
                    }
                }
                if (i != minj)
                {
                    string k = b[i];
                    b[i] = b[minj];
                    b[minj] = k;
                }
            }
            for (int i = 0; i < n - 1; i++)
            {
                Console.Write(b[i] + " ");
            }
            Console.WriteLine(b[n - 1]);
            bool s = true;
            for (int i = 0; i < n; i++)
            {
                if (a[i] != b[i])
                {
                    s = false;
                    break; 
                }
            }



            if (s)
            {
                Console.WriteLine("Stable");
            }
            else
            {
                Console.WriteLine("Not stable");
            }
        }
        static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
        static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
    }
}

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

int H, W;
vector<string> S;

bool check(auto T) {
  vector<bool> used(W);
  set<int> uniq;
  for(auto i=0; i<W; ++i) if(!used[i]) {
    for(auto j=i+1; j<W; ++j) if(!used[j]) {
      auto same = true;
      for(auto k=0; k<H; ++k) same &= (T[k][i] == T[H-1-k][j]);
      if(!same) continue;
      used[i] = used[j] = true;
      break;
    }
    if(!used[i]) uniq.emplace(i);
  }
  if(uniq.empty()) return true;
  if(2 <= uniq.size()) return false;
  auto i = *begin(uniq);
  for(auto k=0; k<H; ++k) if(T[k][i] != T[H-1-k][i]) return false;
  return true;
}

bool dfs(auto T, auto used, auto n) {
  if(n == H) return check(T);
  if(used[n]) return dfs(T, used, n+1);
  for(auto i=0; i<H; ++i) if(T[i].empty()) {
    used[n] = true;
    T[i] = S[n];
    for(auto m=n+1; m<H; ++m) if(!used[m]) {
      used[m] = true;
      T[H-1-i] = S[m];
      if(dfs(T, used, n+1)) return true;
      used[m] = false;
      T[H-1-i].clear();
    }
    return false;
  }
  assert(-1);
}

string solve() {
  if(H&1) for(auto i=0; i<H; ++i) {
    vector<string> T(H);
    vector<bool> used(H);
    T[H/2] = S[i];
    used[i] = true;
    if(dfs(T, used, 0)) return "YES";
  } else {
    if(dfs(vector<string>(H), vector<bool>(H), 0)) return "YES";
  }
  return "NO";
}

int main() {
  cin >> H >> W;
  S.resize(H);
  for(auto& i: S) cin >> i;
  cout << solve() << endl;
}


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

int main(){
    int r; cin >> r;
    if(r < 1200) cout << "ABC" << endl;
    if(r >= 1200 && r < 2800) cout << "ARC" << endl;
    if(r >= 2800) cout << "AGC" << endl;
}

Measured memory_bytes: 256