akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define drep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define MAGICLINE ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define se second
#define fs first
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, pair<int, int> > PII;
typedef priority_queue<PII,
                       vector<PII>,
                       greater<PII> > dijQ;

const int MN = 100002;
int dist[MN];
bool parent[MN], visit[MN];
queue<int> Q;
vector<int> V[MN];

void dfs(int node){
    visit[node] = true;
    int mn = 0;
    rep(i, 0, V[node].size()){
        int next = V[node][i];
        if(!visit[next]) dfs(next);
        mn = max(mn, dist[next]);
    }
    dist[node] = mn+1;
}

int main(){
    int n, m; scanf("%d %d", &n, &m);
    rep(i, 0, m){
        int a, b; scanf("%d %d", &a, &b);
        V[a].pb(b);
        parent[b] = true;
    }
    rep(i, 1, n+1)
        if(!parent[i])
            Q.push(i);

    while(!Q.empty()){
        int curr = Q.front(); Q.pop();
        dfs(curr);
    }

    int fin = 0;
    rep(i, 1, n+1) fin = max(fin, dist[i]);
    printf("%d\n", fin-1);
    return 0;
}


Measured memory_bytes: 12544
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, m, c, tmp, a, ans = 0;
	scanf("%d%d%d", &n, &m, &c);
	vector<int> b(m);
	rep(i, m)scanf("%d", &b[i]);
	rep(i, n) {
		a = 0;
		rep(j, m) {
			scanf("%d", &tmp);
			a += tmp * b[j];
		}
		if (a + c > 0)++ans;
	}
	printf("%d\n", ans);

	Please AC;
}


Measured memory_bytes: 888
#include    <stdio.h>

int main(void)
{
  int x, y;
  
  while (1) {
    scanf("%d %d", &x, &y);
    if (x == 0 && y == 0) break;
    if (x < y) {
      printf("%d %d\n", x, y);
    } else {
      printf("%d %d\n", y, x);
    }
  }
  
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <algorithm>
#include <cstddef>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <list>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
//add #define GRAPH for graph theory problems
#define mp make_pair
#define pb push_back
#ifdef GRAPH
typedef pair <int, int> Edge;
#define v first
#define w second
#endif
#ifdef GEOMETRY
typedef pair <int, int> Point;
#define x first
#define y second
#endif
#ifdef FILEIO
#define FILEOPEN(in, out) freopen(in, "r", stdin);freopen(out, "w", stdout);
#endif
using LL = long long;
using ULL = unsigned long long;
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define rep(i, n) for (int (i) = 0; (i) < n; (i)++)
#define until(x) while (!x)
#define fail(s) assert(!s)
const int INF = 0x3f3f3f3f;
const int EPS = 1e-6;
const int MAXN = 3005;
int n;
double a[MAXN];
double dp[MAXN][MAXN];
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i];
	dp[1][1] = a[1];
	dp[1][0] = (1 - a[1]);
	for (int i = 2; i <= n; i++) 
		for (int j = 0; j <= i; j++) {
			if (j >= 1)dp[i][j] = dp[i - 1][j - 1] * a[i];
			dp[i][j] += (dp[i - 1][j] * (1 - a[i]));
		}
	double ans = 0;
	for (int j = (int)ceil(n / 2) + 1; j <= n; j++)ans += dp[n][j];
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}


Measured memory_bytes: 68992
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-9
# define MOD 1024523
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=105;

struct Node{int w, v;}node[N];

int dp[N][305];

