akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

const int MAX = 100100;
#define WHITE 0
#define BLACK 1
#define LEFT  0
#define RIGHT 1

int n,cost[2][MAX];
bool arr[MAX];

inline bool isValid(int x) { return 0 <= x && x < n; }

void makeCost(int sp) {
  rep(color,2) {
    for(int cur=sp;((sp==0)?cur<n:cur>=0);((sp==0)?++cur:--cur)) {
      while( ((sp==0)?cur<n:cur>=0) && arr[cur] != color ) ((sp==0)?++cur:--cur);
      if( !( 0 <= cur && cur < n ) ) break;
      deque<int> deq;
      bool state = color;
      while( ((sp==0)?cur<n:cur>=0) && state == arr[cur] ) {
        deq.push_back(((sp==0)?cur++:cur--));
        state = !state;
      }
      ((sp==0)?--cur:++cur);
      int v = 0;
      while( !deq.empty() ) {
        cost[sp==0][deq.back()] = v++;
        deq.pop_back();
      }
    }
  }
}

int calcCost(int sp) {
  int coef = ( sp == 0 ) ? +1 : -1;
  int maxi = 1;
  rep(color,2) {
    for(int cur=sp;((sp==0)?cur<n:cur>=0);cur += coef) {
      while( ((sp==0)?cur<n:cur>=0) && arr[cur] != color ) cur += coef;
      if( !isValid(cur) || !isValid(cur+coef) ) break;
      if( arr[cur+coef] != color ) continue;
      int tmp = cost[sp!=0][cur] + 2 + cost[sp==0][cur+coef];
      int next = (cur+coef) + coef * cost[sp==0][cur+coef] + coef;
      if( isValid(next) && arr[next-1] == arr[next] ) {
        tmp += (cost[sp==0][cur+coef+coef*cost[sp==0][cur+coef]+coef]+1);
      }

      // ... 0 0 1 ...
      // ... 0 0 0 1 ...
      maxi = max(maxi,tmp);
      if( isValid(cur+2*coef) && arr[cur+2*coef] == color ) {
        tmp = cost[sp!=0][cur] + 3 + cost[sp==0][cur+2*coef];
        maxi = max(maxi,tmp);
      }
    }
  }
  return maxi;
}

void bf() {
  int maxi = 0;
  rep(i,n) REP(j,i,n) {
    vector<bool> vec;
    rep(k,n) vec.push_back(arr[k]);
    REP(k,i,j+1) vec[k] = !vec[k];
    rep(sp,n) {
      int tmp = 0;
      bool state = vec[sp];
      int cur = sp;
      while( cur < n && state == vec[cur] ) {
        ++tmp;
        cur++;
        state = !state;
      }
      maxi = max(maxi,tmp);
    }
  }
  cout << "bf = " << maxi << endl;
}

void compute() {
  //bf();
  makeCost(0);
  makeCost(n-1);
  /*
  rep(i,2) {
    cout << "color = " << (i?"RIGHT":"LEFT") << endl;
    rep(j,n) {
      cout << cost[i][j] << " ";
    } puts("");
  }
  */
  int maxi = 1;
  rep(i,2) rep(j,n) maxi = max(maxi,cost[i][j]+1);
  maxi = max(maxi,calcCost(0));
  maxi = max(maxi,calcCost(n-1));
  cout << maxi << endl;
}

int main() {
  cin >> n;
  rep(i,n) cin >> arr[i];
  compute();
  return 0;
}

Measured memory_bytes: 2164
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long k = sc.nextLong();
		long d = sc.nextLong();
		long absx = Math.abs(x);
		if (absx / d >= k) {
			System.out.println(absx - k * d);
		} else {
			long r = k - absx / d;
			long start = absx % d;
			if (r % 2 == 0) {
				System.out.println(start);
			} else {
				long ans = Math.min(Math.abs(start + d), Math.abs(start - d));
				System.out.println(ans);
			}
		}
	}
}
 
 
 
 
 
 
 
 
 
 


Measured memory_bytes: 36096
from bisect import bisect_right
 
N = int(input())
L = sorted(list(map(int, input().split())))
 
ans = 0
for i in range(1, N-1):
    for j in range(i+1, N):
        ans += max(0, i - bisect_right(L, L[j] - L[i]))
print(ans)

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

#define MAXN 100
#define INF 10000001
#define WHITE 0
#define BLACK 1

struct node{
  int nodev; //ノード番号
  int omomi; //node[i]からこのノードへの重み
  int *next;
};
typedef struct node * NodePointer;

NodePointer insert(int, int, int);
NodePointer make_1node(int, int, NodePointer);
void initializeSingleSource(int, int *, int*, int*);

NodePointer head[MAXN];

