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

typedef long long ll;

int choose(int n,int k){
    int x = 1, y = 1;
    for(int i=1;i<=k;i++){
        x *= n - (i - 1);
        y *= i;
    }
    return x / y;
}

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

    int n,m;
    cin >> n >> m;
    int ansn = 0,ansm = 0;
    if(n<2) ansn = 0;
    if(m<2) ansm = 0;
    if(n>=2) ansn = choose(n,2);
    if(m>=2) ansm = choose(m,2);
    cout << ansn+ansm << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

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);
        }
    }
    return res;
}

int main() {
    ll n, k, sum = 0, ans = 1;
    cin >> n >> k;
    vector<ll> a(n), div;
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }
    if(sum < k){

    }
    div = divisor(sum);
    for(auto d : div){
        vector<ll> v;
        ll lhs = 0, rhs = 0;
        for(int i=0;i<n;i++){
            ll m = a[i]%d;
            v.push_back(m);
            rhs += d-m;
        }
        SORT(v);
        for(int i=0;i<n;i++){
            lhs += v[i];
            rhs -= d-v[i];
            if(lhs == rhs && lhs <= k){
                ans = max(ans, d);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
                      basic_ostream<charTDummy, traitsDummy> &(
                          basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex)
    exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex)
    exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  string s = readString();

  print(s.find_last_of('Z') - s.find_first_of('A') + 1);

  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <numeric>

using namespace std;
using lint = long long;

constexpr lint Inf = 4'500'000'000'000'000'007LL; //4.5e18+7

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


lint modinv(lint a, lint m) {
	lint b = m, u = 1, v = 0;
	while (b != 0) {
		lint t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int main() {
	lint n;
	cin >> n;

	if (n == 1) cout << 1 << endl;
	else if (n == 2) cout << 3 << endl;
	else {
		lint ans = Inf;
		n <<= 1;
		for (lint a = 2; a * a <= n; ++a) {
			if (n % a == 0 && gcd(a, n / a) == 1) {
				const lint b = n / a;

				chmin(ans, a * modinv(a, b) - 1);
				chmin(ans, b * modinv(b, a) - 1);
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1e7;
int _par[MAX_N];//親
int _rank[MAX_N];//木の深さ

//n要素で初期化 parは親の要素の番号
void init(int n){
  for(int i=0; i<n; i++){
    _par[i] = i;
    _rank[i]=0;
  }
}

//木の根を求める
int find(int x){
  if(_par[x]==x){
    return x;
  }
  else{
    return _par[x] = find(_par[x]);
  }
}

//xとyの属する集合の併合
void unite(int x, int y){
  x=find(x);
  y=find(y);
  if(x==y) return;

  if (_rank[x] < _rank[y]){
    _par[x] = y;
  }else{
    _par[y]=x;
    if(_rank[x] == _rank[y])_rank[x]++;
  }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y){
  return find(x) == find(y);
}


int main(){
  
  int N,A,B,C;
  int ans = INT_MAX;
  cin >> N >> A>> B>> C;
  int l[N];
  for (int i=0; i<N; i++){
    cin >> l[i];
  }
  for(int i1=0; i1 < 4; i1++){
    for(int i2=0; i2 < 4; i2++){
      for(int i3=0; i3 < 4; i3++){
	for(int i4=0; i4 < 4; i4++){
	  for(int i5=0; i5 < 4; i5++){
	    for(int i6=0; i6 < 4; i6++){
	      for(int i7=0; i7 < 4; i7++){
		for(int i8=0; i8 < 4; i8++){
		  init(4);
		  _par[0] = i1;
		  _par[1] = i2;
		  _par[2] = i3;
		  _par[3] = i4;
		  _par[4] = i5;
		  _par[5] = i6;
		  _par[6] = i7;
		  _par[7] = i8;
		  int cost=0;
		  int A_tmp=0;
		  int B_tmp=0;
		  int C_tmp=0;
		  int A_count=0;
		  int B_count=0;
		  int C_count=0;
		  for(int i=0; i<N; i++){
		    if(_par[i]==1){
		      C_tmp +=l[i];
		      C_count +=1;
		      if(C_count >1) cost +=10;
		    }
		    if(_par[i]==2){
                      B_tmp +=l[i];
		      B_count +=1;
                      if(B_count >1) cost +=10;
                    }
		    if(_par[i]==3){
                      A_tmp +=l[i];
		      A_count +=1;
                      if(A_count >1) cost +=10;
                    }
		  }
		  if(A_count ==0 || C_count==0 || B_count==0) continue;
		    cost += abs(A-A_tmp) + abs(B-B_tmp) + abs(C-C_tmp);
		    ans = min(cost,ans);
		  
		}
	      }	      	     
	    }
	  }
	}
      }
    }
  }
  cout << ans<< endl;
 

}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int b[N];  //b[len-i]表示第i位（从后往前）10^(i-1)
int k[2020];  //k[i]表示余数是i的个数
long long ans=0;
int main(){
    string s;
    cin>>s;
    int len=s.length();
    
    b[len-1]=1;
    for(int i=len-2;i>=0;i--){
        b[i]=(b[i+1]*10)%2019;
    }
    
    int sum=0;
    for(int i=len-1;i>=0;i--){
        sum=(sum+(s[i]-'0')*b[i])%2019;
        k[sum]++;
    }
    
    ans+=k[0]; //余数是零直接符合
    
    //如果两个数余数相等，相减后余数为0
    for(int i=0;i<=2018;i++)
		ans+=k[i]*(k[i]-1)/2; 

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


Measured memory_bytes: 4476
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    int n,k,d,ans=0,s;
    cin>>n>>k;
    vll a(n);
    
    rep(i,n)a.at(i)=0;
    
    rep(i,k){
        cin>>d;
        rep(j,d){
            cin>>s;
            a.at(s-1)=1;
        }
    }
    rep(i,n){
        if(a.at(i)==0)ans++;
    }
    cout<<ans<<endl;
}
   



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

int mod = 1e9 + 7;

char s[223456];
char t[223456];

int main() {
	make3(n, m, k);
	make2(x, y);
	x--; y--;
	scanf("%s", s);
	scanf("%s", t);
	int x1 = 0, x2 = m;
	int y1 = 0, y2 = n;
	bool ok = true;
	FORD(i,k-1,0) {
		if (s[i] == 'L') {
			x1++;
		} else if (s[i] == 'R') {
			x2--;
		} else if (s[i] == 'U') {
			y1++;
		} else if (s[i] == 'D') {
			y2--;
		}
		if (x1 >= x2 || y1 >= y2) ok = false;
		x1 = max(x1, 0);
		y1 = max(y1, 0);
		x2 = min(x2, m);
		y2 = min(y2, n);
		if (i == 0) continue;
		if (t[i-1] == 'L') {
			x2++;
		} else if (t[i-1] == 'R') {
			x1--;
		} else if (t[i-1] == 'U') {
			y2++;
		} else if (t[i-1] == 'D') {
			y1--;
		}
		x1 = max(x1, 0);
		y1 = max(y1, 0);
		x2 = min(x2, m);
		y2 = min(y2, n);
	}

	if (ok && x1 <= y && y < x2 && y1 <= x && x < y2) printf("YES\n");
	else printf("NO\n");
}






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

using namespace std;

int main() {
    int n, a;
    unordered_set<int> s;
    cin >> n;
    while (n--) {
        cin >> a;
        if (s.count(a)) s.erase(a);
        else s.insert(a);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 4388
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;

int main ()
{
  ll N;
  cin >> N;
  ll a[100001+2];

  int p = 0;
  int d = 0;
  a[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
    d += abs(a[i] - p);
    p = a[i];
  }
  a[N+1] = 0;
  d += abs(p);

  for (int s = 1; s <= N; s++) {
    if ((a[s] < a[s-1]) && (a[s] < a[s+1]) ||
        (a[s] > a[s-1]) && (a[s] > a[s+1])) {
      printf("%d\n", d - 2 * min(abs(a[s] - a[s-1]), abs(a[s] - a[s+1])));
    } else {
      printf("%d\n", d);
    }
  }
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

 // void dfs(ll node){
 // 	vis[node]=1;
 // 	res.pb(node);
 //    vector<ll> ans;


 // 	for(auto i:v[node]){
 // 		if(!vis[i]){
 // 			ans.pb(i);

 // 		}
 // 	}
 // 	sort(ans.begin(),ans.end());

 // 	for(auto i:ans){
 // 		if(!vis[i])
 // 			dfs(i);
 // 	}




 // }
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
bool sortbyme(const pair<int,int> &a, 
              const pair<int,int> &b){
	return (a.first+a.second > b.first+b.second);

}
void solve(){

ll n;
cin>>n;
ll dp[2001];
memset(dp,0,sizeof dp);
dp[0]=1;

dp[3]=1;
for(ll i=4;i<=n;i++){
	for(ll j=3;j<=i;j++){
		dp[i]=(dp[i]%mod+dp[i-j]%mod)%mod;

	}

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






return;
}



int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    

    ll t;
    t=1;
    // cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
int main(){
    long long  n, a[80+1]={0}, money=1000, stock=0;

    scanf("%lld", &n);
    for(int i=0; i<n; i++){
        scanf("%lld", &a[i]);
    }

    for(int i=0; i<n-1; i++){

        //値上がるなら買ってすぐ売る
        if( a[i] < a[i+1] ){
            stock = money / a[i];
            money = money % a[i];

            money = money + stock*a[i+1];
        }
    }
    printf("%lld\n", money);
    return 0;
}

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

using namespace std;

# define ll long long
#define mp make_pair


int n;
ll a[1+int(1e5)];

pair < ll, ll > get_range( int i ){
	if( i == n+1 ){
		return mp(2,2);
	}
	pair < ll, ll > x ;
	x = get_range( i + 1 ); 
	ll smallest, largest;
	smallest = x.first;
	largest = x.second;
	if( smallest == -1 )
		return x;
	if( a[i] > largest )
		return mp( -1 ,-1 );
	ll smallest_divisor = ( smallest - 1 ) / a[i];
	ll largest_divisor = largest / a[i];
	ll min_children, max_children;
	min_children = ( smallest_divisor + 1 ) * a[i];
	if ( min_children > largest ){
		return mp( -1 ,-1 );
	}
	max_children = ( ( largest_divisor + 1 ) * a[i] ) - 1;
	return mp( min( min_children, min_children), max( min_children, max_children));
}


int main (){
	//freopen("input.txt", "r", stdin); // redirects standard input
	//freopen("output.txt", "w", stdout); // redirects standard output
	cin >> n;
	for( int i = 1; i <= n; i++ )
		cin >> a[i];
	pair < ll, ll > x ;
	x = get_range( 1 );
	if( x.first == -1 )
		cout << -1;
	else
	 	cout << x.first << " " << x.second ;
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int read( ){
	int x=0,y=1;char ch=' ';
	for(;(ch!='-' && (ch>'9' || ch<'0'));ch=getchar( ));
	if(ch=='-')y=-1,ch=getchar( );
	for(;ch>='0' && ch<='9';ch=getchar( ))x=x*10+ch-48;
	return x*y;
}
const int inf=0x3f3f3f3f;
int a,b;
int main( ){
	int x,y,z,k;
	a=read( );b=read( );
	k=(b-1)/(a-1);
	if( (b-1)%(a-1) )++k;
	printf("%d\n",k);
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ull unsigned long long
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;
long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main() {
	int N, i, gcdmax;
	vector<int> A(100000),L(100000),R(100000);
	cin >> N;
	REP(i, N) {
		cin >> A[i];
	}
	L[0] = A[0];
	R[N - 1] = A[N - 1];
	for (int i = 1; i < N - 1; i++) {
		L[i] = GCD(A[i], L[i - 1]);
	}
	for (int i = N - 2; i > 0; i--) {
		R[i] = GCD(A[i], R[i + 1]);
	}
	gcdmax = R[1];
	for (int i = 1; i < N - 1; i++) {
		gcdmax = max(gcdmax, (int)GCD(L[i - 1], R[i + 1]));
	}
	gcdmax = max(gcdmax, L[N - 2]);
	cout << gcdmax << endl;
	return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <valarray>

int main(void) {

	bool on = true;
	int year;
	std::cin >> year;
	switch (year){
	case 3:
		break;
	case 5:
		break;
	case 7:
		break;
	default:
		on = false;
		break;
	}


	std::cout << ((on)? "YES\n":"NO\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  // A, B, C
  // B+C, A+C, A+B -> B-A
  // 2A+B+C, A+2B+C, A+B+2C -> A-B
  // 2A+3B+3C, 3A+2B+3C , 3A+3B+2B -> B-A
  int64_t A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K % 2)
    cout << B - A << endl;
  else
    cout << A - B << endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    double l;
    cin>>l;
    cout << fixed << setprecision(6);
    dunk(l*l*l/27);
}



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

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

    string n;
    cin >> n;

    cout << (n[0] == n[2] ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long LL; 
int main(int argc, char* argv[])
{
	string N;
	cin>>N;
	LL i;
	LL nums=0;
	for (i=0;i<N.size();i++){
		nums+=N[i]-'0';
	}
	if (nums%9==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3372
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main()
{
  vector<int> v(3);
  for(int i=0; i<3; i++) cin >> v[i];
  sort(v.begin(),v.end());
  cout << v[0] << " " << v[1] << " " << v[2] << endl;
  return 0;
}

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

int main() {
  int N;
  cin>>N;
  int ans = 0;
  int h;
  int maxh = 0;
  
  for(int i = 0;i < N;i++){
    cin>>h;

    if(h >= maxh){
      maxh = h;
      ans++;
    }
  }

  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
mod = 10**9 + 7

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """

    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb = Combination(5*10**5)

if n - k <= 1:
    ans = comb(2*n-1, n)
else:
    ans = 0
    for i in range(k+1):
        ans += comb(n, i) * comb(n-1, i)
        ans %= mod

print(ans)


Measured memory_bytes: 115820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 10000000099
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N, K;
  cin >> N >> K;
  cout << min(N % K, K - (N % K)) << endl;
}

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

using namespace std;
typedef long long ll;

int N, A, B, C, D;
int mo = 1e9+7;
int dp[1010][1010];
ll fact[1004];
ll invfact[1004];

ll extgcd(int a, int b, int& x, int& y){
  int d = a;
  if(b != 0){
    d = extgcd(b, a%b, y, x);
    y -= (a / b) * x;
  }
  else{
    x = 1; y = 0;
  }
  return d;
}
//mod mにおけるaの逆元
ll mod_inverse(ll a, int m){
  int x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}

void make_facttable(){
  fact[0] = 1;
  for(int i = 1; i <= 1000; i++){
    fact[i] = (fact[i-1] * i) % mo;
  }
  for(int i = 0; i <= 1000; i++){
    invfact[i] = mod_inverse(fact[i], mo);
  }
}

ll iexp(ll x, ll y){
  ll res = 1;
  for(int i = 0; i < y; i++)  res = (res * x) % mo;
  return res;
}


int main(){
  cin >> N >> A >> B >> C >> D;
  make_facttable();

  for(int i = 0; i <= N+1; i++) fill(dp[i], dp[i]+N+1, 0);
  dp[A][0] = 1;
  for(int i = A; i <= B; i++){
    for(int j = 0; j <= N; j++){
      ll kfact = iexp(invfact[i], C);
      dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mo;
      for(int k = C; k <= D; k++){
        if(j - k*i >= 0){
          dp[i+1][j] = ((dp[i+1][j] + ((((((((dp[i][j-k*i] * fact[N-j+k*i]) % mo) * invfact[N-j]) % mo) * kfact) % mo) * invfact[k]) % mo)) % mo);
          kfact = (kfact * invfact[i]) % mo;
        }
        else break;
      }
    }
  }

  cout << dp[B+1][N] << endl;

  return 0;
}


Measured memory_bytes: 4224
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()

row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()


Measured memory_bytes: 68524
using System;
using System.Collections.Generic;
using System.Linq;

public static class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var N = vals[0];
        var D = vals[1];
        var count = 0;
        for (int i = 0; i < N; i++)
        {
            vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var x = vals[0];
            var y = vals[1];
            if (x * x + y * y <= D * D)
            {
                count++;
            }
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 46920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  ll n, m;
  cin >> n >> m;
  if(m%2==0) {
    rep(i,m/2) cout << i+1 << " " << m-i+1 << endl;
    rep(i,m/2) cout << m+i+2 << " " << m*2+1-i << endl;
  }
  else {
    rep(i,m/2) cout << i+1 << " " << m-i << endl;
    rep(i,m/2+1) cout << m+1+i << " " << 2*m+1-i << endl;
  }
  return 0;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I1000000007 (1000000007)
#define I998244353   (998244353)
#define IINF             (1<<28)
#define LINF           (1LL<<60)
#define ALL(a)         (a).begin(), (a).end()
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "YES", "NO")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  int N;
  vector<int> A;

  void init() {
    cin >> N;
    A.resize(N);
    rep(i, N) {
      cin >> A[i];
    }
  }

  void solve() {
    int a = A.size();
    sort(ALL(A));
    A.erase(unique(ALL(A)), A.end());
    yesno(a == A.size());
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
    #pragma GCC optimize("unroll-loops")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("-O3")
    #pragma GCC optimize("no-stack-protector")
    #pragma GCC optimize("fast-math")
 
#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ld  double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("input.txt");ofstream cout("output.txt");
#define pw(x) (1ll << x)
#define sz(x) (ll)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
//#define for(int i=0;i<n;i++) for(ll i=0;i<n;i++)
using namespace std;
//using namespace __gnu_pbds;
ld eps = (ld)1 / 1e6;
ll inf = INT_MAX, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const ll to[5]={0,4,6,7,9};
//const ll N=2*1e5+1;
const ll R=1e4;
const ll to[7]={1,2,3,1,3,2,1};
const ll tx[4]={0,0,-1,1};
const ll ty[4]={-1,1,0,0};
const char rev_to[4]={'E','W','N','S'};
const ll N=1e5;
signed main(){
    fast_io;
   ll n;
   cin>>n;
   ll ans=0;
    for(ll i=1;i<=n;i++){
        if(i%3 && i%5) ans+=i;
    }
    cout<<ans;
    return 0;
}
 
/*
 
 
 
    /////
 
*/

Measured memory_bytes: 3652
//Author: Rahul Purohit

#include<bits/stdc++.h>
#define vi vector<int>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll  long long int
#define pi pair<ll,ll>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
int gcd(int a, int b)
{
	if(b==0)
		return a;
	else
		return (b,a%b);
}
/*ll isp[N]={1};
void sieve(int n)
{
	isp[0]=isp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(isp[i]==1)
		{
			for(int j=i*i;j<=n;j+=i)
			{
				isp[j]==0;
			}
		}
	}
}*/
ll pow(int x,int  y,int m)
{
	ll ans=1;
	while(y!=0)
	{
		if(y%2==1)
		{
			ans=(ans*x)%m;
		}
		x=(x*x)%m;
		y/=2;
	}
	return ans;
}
template <class x>
void swap(x &a,x &b)
{
	x tp;
	tp=a;
	a=b;
	b=tp;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll n,m;
    cin>>n>>m;
    ll l,r,l1=-1,r1=n+1;
    for(auto i=0;i<m;++i)
    {
        cin>>l>>r;
        l1=max(l,l1);
        r1=min(r,r1);
    }
    if(l1<=r1)
        cout<<r1-l1+1;
    else
        cout<<"0\n";
    return 0;
}


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

using namespace std;

const long long INF = 1LL << 60;
const long long P = 1000000007;

int main() {
  int r,g;
  cin >> r >> g;
  cout << 2*g-r << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int>h(n);
  for(int i=0;i<n;i++)cin>>h[i];
  int ans=0;
  for(int i=0;i<n;i++){
    if(h[i]>=k)ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main() {

	int x,n;

	n = 0;

	for (n = 1; n <= 10000; n+0) {

		cin >> x;

		if (x >= 1 && x <= 10000) {

			cout << "Case " << n++<< ":" << " " << x << endl;

		}

		else if (x == 0) {
			break;
		}

	}

}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
#define sl(a) scanf("%ld",&a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%ld\n",a)
#define pll(a) printf("%lld\n",a) 
#define sc(a) scanf("%c",&a)a
#define pc(a) printf("%c",a)
#define ll long long
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF INT_MAX
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define VI vector<int>
#define VL vector<ll>
#define PI pair<int,int>
#define PL pair<ll,ll>
long double PIE=acos(-1);
//////////////////////////////////////////////////////////////
const ll N=1e5+5;
ll Ans=1;
bool done[1000009];
vector < ll > primes;

void FindPrime(ll N)
{
    done[1] = 1;
    for(int i=2;i<=N;i++)
	{
        if(done[i]) continue;
        for(int j=i*2;j<=N;j+=i)
		{
            done[j] = 1;
        }
        primes.push_back(i);
    }
}

ll solve(ll Num)
{
    for(int i=0;i<primes.size();i++)
	{
    	int p=primes[i];
        if(p*p*p > Num) break;
        ll Count = 1;
        while(Num%p == 0)
		{
            Num /= p,Count++;
        }
        Ans *= Count;
    }
    ll sq = (ll)sqrt(Num);
    if(!done[Num]) 
	Ans *= 2;
    else if(sq*sq == Num && !done[sq]) 
	Ans *= 3;
    else if(Num != 1) 
	Ans *= 4;
    return Ans;
}


ll fact[N], invfact[N];



ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll modinv(ll k)
{
	return pow(k, mod-2, mod);
}


ll nCr(ll x, ll y)
{
	if(y>x)
		return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}

void initinv()
{
	fact[0]=1;
	fr(i,1,N)
	{
		fact[i]=(i*fact[i-1])%mod;
	}
	invfact[N]=modinv(fact[N]);
	for(int i=N-1;i>=1;i--)
	{
		invfact[i]=((i+1)*invfact[i+1])%mod;
	}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
int main()
{
	int n;
	cin>>n;
	int h[n+1];
	fr(i,1,n)
	cin>>h[i];
	int dp[n+1];
	fr(i,0,n)
	{
		dp[i]=INT_MAX;
	}
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	fr(i,3,n)
	{
		dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
	}
	cout<<dp[n];
    return 0;
}





Measured memory_bytes: 4416
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



// dp[i][j]: i番目まででxがjになる確率
int n, x, a[222], dp[222][100100], res, f[222];

signed main() {
	f[0] = 1;
	reps(i,1,222) f[i] = f[i-1]*i %mod;
	cin >> n >> x;
	rep(i,n) cin >> a[i];
	sort(a,a+n), reverse(a,a+n);
	dp[0][x] = 1;
	rep(i,n) rep(j,x+1) if (dp[i][j]) {
		(dp[i+1][j%a[i]] += dp[i][j] * mop(n-i,mod-2)) %= mod;
		(dp[i+1][j] += dp[i][j] * (n-i-1) %mod * mop(n-i,mod-2)) %= mod;
	}
	reps(i,1,x+1) (res += i * dp[n][i] %mod * f[n]) %= mod;
	cout << res << endl;
}

Measured memory_bytes: 155904
n, m, x, y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))

xn = max(xn)
ym = min(ym)

for z in range(x+1,y+1):
    if xn< z <=ym:
        print('No War')
        exit()
print('War')


Measured memory_bytes: 9172
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n,m;
    scanf("%ld%ld", &n, &m);

    char str0[55][55]={0};
    char str1[55][55]={0};
    long i;
    for(i=0; i<n; i++) {
        scanf("%s", str0[i]);
    }
    for(i=0; i<m; i++) {
        scanf("%s", str1[i]);
    }

    long j,k;
    for(i=0; i<=n-m; i++) {
        for(j=0; j<=n-m; j++) {
            for(k=0; k<m; k++) {
                if(strncmp(&(str0[k+i][j]), str1[k], m)!=0) {
                    break;
                }
            }
            if(k==m) {
                printf("Yes\n"); return 0;
            }
        }
    }
    printf("No\n");

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){

long a,b,i,n;

while(scanf("%ld",&a)!=EOF){

scanf("%ld",&b);

n = a+b;

for(i=1;i<10;i++){

 n = n/10;

if(n==0) break;

}

printf("%ld\n",i);

}


}

Measured memory_bytes: 1028
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
#define AMA (1000000007)
int N;
int R;
ll S[100005];
ll kai[100005];

int seg[5000005];
int n;
void init(int _n){
  memset(seg,0,sizeof(seg));
  n = 1;
  while( n < _n ) n*=2;
}

int sum(int id){
  id = n+id-1;
  int res = seg[id];
  // printf("sum::\n");
  while( id > 0 ){
    //  printf("%d  %d %d\n",id,seg[id],res);
    id = (id-1)/2;
    res += seg[id];
  }
  return res;
}

void add(int a,int b,int l,int r,int x,int id){
  // printf("%d %d %d %d %d %d\n",a,b,l,r,x,id);
  if( a <= l && r-1 <= b ){
    seg[id] += x;
    //    puts("in");
  } else if ( r <= a || b <= l ){
    // printf("break\n");
  } else {
    add( a, b, (l+r)/2, r, x, id * 2 + 2 );
    add( a, b, l, (l+r)/2, x, id * 2 + 1 );
  }
  
}


int main(){
  kai[0] = 0;
  kai[1] = 1;
  for(ll i=2;i<=100000;i++){
    kai[(int)i] = (kai[(int)(i-1)] * i)%AMA;
   
    //    if ( i < 5 ) printf("%lld %lld\n",i,kai[i]);
  }
  while ( 1 ){
    cin >> N;
    if(!N) break;
    cin >> R;
    init(N+1);
    for(int i=0;i<N;i++)
      S[i] = (ll)i;
    for(int i=0;i<R;i++){
      int s,t;
      cin >> s >> t;
      s--; t--;
      swap(S[s],S[t]);
    }
    
    ll res = 0;
    for(int i=0;i<N;i++){
      /*
      for(int j=0;j<N;j++){
	printf("%d ",sum(j));
      }
      puts("");
      */
      int mi = sum(S[i]);
      int id = max(0,N - i -1);
      ll zyun = kai[id];
      /*      
      printf ("S[%d] = %d\n",i,S[i]);
      printf("%d = ",id);
      printf("%lld\n",zyun);
      printf("%d - %d - 1 = %d\n",N,i,id);
      printf("mi = %d\n",mi);
      printf("jazy = %d\n",S[i] - mi );
      */
      res += ( zyun * max((ll)0,(S[i] - mi)) )%AMA;
      res %= AMA;
      add( S[i], N, 0, n, 1, 0 );
      /*   
      printf("%d\n",i);
      printf("res = %lld\n",res);
      */    
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 22256
a,b = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp
judge = true
a.times do |i|
  if s[i] == "-"
    judge = false
  end
end
if s[a] != "-"
  judge = false
end
b.times do |i|
  if s[a+1+i] == "-"
    judge = false
  end
end
if judge
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14356
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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;}


int main()
{
  int n ;
  cin >> n  ;
  cout <<(n-2)*180 <<endl ;
    


  return 0 ;
}




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

int main()
{
	string ob1, ob2, ob3;
	int n_ob1, n_ob2;

	cin >> ob1;
	cin >> ob2;
	cin >> n_ob1;
	cin >> n_ob2;
	cin >> ob3;

	if(ob1 == ob3){
		n_ob1--;
	}
	else if(ob2 == ob3){
		n_ob2--;
	}

	cout << n_ob1 << " " << n_ob2 << "\n";

	return 0;
}

Measured memory_bytes: 256
<?php
for($i=0; $i<6; $i++){
    $arr[] = trim(fgets(STDIN));
}

for($i=0; $i<count($arr)-1; $i++){
    for($s=$i+1; $s<count($arr)-1; $s++){
        if($arr[5] < abs($arr[$i] - $arr[$s])){
            echo ":(";
            exit;
        }
    }
}

echo "Yay!";
?>

Measured memory_bytes: 4856
// ABC144_A
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B;
    cin >>  A >>B;
    if(A >=1 && A <= 9 && B >=1 && B <=9 ){
        cout  << A*B << endl;
    }
    else {
        cout << "-1" << endl;
    }
}

Measured memory_bytes: 256
import sys

n = int(input())
list = []

for i in range(0,n):
    si,pi = input().split()
    list.append({'i':i,'s':si,'p':int(pi)})

list = sorted(list, key=lambda x: (x['s'],-x['p'])) 

for i in range(0,n):
    print(list[i]['i']+1)


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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

vector<pair<int, int>> power;
pair<int, int> niz[1010];
int dp[100010];
const int INF = 1e9;

bool sortiraj(pair<int, int> a, pair<int, int> b)
{
    if(a.fi < b.fi) return true;
    if(a.fi > b.fi) return false;
    return a.se < b.se;
}

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

    int h, n;
    cin >> h >> n;
    for(int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        niz[i] = mp(a,b);
    }
    sort(niz, niz + n, sortiraj);
    for(int i = 0; i < n; i++)
    {
        if(i == 0) power.pb(niz[i]);
        else if(power[power.size() - 1].fi != niz[i].fi) power.pb(niz[i]);
    }


    for(int i = 0; i <= 1e5; i++)
        dp[i] = INF;

    dp[0] = 0;

    for(int i = 1; i <= 1e5; i++)
    {
        for(int j = 0; j < power.size(); j++)
        {
            if(power[j].fi > i) break;
            dp[i] = min(dp[i], dp[i - power[j].fi] + power[j].se);
        }
    }
    int res = INF;
    for(int i = h; i <= 1e5; i++)
        res = min(res, dp[i]);
    cout << res;


    return 0;
}

/* 9 5
2 1
4 1
4 2
8 3
8 6
*/


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 100000000
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}

int main(){
	int x,t;
	cin>>x>>t;
	int ans=max(x-t,0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long res = 0;
	long A, B, C; cin >> A >> B >> C;

	res = min(C, B / A);

	cout << res << endl;
}

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

int main() {
  int N;
  string A ="Three";
  cin >> N ;
  for ( int i = 0; i < N ; i++ ){
    string S;
    cin >> S ;
    if (S == "Y"){
    A = "Four";
    break;
    }
  }
  cout << A << endl;
}
  
  


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

using namespace std;

int main(void){
  double a, b, c, d;
  scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
  printf("%lf\n", sqrt((a - c)*(a - c) + (b - d)*(b - d)));
  return 0;
}



Measured memory_bytes: 3224
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<utility>
#include<sstream>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1005;
int a[20][10005],b[20][10005];
int num[10005],ans;
int r,c;
void cr(int i)
{
    for(int j = 1;j <= c;j++)b[i][j] = !b[i][j];
}
void cc(int j)
{
    for(int i = 1;i <= r;i++)b[i][j] = !b[i][j];
}
void init()
{
    for(int i = 1;i <= r;i++)
        for(int j = 1;j <= c;j++)
        b[i][j] = a[i][j];
}
void work()
{
    int temp = 0;
    for(int j = 1;j <= c;j++)
    {
        num[j] = 0;
        for(int i = 1;i <= r;i++)
            if(b[i][j])num[j]++;
        temp = temp + max(num[j],r - num[j]);
    }
    ans = max(ans,temp);
}
void dfs(int n)
{
    if(n == r + 1)
    {
        work();
        return;
    }
    dfs(n + 1);
    cr(n);
    dfs(n + 1);
    cr(n);
}
int main()
{
	#ifdef LOCAL
	freopen("C:\\Users\\巍巍\\Desktop\\in.txt","r",stdin);
	//freopen("C:\\Users\\巍巍\\Desktop\\out.txt","w",stdout);
	#endif // LOCAL
	while(scanf("%d%d",&r,&c) != EOF)
    {
        if(!r&&!c)break;
        for(int i = 1;i <= r;i++)
        {
            for(int j = 1;j <= c;j++)
                scanf("%d",&a[i][j]);
        }
        ans = 0;
        init();
        dfs(1);
        printf("%d\n",ans);
    }
	return 0;
}

Measured memory_bytes: 2012
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    string a,b;
    cin>>a>>b;
    string c=a+b;
    int k=stoi(c);
    int p=sqrt(k);
    if(p*p==k){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    cout<<endl;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
a = list(map(int, input().split()))
#s = input()
x = sum(a)/(4*m)

ct = 0
for aa in a:
    if aa >= x:
        ct += 1

if ct >= m:
    print('Yes')
else:
    print('No')
#ss= []
#for i in range(n):
#    ss.appned(int(input()))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;
    
    rep(i, k){
        if (a >= b){
            b *= 2;
        }else{
            if (b >= c){
                c *= 2;
            }
        }
    }
    bool f = (a < b && b < c) ;
    cout << (f?"Yes":"No") << endl;
    return 0;
}

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

int n, m;
vector<string> A(0), B(0);

bool check(int y, int x) {
    for(int i = 0; i < m; i++) {
        string sub;

        sub = A[i + y].substr(x, m);
        if(sub != B[i]) return false;
    }
    return true;
}

int main() {
    cin >> n >> m;
    for(int i = 0; i < n + m; i++) {
        string s;

        cin >> s;
        if(i < n) A.push_back(s);
        else B.push_back(s);
    }

    for(int i = 0; i + m <= n; i++) {
        for(int j = 0; j + m <= n; j++) {
            if(check(i, j)) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
}


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(){
    int n, a[100005];
    cin >> n;
    rep(i,n) cin >> a[i];
    int cnt = 0, ans = 0;
    rep(i,n-1){
        if(a[i] >= a[i+1]){
            cnt++;
        }else{
            ans = max(ans,cnt);
            cnt = 0;
        }
    }
    ans = max(ans,cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
 
public class Main {
    public static void main(final String[] args) throws Exception {
 
        final Scanner scan = new Scanner(System.in);
        final String line = scan.nextLine();
        String[] cells = line.split(" ");
 
        long tate = Long.parseLong(cells[0]);
        long yoko = Long.parseLong(cells[1]);
        long ans1 = (tate / 2) * (yoko/2);
        long ans2 = (tate - (tate /2)) * (yoko - (yoko/2));
        
        if(tate == 1 || yoko ==1){
          System.out.println(1);
        }else{
          long ans = ans1 + ans2;
          System.out.println(ans);
        }
        
        scan.close();
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    string s1, s2;
    cin >> s1 >> s2;
    reverse(s2.begin(), s2.end());
    if(s1 == s2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256