int main ()
{
    int n, W;
    scanf("%d%d",&n,&W);
    FOR(i,1,n) scanf("%d%d",&node[i].w,&node[i].v);
    FOR(i,1,n) {
        int tmp=node[i].w-node[1].w;
        for (int j=i; j>=1; --j) for (int k=300; k>=tmp; --k) {
            dp[j][k]=max(dp[j][k],dp[j-1][k-tmp]+node[i].v);
        }
    }
    int V=W/node[1].w, ans=0;
    for (int i=V; i>=1; --i) {
        int y=min(W-node[1].w*i,300);
        ans=max(ans,dp[i][y]);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
double a,b,c,d,e,f;
double x1,y1,x2,y2,x3,y3,xp,yp;
while(cin>>x1){
cin>>y1>>x2>>y2>>x3>>y3>>xp>>yp;
x1-=x3;y1-=y3;x2-=x3;y2-=y3;xp-=x3;yp-=y3;
if((a=x1*y2-x2*y1)>0)b=1;else b=-1;
if((c=b*(x1*yp-xp*y1))<0){cout<<"NO"<<endl;continue;}
if((d=b*(xp*y2-x2*yp))<0){cout<<"NO"<<endl;continue;}
if(c+d>a*b)cout<<"NO"<<endl;else cout<<"YES"<<endl;
}
return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1000000007;

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

//********************************template END****************************************//

void solve(void)
{
	int A, B;
	cin >> A >> B;
	cout << A + B / 2 << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 384
n, t = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(n)]

m, d = 0, [0] * t
for a, b in sorted(ab):
  m = max(m, b+d[t-1])
  for l in range(t-1,a-1,-1):
    if(b+d[l-a] > d[l]):
      d[l] = b+d[l-a]
print(m)

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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;
int dp[N];
vi adj[N];
int inDeg[N];
queue < int > q;

void solve(){

    scanf("%d %d" , &n , &m);

    for(int i = 0 ; i < m ; i ++){
        int u , v;
        scanf("%d %d" , &u , &v);

        adj[u].push_back(v);
        inDeg[v] ++;
    }
    for(int i = 1 ; i <= n ; i ++){
        if(!inDeg[i])q.push(i);
    }

    int ans = 0;
    while( !q.empty() ){
        int u = q.front();
        q.pop();

        ans = max(ans , dp[u]);
        for(int v : adj[u]){
            dp[v] = max(dp[v] , 1 + dp[u]);
            inDeg[v] --;
            if(inDeg[v] == 0)q.push(v);
        }
    }
    printf("%d\n" , ans);
}

main(){
    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
            solve();
    }

    return 0;
}






Measured memory_bytes: 9088
// ------------------
// author: MatsuTaku
// date  : 22/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int A,B,C,X,Y; cin>>A>>B>>C>>X>>Y;
  int ans1 = A*X+B*Y;
  int ans2 = X>=Y ? A*(X-Y)+C*Y*2 : C*X*2+B*(Y-X);
  int ans3 = max(X,Y)*C*2;
  cout << min(min(ans1, ans2), ans3) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/


signed main(){
  int n;
  cin>>n;
  vi s(n);
  rep(i,n)cin>>s[i];
  int q;
  cin>>q;
  vi t(q);
  rep(i,q)cin>>t[i];
  int ans=0;
  
  rep(i,q){
    int l=-1,r=n,m;
    while(l+1<r){
      m=(l+r)/2;
      // if(s[m]==t[i]){
      //   break;
      // }
      if(s[m]<t[i]) l=m;
      else r=m;
    }
    if(l>=0&&s[l]==t[i]) ans++;
    else if(r<n&&s[r]==t[i]) ans++;

  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3860
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);

    rep(i,0,n)
        cin >> p[i];

    sort(p.begin(), p.end());

    ll accm(0);
    rep(i,0,k)
        accm += p[i];
       
    cout << accm << endl; 

    return 0;
}


Measured memory_bytes: 3648
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	h,w=MI()

	S=["#"*(w+1)]
	for _ in range(h):
		S.append("#"+input().rstrip().decode())
	#print(S)

	G=[[10**10]*(w+1) for _ in range(h+1)]

	if S[1][1]=="#":
		G[1][1]=1
	else:
		G[1][1]=0

	for i in range(1,h+1):
		for j in range(1,w+1):
			#print(G)
			if i==j==1:
				continue
			a=G[i-1][j]+(S[i-1][j]=="." and S[i][j]=="#")
			b=G[i][j-1]+(S[i][j-1]=="." and S[i][j]=="#")
			#print(i,j,a,b)
			G[i][j]=min(a,b)

	print(G[h][w])













if __name__ == "__main__":
	main()


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

void    chmax(long long *left, long long right)
{
        if (*left < right)
        {
                *left = right;
        }
}

int             main(void)
{
        int                     n;
        int                     w_max;
        int                     weight[100];
        int                     value[100];
        long long       answer[100][100001] = {0};
        long long       max = 0;
        int                     i;
        int                     j;

        scanf("%d%d", &n, &w_max);
        for (i = 0; i < n; i++)
        {
                scanf("%d%d", &weight[i], &value[i]);
        }
        for (i = 0; i <= w_max; i++)
        {
                if (i < weight[0])
                        answer[0][i] = 0;
                else
                        answer[0][i] = value[0];
        }
        for (i = 1; i < n; i++)
        {
                for (j = 0; j <= w_max; j++)
                {
                        if (j + weight[i] <= w_max)
                        {
                                chmax(&answer[i][j + weight[i]], answer[i - 1][j] + value[i]);
                        }
                        chmax(&answer[i][j], answer[i - 1][j]);
                }
        }
        for (i = 0; i <= w_max; i++)
        {
                chmax(&max, answer[n - 1][i]);
        }
        printf("%lld\n", max);
        return (0);
}

Measured memory_bytes: 79852
#include <iostream>

using namespace std;

int main(){
  int a, b, c, d, ans;
  cin >> a >> b >> c >> d;

  if (b<=c || d<=a) ans=0;
  else if (a<=c && d<=b) ans=d-c;
  else if (a>=c && d>=b) ans=b-a;
  else if (c<=a) ans=d-a;
  else ans=b-c;

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 55;
const ll mm = 1e+18;
void solve()
{
    int x;
    cin>>x;
    int cu=400;
    int f=8;
    while(1){
        if(x>=cu&&x<cu+200){
            cout<<f;
            return;
        }
        cu+=200;
        f--;
    }
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // freopen("sp.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll i,j,m,n,k;
    ll t;
    string s;
    cin>>n;
    while(n>0)
    {
        s.pb((n-1+26)%26+'a');
        n=(n-1)/26;
    }
    reverse(s.begin(),s.end());
    cout<<s;
}


Measured memory_bytes: 3648
import numpy as np

n, m = list(map(int, input().split()))
ablist = [list(map(int, input().split())) for _ in range(m)]

from1 = np.zeros(n, dtype=int)
ton = np.zeros(n, dtype=int)

for ab in ablist :
    if ab[0] == 1 :
        from1[ab[1]-1] = 1
    elif ab[1] == n :
        ton[ab[0]-1] = 1

if sum(from1*ton) > 0 :
    print("POSSIBLE")
else :
    print("IMPOSSIBLE")

Measured memory_bytes: 62316
#include<stdio.h>
int main(){
int i,j,k,n,v;
int a[1000];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(i=0;i<n-1;i++){
printf("%d ",a[i]);
}
printf("%d\n",a[i]);
for(i=1;i<n;i++){
v=a[i];
j=i-1;
while(j>=0&&a[j]>v){
a[j+1]=a[j];
j--;
a[j+1]=v;
}
for(k=0;k<n-1;k++){
printf("%d ",a[k]);
}
printf("%d\n",a[k]);
}
return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    int check = N % 10;

    if (check == 3) {
        cout << "bon" << endl;
    }
    else if (check == 0 || check == 1 || check == 6 || check == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }
}

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

int main(void) {
	int n,i;
	scanf("%d", &n);
	
	int a[n];

	for(i=0; i<n; i++) {
		int j, check;
		double circ[6];
		double dist, center;
		
		for(j=0; j<6; j++)
			scanf("%lf", &circ[j]);
		
		center = circ[2] + circ[5];
		dist = sqrt( pow(circ[0]-circ[3], 2.0) + pow(circ[1]-circ[4], 2.0) );
		
		if(center<dist) check = 0;
		else if(fabs(circ[2]-circ[5])-dist<=0) check = 1;
		else{
			if(circ[2] > circ[5]) check = 2;
			else check = -2;
		}
		
		a[i] = check;
	}
			
	for(i=0; i<n; i++)
		printf("%d\n", a[i]);
			
	return 0;
}		

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int prev = sc.nextInt();
        int count = 1;
        int total = 0;
        for (int i = 1; i < n; i++) {
            int x = sc.nextInt();
            if (x == prev) {
                count++;
            } else {
                total += count / 2;
                prev = x;
                count = 1;
            }
        }
        total += count / 2;
       System.out.println(total);
    }
}