int main()
{
  int i, j, n, u, k, v, omo, mincost;
  int d[MAXN], pi[MAXN], color[MAXN];
  NodePointer p;
  scanf("%d",&n);

  for(i = 0; i < n; i++) {
    head[i] = make_1node(-1,-1,NULL);
  }
  
  for(i = 0; i < n; i++) {
    scanf("%d%d",&u,&k);
    
    for(j = 0; j < k; j++) {
      scanf("%d%d",&v,&omo);
      insert(v, omo, u);
    }
  }

  initializeSingleSource(n, d, pi, color);
  while(1) {
    mincost = INF;
    for(i = 0; i < n; i++) {
      if(color[i] != BLACK && d[i] < mincost) {
	mincost = d[i];
	u = i;
      }
    }

    if(mincost == INF) break;

    color[u] = BLACK;

    for(i = 0; i < n; i++) {
      p = head[i];
      while((p = p->next) != NULL) {
	if(color[p->nodev] != BLACK && d[i] + p->omomi < d[p->nodev]) {
	  pi[p->nodev] = i;
	  d[p->nodev] = d[i] + p->omomi;
	}
      }
    }
    
  }

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

NodePointer insert(int v, int omo, int u)
{
  NodePointer newnode;

  newnode = make_1node(v, omo, head[u]->next);
  head[u]->next = newnode;

  return newnode;
}

NodePointer make_1node(int v, int omo, NodePointer p)
{
  NodePointer n;

  n = (NodePointer)malloc(sizeof(struct node));

  n->nodev = v;
  n->omomi = omo;
  n->next = p;

  return n;
}

 void initializeSingleSource(int n, int *d, int *pi, int *color)
{
  int i;
  
  for(i = 0; i < n; i++) {
    d[i] = INF;
    pi[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;
}



Measured memory_bytes: 1960
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K;
ll cnt[MAX_N];

void solve() {
	cin >> N >> K;
	rep(i, 1, N + 1) {
		if((2 * i) % K == 0) {
			cnt[i % K]++;
		}
	}
	ll res = 0;
	rep(i, 0, K) {
		res += cnt[i] * cnt[i] * cnt[i];
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
# https://atcoder.jp/contests/abc114/tasks/abc114_c

n = int(input())

def dfs(s, n):
    if int(s) > n:
        return 0
    ret = 1 if all([s.count(c) > 0 for c in '753']) else 0
    for c in ['7', '5', '3']:
        ret += dfs(s + c, n)
    return ret

ans = dfs('0', n)
print(ans)

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

string s;

int main() {
    cin >> s;
    ll n = s.size();
    s = s + "$";

    string prev = s.substr(0, 1);
    ll k = 1;
    for(int i=1; i<n; i++) {
        if(prev == s.substr(i, 1)) {
            prev = s.substr(i, 2);
            i++;
        }
        else {
            prev = s.substr(i, 1);
        }
        k++;
    }
    if(prev.size() == 2 && prev[1] == '$')  k--;
    cout << k << endl;
}

Measured memory_bytes: 772
d = int(input())
c = list(map(int, input().split()))
prev = [0] * 26
for i in range(d):
  s = list(map(int, input().split()))
  happy = - (10 ** 10)
  ans = 0
  for j in range(26):
    tmp = s[j]
    cost = 0
    for k in range(26):
      if j == k:
        continue
      cost += c[k] * (i - prev[k])
    tmp -= cost
    if tmp > happy:
      happy = tmp
      ans = j
  prev[ans] = i
  print(ans+1)

Measured memory_bytes: 68964
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;

int a, b, c, d;

int main(){

	scanf("%d%d%d", &a, &b, &c);
	d = a > b ? a : b;
	printf("%d\n", (c % d != 0) + c / d);

	return 0;
}

Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    long sum_a, min_a = long.max;
    int mc;
    foreach (a; readln.split.to!(long[])) {
        if (a < 0) ++mc;
        a = abs(a);
        sum_a += a;
        min_a = min(min_a, a);
    }
    writeln(sum_a - (mc%2 == 1 ? min_a*2 : 0));
}

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

typedef long long ll;

const ll M = 1e9 + 7;

ll fact(ll k) {
	if (k == 0)return 1;
	return k % M * fact(k - 1) % M;
}

ll calc(ll a, ll b) {
	if (b == 0)return 1;
	else if (b % 2 == 0) {
		ll d = calc(a, b / 2);
		return (d*d) % M;
	}
	else {
		return (a*calc(a, b - 1)) % M;
	}
}

ll sec(ll a, ll b) {
	ll sum = fact(a);
	ll A = fact(a - b);
	ll B = fact(b);

	ll ans = sum * calc(B, M - 2) % M * calc(A, M - 2) % M;
	return ans;
}


map<ll, ll> prime_factor(ll n) {
	map<ll, ll> res;
	for (ll i = 2; i*i <= n; i++) {
		while (n%i == 0) {
			res[i]++;
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}

int main() {
	ll n, m;
	cin >> n >> m;
	map<ll, ll> ma;
	ma = prime_factor(m);

	ll sum = 1;
	for (auto it = ma.begin(); it != ma.end(); it++) {
		ll k = it->second;
		ll tmp = sec(n+k-1,n-1);
		sum = (sum * tmp) % M;
	}

	cout << sum << endl;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}

long long arr[100005];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int k; cin >> k;

    // work backwards poggers

    for(int i = k - 1; i >= 0; --i)
        cin >> arr[i];

    long long low = 2, high = 2;

    for(int i = 0; i < k; ++i){
        high = (high - high % arr[i]) + arr[i] - 1;
        if(low % arr[i] > 0)
            low = (low - low % arr[i]) + arr[i];
        //cout << start << endl;
    }

    long long cop = low, cop1 = high;

    for(int i = k - 1; i >= 0; --i){
        cop -= cop % arr[i];
        cop1 -= cop1 % arr[i];
    }

    if(cop != 2 || cop1 != 2){
        cout << "-1\n";
        return 0;
    }

    cout << low << " " << high << "\n";


    return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
     long long a,b;
     int num=0;
     cin>>a>>b;
     for(int i=a;i<=b;i++)
     {
     	if(i/10000==i%10&&i/1000%10==i/10%10)
     	num++;
     }
     cout<<num;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long gcd(long long a,long long b)
{
	if(a==0)
		return b;
	return gcd(b%a,a);
}
int main()
{
	long long a,b;
	cin>>a>>b;
	cout<<(a*b)/gcd(a,b);
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if((a + b) % 2 == 0) System.out.println((a+b)/2);
        else System.out.println((a+b+1)/2);
    }
}

Measured memory_bytes: 21588
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define debug(...) fprintf(stderr,_VA_ARGS_)

typedef long long LL;
typedef unsigned int uint;
typedef std::vector<int> vi;
typedef unsigned long long uLL;
template<typename T> inline void I(T &x){
	register int ch,k=1;
	while(ch=getchar(),ch<'/')k=(ch=='-' ? -1 : k);x=ch-'0';
	while(ch=getchar(),ch>'/')x=((x+(x<<2))<<1)+ch-'0';x*=k;
}

const int maxn=1e3+7;
struct Node{int x,y;};
int d[maxn][maxn];
int main(){
	memset(d,-1,sizeof(d));
	int n,m;scanf("%d%d",&n,&m);
	std::queue<Node>aaa;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j){
			char ch;scanf(" %c",&ch);
			if(ch=='#')d[i][j]=0,aaa.push((Node){i,j});
		}
	int ans=0;
	while(!aaa.empty()){
		int x=aaa.front().x;
		int y=aaa.front().y;
		ans=d[x][y],aaa.pop();
		static const int X[]={-1,0,0,1};
		static const int Y[]={0,-1,1,0};
		for(int k=0;k<4;++k){
			int xx=x+X[k],yy=y+Y[k];
			if(xx<1 || xx>n)continue;
			if(yy<1 || yy>m)continue;
			if(~d[xx][yy])continue;
			d[xx][yy]=d[x][y]+1;
			aaa.push((Node){xx,yy});
		}
	}printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 12432
n = int(input())
s = str(input())
numr = s.count("R")
numg = s.count("G")
numb = s.count("B")
ans = numr*numb*numg
for i in range(len(s)):
    if s[i] == "R":
        for j in range(len(s)):
            if s[j] == "G":
                if i<j:
                    if i+2*(j-i) < n and  s[i+2*(j-i)] == "B":
                        ans -= 1
                    if i-(j-i) >= 0 and  s[i-(j-i)] ==  "B":
                        ans -= 1
                if i>j:
                    if i-2*(i-j) >= 0 and  s[i-2*(i-j)] == "B":
                        ans -= 1
                    if i+(i-j) < n and s[i+(i-j)] ==  "B":
                        ans -= 1
                if (i+j)%2 == 0 and s[(i+j)//2] == "B":
                    ans -= 1
 
print(ans)

Measured memory_bytes: 9264
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long row=1;
	long long col=n;
	for(int i=2;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{	
			row=i;
			col=n/i;
		}	
	}
	cout<<row+col-2;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int henkan(char);
void bubbleSort(char *,char *,int);
void selectionSort(char *,char *,int);

int main(){
  char A1[40],A2[40];
  char B1[40],B2[40];
  char C[2];
  int N;
  int i;
  int flag=1;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%s",C);
    A1[i]=B1[i]=C[0];
    A2[i]=B2[i]=C[1];
  }
  bubbleSort(A1,A2,N);
  for(i=0;i<N;i++){
    printf("%c%c",A1[i],A2[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n");
  printf("Stable\n");
  selectionSort(B1,B2,N);
  for(i=0;i<N;i++){
    printf("%c%c",B1[i],B2[i]);
    if(i!=N-1) printf(" ");
    if(A1[i]!=B1[i] || A2[i]!=B2[i]) flag=0;
    }
  printf("\n");
  if(flag) printf("Stable");
  else printf("Not stable");
  printf("\n");

  return 0;
  
}
int henkann(char c){
  return c-48;
}
void bubbleSort(char A1[],char A2[],int N){
  int flag=1;
  int j;
  char tmp1,tmp2;
  while(flag){
    flag=0;
    for(j=N-1;j>0;j--){
      if(henkann(A2[j])<henkann(A2[j-1])){
	tmp2=A2[j];
	tmp1=A1[j];
	A2[j]=A2[j-1];
	A1[j]=A1[j-1];
	A2[j-1]=tmp2;
	A1[j-1]=tmp1;
	flag=1;
      }
    }
  }
}

void selectionSort(char A1[],char A2[],int N){
  int i,j,minj;
  char tmp1,tmp2;
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A2[minj]>A2[j]){
	minj=j;
      }
    }
    tmp2=A2[i];
    tmp1=A1[i];
    A2[i]=A2[minj];
    A1[i]=A1[minj];
    A2[minj]=tmp2;
    A1[minj]=tmp1;
  }
}
  



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define ENDL '\n'
using namespace std;
typedef unsigned long long int ulli;
int main()
{
  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ulli n, AC=0, WA=0, TLE=0, RE=0;
  cin>>n;
  string aux;
  for(ulli i=0; i<=n; ++i)
  {
    getline(cin, aux);
    if(aux=="AC")
    AC++;
    if(aux=="WA")
    WA++;
    if(aux=="TLE")
    TLE++;
    if(aux=="RE")
    RE++;
  }
  cout<<"AC x "<<AC<<ENDL;
  cout<<"WA x "<<WA<<ENDL;
  cout<<"TLE x "<<TLE<<ENDL;
  cout<<"RE x "<<RE<<ENDL;
  return 0;
}


Measured memory_bytes: 3596
#include<iostream>

using namespace std;

int main(){

    int n;

    cin >> n;

    int a[20];
    int b[20],c[19];

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

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

    for (int i=0 ; i<n-1;i++){
        cin >> c[i];
    }

    int s=0;

    s=s+b[a[0]];

    for (int i=1 ; i<n; i++){
        s=s+b[a[i]];
        if (a[i]==a[i-1]+1) 
            s=s+c[a[i]-1];
    }

    cout << s << endl;







}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


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



Measured memory_bytes: 3116
N, D, *X = map(int, open(0).read().split())
*X, = zip(*[iter(X)]*D)

cnt = 0
for i, x in enumerate(X):
    for j in range(i+1, N):
        d = 0
        for y, z in zip(x, X[j]):
            d += (y-z)**2
        if (d**0.5).is_integer():
            cnt += 1

print(cnt)


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>

int main(void)
{
  int i, x, h;
  double s;

  scanf("%d\n%d", &x, &h);
  while(x!=0 && h!=0)
    {
      s=x*x+2.0*x*sqrt(x*x/4.0+h*h);

      printf("%f\n",s);

      scanf("%d\n%d", &x, &h);
    }
  return 0;
}

Measured memory_bytes: 632
const input = require('fs').readFileSync('/dev/stdin', 'UTF-8');

const rectangle = input => {
  const [length, width] = input.split(' ').map(val => Number(val));
  const area = length * width;
  const perimeter = (length + width) * 2;
  console.log([area, perimeter].join(' '));
};

rectangle(input);



Measured memory_bytes: 15136
def main():
  N=int(input())
  V=list(map(int, input().split()))
  C=list(map(int, input().split()))
  sum=0
   
  for i in range(0,N):
    t=V[i]-C[i]
    if t>=0:
      sum+=t

      
  print(sum)
    
  
main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
 
int main(){
    int N, M;
    cin >> N >> M;
    int a[100001] = {}, tmp;
    for(int i=0;i<M;i++){
        cin >> tmp;
        a[tmp] = 1; // 壊れていたら1
    }

    ll dp[N+1] = {}; // 0~N
    dp[0] = 0;
    // 1段目
    if(a[1] == 0){
        dp[1] = 1;
    }else{
        dp[1] = 0;
    }
    // 2段目
    if(a[2] == 0){
        if(a[1] == 0)
            dp[2] = 2;
        else
            dp[2] = 1;
    }else{
        if(a[1] == 1){
            cout << 0 << endl;
            return 0;
        }else{
            dp[2] = 0;
        }
            
    }
    // 3~N段目
    for(int i=3;i<=N;i++){
        if(a[i-1] == 1 && a[i-2] == 1){
            cout << 0 << endl;
            return 0;
        }else if(a[i-1] == 1){
            dp[i] = dp[i-2];
        }else if(a[i-2] == 1){
            dp[i] = dp[i-1];
        }else{
            dp[i] = dp[i-1] + dp[i-2];
        }
        dp[i] = dp[i] % MOD;
    }

    cout << dp[N] << endl;

}

Measured memory_bytes: 1408
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

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

int n;
// string s;
V<V<Pii>> edges;

long long modpow(long long x, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int func(int node, int parent) {
    int s = 1;
    FOR(i, edges[node]) {
        if (i->second == parent) continue;
        i->first = func(i->second, node);
        s += i->first;
    }
    return s;
}

int main() {
    cin >> n;

    edges = V<V<Pii>>(n);
    REP(i, n-1) {
        int a, b; cin >> a >> b; a--; b--;
        edges[a].push_back({-1, b});
        edges[b].push_back({-1, a});
    }

    func(0, -1);

    ll ex_numerator = 0, ex_denominator = modpow(2, n, MOD);
    REP(i, n) {
        FOR(j, edges[i]) {
            if (j->first == -1) continue;
            ll x = modpow(2, j->first, MOD), y = modpow(2, n - (j->first), MOD);
            ex_numerator += (x-1) * (y-1) % MOD;
            ex_numerator %= MOD;
        }
    }
    ex_numerator += ex_denominator;
    ex_numerator %= MOD;
    ex_numerator += MOD - 1;
    ex_numerator %= MOD;
    ex_numerator += MOD - modpow(2, n-1, MOD) * n % MOD;
    ex_numerator %= MOD;

    std::cout << modpow(ex_denominator, MOD-2, MOD) * ex_numerator % MOD << '\n';

    return 0;
}


Measured memory_bytes: 18176
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(S: str):
    f = S[0] == S[1] or S[1] == S[2] or S[2] == S[3]
    return 'Bad' if f else 'Good'


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = (next(tokens))  # type: int
    result = solve(S)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5752
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

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

    sort(a, a+n);
    cout << a[n-1] << " ";

    int half = lower_bound(a, a+n, a[n-1]/2) - a;

    if (a[min(half, n-2)] - a[n-1]/2 <= a[n-1]/2 - a[max(0, half-1)]) {
        cout << a[min(half, n-2)] <<  endl;
    } else {
        cout << a[max(0, half-1)] << endl;
    }

    return 0;
}

Measured memory_bytes: 640
S = input()
T = input()

def func(s, t):
    x = len(t)
    for i in range(len(t)):
        if s[i]==t[i]:
            x-=1
    return x
ans = 10000
for j in range(len(S)-len(T)+1):
    s = S[j:j+len(T)]
    ans = min(ans, func(s,T))
print(ans)

Measured memory_bytes: 67212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC
{
	class Program
	{
		static void Main(string[] args)
		{
			var m = Convert.ToInt32(Console.ReadLine());

			Console.WriteLine(48 - m);
		}
	}
}


Measured memory_bytes: 11220
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
vector<int> G[MAXN];
bool visit[MAXN];
int dp[MAXN];

int dfs(int cur) {
    if (visit[cur]) return dp[cur];
    visit[cur] = 1;
    if (G[cur].size() == 0) return dp[cur] = 0;
    int ans = 0;
    for (auto i : G[cur]) {
        ans = max(ans, dfs(i));
    }
    return dp[cur] = ans + 1;
}

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    for (int i = 0; i < M; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        G[a].push_back(b);
    }
    int ans = 0;
    for (int i = 1; i <= N ; i++) {
        ans = max(ans, dfs(i));
    }
    printf("%d\n", ans);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visited[MAX]; // 訪問状況

int n, m; // 変数
ll a;
double b;

int main() {
// input
    cin >> a >> b;
// solve
// output
    cout << (a * (ll)(b * 100 + 0.001) / 100) << "\n";
}

Measured memory_bytes: 3716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> marblesPlace = Arrays.asList(br.readLine().split(""));

            int countMarble = 0;
            for (String marble : marblesPlace) {
                if (marble.equals("1")) {
                    countMarble += 1;
                }
            }

            System.out.println(countMarble);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 23380
N, Y = map(int, input().split())
Y //= 1000
for nog in range(N + 1):
    for hig in range(N + 1 - nog):
        yuk = N - nog - hig
        if nog + hig * 5 + yuk * 10 == Y:
            print(yuk, hig, nog)
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int H,W,K;
    cin >> H >> W >> K;
    vector<string> c(H);
    REP(i,H) cin >> c[i];

    int ans = 0;
    REP(i, 1<<H){
        REP(j, 1<<W){
            int b = 0;
            REP(h, H){
                if((i&(1<<h))==0) continue;
                REP(w, W){
                    if((j&(1<<w))==0) continue;
                    if(c[h][w]=='#') b++;
                }
            }
            if(b==K)ans++;
        }
    }    
    pr(ans);
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define endl '\n'
#define modulo 1000000007
#define int int64_t
//#pragma GCC optimize("trapv")
#define float double
#define PI acos(-1);
#define sinDegrees(x) sin((x) * PI / 180.0)
#define tanDegrees(x) tan((x) * PI / 180.0)
#define atanDegrees(x) atan(x)* 180.0 / PI
using namespace std;
int power(int x,int y,int m)
{
int temp;
if(y == 0)
return 1;
temp = (power(x, y/2,m))%m;
if (y%2 == 0)
return ((temp%m)*temp);
else
return ((x*temp%m)*temp%m)%m;
}
int inv(int x)
{
return (power(x,modulo-2,modulo))%modulo;
}
bool comp(int a,int b)
{
return a<b;
}
///Solution created by:Ahmadsm2005
int DP[51][2501][51][2],arr[51];
int maxer,A;
int Recursion(int n,int total,int taken,bool changed){
int flag=0;
if(total==A*taken&&taken&&changed)
flag=1;
if(n>=maxer)
return flag;
if(DP[n][total][taken][changed]+1)
return DP[n][total][taken][changed];
DP[n][total][taken][changed]=0;
DP[n][total][taken][changed]=Recursion(n+1,total+arr[n],taken+1,1)+Recursion(n+1,total,taken,0)+flag;
return DP[n][total][taken][changed];
}
int32_t main()
{
//freopen("output.txt","w", stdout);
//freopen("output.txt","r", stdin);
//iostream::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n>>A;
maxer=n;
for(int i=0;i<n;i++)
cin>>arr[i];
for(int i=0;i<51;i++){
for(int l=0;l<2501;l++)
for(int z=0;z<51;z++)
for(int q=0;q<2;q++)
DP[i][l][z][q]=-1;
}
cout<<Recursion(0,0,0,1);
return 0;
}


Measured memory_bytes: 102016
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       ll n;
       cin>>n;
       cout<<n+n*n+n*n*n;
        
    }
    return 0;
}

Measured memory_bytes: 3600
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = Integer.parseInt(sc.nextLine());
			double nDouble =(double)n;
			if(n==0){
				break;
			}
			String[] line= sc.nextLine().split(" ");
			double[] s = new double[n];
			double m=0;
			double sum=0;
			double alpha=0;
			for(int i=0;i<n;i++){
				s[i]=Double.parseDouble(line[i]);
				sum+=s[i];
			}
			m=sum/nDouble;
			sum=0;
			for(int i=0;i<n;i++){
				sum+=(s[i]-m)*(s[i]-m);
			}
			alpha=Math.sqrt(sum/n);
			System.out.printf("%.5f",alpha);
			System.out.println();
		}
	}
}

