akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

map<vector<int>, int> mp;

ll combination(ll n, ll r){
  ll num = 1;
  ll div = 1;
  for (int i = 1; i <= r; i++) {
    num *= (n - i + 1);
    div *= i;
  }
  return num / div;
}

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  mp.clear();
  REP(i, n) {
    string s;
    cin >> s;
    vector<int> a;
    REP(j, s.size()) a.push_back(s[j] - 'a');
    SORT(a);
    if (!mp.count(a)) mp[a] = 1;
    else
      mp[a]++;
  }
  ll ans = 0;
  //for (auto it = mp.begin(); it != mp.end(); it++) {
  EACH(it, mp) {
    if (it.second >= 2) ans += combination(it.second, 2);
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 12800
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(){
  int i=0,j;
  char S[101];
  long k;
  scanf("%s",S);
  scanf("%ld",&k);
  for(i=0;i<k;i++){
    if((S[i] - '0') != 1){
      printf("%c\n",S[i]);
      return 0;
    }
  }
  puts("1");
  return 0;
}
  
  



Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll dp[10][100007];

int main(){
  ll X;
  rep(i,6){
    dp[i][0] = 1;
  }
  cin >> X;
  rep(i,X+1){
    rep(j,6){
      rep(k,6){
        if(i>=100+j){
          if(dp[k][i-100-j]==1){
            dp[j][i] = 1;
          }
        }
      }
    }
  }
  rep(i,6){
    if(dp[i][X]==1){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a % 2 != b % 2) {
			System.out.println("IMPOSSIBLE");
		} else {
			System.out.println((a + b) / 2);
		}
	}
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

ll pat(int whole, int part_min, int part_max) {
    ll sum = 0;
    ll wCp = whole;
    // wC1 .. wCp
    // printf("whole=%d, part=%d..%d\n", whole, part_min, part_max);
    for (int i=1; i<=part_max; ++i) {
        if (part_min <= i) sum += wCp;
        wCp = wCp * (whole-i) / (i+1);
    }
    return sum;
}

void solve(int N,int A,int B,vector<ll>& a) {
    sort(ALL(a)); // reverse(ALL(a));
    ll ac = accumulate(a.end()-A, a.end(), 0LL);
    int denom = A;
    for (int i=A; i<B; ++i) {
        ll ac2 = ac + a[(N-1)-i];
        int denom2 = denom + 1;
        // if (ac/denom > ac2/denom2) break;
        if (ac*denom2 > ac2*denom) break;
        ac = ac2;
        denom = denom2;
    }
    ll last_val = a[(N-1)-(denom-1)];
    int whole = upper_bound(ALL(a), last_val) - lower_bound(ALL(a), last_val);
    int part = upper_bound(a.end()-denom,a.end(), last_val) - (a.end()-denom);
    // fprintf(stderr, "ac=%lld,denom=%d; last_val=%lld, whole=%d, part=%d\n", ac,denom, last_val, whole, part);

    int other = denom - part;
    int part_min = A - other;

    printf("%.8Lf\n", (long double)ac / denom);
    printf("%lld\n", pat(whole, part_min, part));
}

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


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void)
{

	int n;
	int ans;

	scanf("%d", &n);

	ans = n % 1000;

	if (ans == 0) {
		ans = 0;
	}
	else {
		ans = 1000 - ans;
	}

	printf("%d", ans);


	return 0;
}

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

int main() {
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vl a(m),b(m);
    vl toN(200001,0);
    bool flag = false;
    rep(i,m){
        cin >> a[i] >> b[i];
        if(a[i] == 1) toN[b[i]]++;
    }
    rep(i,m){
        if(b[i] == n && toN[a[i]] > 0) flag = true;
    }
    if(flag) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

typedef long long LL;
const int P = 1e9 + 7;
const int N = 1e5 + 10, M = 2e5 + 10;
int n, m, S, T; LL ans;
struct D{int x, y, v;} a[M];
struct edge{int ed, ne, v;} e[M<<1]; int he[N], en;
LL dis1[N], dis2[N], kry, num1[N], num2[N];
queue<int> q; bool inq[N];
int d[N];
LL zyf[N+M], sum; int cnt;

void ins(int a, int b, int c) {
	e[++en].ed = b; e[en].v = c; e[en].ne = he[a]; he[a] = en;
}

bool cmp1(int a, int b) {return dis1[a] > dis1[b];}
bool cmp2(int a, int b) {return dis2[a] > dis2[b];}

int main() {
	int i, j, u, v;
	scanf("%d%d", &n, &m);
	scanf("%d%d", &S, &T);
	rep(i, 1, m) {
		scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].v);
		ins(a[i].x, a[i].y, a[i].v);
		ins(a[i].y, a[i].x, a[i].v);
	}
	
	rep(i, 1, n) d[i] = i;
	
	rep(i, 1, n) dis1[i] = 0x3f3f3f3f3f3f3f;
	q.push(S); dis1[S] = 0;
	while(!q.empty()) {
		u = q.front(); inq[u] = 0; q.pop();
		for(i = he[u]; i; i = e[i].ne)
		if(dis1[u] + e[i].v < dis1[e[i].ed]) {
			v = e[i].ed;
			dis1[v] = dis1[u] + e[i].v;
			if(!inq[v]) {q.push(v); inq[v] = 1;}
		}
	}
	
	sort(d+1, d+n+1, cmp1);
	num1[T] = 1;
	rep(i, 1, n) {
		u = d[i];
		for(j = he[u]; j; j = e[j].ne)
		if(dis1[u] + e[j].v == dis1[e[j].ed]) num1[u] = (num1[u] + num1[e[j].ed]) % P;
	}
//	rep(i, 1, n) printf("%d ", d[i]); puts("");
//	rep(i, 1, n) printf("%lld ", dis1[i]); puts("");
//	rep(i, 1, n) printf("%lld ", num1[i]); puts("");
	
	
	rep(i, 1, n) dis2[i] = 0x3f3f3f3f3f3f3f;
	q.push(T); dis2[T] = 0;
	while(!q.empty()) {
		u = q.front(); inq[u] = 0; q.pop();
		for(i = he[u]; i; i = e[i].ne)
		if(dis2[u] + e[i].v < dis2[e[i].ed]) {
			v = e[i].ed;
			dis2[v] = dis2[u] + e[i].v;
			if(!inq[v]) {q.push(v); inq[v] = 1;}
		}
	}
	
	sort(d+1, d+n+1, cmp2);
	num2[S] = 1;
	rep(i, 1, n) {
		u = d[i];
		for(j = he[u]; j; j = e[j].ne)
		if(dis2[u] + e[j].v == dis2[e[j].ed]) num2[u] = (num2[u] + num2[e[j].ed]) % P;
	}
//	rep(i, 1, n) printf("%lld ", dis1[i]); puts("");
//	rep(i, 1, n) printf("%lld ", dis2[i]); puts("");
	
	kry = dis1[T];
	rep(i, 1, n) 
	if(dis1[i]*2 == kry) zyf[++cnt] = num1[i] * num2[i] % P;
	rep(i, 1, m) {
		u = a[i].x; v = a[i].y;
		if(dis1[u] > dis1[v]) swap(u, v);
		if(dis1[u] + a[i].v == dis1[v] && dis1[u]*2 < kry && dis1[v]*2 > kry) zyf[++cnt] = num2[u] * num1[v]%P;
	}
	rep(i, 1, cnt) sum = (sum + zyf[i]) % P;
	rep(i, 1, cnt) ans = (ans + zyf[i] * (sum - zyf[i]) % P + P) % P;
	printf("%lld\n", ans);
	return 0;
}

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