Measured memory_bytes: 22100
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

func main() {
	sc.Split(bufio.ScanWords)
	n, x := nextInt(), nextInt()

	ans := abs(nextInt() - x)
	for i := 1; i < n; i++ {
		ans = gcd(ans, abs(nextInt()-x))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define PB(a,num) FOR(i,0,num) {ll x; scanf("%lld",&x); a.pb(x); }
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111

string a[4], b;

char SW(char c1,char c2,char info) {
  if (info == 'o') {
	if (c2 == 'S') {
	  if (c1 == 'S') {
		return 'S';
	  }
	  else {
		return 'W';
	  }
	}
	else {
	  if (c1 == 'S') {
		return 'W';
	  }
	  else {
		return 'S';
	  }
	}
  }
  else {
	if (c2 == 'S') {
	  if (c1 == 'S') {
		return 'W';
	  }
	  else {
		return 'S';
	  }
	}
	else {
	  if (c1 == 'S') {
		return 'S';
	  }
	  else {
		return 'W';
	  }
	}
  }
}

bool solve(ll x) {
  FOR(i, 3, n) {
	a[x] += SW(a[x][i - 2], a[x][i - 1], b[i - 1]);
  }
  if ((a[x][0] == SW(a[x][n - 2], a[x][n - 1], b[n - 1])) && (a[x][1] == SW(a[x][n - 1], a[x][0], b[0]))) {
	return true;
  }
  else {
	return false;
  }
}

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

  if (b[1] == 'o') {
	a[0] = "SSS";
	a[1] = "WSW";
	a[2] = "WWS";
	a[3] = "SWW";
  }
  else {
	a[0] = "WSS";
	a[1] = "SSW";
	a[2] = "SWS";
	a[3] = "WWW";
  }

  FOR(i, 0, 4) {
	if (solve(i)) {
	  cout << a[i] << endl;
	  return 0;
	}
  }
  cout << "-1" << endl;

  return 0;
}

Measured memory_bytes: 896
p = [1] * (1000000 + 1)
p[0], p[1] = 0, 0
for i in range(2, int(1000000 ** 0.5) + 1):
    if not p[i]:
        continue
    for j in range(2 * i, 1000000 + 1, i):
        p[j] = 0

while 1:
    try:
        n = int(input())
        print(sum(p[:n+1]))
    except:
        break



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

int W, H;
char visit[21][21];
int dfs(int h, int w){
  int sum=1;
  if(0>w || w==W || 0>h || h==H) return 0;
  if(visit[h][w]=='#')  return 0;
  if(visit[h][w]=='!')   return 0;
    visit[h][w] = '!';
    sum += dfs(h, w+1);
    sum += dfs(h, w-1);
    sum += dfs(h+1, w);
    sum += dfs(h-1, w);
   
  return sum;
}

int main(void){
  int w1, h1;
  string str;
  while(cin >> W >> H){
    if(W == 0 && H == 0)  break;
    for(int i=0; i<H; i++){
      cin >> str;
      for(int j=0; j<W; j++){
        visit[i][j] = str[j];
        if(visit[i][j] == '@'){
          visit[i][j] = '.';
          w1 = j; h1 = i;  
        }
      }
    }
    cout << dfs(h1, w1) <<endl;
  }
   
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  if(n%10==3) cout << "bon\n";
  else if(n%10==0 || n%10==1 || n%10==6 || n%10==8) cout  << "pon\n";
  else cout << "hon\n";
  return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace ABC92
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = int.Parse(ReadLine());
            int B = int.Parse(ReadLine());
            int C = int.Parse(ReadLine());
            int D = int.Parse(ReadLine());
            WriteLine(Math.Min(A, B )+ Math.Min(C, D));
        }
    }
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
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;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  auto v=divisor(m);
  ll ans=0;
  for(auto e: v){
    if(e*n<=m) chmax(ans,e);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var V = Console.ReadLine().Split().Select((s, index) => new { Value = int.Parse(s), Index = index }).ToArray();
            var evenCosts = from value in V
                            where value.Index % 2 == 0
                            group value by value.Value into g
                            let cost = new { Value = g.Key, Cost = V.Length / 2 - g.Count() }
                            orderby cost.Cost
                            select cost;
            var oddCosts = from value in V
                           where value.Index % 2 == 1
                           group value by value.Value into g
                           let cost = new { Value = g.Key, Cost = V.Length / 2 - g.Count() }
                           orderby cost.Cost
                           select cost;

            int ans = int.MaxValue;
            foreach (var even in evenCosts.Take(2))
            {
                foreach (var odd in oddCosts.Take(2))
                {
                    if (even.Value != odd.Value)
                    {
                        ans = Min(ans, even.Cost + odd.Cost);
                    }
                }
            }

            if (ans == int.MaxValue)
            {
                ans = V.Length / 2;
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 42508
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair <int, int>
#define vi vector<int>
 
#define read1(a) int a; scanf("%d", &a)
#define read2(a, b) int a, b; scanf("%d %d", &a, &b)
#define read3(a, b, c) int a, b, c; scanf("%d %d %d", &a, &b, &c)
 
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define readgi(n) F0R(i, n) { scanf("%d", &arr[i]); }
#define readgs(n) F0R(i, n) { scanf(" %c", &arr[i]); }
 
#define f first
#define s second
 
const int MOD = 1000000007;
const int MAX = 100005;
 
ll a[MAX];
vector<ll> care;
map<ll, ll> dp;
ll ans[MAX];
int main() {
    int n, q; scanf("%d %d", &n, &q);
    a[0] = n;
    F0R(i, q) {
        ll k; scanf("%lld", &a[i+1]);
    }
    ll mins = 1000000000000000001;
    for (int i=q;~i;i--) {
        if ((ll)a[i] < mins) { care.pb(mins = (ll)a[i]); }
    }
    dp[care[0]] = 1;
    for (ll i : care) {
        if (i == care[0]) { continue; }
        auto j = dp.end(); j--;
        while (j->f > i) {
            dp[i] += dp[j->f]*((j->f)/i);
            dp[(j->f)%i] += dp[j->f];
            dp.erase(j--); j = dp.end(); j--;
        }
    }
    for (auto i : dp) { ans[i.f] = i.s; }
    for (int i=n; i>=1; i--) { ans[i] += ans[i+1]; }
    FOR(i, 1, n+1) { printf("%lld\n", ans[i]); }
}

Measured memory_bytes: 10228
#include <iostream>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<string> ss(n);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ss[i] = s;
  }
  
  sort(ss.begin(), ss.end());
  unsigned long long result = 0;
  string s_base = "";
  unsigned long long group_count = 0;
  for(int i = 0; i < n; i++) {
    if (s_base == ss[i]) {
      group_count++;
    } else {
      result += group_count * (group_count+1) / 2;
      group_count = 0;
      s_base = ss[i];
    }
  }
  result += group_count * (group_count+1) / 2;
  
  cout << result << endl;
  
  return 0;
}


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