Measured memory_bytes: 29616
package main
          
import (       
        "errors"   
        "fmt"
        "strings"
)                       
                        
func isTapDanceEasy(s string) bool {
        if len(s) >= 1 && len(s) <= 100 {
                odds := make([]string, 0)
                evens := make([]string, 0)
                sl := strings.Split(s, "")
                                                 
                for i, char := range sl {                                                                                             
                        if (i+1)%2 == 0 {
                                evens = append(evens, char)
                                continue
                        }
                        odds = append(odds, char)
                }                   
                odd := strings.Join(odds, "")                       
                even := strings.Join(evens, "")             
                if strings.Contains(odd, "L") || strings.Contains(even, "R") {
                        return false                                       
                }          
                return true
        }  
        panic(errors.New("No solution"))
}

func main() {
        var s string
        fmt.Scan(&s)
        if isTapDanceEasy(s) {
                fmt.Println("Yes")  
        } else {
                fmt.Println("No")
        }
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		//???????????£?¨??????????
		int house [][][];
		house = new int[4][3][10];//b?£?f??????r??????v???

		//????????°????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		for(int h = 0; h < n ; h++){

			int b = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int v = sc.nextInt();


			house[b-1][f-1][r-1] += v;
		}

		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 10; k++){
					System.out.print(" " + house[i][j][k]);
				}
				System.out.println("");
			}
			if(i != 3){
				System.out.println("####################");
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 30136
#coding: utf-8

num = gets.to_i

num.times do
	b,c = [], []
	data = gets.chomp.split(' ').map(&:to_i)

	data.each do |a|
		if (b.last || 0) < a then
			b << a
		elsif (c.last || 0) < a then
			c << a
		else
			break
		end
	end

	puts (data.size == (b.size + c.size)) ? "YES" : "NO"
end

Measured memory_bytes: 6100
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;

using qul = queue<ll>;

int main() {
    ll N, K,sum = 0;
    cin >> N >> K;
    vel p(N);
    REP(i, N) cin >> p[i];
    sort(ALL(p));
    REP(i, K)sum += p[i];
    cout << sum << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
struct Combin{
	#define N 1000005
	int fac[N],rv[N],facrv[N];
	Combin(){
		fac[0]=rv[1]=facrv[0]=1;
		for(int i=2;i<N;i++) rv[i]=((-(mod/i)*1LL*rv[mod%i]%mod)+mod)%mod;
		for(int i=1;i<N;i++) fac[i]=1LL*fac[i-1]*i%mod;
		for(int i=1;i<N;i++) facrv[i]=1LL*facrv[i-1]*rv[i]%mod;
	}
	int C(int r1,int n1){
		if(r1>n1) return 0;
		return fac[n1]*1LL*facrv[r1]%mod*facrv[n1-r1]%mod;
	}
	#undef N
}C;
#define N 10004
char a[N],b[N];
int num[2],len;
int dp[N][N];
int main(){
    scanf("%s%s",a+1,b+1);
    len=strlen(a+1);
    for(int i=1;i<=len;i++)
        if(a[i]=='1') num[b[i]-'0']++;
    dp[0][0]=1;
    for(int i=1;i<=num[0];i++){
        dp[0][i]=dp[0][i-1]*1LL*i*i%mod;
        for(int j=1;j<=num[1];j++)
            dp[j][i]=(dp[j][i-1]*1LL*i*i+dp[j-1][i]*1LL*i*j)%mod;
    }

    long long ans=0;
    for(int i=0;i<=num[1];i++)
        ans+=C.fac[i]*1LL*C.fac[i]%mod*C.C(i,num[1])%mod*dp[num[1]-i][num[0]]%mod*C.C(i,num[0]+num[1])%mod;
    cout<<ans%mod<<endl;
    return 0;
}

Measured memory_bytes: 401152
//#define local
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
#ifdef local
#include "debug.cpp"
#else
#define debug(...)
#endif

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    ll n,m; cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        ll a,b; cin >> a >> b; --a; --b;
        uf.unite(a,b);
    }
    ll res = 0;
    rep(i,n){
        res = max(res,(ll)uf.size(i));
    }
    cout << res << endl;
}

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