map<pair<int, int>, bool> memo;
bool solve(int x, int y) {
  auto p = make_pair(x, y);
  if (memo.count(p)) return memo[p];
  if (x == 0) return y == 0;
  if (x < 0) return false;
  memo[p] = solve(x - 1, y - 2) or solve(x - 1, y - 4);
  return memo[p];
}

int main() {
  int x, y;

  cin >> x >> y;

  bool ok = solve(x, y);
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3920
# coding: utf-8

N, Q = map(int, input().split())
S = input()
l_r = [tuple(map(int, input().split())) for _ in range(Q)]

isAC = [0] * N
cnt = 0
for i in range(len(S) - 1):
    if S[i] == "A" and S[i + 1] == "C":
        cnt += 1
    isAC[i + 1] = cnt

for l, r in l_r:
    print(isAC[r - 1] - isAC[l - 1])


Measured memory_bytes: 19792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 

 
int main(void){
    int k;
    cin>>k;
    k--;
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<a[k]<<endl;
    return 0;
}

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

int main() {
    string S, T;
    cin >> S >> T;

    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
        {
            ans++;
        }
        
    }
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vll a(n);
    vll b(n);
    rep(i, n) {
        cin >> a[i];
        b[i] = a[i] - (i+1);
    }
    sort(b.begin(), b.end());
    ll x = b[n/2];
    ll ans = 0;
    rep(i, n) {
        ans += abs(a[i] - (x+i+1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)
 
int main() {
	// 入力
	string S;
	ll K;
	cin >> S >> K;
	
	// 解法
	int ans = 1;
	for (int i = 0; i < K; ++i) {
		if (S.substr(i,1)!="1"){
			ans = stoi(S.substr(i, 1));
			break;
		} 
	}
	
	//出力
	printf("%lld\n", ans);
}
 


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

const ll INF = 1e18;

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

	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
		cin >> h[i];
	vector<ll> dp(n, 0);
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = INF;
		for (int j = 1; j <= 2; j++) {
			dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
		}
	}
	cout << dp[n - 1];
	
	return 0;
}


Measured memory_bytes: 4588
package main
import "fmt"
func main(){
	var a,b,c int
	ans := 0
	fmt.Scan(&a,&b)
	for i :=0;i<a;i+=1 {
		fmt.Scan(&c)
		if b<=c {
			ans += 1
		}
	}
	fmt.Printf("%d",ans)
	
}


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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int N, M, ans;
   cin >> N >> M;
   vector<int> X(M);
   rep(i, M) cin >> X.at(i);
   if (M <= N) ans = 0;
   else {
     vector<int> Y(M - 1);
     sort(X.begin(), X.end());
     rep(i, M - 1) Y.at(i) = X.at(i + 1) - X.at(i);
     sort(Y.begin(), Y.end());
     if (N > 1) {
       rep(i, M - N) ans += Y.at(i);
     }
     else ans = X.at(M - 1) - X.at(0);
   }
   cout << ans << endl;
 }


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