int main() {
	string str="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int n;
	string a;
	cin>>n>>a;
	for(int i=0; i<a.size(); i++) {
		a[i]=str[int(a[i]-'A')+n];
	}
	cout<<a<< endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    int d;
    scanf("%d",&d);
    if(d==22)printf("Christmas Eve Eve Eve\n");
    if(d==23)printf("Christmas Eve Eve\n");
    if(d==24)printf("Christmas Eve\n");
    if(d==25)printf("Christmas\n");
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));

    ll max = 0;
    ll smaller=0, greater=0,equal = 0;

    ll i = 0;
    ll x;
    while (i < n)
    {
        x = a[i];
        while (i<n and a[i] == x)
        {
            i++;
            equal++;
        }
        ll j = i;
        while (j<n and a[j] - x == 1)
        {
            j++;
            greater++;
        }
        if (smaller + equal + greater > max)
            max = smaller + equal + greater;
        if(a[i]-x==1)smaller = equal;
        else smaller = 0;
        greater = 0;
        equal = 0;
    }

    cout<<max<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr array<char, 3> CH{'R', 'G', 'B'};

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

    int n;
    string s;
    cin >> n >> s;

    vector<int> r_count(n);
    vector<int> g_count(n);
    vector<int> b_count(n);

    map<char, int> letter_count;
    for (int i = 0; i < n; i++) {
        letter_count[s[i]]++;

        r_count[i] = letter_count['R'];
        g_count[i] = letter_count['G'];
        b_count[i] = letter_count['B'];
    }

    int ans = 0;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            if (s[i] == 'R' && s[j] == 'G') {
                ans += b_count[n - 1] - b_count[j];
                if (j + j - i < n)
                    ans -= (b_count[j + j - i] - b_count[j + j - i - 1]);
            }
            if (s[i] == 'R' && s[j] == 'B') {
                ans += g_count[n - 1] - g_count[j];
                if (j + j - i < n)
                    ans -= (g_count[j + j - i] - g_count[j + j - i - 1]);
            }
            if (s[i] == 'G' && s[j] == 'R') {
                ans += b_count[n - 1] - b_count[j];
                if (j + j - i < n)
                    ans -= (b_count[j + j - i] - b_count[j + j - i - 1]);
            }
            if (s[i] == 'G' && s[j] == 'B') {
                ans += r_count[n - 1] - r_count[j];
                if (j + j - i < n)
                    ans -= (r_count[j + j - i] - r_count[j + j - i - 1]);
            }
            if (s[i] == 'B' && s[j] == 'R') {
                ans += g_count[n - 1] - g_count[j];
                if (j + j - i < n)
                    ans -= (g_count[j + j - i] - g_count[j + j - i - 1]);
            }
            if (s[i] == 'B' && s[j] == 'G') {
                ans += r_count[n - 1] - r_count[j];
                if (j + j - i < n)
                    ans -= (r_count[j + j - i] - r_count[j + j - i - 1]);
            }
        }
    }

    cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    int res = 0;
    rep(i,n+1){
        if(i%2==0) continue;
        int temp = 0;
        rep(j,n) if(i%(j+1)==0) temp++;
        if(temp ==8) res++;
    }
    cout << res << endl;
}

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