int main() {
  
  string a,b ; cin >> a >> b ; 
  //vector<int> vec(n); for ( int i = 0 ; i < n ; i++ ) cin >> vec[i] ; 
  int ans = 0 ;
  for ( int i = 0 ; i < 3 ; i++) {

      if (a[i] == b[i]) ans ++;
  }
  
  cout << ans << endl;
}



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;

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

  ll ans = 0;
  ll _max;
  for (ll i = 1; ; i++) {

    ans += i;
    if (ans >= n) {
      _max = i;
      break;
    }
  }
  ll huyou = (ll)(_max + 1) * _max / 2 - n;
  for (int i = 1; i <= _max; i++) {
    if (i == huyou) continue;
    cout << i << endl;
  }
  return 0;
}


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

int main(){
    int n, q, a, b, c;
    cin >> n >> q;

    vector<list<int>> v(n);

    for(int i = 0; i < q; i++){
        cin >> a;
        if(a == 0){
            cin >> b >> c;
            v[b].push_back(c);
        }else if(a == 1){
            cin >> b;
            list<int>::iterator it = v[b].begin();
            if(it != v[b].end())    cout << *it;

            while(++it != v[b].end()){
                cout << " " << *it;
            }
            cout << endl;
        }else if(a == 2){
            cin >> b >> c;
            v[c].splice(v[c].end(), v[b]);
        }
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int a, b, t;
  cin >> a >> b >> t;
  cout << (t/a)*b << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include<string.h>

int main(void)
{
    char array[5];
    char swap;
    int c,d,n=4,test=0;
    scanf("%s",array);
    for (c = 0 ; c < n - 1; c++)
    {
        for (d = 0 ; d < n - c - 1; d++)
        {
            if (array[d] > array[d+1]) /* For decreasing order use < */
            {
                swap       = array[d];
                array[d]   = array[d+1];
                array[d+1] = swap;
            };
            
        };
    };
    if(array[0]!=array[1]){
        test=-1;
    };
    if(array[2]!=array[3]){
        test=-1;
    };
    if(array[0]==array[2]){
        test=-1;
    };
    if(test==0){
        printf("Yes");
    }
    else{
        printf("No");
    };
    return 0;
};

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int, int>;

// Sieve of Eratosthenes
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (int i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.emplace_back(i);
      f[i] = i;
      for (int j = i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }

  bool isPrime(int x) { return f[x] == x; }

  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }

  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p)
        res.back().second++;
      else
        res.emplace_back(p, 1);
    }
    return res;
  }
} primes(100);