int res=0;

void water(vector<int> &h,int l,int r){
  bool all=true;
  bool end=true;
  int between;
  
  for(int i=l;i<r+1;i++){
    if(h.at(i)==0){
      all=false;
      between=i;
    }
    else
      end=false;
  }
  
  if(end)
    return;
  
  if(all){
    for(int i=l;i<r+1;i++){
      h.at(i)--;
    }
    res++;
  }
  
  if(!end){
    water(h,l,between-1);
    water(h,between+1,r);
  }
}


int main(){
  int N;
  cin>>N;
  vector<int>h(N);
  for(int i=0;i<N;i++)
    cin>>h.at(i);
  
  water(h,0,N-1);
  
  cout<<res;
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (ll)1000000007

int main()
{
    int N;
    ll K;
    cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    ll c = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i != j)
            {
                if (A[j] > A[i])
                {
                    c++;
                }
            }
        }
    }
    ll count = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        for (int j = i - 1; j >= 0; j--)
        {

            if (A[j] > A[i])
            {
                count++;
            }
        }
    }
    ll ans = 0;
    ll k = K;
    K = K * (K - 1)/2 % INF;
    ans = k * count % INF + K * c % INF;
    cout << ans % INF << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  char S[222];
  cin >> S;
  int s = strlen(S);
  for (int i = s-2; i > 0; i -= 2) {
    if (strncmp(S, S+i/2, i/2) == 0) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        String T = scan.next();
        char[] s = S.toCharArray();
        char[] t = T.toCharArray();
        HashMap<Character, Character> map1 = new HashMap<>();
        HashMap<Character, Character> map2 = new HashMap<>();
        boolean answer = true;
        for (int i = 0; i < s.length; i++) {
            if (map1.containsKey(s[i])) {
                if (map1.get(s[i]) != t[i]) {
                    answer = false;
                    break;
                }
            }
            if (map2.containsKey(t[i])) {
                if (map2.get(t[i]) != s[i]) {
                    answer = false;
                    break;
                }
            }
            map1.put(s[i],t[i]);
            map2.put(t[i],s[i]);
        }
        System.out.println(answer ? "Yes" : "No");
    }
}


Measured memory_bytes: 29176
import sys
input = sys.stdin.readline
n,d,a = map(int,input().split())
attack = [0 for _ in range(n)]
event = []
for i in range(n):
  x,h = map(int,input().split())
  h = (h-1)//a+1
  event.append([x-d,0,h,i])
  event.append([x+d,1,h,i])