int[10^^5] AS;

void main()
{
    auto N = readln.chomp.to!int;
    auto as = readln.split.to!(int[]);

    auto x = as[0];
    foreach (a; as) {
        x = gcd(x, a);
    }
    writeln(x);
}

Measured memory_bytes: 4220
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

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


int main(){
    ll N, K;
    cin >> N >> K;
    ll x = N / K;
    if(K % 2 == 1) {
        cout << x * x * x << endl;
    }
    else{
        ll y = N * 2 / K;
        cout << (y-x)*(y-x)*(y-x) + x * x * x << endl;
    }

    return 0;

}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int K, i, count1=0, count2=0;
	scanf("%d", &K);
	
	for(i=1;i<=K;i++){
		if(i%2==0){
			count1++;
		}else{
			count2++;
		}
	}
	printf("%d\n", count1*count2);
	
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	set<int> st;
	for(int i = 0;i <= 999;i++){
		int a1 = -1,a2 = -1,a3 = -1;
		for(int j = 0;j < s.size();j++){
			if(a1 == -1 && a2 == -1 && a3 == -1 && s[j]-'0'== i/100){
				a1 = s[j]-'0';
			}
			else if(a1 != -1 && a2 == -1 && a3 == -1 && s[j]-'0'== i/10 % 10){
				a2 = s[j]-'0';
			}
			else if(a1 != -1 && a2 != -1 && a3 == -1 && s[j]-'0'==i%10){
				a3 = s[j]-'0';
			}
			if(a1!=-1&&a2!=-1&&a3!=-1) break;
		}
		if(a1!=-1&&a2!=-1&&a3!=-1){
//			cout << a1 <<" " << a2 << " " << a3 << endl;
			int y = a1 * 100 + a2 * 10 + a3;
			st.insert(y);
//			printf("%03d\n",y);
		}
	}
	cout << st.size() << endl;
	return 0;
}//123123213213