int comb(int n, int r) {
  if (n < r) return 0;
  int x = 1;
  rep(i, r) x = x * (n-i) / (i+1);
  return x;
}

void Main() {
  int n;
  cin >> n;
  map<int, int> m;
  REP(i, 2, n+1) for (int a : primes.factorList(i)) m[a]++;
  int t = 0;
  int f = 0;
  int ans = 0;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    int c = itr->second;
    if (2 <= c) t++;
    if (4 <= c) f++;
    if (74 <= c) ans++;
  }
  ans += comb(f, 2) * (t - 2);
  t = 0;
  f = 0;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    int c = itr->second;
    if (4 <= c) t++;
    if (14 <= c) f++;
  }
  ans += f * (t - 1);
  t = 0;
  f = 0;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    int c = itr->second;
    if (2 <= c) t++;
    if (24 <= c) f++;
  }
  ans += f * (t - 1);
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    vi vec(n);
    REP(i,n){
        cin>>vec[i];
    }
    int ans=INF;
    REP(i,n-m+1){
        if(vec[i]<=0&&vec[i+m-1]<=0){
            chmin(ans,abs(vec[i]));
        }else if(vec[i]>=0&&vec[i+m-1]>=0){
            chmin(ans,abs(vec[i+m-1]));
        }else{
            chmin(ans,abs(vec[i])+abs(vec[i+m-1])+min(abs(vec[i]),abs(vec[i+m-1])));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>

using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long int64;
typedef vector<int64> vec;
typedef vector<vec> mat;

int64 N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const int64 MOD = (1e+9) + 7;
const int64 INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<int64,int64> P;

typedef vector<P> vp;
typedef vector<vp> matP;

void kill()
{
  cout << -1 << endl;
  exit(0);
}
int main()
{
    int N, K;
    cin >> N;
    cin >> K;
    vector<int> P(N);
    vector<int> UD(N);
    int cnt = 1;
    for (int i = 0; i < N; i++){
        cin >> P[i];
        if (i >= 1 && P[i - 1] < P[i]){
            cnt++;
        } else {
            cnt = 1;
        }
        UD[i] = cnt;
    }
    set<int> a, b;
    
    for (int i = 0; i < K; i++){
        a.insert(P[i]);
    }
    set<int>::iterator ite, ite2;
    

    //int ans = 1;
    int ans = UD[K - 1] < K;
    int sameFlag = 0;
    int prevFlag = 0;
    for (int i = K; i < N; i++){
        //printf("(%d, %d) UD[%d] = %d\n",*a.begin(), -*b.begin(), i, UD[i]);
        if (UD[i] >= K){
            sameFlag = 1;
        //} else if (!(P[i - K] == *a.begin() && P[i] > -*b.begin())){
        } else if ((P[i - K] != (*a.begin()) || P[i] < (*a.rbegin()))) {
            ans++;
        }
        a.insert(P[i]);
        a.erase(P[i - K]);
    }
    if (UD[K - 1] >= K){
      sameFlag = 1;
    }
    cout<<ans + sameFlag <<endl;
    return 0;
}




Measured memory_bytes: 11136
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd
#define int ll

int n,a,k;

vector <int> g;



int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a >> k;
        int t=a%k;
        for(int i=a/k;i>=0;i--){
            if(t%(i+1)==0){
                g.pb(i);
                break;
            }
            if(i>k){
                int d=i+1,f=t-i-1;
                i-=d/k; d%=k;
                if(d>t) i--;
                i++;
                t=(f%k+k)%k;
            }
            else{
                int p=t%(i+1);
                p--;
                p=i-p;
                p=k-p;
                t=p;
            }
        }
    }
    int x=0;
    for(int i : g){
        x^=i;
    }
    if(x) cout << "Takahashi";
    else cout << "Aoki";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  ll a,b;
  cin>>a>>b;
  ll mx=max(a,b);
  for(ll i=mx;;i+=mx){
    if(i%a==0&&i%b==0){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3628
N,M = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)
X.sort!

if N>=M
  puts 0
  exit
end

d = Array.new(M,0)

for i in 0..M-2 do
  d[i] = X[i+1] - X[i]
end

d.sort!

sum = 0

for i in 0..M-N do
  sum += d[i]
end

puts sum


Measured memory_bytes: 9720