event.sort()
#print(event)
ans = 0
now = 0
for j in range(2*n):
  x,m,h,i = event[j]
  if m == 0:
    if h > now:
      attack[i] += h-now
      ans += h-now
      now = h
  else:
    now -= attack[i]
print(ans)

Measured memory_bytes: 110540
import math
from functools import reduce

def getD(num):
    input_list = [2 if i % 2 == 0 else i for i in range(num+1)]
    input_list[0] = 0
    bool_list = [False if i % 2 == 0 else True for i in range(num+1)]
    sqrt = int(math.sqrt(num))
    
    for serial in range(3, sqrt + 1, 2):
        if bool_list[serial]:
            for s in range(serial ** 2, num+1, serial):
                if bool_list[s]:
                    input_list[s] = serial
                    bool_list[s] = False
    return input_list

N = int(input())
A = list(map(int, input().split()))

D = getD(max(A))
pairwise_coprime = True
use_divnum = set()
for i in range(N):
    k = A[i]
    while k != 1:
        if D[k] in use_divnum:
            pairwise_coprime = False
            break
        else:
            use_divnum.add(D[k])
        div = D[k]
        while k % div == 0 and k > 1:
            k = k // div

if pairwise_coprime:
    print('pairwise coprime')
    exit()

if reduce(math.gcd, A) == 1:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 127544
def to_sec(a):
    h,m,s = map(int,a.split(":"))
    return 3600*h+60*m+s

while 1:
    n = int(raw_input())
    if n == 0: break
    used = [0]*86401
    for loop in range(n):
        a,b = raw_input().split()
        a,b = to_sec(a),to_sec(b)
        used[a] += 1
        used[b] -= 1
    for i in range(1,86401):
        used[i] += used[i-1]
    print max(used)

Measured memory_bytes: 9580
[n,m,x,y] = [int(i) for i in input().split()]

xs = [int(i) for i in input().split()]
ys = [int(i) for i in input().split()]

checker = 0

#x < z <= y
for z in range(x+1,y+1):
    #x1,x2,... < z かつ y1,y2... >= z
    if max(xs) < z and min(ys) >= z:
        checker = 1

if checker:
    print("No War")
else:
    print("War")


Measured memory_bytes: 38304
#include<iostream>
#include<string>
#include<algorithm>
#include<string.h>

using namespace std;

int main() {
	string s;
	cin >> s;
	bool er = false, r = false;

	int p = 0;
	int size = s.length();
	while (p < size) {

		if (size -p >= 5 && equal(s.begin() + p, s.begin() + p + 5, "erase")) { //文字がerase
			p += 5;
			r = true;
			er = false;
			//cout << "erace" << endl;
		}
		else if (size -p >= 5&&equal(s.begin() + p, s.begin() + p + 5, "dream")) { //dream
			p += 5;
			er = true;
			r = false;
			//cout << "dream" << endl;
		}
		else if (size -p >= 2 && er && equal(s.begin() + p, s.begin() + p + 2, "er")) { //er
			p += 2;
			er = false;
			//cout << "er" << endl;
		}
		else if (r && equal(s.begin() + p, s.begin() + p + 1, "r")) {
			p += 1;
			r = false;

			//cout << "r" << endl;
		}
		else {
			cout << "NO";
			return 0;
		}

	}

	cout << "YES";

	return 0;
}

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

int dp[3333][3333];