Measured memory_bytes: 384
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
items = [
    [(0, 0), (0, 1), (0, 2)],
    [(1, 0), (1, 1), (1, 2)],
    [(2, 0), (2, 1), (2, 2)],
    [(0, 0), (1, 0), (2, 0)],
    [(0, 1), (1, 1), (2, 1)],
    [(0, 2), (1, 2), (2, 2)],
    [(0, 0), (1, 1), (2, 2)],
    [(0, 2), (1, 1), (2, 0)]
]

is_bingo = False
for item in items:
    is_bingo = \
        a[item[0][0]][item[0][1]] in b and \
        a[item[1][0]][item[1][1]] in b and \
        a[item[2][0]][item[2][1]] in b
    if is_bingo:
        print("Yes")
        exit(0)
print("No")


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		long A = nextLong();
		long B = nextLong();
		int C = nextInt();
		int D = nextInt();

		long ans = B-A+1-((B/C+B/D-B/(lcm(C,D)))-((A-1)/C+(A-1)/D-(A-1)/(lcm(C,D))));

		System.out.println(ans);
	}

public static long gcd(long a, long b) {
	long x, y;
	if (a < b) {
		x = b;
		y = a;
	} else {
		x = a;
		y = b;
	}
	long r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
public static long lcm(long a, long b) {
	long x, y;

	return ((a / gcd(a, b)) * b);
}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

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

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

int N, M;
typedef pair<int, long long> Edge;
vector<vector<Edge> > G;

const long long INF = 1LL<<59;

int main() {
    while (cin >> N >> M) {
        G.clear();
        G.resize(N);
        for (int i = 0; i < M; ++i) {
            int a, b;
            long long c;
            cin >> a >> b >> c;
            --a, --b;
            G[a].push_back(Edge(b, c));
        }
        
        vector<long long> dist(N, -INF);
        dist[0] = 0;
        for (int iter = 0; iter < N*2; ++iter) {
            bool finish = true;
            for (int v = 0; v < N; ++v) {
                for (auto e : G[v]) {
                    if (chmax(dist[e.first], dist[v] + e.second)) {
                        if (e.first == N-1) finish = false;
                    }
                }
            }
            
            if (iter > N && !finish) {
                cout << "inf" << endl;
                return 0;
            }
        }
        
        cout << dist[N-1] << endl;
    }
}










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

int main(){
	cout << fixed << setprecision(12);	
	
	int a,b;

	cin>>a>>b;
	

	cout<<a/b<<" ";
	cout<<a%b<<" ";
	cout<<(double)a/b<<endl;

	return 0;
}




Measured memory_bytes: 3288
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	bool flg = true;

	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		if (a % 2 == 0) {
			if (a % 3 != 0 and a % 5 != 0) flg = false;
		}
	}

	cout << (flg ? "APPROVED" : "DENIED");

	return 0;
}