int main(){
    string s, t;
    cin >> s >> t;
    int N = s.size();
    int M = t.size();

    for(int i=1; i<=N; i++){
        for(int j=1; j<=M; j++){
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            dp[i][j] = max(dp[i][j], dp[i][j-1]);
            if(s[i-1] == t[j-1])
                dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
        }
    }

    string ans(dp[N][M], '.');
    int cnt = dp[N][M]-1;
    int i = N, j = M;
    while(i != 0 && j != 0){
        int num = dp[i][j];
        if(num == 0) break;
        if(dp[i-1][j] == num){
            i--;
        }else if(dp[i][j-1] == num){
            j--;
        }else if(dp[i-1][j] == num-1 && dp[i][j-1] == num-1){
            i--; j--;
            ans[cnt] = s[i];
            cnt--;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 41216
N = int(input())
LR = [list(map(int, input().split())) for _ in range(N)]
maxl = 1
minr = 10**9+1
maxdis = 0
for i in range(N):
    if maxl < LR[i][0]:
        maxl = LR[i][0]
    if minr > LR[i][1]:
        minr = LR[i][1]
    if LR[i][1] - LR[i][0] > maxdis:
        maxdis = LR[i][1] - LR[i][0]

res = maxdis+1 + max(0, minr - maxl+1)

LR.sort(key=lambda x: x[1])
LR.sort(key=lambda x: x[0])

minb = 10**9+5
for i in range(N-1, -1, -1):
    minb = min(minb, max(0, LR[i][1]-maxl+1))
    LR[i].append(minb)
for i in range(N-1):
    res = max(res, max(0, minr - LR[i][0]+1)+LR[i+1][2])
print(res)


Measured memory_bytes: 69336
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

S = input()

A = [S.count("a"), S.count("b"), S.count("c")]

if max(A) - min(A) <= 1 :
	print("YES")
else:
	print("NO")

Measured memory_bytes: 10576
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入
void warshall_floyd(vector<vector<long long>> &dist, vector<vector<long long>> &prev) {
    int V = dist.size();
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                if (dist[i][k] + dist[k][j] < dist[i][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                    prev[i][j] = prev[k][j];
                }
            }
        }
    }
}

vector<int> get_path(const vector<vector<long long>> &prev, int s, int t) {
    vector<int> path;
    for (int cur = t; cur != s; cur = prev[s][cur]) {
        path.push_back(cur);
    }
    path.push_back(s);
    reverse(path.begin(), path.end());
    return path;
}

int main(){
    int N,M;
    cin>>N>>M;
    vector<vector<ll>> dist(N,vector<ll>(N,INF));
    vector<vector<ll>> prev(N,vector<ll>(N,INF));
    vector<vector<bool>> root(N,vector<bool>(N,true));
    int a,b,c;
    REP(i,M){
        cin >> a>>b>>c;
        a--;
        b--;
        dist[a][b]=c;
        dist[b][a]=c;
        prev[a][b]=a;
        prev[b][a]=b;
        root[a][b]=false;
        root[b][a]=false;
    }
    warshall_floyd(dist,prev);
    REP(i,N-1){
        REP2(j,i+1,N){
            vector<int> path=get_path(prev,i,j);
            
            REP(k,path.size()-1){
                root[path[k]][path[k+1]]=true;
                root[path[k+1]][path[k]]=true;
            }
        }
    }
    

    int cnt=0;
    REP(i,N-1){
        REP2(j,i+1,N){
            
            if(!root[i][j]){
                cnt++;
            } 
        }
    }
    cout<<cnt<<endl;
    
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
 char s[50];
 int ans=0;
 int cnt=0;

 cin>>s;

 for(int i=0;i<strlen(s);i++){
  if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
   cnt=1;
   for(int j=i+1; j<strlen(s); j++){
    if(s[j]=='A' || s[j]=='C' || s[j]=='G' || s[j]=='T'){
     cnt++;
    }
    else break;
   }
   ans=max(ans,cnt);
  }
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int s[222222] = {};
vector<int> e[222222];
bool used[222222] = {};
void dfs(int now){
  used[now] = true;
  for(auto&& i: e[now])
    if(!used[i])
      s[i] += s[now], dfs(i);
}
signed main(){
  int n, m, a, b;
  cin>>n>>m;
  for(int i = 0; i < n - 1; i++)
    cin>>a>>b,
    a--, b--,
    e[a].push_back(b),
    e[b].push_back(a);
  while(m--)
    cin>>a>>b,
    a--,
    s[a] += b;
  dfs(0);
  cout<<s[0];
  for(int i = 1; i < n; i++)
    cout<<' '<<s[i];
  cout<<endl;
}


Measured memory_bytes: 21888
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1,i;rrp(i,n-r+1,n+1)ans*=i;return ans/=fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n,m;
 cin>>n;
 map<ll,ll>map,as,vec,already;
 ll a;
 rep(i,0,n){
  cin>>a;
  vec[i]=a;
  map[a]++;
 }
 ll cmp=0;
 rep(i,0,n){
  if(already[vec[i]]==0){
   already[vec[i]]=1;
   cmp+=(map[vec[i]]*(map[vec[i]]-1))/2;
  }
 }
  ///*
 rep(i,0,n){
  if(already[vec[i]]==1){
   already[vec[i]]=2;
   as[vec[i]]=cmp-map[vec[i]]+1;
  }
  //cout<<i<<" "<<cmp<<" ";
  pr(as[vec[i]]);
 }
 //*/
 return 0;}



Measured memory_bytes: 39808
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int H, W;
    cin >> H >> W;

    for (int i = 0; i < H; i++){
        char S[W];
        for (int j = 0; j < W; j++){
            cin >> S[j];
        }
        for (int j = 0; j < W; j++){
            if (j == W - 1){
                cout << S[j] << endl;
            }
            else {
                cout << S[j];
            }
        }
        for (int j = 0; j < W; j++){
            if (j == W - 1){
                cout << S[j] << endl;
            }
            else {
                cout << S[j];
            }
        }
    }
}

Measured memory_bytes: 256
a = int(input())
b = [0,0,0,0,0]
for _ in range(a):
  n = input()
  if n[0]=="M":
    b[0]+=1
  elif n[0]=="A":
    b[1]+=1
  elif n[0]=="R":
    b[2]+=1
  elif n[0]=="C":
    b[3]+=1
  elif n[0]=="H":
    b[4]+=1
ans = 0
for i in range(3):
  for j in range(1+i,4):
    for k in range(1+j,5):
      ans += b[i]*b[j]*b[k]
print(ans)

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

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

		while (true) {
			a = scan.nextInt();
			op = scan.next();
			b = scan.nextInt();

			if (op.equals("?")) break;
			
			System.out.printf("%d\n",
				  op.equals("+") ? a+b
				: op.equals("-") ? a-b
				: op.equals("*") ? a*b
								: a/b );
		}
	}
}

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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }

inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }

template <typename T> inline bool chkmax(T &x, const T &y){ return y > x ? x = y, 1 : 0; }
template <typename T> inline bool chkmin(T &x, const T &y){ return y < x ? x = y, 1 : 0; }

#ifdef ONLINE_JUDGE
#define debug(...) ;
#else
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define DEBUG
#endif

//---------------------------------------------------------head----------------------------------------------------

const int maxn = 1e5 + 100;

const int mod = 1e9 + 7;

int fac[maxn], ifac[maxn];

int pow_mod(int x, int n)
{
	int y = 1;
	while(n)
	{
		if(n & 1) y = 1ll * y * x % mod;
		x = 1ll * x * x % mod;
		n >>= 1;
	}
	return y;
}

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