Measured memory_bytes: 3044
h,w=map(int,raw_input().split())
c=[[1]*(w+1)]+[[1]+map(int,raw_input().split()) for _ in xrange(h)]
dp=[[0]*(w+1) for i in xrange(h+1)]
for i in xrange(h):
	for j in xrange(w):
		if c[i+1][j+1]==0:
			dp[i+1][j+1]=min(dp[i][j+1],dp[i+1][j],dp[i][j])+1
print(max([max(i) for i in dp])**2)

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

int main(int argc, char const *argv[]) {
    int N;
    string S;
    cin >> N >> S;

    for (int i = 0; i < int(S.size()); i++) {
        cout << char((S.at(i) - 'A' + N) % 26 + 'A');
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    int n,k,i,j,count,p,r;
    long long sum=0;
    int max(int a,int b);
    scanf("%d%d",&n,&k);
    for(i=k+1;i<=n;i++)
    {
        r=n%i;
        p=n/i;
        sum+=p*max(0,i-k);//前半段;
        sum+=max(0,r-k+1);//后半段;
    }
    if(k==0)
        sum-=n;//坑;
    printf("%lld\n",sum);
    return 0;
}
int max(int a,int b)
{
    if(a>b) return 0;
    else return b;
}


Measured memory_bytes: 128