LL C(int n, int m)
{
	if(n < 0 || m < 0 || n - m < 0) return 0;
	return 1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

int main()
{
	int N = maxn - 10;
	fac[0] = 1; forn(i, 1, N) fac[i] = 1ll * fac[i - 1] * i % mod;
	forn(i, 0, N) ifac[i] = pow_mod(fac[i], mod - 2);
	scf(n); ++n;
	int u, v;
	forn(i, 1, n)
	{
		scf(a[i]);
		if(lst[a[i]]) u = lst[a[i]], v = i;
		lst[a[i]] = i;
	}
	assert(u < v);
	forn(k, 1, n)
	{
		LL ans = 1ll * C(n - 2, k) + 2ll * C(n - 2, k - 1) - 1ll * C(n - (v - u + 1), k - 1) + 1ll * C(n - 2, k - 2);
		printf("%d\n", (ans % mod + mod) % mod);
	}
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char C;
  cin >> C;
  int i = 0; 
  string str;
  str = "abcdefghijklmnopqrstuvwxyz";
  for (; C!=str.at(i);i++);
  cout << str.at(i+1) << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
l = list(map(int,input().split()))
s = set()
loop = []
ls = set()
pas1 = []
pas2 = []
now = 1
count = 0
if k == 1:
    print(l[0])
    exit()
for i in range(2*n):
    a = l[now-1]
    if a in s:
        if a in ls:
            k -= count+1
            print(loop[k%len(loop)])
            
            exit()
        else:
            ls.add(a)
            loop.append(a)
            now = a
            count += 1
            if count == k:
                print(a)
                exit()
        
        
    else:
        now = a
        s.add(a)
        count += 1
        pas1.append(a)
        
        if count == k:
            print(a)
            exit()
    


Measured memory_bytes: 32568
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<P> x(n);
	REP(i,n) {
		cin>>x[i].first;
		x[i].first--;
		x[i].second=i+1;
	}
	sort(ALL(x));
	vector<ll> ans(n*n,-1);
	ll pos=0;
	REP(i,n) {
		ans[x[i].first]=x[i].second;
		REP(j,x[i].second-1) {
			if(pos==x[i].first) {
				cout<<"No"<<endl;
				return 0;
			}
			if(ans[pos]!=-1) j--;
			else ans[pos]=x[i].second;
			pos++;
		}
	}
	REP(i,n) x[i].first=n*n-1-x[i].first;
	sort(ALL(x));
	reverse(ALL(ans));
	pos=0;
	REP(i,n) {
		REP(j,n-x[i].second) {
			if(pos==x[i].first) {
				cout<<"No"<<endl;
				return 0;
			}
			if(ans[pos]!=-1) j--;
			else ans[pos]=x[i].second;
			pos++;
		}
	}
	reverse(ALL(ans));
	cout<<"Yes"<<endl;
	DUMP(ans);
}


Measured memory_bytes: 3200
/*input
5 5
.#.#.
#.#.#
.#.#.
#.#.#
.#.#.


*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	ll h,w;
	cin>>h>>w;
	ll dp[h][w];
	ll a[h][w];
	char c;
	rep(i,0,h){
		rep(j,0,w){
			cin>>c;
			if(c=='.')a[i][j]=0;
			else a[i][j]=1;
		}
	}
	dp[0][0]=a[0][0];
	rep(i,1,w){if(!a[0][i-1]) dp[0][i]=a[0][i]+dp[0][i-1];else dp[0][i]=dp[0][i-1];}
	rep(i,1,h){if(!a[i-1][0]) dp[i][0]=a[i][0]+dp[i-1][0];else dp[i][0]=dp[i-1][0];}
	rep(i,1,h){
		rep(j,1,w){
			dp[i][j]=inf;
			if(!a[i-1][j])dp[i][j]=min(dp[i][j],dp[i-1][j]+a[i][j]);
			else dp[i][j]=min(dp[i][j],dp[i-1][j]);
			if(!a[i][j-1])dp[i][j]=min(dp[i][j],dp[i][j-1]+a[i][j]);
			else dp[i][j]=min(dp[i][j],dp[i][j-1]);
		}
	}
	//rep(i,0,h){rep(j,0,w)cout<<dp[i][j];cout<<endl;}
	cout<<dp[h-1][w-1]<<endl;
	return 0;
}




Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<cmath>
#include<stack>
using namespace std;
struct node
{
    int val;
    node* next;
};
/*
 99992149
      123
 */
int isSu(long long int x)
{
    long long int up = sqrt(x);
    for(int i = 2;i<=up;i++)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
int main()
{
    int n,tmp,ans=0;
    cin>>n;
    vector<int> all;
    for(int i = 0;i<n;i++)
    {
        cin>>tmp;
        all.push_back(tmp);
    }
    for(int i = 0;i<n-1;i++)
        for(int j = i+1;j<n;j++)
            ans+=(all.at(i)*all.at(j));
            
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
int main()
{
	char s[100009];
	scanf("%s",s);
	int i,len=strlen(s);
	long long san[100009],ans,er;
	san[0]=1;
	for (i=1;i<100009;i++)
	{
		san[i]=san[i-1]*3;
		san[i]%=mod;
	}
	ans=0;
	er=1;
	for (i=0;i<len;i++)
	{
		if (s[i]==49)
		{
			ans+=er*san[len-i-1];
			ans%=mod;
			er*=2;
			er%=mod;
		}
	}
	ans+=er;
	ans%=mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,W;
    cin>>n>>W;

    ll w[n],v[n];

    for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];
    
    ll dp[n+1][W+1];

    for(int i=0;i<=n;i++)
        for(int j=0;j<=W;j++)
            {
                if(i==0 || j==0)
                    dp[i][j] = 0;
                else if(w[i-1]<=j)
                    dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
                else
                    dp[i][j] = dp[i-1][j];
            }
    

    cout<<dp[n][W]<<endl;

    return 0;
}

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

int main() {
    ll n;
    cin >> n;
    ll a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    if(n%2 == 0){
        bool correct=true;
        if(a[0]!=1 || a[1]!=1) correct=false;
        for(int i=1;i<n-2;i+=2){
            if(a[i+1]-a[i]!=2 || a[i+2]!=a[i+1] ) correct=false;
        }
        if(correct){
            ll ans=1;
            for(int i=0;i<n/2;i++){
                ans *= 2;
                ans %= 1000000007;
            }
            cout << ans << endl;
        }
        else cout << 0 << endl;
    }
    else{
        bool correct=true;
        if(a[0]!=0) correct=false;
        for(int i=0;i<n-2;i+=2){
            if(a[i+1]-a[i]!=2 || a[i+2]!=a[i+1]) correct=false;
        }
        if(correct){
            ll ans=1;
            for(int i=0;i<n/2;i++){
                ans *= 2;
                ans %= 1000000007;
            }
            cout << ans << endl;
        }
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c <= 21){
        cout << "win" << endl;
    }else{
        cout << "bust" << endl;
    }
  

    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  ll n;
  cin >> n;
  ll ans = n / 11 * 2;
  n -= n / 11 * 11;
  if(n > 6)ans += 2;
  else if(n != 0)ans++;
  cout << ans << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

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

using namespace std;

signed main() {
    int n;
    cin >> n;
    ll memo[87] = {};
    memo[0] = 2;
    memo[1] = 1;
    for (size_t i = 2; i <= n; i++) {
      memo[i] = memo[i - 1] + memo[i - 2];
    }

    cout << memo[n] << endl;
}


Measured memory_bytes: 256
while True:
    a, op, b = input().split()   # 3変数ともに文字列として読み込む
    a =int(a)                   # a を整数に変換
    b = int(b)                   # b を整数に変換


    if op=="?": 
        break
    else: #opが"?"以外の時
        if op=="+":
            print(a+b)
        elif op=="-":
            print(a-b)
        elif op=="*":
            print(a*b)
        elif op=="/":
            print(a//b)



Measured memory_bytes: 5592
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
l = inp.shift().split(' ')
N = l.shift() * 1
M = l.shift() * 1
X = l.shift() * 1
Y = l.shift() * 1
xa = inp.shift().split(' ')
xa.push(X)
ya = inp.shift().split(' ')
ya.push(Y)
l = X
r = Y
for (i=0; i<N; i++) {
    if (l < xa[i] * 1) {
        l = xa[i] * 1
    }
}
for (i=0; i<M; i++) {
    if (r > ya[i] * 1) {
        r = ya[i] * 1
    }
}
if (l < r) {
    console.log('No War')
} else {
    console.log('War')
}



Measured memory_bytes: 7372
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100+10;
int a[N],b[N],n,x;
int main() {
    while(~scanf("%d",&n)){
        a[0]=0;
        b[0]=0;
        for(int i=1;i<=n;i++){
            scanf("%d",&x);
            a[i]=a[i-1]+x;
        }

        for(int i=1;i<=n;i++){
            scanf("%d",&x);
            b[i]=b[i-1]+x;
        }
        int _max=0;
        for(int i=1;i<=n;i++){
            _max=max(_max,a[i]+b[n]-b[i-1]);
        }
        printf("%d\n",_max);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int X,Y,Z,A,B,C;
scanf("%d%d%d",&X,&Y,&Z);
A=X;
B=Y;
C=Z;
X=C;
Y=A;
Z=B;
printf("%d %d %d",X,Y,Z);
return 0;
}

Measured memory_bytes: 128
// AOJ Volume 0 Problem 0086

#include <stdio.h>
#include <string.h>

int masu[101][101];

void magic(int n)
{
	int i, j;
	int x, y;

	memset(masu, 0, sizeof(masu));
	
	/* ツ陳可崢づ個暗ェツづつ可コ */
	x = (n + 1) / 2;
	y = (n + 1) / 2 + 1;
	masu[y][x] = 1;		
	
	for (i = 2; i <= n * n; i++){
		/* ツ右ツ偲篠づ淞可コ */
		x++;
		y++;

		do{
			// ツ右ツづ可づ債づ敖出ツつオツづつ「ツづゥ
			if (x > n){
				x = 1;
			}
	
			// ツ債カツづ可づ債づ敖出ツつオツづつ「ツづゥ
			if (x < 1){
				x = n;
			}
			
			// ツ可コツづ可づ債づ敖出ツつオツづつ「ツづゥ
			if (y > n){
				y = 1;
			}
		
			// ツ甘ケツづ可鳴づ慊づづつ「ツづゥ
			if (1 <= x && x <= n && 1 <= y && y <= n && masu[y][x] != 0){
				x--;
				y++;
			}
		} while (x < 1 || n < x || y < 1 || n < y || masu[y][x] != 0);
		masu[y][x] = i;
	}
	
	for (y = 1; y <= n; y++){
		for (x = 1; x <= n; x++){
			printf("%4d", masu[y][x]);
		}
		printf("\n");
	}
}

int main(void)
{
	int n;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		magic(n);
	}
	return (0);
}

Measured memory_bytes: 0